git.s-ol.nu subv / 6629c38
fix validate.py tests s-ol 10 months ago
1 changed file(s) with 14 addition(s) and 14 deletion(s). Raw diff Collapse all Expand all
325325 [(19, 'i'), (5, 'rd'), (0, 'funct3'), (10, 'rs'), (66, 'imm12')]
326326 >>> validate_opi(subv.parse('13/opi 5/rd/t0 3/subop/sltu 5/rs/t0 8/imm12')['instr'])
327327 [(19, 'i'), (5, 'rd'), (3, 'funct3'), (5, 'rs'), (8, 'imm12')]
328 >>> validate_opi(subv.parse('13/opi 5/rd/t0 1/subop/sll 0/imm7 5/rs/t0 8/imm5')['instr'])
328 >>> validate_opi(subv.parse('13/opi 5/rd/t0 1/subop/sll 0/mode/norm 5/rs/t0 8/imm5')['instr'])
329329 [(19, 'i'), (5, 'rd'), (1, 'funct3'), (5, 'rs'), (8, 'imm12')]
330330 >>> validate_opi(subv.parse('13/opi 5/rd/t0 1/subop/sll 5/rs/t0 8/imm12')['instr'])
331331 [(19, 'i'), (5, 'rd'), (1, 'funct3'), (5, 'rs'), (8, 'imm12')]
332 >>> validate_opi(subv.parse('13/opi 5/rd/t0 5/subop/sra 20/imm7 5/rs/t0 8/imm5')['instr'])
332 >>> validate_opi(subv.parse('13/opi 5/rd/t0 5/subop/sra 20/mode/alt 5/rs/t0 8/imm5')['instr'])
333333 [(19, 'i'), (5, 'rd'), (5, 'funct3'), (5, 'rs'), (1032, 'imm12')]
334334 >>> validate_opi(subv.parse('13/opi 5/rd/t0 5/subop/sra 5/rs/t0 408/imm12')['instr'])
335335 [(19, 'i'), (5, 'rd'), (5, 'funct3'), (5, 'rs'), (1032, 'imm12')]
336336
337 >>> validate_opi(subv.parse('13/opi 5/rd/t0 1/subop/sll 12/imm7 5/rs/t0 8/imm5')['instr'])
338 Traceback (most recent call last):
339 ...
340 ValueError: comp-op 1/funct3/sll needs to go with comp-mode 0/imm7/norm
337 >>> validate_opi(subv.parse('13/opi 5/rd/t0 1/subop/sll 20/mode/alt 5/rs/t0 8/imm5')['instr'])
338 Traceback (most recent call last):
339 ...
340 ValueError: comp-op 1/funct3/sll needs to go with comp-mode 0/funct7/norm
341341 >>> validate_opi(subv.parse('13/opi 5/rd/t0 1/subop/sll 5/rs/t0 108/imm12')['instr'])
342342 Traceback (most recent call last):
343343 ...
344 ValueError: comp-op 1/funct3/sll needs to go with comp-mode 0/imm7/norm
345 >>> validate_opi(subv.parse('13/opi 5/rd/t0 5/subop/sra 10/imm7 5/rs/t0 8/imm5')['instr'])
346 Traceback (most recent call last):
347 ...
348 ValueError: comp-op 5/funct3/sra needs to go with comp-mode 20/imm7/alt
344 ValueError: comp-op 1/funct3/sll needs to go with comp-mode 0/funct7/norm
345 >>> validate_opi(subv.parse('13/opi 5/rd/t0 5/subop/sra 0/mode/norm 5/rs/t0 8/imm5')['instr'])
346 Traceback (most recent call last):
347 ...
348 ValueError: comp-op 5/funct3/sra needs to go with comp-mode 20/funct7/alt
349349 >>> validate_opi(subv.parse('13/opi 5/rd/t0 5/subop/sra 5/rs/t0 208/imm12')['instr'])
350350 Traceback (most recent call last):
351351 ...
352 ValueError: comp-op 5/funct3/sra needs to go with comp-mode 20/imm7/alt
352 ValueError: comp-op 5/funct3/sra needs to go with comp-mode 20/funct7/alt
353353 """
354354 op = inputs.pop(0)
355355
368368 except ValueError:
369369 imm = pop_immediate(inputs, 12)
370370 shamt = ((imm[0] & 0b11111), 'imm5')
371 mode = (imm[0] >> 5, 'imm7')
371 mode = (imm[0] >> 5, 'funct7')
372372
373373 expect_mode = "alt" if funct[2] == "sra" else "norm"
374374 expect_val = 32 if expect_mode == "alt" else 0
377377 raise ValueError(
378378 "comp-op {} needs to go with comp-mode {}".format(
379379 subv.format_part(funct),
380 subv.format_part((expect_val, "imm7", expect_mode)),
380 subv.format_part((expect_val, "funct7", expect_mode)),
381381 )
382382 )
383383