aboutsummaryrefslogtreecommitdiff
path: root/parse.py
diff options
context:
space:
mode:
authorNeel Gala <neelgala@incoresemi.com>2022-05-02 18:28:53 +0530
committerNeel Gala <neelgala@incoresemi.com>2022-05-02 18:28:53 +0530
commitbc92b799d9e96b53a0e57e738bff8f12e6e1fc2d (patch)
tree5a36c75c9e2bec76221ae0df092d7d0f98c1cf20 /parse.py
parent738fa4a5695edd54bede848f103f5d69fb5bdc6c (diff)
downloadriscv-opcodes-bc92b799d9e96b53a0e57e738bff8f12e6e1fc2d.zip
riscv-opcodes-bc92b799d9e96b53a0e57e738bff8f12e6e1fc2d.tar.gz
riscv-opcodes-bc92b799d9e96b53a0e57e738bff8f12e6e1fc2d.tar.bz2
adding support for spinalhdl code generation
Diffstat (limited to 'parse.py')
-rwxr-xr-xparse.py16
1 files changed, 13 insertions, 3 deletions
diff --git a/parse.py b/parse.py
index 4ae4a51..11eb4c0 100755
--- a/parse.py
+++ b/parse.py
@@ -706,13 +706,16 @@ def make_ext_latex_table(type_list, dataset, latex_file, ilen, caption):
latex_file.write(header+content+endtable)
-def make_chisel(instr_dict):
+def make_chisel(instr_dict, spinal_hdl=False):
chisel_names=''
cause_names_str=''
csr_names_str = ''
for i in instr_dict:
- chisel_names += f' def {i.upper().replace(".","_"):<18s} = BitPat("b{instr_dict[i]["encoding"].replace("-","?")}")\n'
+ 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'
for num, name in causes:
cause_names_str += f' val {name.lower().replace(" ","_")} = {hex(num)}\n'
cause_names_str += ''' val all = {
@@ -740,7 +743,10 @@ def make_chisel(instr_dict):
csr_names_str += ''' res.toArray
}'''
- chisel_file = open('inst.chisel','w')
+ if spinal_hdl:
+ chisel_file = open('inst.spinalhdl','w')
+ else:
+ chisel_file = open('inst.chisel','w')
chisel_file.write(f'''
/* Automatically generated by parse_opcodes */
object Instructions {{
@@ -857,6 +863,10 @@ if __name__ == "__main__":
if '-chisel' in sys.argv[1:]:
make_chisel(instr_dict)
logging.info('inst.chisel generated successfully')
+
+ if '-spinalhdl' in sys.argv[1:]:
+ make_chisel(instr_dict, True)
+ logging.info('inst.spinalhdl generated successfully')
if '-sverilog' in sys.argv[1:]:
make_sverilog(instr_dict)