aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore3
-rw-r--r--Makefile6
-rw-r--r--README.md1
-rwxr-xr-xparse.py16
4 files changed, 20 insertions, 6 deletions
diff --git a/.gitignore b/.gitignore
index 406d882..b0ae6e9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,9 +5,8 @@ inst.go
instr-table.tex
priv-instr-table.tex
inst.rs
-
+inst.spinalhdl
inst.sverilog
-
instr_dict.yaml
__pycache__/
diff --git a/Makefile b/Makefile
index b8cd4db..be917b4 100644
--- a/Makefile
+++ b/Makefile
@@ -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)
diff --git a/README.md b/README.md
index 0df0cba..d65b0c7 100644
--- a/README.md
+++ b/README.md
@@ -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:
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)