From c3fbef6e64506057e832334e1dfa26efde67777e Mon Sep 17 00:00:00 2001 From: jjsuperpower Date: Wed, 10 Aug 2022 22:16:20 -0500 Subject: added make file --- hdl/utils.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 hdl/utils.py (limited to 'hdl/utils.py') diff --git a/hdl/utils.py b/hdl/utils.py new file mode 100644 index 0000000..6aad95f --- /dev/null +++ b/hdl/utils.py @@ -0,0 +1,22 @@ +import sys +from typing import Callable +from amaranth import Elaboratable +from amaranth.back import verilog, cxxrtl + +def cmd(hdl, tb:Callable): + if len(sys.argv) <= 1: + exit() + + if sys.argv[1] == "sim": + tb(sys.argv[0].replace('.py', '.vcd')) + exit() + + if sys.argv[1] == "v": + out = verilog.convert(hdl, ports=hdl.ports) + with open(sys.argv[0].replace('.py', '.v'), 'w') as f: + f.write(out) + + elif sys.argv[1] == "cc": + out = cxxrtl.convert(hdl, ports=hdl.ports) + with open(sys.argv[0].replace('.py', '.cc'), 'w') as f: + f.write(out) \ No newline at end of file -- cgit v1.2.3