diff --git a/cheshire.mk b/cheshire.mk index 8dbbe10f..03f5e492 100644 --- a/cheshire.mk +++ b/cheshire.mk @@ -7,6 +7,7 @@ # Paul Scheffler BENDER ?= bender +MORTY ?= morty VLOG_ARGS ?= -suppress 2583 -suppress 13314 VSIM ?= vsim @@ -163,6 +164,17 @@ $(CHS_ROOT)/target/xilinx/scripts/add_sources.tcl: Bender.yml CHS_XILINX_ALL += $(CHS_ROOT)/target/xilinx/scripts/add_sources.tcl +############# +# Pickle # +############# + +$(CHS_ROOT)/target/pickle/sources.json: Bender.yml Bender.lock + $(BENDER) sources -t fpga -t cv64a6_imafdcsclic_sv39 -t cva6 -f > $@ + +$(CHS_ROOT)/target/pickle/%.sv: $(CHS_ROOT)/target/pickle/sources.json + $(MORTY) -f $^ --top $* -i --sequential --propagate_defines -o $@ + + ################################# # Phonies (KEEP AT END OF FILE) # ################################# diff --git a/target/pickle/.gitignore b/target/pickle/.gitignore new file mode 100644 index 00000000..2a390c97 --- /dev/null +++ b/target/pickle/.gitignore @@ -0,0 +1,2 @@ +sources.json +*.sv diff --git a/target/pickle/get_config.py b/target/pickle/get_config.py new file mode 100644 index 00000000..59b85c08 --- /dev/null +++ b/target/pickle/get_config.py @@ -0,0 +1,34 @@ +import sys +import time +from pyslang import * + +class ModuleVisitor: + def __init__(self, file_in: str): + self.tree = SyntaxTree.fromText(file_in) + self.comp = Compilation() + self.comp.addSyntaxTree(self.tree) + # Analysis results; contains per-transform dicts indexed by *syntax source start offsets*! + # self.compinfo = defaultdict(dict) + # self.compinfo['__eval'] = EvalContext(self.comp) + # self.compinfo['__iterate'] = self._iterate_member + + def traverse(self) -> str: + # Analyze compilation first and collect info + self.comp.getRoot().visit(self._comp_visit) + #return self._rewrite_member(self.tree.root) + + def _comp_visit(self, sym): + print(sym) + #if isinstance(sym, AssignmentExpression): + # analyze_assignment(self.compinfo, sym) + #elif isinstance(sym, Expression): + # analyze_expression(self.compinfo, sym) + +def main(file_in: str, top_module: str): + ModuleVisitor(file_in).traverse() + + + +# TODO: cmdline parser! +if __name__ == '__main__': + sys.exit(main('cheshire_soc.sv', 'cheshire_soc'))