diff options
Diffstat (limited to 'parse.py')
-rwxr-xr-x | parse.py | 16 |
1 files changed, 13 insertions, 3 deletions
@@ -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) |