From bc92b799d9e96b53a0e57e738bff8f12e6e1fc2d Mon Sep 17 00:00:00 2001 From: Neel Gala Date: Mon, 2 May 2022 18:28:53 +0530 Subject: adding support for spinalhdl code generation --- parse.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'parse.py') 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) -- cgit v1.1