aboutsummaryrefslogtreecommitdiff
path: root/parse.py
diff options
context:
space:
mode:
authorLucas-Wye <lustrew@foxmail.com>2023-03-10 17:11:16 +0800
committerLucas-Wye <lustrew@foxmail.com>2023-03-10 17:11:16 +0800
commit811478c0afd26ea5f96936e5b9361e169d05e29a (patch)
tree80fc37cb14a900b0024957dd0431a861643d368b /parse.py
parented68c21b025ced3e09bc6ad753947ec8248f89ec (diff)
downloadriscv-opcodes-811478c0afd26ea5f96936e5b9361e169d05e29a.zip
riscv-opcodes-811478c0afd26ea5f96936e5b9361e169d05e29a.tar.gz
riscv-opcodes-811478c0afd26ea5f96936e5b9361e169d05e29a.tar.bz2
change the generation part of chisel
Diffstat (limited to 'parse.py')
-rwxr-xr-xparse.py34
1 files changed, 32 insertions, 2 deletions
diff --git a/parse.py b/parse.py
index 9714e99..30f868c 100755
--- a/parse.py
+++ b/parse.py
@@ -733,6 +733,12 @@ def make_ext_latex_table(type_list, dataset, latex_file, ilen, caption):
# dump the contents and return
latex_file.write(header+content+endtable)
+def instr_dict_2_extensions(instr_dict):
+ extensions = []
+ for item in instr_dict.values():
+ if item['extension'][0] not in extensions:
+ extensions.append(item['extension'][0])
+ return extensions
def make_chisel(instr_dict, spinal_hdl=False):
@@ -742,8 +748,32 @@ def make_chisel(instr_dict, spinal_hdl=False):
for i in instr_dict:
if spinal_hdl:
chisel_names += f' def {i.upper().replace(".","_"):<18s} = M"b{instr_dict[i]["encoding"].replace("-","-")}"\n'
- else:
- chisel_names += f' def {i.upper().replace(".","_"):<18s} = BitPat("b{instr_dict[i]["encoding"].replace("-","?")}")\n'
+ # else:
+ # chisel_names += f' def {i.upper().replace(".","_"):<18s} = BitPat("b{instr_dict[i]["encoding"].replace("-","?")}")\n'
+ if not spinal_hdl:
+ extensions = instr_dict_2_extensions(instr_dict)
+ all_instr = " val AllType = "
+ for e in extensions:
+ e_instrs = filter(lambda i: instr_dict[i]['extension'][0] == e, instr_dict)
+ if "rv128_" in e:
+ e_format = e.replace("rv128_", "").upper() + "128"
+ elif "rv64_" in e:
+ e_format = e.replace("rv64_", "").upper() + "64"
+ elif "rv32_" in e:
+ e_format = e.replace("rv32_", "").upper()
+ elif "rv_" in e:
+ e_format = e.replace("rv_", "").upper()
+ else:
+ e_format = e.upper
+ all_instr += e_format + "Type ++ "
+ chisel_names += f' val {e_format+"Type"} = Map(\n'
+ for instr in e_instrs:
+ tmp_instr_name = '"'+instr.upper().replace(".","_")+'"'
+ chisel_names += f' {tmp_instr_name:<18s} -> BitPat("b{instr_dict[instr]["encoding"].replace("-","?")}"),\n'
+ chisel_names += f' )\n'
+
+ chisel_names += all_instr[:-3]
+
for num, name in causes:
cause_names_str += f' val {name.lower().replace(" ","_")} = {hex(num)}\n'
cause_names_str += ''' val all = {