From f4fc0228b9b409769d4b472bc81d3d89bc189a04 Mon Sep 17 00:00:00 2001 From: Nathaniel Navarro Date: Tue, 20 Aug 2024 12:30:02 -0400 Subject: [PATCH] add calyx wrapper flag for calyx wrapped AXI runnign via xclrun --- fud/fud/xclrun.py | 14 +++++++++++--- fud2/scripts/xilinx.rhai | 4 ++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/fud/fud/xclrun.py b/fud/fud/xclrun.py index 1c6eba84c..90ab059e7 100644 --- a/fud/fud/xclrun.py +++ b/fud/fud/xclrun.py @@ -66,7 +66,7 @@ def convert_to_fp(value: float): raise InvalidNumericType('Fud only supports "fixed_point" and "bitnum".') -def run(xclbin: Path, data: Mapping[str, Any]) -> Dict[str, Any]: +def run(xclbin: Path, data: Mapping[str, Any], calyx_wrapper: bool) -> Dict[str, Any]: """Takes in a json data output and runs pynq using the data provided returns a dictionary that can be converted into json @@ -87,7 +87,14 @@ def run(xclbin: Path, data: Mapping[str, Any]) -> Dict[str, Any]: # Run the kernel. kernel = getattr(ol, list(ol.ip_dict)[0]) # Like ol.wrapper_1 - kernel.call(*buffers) + + # The old verilog AXI wrapper requires a timeout value + # (although I don't think it is used in the verilog anywhere) + if calyx_wrapper: + kernel.call(*buffers) + else: + timeout = 1000 + kernel.call(timeout, *buffers) # Collect the output data. for buf in buffers: @@ -125,6 +132,7 @@ def xclrun(): metavar="FILE", help="write JSON results to a file instead of stdout", ) + parser.add_agument("--calyx-wrapper", help="pass when using the newer calyx AXI wrappers", action="store_true") args = parser.parse_args() # Load the input JSON data file. @@ -132,7 +140,7 @@ def xclrun(): in_data = sjson.load(f, use_decimal=True) # Run the program. - out_data = run(Path(args.bin), in_data) + out_data = run(Path(args.bin), in_data, args.calyx_wrapper) # Dump the output JSON data. outfile = open(args.out, "w") if args.out else sys.stdout diff --git a/fud2/scripts/xilinx.rhai b/fud2/scripts/xilinx.rhai index 10692d7ad..015f7c377 100644 --- a/fud2/scripts/xilinx.rhai +++ b/fud2/scripts/xilinx.rhai @@ -1,4 +1,3 @@ -// import "calyx" as c; import "axi" as axi; import "rtl_sim" as sim; import "testbench" as tb; @@ -125,11 +124,12 @@ fn xrt_setup(e) { e.rule("emconfig", "$vitis-dir/bin/emconfigutil --platform $platform"); e.build_cmd(["emconfig.json"], "emconfig", [], []); + let calyx_wrapper = if e.config_constrained_or("calyx-wrapper", ["true", "false"], "false") {""} else {"--calyx-wrapper"}; // Execute via the `xclrun` tool. e.config_var("xrt-dir", "xilinx.xrt"); e.rule( "xclrun", - "bash -c 'source $vitis-dir/settings64.sh ; source $xrt-dir/setup.sh ; XRT_INI_PATH=$xrt_ini EMCONFIG_PATH=. XCL_EMULATION_MODE=$xilinx-mode $python -m fud.xclrun --out $out $in'" + `bash -c 'source $vitis-dir/settings64.sh ; source $xrt-dir/setup.sh ; XRT_INI_PATH=$xrt_ini EMCONFIG_PATH=. XCL_EMULATION_MODE=$xilinx-mode $python -m fud.xclrun ${calyx_wrapper} --out $out $in'` ); e.arg("pool", "console");