diff options
-rw-r--r-- | .gitignore | 3 | ||||
-rw-r--r-- | Makefile | 6 | ||||
-rw-r--r-- | README.md | 1 | ||||
-rwxr-xr-x | parse.py | 16 |
4 files changed, 20 insertions, 6 deletions
@@ -5,9 +5,8 @@ inst.go instr-table.tex priv-instr-table.tex inst.rs - +inst.spinalhdl inst.sverilog - instr_dict.yaml __pycache__/ @@ -12,7 +12,7 @@ install: everything .PHONY : everything everything: - @./parse.py -c -chisel -sverilog -rust -latex $(EXTENSIONS) + @./parse.py -c -chisel -sverilog -rust -latex -spinalhdl $(EXTENSIONS) .PHONY : encoding.out.h encoding.out.h: @@ -47,3 +47,7 @@ instr-table.tex: latex .PHONY: priv-instr-table.tex priv-instr-table.tex: latex + +.PHONY: inst.spinalhdl +inst.spinalhdl: + @./parse.py -spinalhdl $(EXTENSIONS) @@ -124,6 +124,7 @@ The following artifacts can be generated using parse.py: - inst.chisel : chisel code to decode instructions - inst.sverilog : system verilog code to decode instructions - inst.rs : rust code containing mask and match variables for all instructions +- inst.spinalhdl : spinalhdl code to decode instructions Make sure you install the required python pre-requisites are installed by executing the following command: @@ -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) |