Skip to content

Commit 3160307

Browse files
authored
[yxi] Rename calyx-axi-wrapper clock signal to ap_clk (#2386)
Another PR whittling down the changes present in #2267. This PR changes the toplevel clock signal from `clk` to `ap_clk`. This should allow us to reuse the existing [`gen_xo.tcl`](https://github.com/calyxir/calyx/blob/main/fud2/rsrc/gen_xo.tcl#L34-L37) and maintain backwards compatibility with the old verilog-axi-wrapper, without requiring a distinction between the two in the `gen_xo.tcl` file. Also fixes a bsd vs gnu `sed` syntax error. The new command should work on both. (bsd sed require terminating commands to end with a `;`, gnu does not) I'll also note that this PR touches a bunch of runt cocotb tests in `tests/axi`. I'm aware that there is a desire to get rid of large snapshots as they tend to get ignored. For now this setup is the best thing I have to make sure breaking changes aren't introduced to either axi-wrapper, so choosing to update them for now.
1 parent 8dec8c2 commit 3160307

15 files changed

+5571
-6262
lines changed

fud2/scripts/cocotb-axi.rhai

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ fn cocotb_setup(e) {
2626
e.rule("copy", "cp $in $out");
2727
// This cleans up the extra `make` cruft, leaving what is in between `{` and `}.`
2828
e.rule(
29-
"cleanup-cocotb", `sed -n '/Output:/,/make\[1\]/{/Output:/d;/make\[1\]/d;p}' $in > $out`
29+
"cleanup-cocotb", `sed -n '/Output:/,/make\[1\]/{/Output:/d;/make\[1\]/d;p;}' $in > $out`
3030
);
3131
}
3232

@@ -49,6 +49,8 @@ op(
4949
c::verilog_noverify,
5050
cocotb_axi,
5151
|e, input, output| {
52+
// Cocotb wants files relative to the location of the makefile.
53+
// This is annoying to calculate on the fly, so we just copy necessary files to the build directory
5254
e.build_cmd(
5355
["Makefile"],
5456
"copy",

fud2/tests/snapshots/tests__test@plan_calyx-to-cocotb-axi.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ rule make-cocotb
2626
rule copy
2727
command = cp $in $out
2828
rule cleanup-cocotb
29-
command = sed -n '/Output:/,/make\[1\]/{/Output:/d;/make\[1\]/d;p}' $in > $out
29+
command = sed -n '/Output:/,/make\[1\]/{/Output:/d;/make\[1\]/d;p;}' $in > $out
3030

3131
build Makefile: copy $cocotb-makefile-dir/Makefile
3232
build axi_test.py: copy $cocotb-makefile-dir/axi_test.py

yxi/axi-calyx/axi_generator.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,8 @@ def add_main_comp(prog, mems):
459459
main_compute = wrapper_comp.comp_instance(
460460
"main_compute", "main", check_undeclared=False
461461
)
462+
# Naming the clock signal `ap_clk` ensures Xilinx tool compatability
463+
wrapper_comp.input("ap_clk", 1, ["clk"])
462464

463465
for mem in mems:
464466
mem_name = mem[name_key]

yxi/axi-calyx/cocotb/axi_test.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,9 @@ async def setup_rams(self, data: Mapping[str, Any]):
3232
# i.e m0_axi_RDATA.
3333
# These prefixes have to match verilog code. See kernel.xml <args>
3434
# and ports assigned within that for guidance.
35-
# In general, the index of `m<idx>_axi` just
36-
# increments by 1 in fud axi generation
37-
#print(f"mem is: {mem}")
3835
rams[mem] = AxiRam(
3936
AxiBus.from_prefix(self.toplevel, f"{mem}"),
40-
self.toplevel.clk,
37+
self.toplevel.ap_clk,
4138
reset = self.toplevel.reset,
4239
# self.toplevel.ap_rst_n,
4340
size=size,
@@ -56,7 +53,7 @@ def get_rams(self):
5653
async def init_toplevel(self):
5754
await Timer(50, "ns")
5855
self.toplevel.reset.value = 1
59-
await ClockCycles(self.toplevel.clk, 5)
56+
await ClockCycles(self.toplevel.ap_clk, 5)
6057
self.toplevel.reset.value = 0
6158
self.toplevel.go.value = 1
6259

@@ -73,10 +70,10 @@ async def run_kernel_test(toplevel, data_path: str):
7370

7471

7572
# set up clock of 2ns period, simulator default timestep is 1ps
76-
cocotb.start_soon(Clock(toplevel.clk, 2, units="ns").start())
73+
cocotb.start_soon(Clock(toplevel.ap_clk, 2, units="ns").start())
7774
await tb.init_toplevel()
7875
await Timer(100, "ns")
79-
await FallingEdge(toplevel.clk)
76+
await FallingEdge(toplevel.ap_clk)
8077

8178

8279
# Finish when ap_done is high or 100 us of simulation have passed.

yxi/axi-calyx/dynamic_axi_generator.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,8 @@ def add_main_comp(prog, mems):
626626
main_compute = wrapper_comp.comp_instance(
627627
"main_compute", "main", check_undeclared=False
628628
)
629+
# Naming the clock signal `ap_clk` ensures Xilinx tool compatability
630+
wrapper_comp.input("ap_clk", 1, ["clk"])
629631

630632
for mem in mems:
631633
mem_name = mem[name_key]

yxi/tests/axi/dynamic/dyn-mem-vec-add-axi-wrapped.expect

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9105,6 +9105,7 @@ assign invoke1_done_in = read_controller_Sum0_done;
91059105
// COMPONENT END: axi_dyn_mem_Sum0
91069106
endmodule
91079107
module wrapper(
9108+
input logic ap_clk,
91089109
input logic A0_ARESETn,
91099110
input logic A0_ARREADY,
91109111
input logic A0_RVALID,
@@ -9199,7 +9200,6 @@ module wrapper(
91999200
output logic Sum0_WID,
92009201
output logic Sum0_BID,
92019202
input logic go,
9202-
input logic clk,
92039203
input logic reset,
92049204
output logic done
92059205
);
@@ -9507,7 +9507,7 @@ assign axi_dyn_mem_A0_write_en =
95079507
_guard1 ? main_compute_A0_write_en :
95089508
1'd0;
95099509
assign axi_dyn_mem_A0_RDATA = A0_RDATA;
9510-
assign axi_dyn_mem_A0_clk = clk;
9510+
assign axi_dyn_mem_A0_clk = ap_clk;
95119511
assign axi_dyn_mem_A0_addr0 =
95129512
_guard2 ? main_compute_A0_addr0 :
95139513
3'd0;
@@ -9527,7 +9527,7 @@ assign axi_dyn_mem_Sum0_write_en =
95279527
_guard4 ? main_compute_Sum0_write_en :
95289528
1'd0;
95299529
assign axi_dyn_mem_Sum0_RDATA = Sum0_RDATA;
9530-
assign axi_dyn_mem_Sum0_clk = clk;
9530+
assign axi_dyn_mem_Sum0_clk = ap_clk;
95319531
assign axi_dyn_mem_Sum0_addr0 =
95329532
_guard5 ? main_compute_Sum0_addr0 :
95339533
3'd0;
@@ -9613,7 +9613,7 @@ assign main_compute_B0_read_data =
96139613
assign main_compute_Sum0_done =
96149614
_guard11 ? axi_dyn_mem_Sum0_done :
96159615
1'd0;
9616-
assign main_compute_clk = clk;
9616+
assign main_compute_clk = ap_clk;
96179617
assign main_compute_B0_done =
96189618
_guard12 ? axi_dyn_mem_B0_done :
96199619
1'd0;
@@ -9631,7 +9631,7 @@ assign axi_dyn_mem_B0_write_en =
96319631
_guard15 ? main_compute_B0_write_en :
96329632
1'd0;
96339633
assign axi_dyn_mem_B0_RDATA = B0_RDATA;
9634-
assign axi_dyn_mem_B0_clk = clk;
9634+
assign axi_dyn_mem_B0_clk = ap_clk;
96359635
assign axi_dyn_mem_B0_addr0 =
96369636
_guard16 ? main_compute_B0_addr0 :
96379637
3'd0;

yxi/tests/axi/dynamic/dyn-mem-vec-add-axi-wrapped.futil

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,7 @@ component axi_dyn_mem_Sum0(@write_together(1) @data addr0: 3, @write_together(1)
670670
}
671671
}
672672
}
673-
component wrapper<"toplevel"=1>(A0_ARESETn: 1, A0_ARREADY: 1, A0_RVALID: 1, A0_RLAST: 1, A0_RDATA: 32, A0_RRESP: 2, A0_AWREADY: 1, A0_WREADY: 1, A0_BVALID: 1, A0_BRESP: 2, A0_RID: 1, B0_ARESETn: 1, B0_ARREADY: 1, B0_RVALID: 1, B0_RLAST: 1, B0_RDATA: 32, B0_RRESP: 2, B0_AWREADY: 1, B0_WREADY: 1, B0_BVALID: 1, B0_BRESP: 2, B0_RID: 1, Sum0_ARESETn: 1, Sum0_ARREADY: 1, Sum0_RVALID: 1, Sum0_RLAST: 1, Sum0_RDATA: 32, Sum0_RRESP: 2, Sum0_AWREADY: 1, Sum0_WREADY: 1, Sum0_BVALID: 1, Sum0_BRESP: 2, Sum0_RID: 1) -> (A0_ARVALID: 1, A0_ARADDR: 64, A0_ARSIZE: 3, A0_ARLEN: 8, A0_ARBURST: 2, A0_RREADY: 1, A0_AWVALID: 1, A0_AWADDR: 64, A0_AWSIZE: 3, A0_AWLEN: 8, A0_AWBURST: 2, A0_AWPROT: 3, A0_WVALID: 1, A0_WLAST: 1, A0_WDATA: 32, A0_BREADY: 1, A0_ARID: 1, A0_AWID: 1, A0_WID: 1, A0_BID: 1, B0_ARVALID: 1, B0_ARADDR: 64, B0_ARSIZE: 3, B0_ARLEN: 8, B0_ARBURST: 2, B0_RREADY: 1, B0_AWVALID: 1, B0_AWADDR: 64, B0_AWSIZE: 3, B0_AWLEN: 8, B0_AWBURST: 2, B0_AWPROT: 3, B0_WVALID: 1, B0_WLAST: 1, B0_WDATA: 32, B0_BREADY: 1, B0_ARID: 1, B0_AWID: 1, B0_WID: 1, B0_BID: 1, Sum0_ARVALID: 1, Sum0_ARADDR: 64, Sum0_ARSIZE: 3, Sum0_ARLEN: 8, Sum0_ARBURST: 2, Sum0_RREADY: 1, Sum0_AWVALID: 1, Sum0_AWADDR: 64, Sum0_AWSIZE: 3, Sum0_AWLEN: 8, Sum0_AWBURST: 2, Sum0_AWPROT: 3, Sum0_WVALID: 1, Sum0_WLAST: 1, Sum0_WDATA: 32, Sum0_BREADY: 1, Sum0_ARID: 1, Sum0_AWID: 1, Sum0_WID: 1, Sum0_BID: 1) {
673+
component wrapper<"toplevel"=1>(@clk ap_clk: 1, A0_ARESETn: 1, A0_ARREADY: 1, A0_RVALID: 1, A0_RLAST: 1, A0_RDATA: 32, A0_RRESP: 2, A0_AWREADY: 1, A0_WREADY: 1, A0_BVALID: 1, A0_BRESP: 2, A0_RID: 1, B0_ARESETn: 1, B0_ARREADY: 1, B0_RVALID: 1, B0_RLAST: 1, B0_RDATA: 32, B0_RRESP: 2, B0_AWREADY: 1, B0_WREADY: 1, B0_BVALID: 1, B0_BRESP: 2, B0_RID: 1, Sum0_ARESETn: 1, Sum0_ARREADY: 1, Sum0_RVALID: 1, Sum0_RLAST: 1, Sum0_RDATA: 32, Sum0_RRESP: 2, Sum0_AWREADY: 1, Sum0_WREADY: 1, Sum0_BVALID: 1, Sum0_BRESP: 2, Sum0_RID: 1) -> (A0_ARVALID: 1, A0_ARADDR: 64, A0_ARSIZE: 3, A0_ARLEN: 8, A0_ARBURST: 2, A0_RREADY: 1, A0_AWVALID: 1, A0_AWADDR: 64, A0_AWSIZE: 3, A0_AWLEN: 8, A0_AWBURST: 2, A0_AWPROT: 3, A0_WVALID: 1, A0_WLAST: 1, A0_WDATA: 32, A0_BREADY: 1, A0_ARID: 1, A0_AWID: 1, A0_WID: 1, A0_BID: 1, B0_ARVALID: 1, B0_ARADDR: 64, B0_ARSIZE: 3, B0_ARLEN: 8, B0_ARBURST: 2, B0_RREADY: 1, B0_AWVALID: 1, B0_AWADDR: 64, B0_AWSIZE: 3, B0_AWLEN: 8, B0_AWBURST: 2, B0_AWPROT: 3, B0_WVALID: 1, B0_WLAST: 1, B0_WDATA: 32, B0_BREADY: 1, B0_ARID: 1, B0_AWID: 1, B0_WID: 1, B0_BID: 1, Sum0_ARVALID: 1, Sum0_ARADDR: 64, Sum0_ARSIZE: 3, Sum0_ARLEN: 8, Sum0_ARBURST: 2, Sum0_RREADY: 1, Sum0_AWVALID: 1, Sum0_AWADDR: 64, Sum0_AWSIZE: 3, Sum0_AWLEN: 8, Sum0_AWBURST: 2, Sum0_AWPROT: 3, Sum0_WVALID: 1, Sum0_WLAST: 1, Sum0_WDATA: 32, Sum0_BREADY: 1, Sum0_ARID: 1, Sum0_AWID: 1, Sum0_WID: 1, Sum0_BID: 1) {
674674
cells {
675675
main_compute = main();
676676
axi_dyn_mem_A0 = axi_dyn_mem_A0();

0 commit comments

Comments
 (0)