diff options
author | Pavel I. Kryukov <pavel.kryukov@phystech.edu> | 2022-06-09 15:27:43 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-09 05:27:43 -0700 |
commit | 08ca2b1ed5fcce8d08bd61a861e71f6e222905eb (patch) | |
tree | 45e9c141067c4a6eb6dc9ebb971c0b4e5cc8c8fa /parse.py | |
parent | 660a1004db4683c6fa2618ce2b81e4d464d4b3d1 (diff) | |
download | riscv-opcodes-08ca2b1ed5fcce8d08bd61a861e71f6e222905eb.zip riscv-opcodes-08ca2b1ed5fcce8d08bd61a861e71f6e222905eb.tar.gz riscv-opcodes-08ca2b1ed5fcce8d08bd61a861e71f6e222905eb.tar.bz2 |
Check for overlaps between different fields (#122)
Diffstat (limited to 'parse.py')
-rwxr-xr-x | parse.py | 15 |
1 files changed, 10 insertions, 5 deletions
@@ -95,6 +95,11 @@ def process_enc_line(line, ext): for (lsb, value, drop) in single_fixed.findall(remaining): lsb = int(lsb, 0) value = int(value, 0) + if encoding[31 - lsb] != '-': + logging.error( + f'{line.split(" ")[0]:<10} has {lsb} bit overlapping in it\'s opcodes' + ) + raise SystemExit(1) encoding[31 - lsb] = str(value) # convert the list of encodings into a single string for match and mask @@ -104,19 +109,19 @@ def process_enc_line(line, ext): # check if all args of the instruction are present in arg_lut present in # constants.py args = single_fixed.sub(' ', remaining).split() - encoding_args = ['-'] * 32 + encoding_args = encoding for a in args: if a not in arg_lut: logging.error(f' Found variable {a} in instruction {name} whose mapping in arg_lut does not exist') raise SystemExit(1) else: (msb, lsb) = arg_lut[a] - for ind in range(lsb, msb): + for ind in range(lsb, msb + 1): # overlapping bits - if encoding_args[ind] != '-': - logging.error(f' Found variable {a} in instruction {name} overlapping {encoding_args[ind]} variable') + if encoding_args[31 - ind] != '-': + logging.error(f' Found variable {a} in instruction {name} overlapping {encoding_args[31 - ind]} variable in bit {ind}') raise SystemExit(1) - encoding_args[ind] = a + encoding_args[31 - ind] = a # update the fields of the instruction as a dict and return back along with # the name of the instruction |