Skip to content

Commit

Permalink
add calyx wrapper flag for calyx wrapped AXI runnign via xclrun
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanielnrn committed Aug 20, 2024
1 parent 442b1ab commit f4fc022
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
14 changes: 11 additions & 3 deletions fud/fud/xclrun.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -125,14 +132,15 @@ 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.
with open(args.data) as f:
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
Expand Down
4 changes: 2 additions & 2 deletions fud2/scripts/xilinx.rhai
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// import "calyx" as c;
import "axi" as axi;
import "rtl_sim" as sim;
import "testbench" as tb;
Expand Down Expand Up @@ -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");

Expand Down

0 comments on commit f4fc022

Please sign in to comment.