@@ -446,7 +446,7 @@ def add_bresp_channel(prog, mem):
446
446
447
447
# NOTE: Unlike the channel functions, this can expect multiple mems
448
448
def add_main_comp (prog , mems ):
449
- wrapper_comp = prog .component ("wrapper " )
449
+ wrapper_comp = prog .component ("Toplevel " )
450
450
wrapper_comp .attribute ("toplevel" , 1 )
451
451
# Get handles to be used later
452
452
read_channel = prog .get_component ("m_read_channel" )
@@ -468,52 +468,54 @@ def add_main_comp(prog, mems):
468
468
# Naming the clock signal `ap_clk` ensures Xilinx tool compatability
469
469
wrapper_comp .input ("ap_clk" , 1 , ["clk" ])
470
470
471
- # TODO: To get these ports to interface with XRT and our current xml_generator.py we need to add a
472
- # `prefixed_mem_name = f"m_axi_{mem[name_key]}"`
473
- # and replace most (but not all) usages of {mem_name} with `prefixed_mem_name`.
474
-
475
471
for mem in mems :
472
+
476
473
mem_name = mem [name_key ]
474
+ # These input/output names in the toplevel (i.e. 'm_axi_A0_ARREADY') need to match
475
+ # the ports(not!! args) kernel.xml file generated by `xml_generator.py`.
476
+ # We add the prefix `m_axi_` to maintain compatibility with the old verilog wrapper.
477
+ # Once we deprecate the old wrapper we can probably remove this prefix here and modify `xml_generator.py`
478
+ prefixed_mem_name = f"m_axi_{ mem [name_key ]} "
477
479
# Inputs/Outputs
478
480
wrapper_inputs = [
479
- (f"{ mem_name } _ARESETn" , 1 ),
480
- (f"{ mem_name } _ARREADY" , 1 ),
481
- (f"{ mem_name } _RVALID" , 1 ),
482
- (f"{ mem_name } _RLAST" , 1 ),
483
- (f"{ mem_name } _RDATA" , mem [width_key ]),
484
- (f"{ mem_name } _RRESP" , 2 ),
485
- (f"{ mem_name } _AWREADY" , 1 ),
486
- (f"{ mem_name } _WRESP" , 2 ),
487
- (f"{ mem_name } _WREADY" , 1 ),
488
- (f"{ mem_name } _BVALID" , 1 ),
481
+ (f"{ prefixed_mem_name } _ARESETn" , 1 ),
482
+ (f"{ prefixed_mem_name } _ARREADY" , 1 ),
483
+ (f"{ prefixed_mem_name } _RVALID" , 1 ),
484
+ (f"{ prefixed_mem_name } _RLAST" , 1 ),
485
+ (f"{ prefixed_mem_name } _RDATA" , mem [width_key ]),
486
+ (f"{ prefixed_mem_name } _RRESP" , 2 ),
487
+ (f"{ prefixed_mem_name } _AWREADY" , 1 ),
488
+ (f"{ prefixed_mem_name } _WRESP" , 2 ),
489
+ (f"{ prefixed_mem_name } _WREADY" , 1 ),
490
+ (f"{ prefixed_mem_name } _BVALID" , 1 ),
489
491
# Only used for waveform tracing, not sent anywhere
490
- (f"{ mem_name } _BRESP" , 2 ),
492
+ (f"{ prefixed_mem_name } _BRESP" , 2 ),
491
493
# Only needed for coctb compatability, tied low
492
- (f"{ mem_name } _RID" , 1 ),
494
+ (f"{ prefixed_mem_name } _RID" , 1 ),
493
495
]
494
496
495
497
wrapper_outputs = [
496
- (f"{ mem_name } _ARVALID" , 1 ),
497
- (f"{ mem_name } _ARADDR" , 64 ),
498
- (f"{ mem_name } _ARSIZE" , 3 ),
499
- (f"{ mem_name } _ARLEN" , 8 ),
500
- (f"{ mem_name } _ARBURST" , 2 ),
501
- (f"{ mem_name } _RREADY" , 1 ),
502
- (f"{ mem_name } _AWVALID" , 1 ),
503
- (f"{ mem_name } _AWADDR" , 64 ),
504
- (f"{ mem_name } _AWSIZE" , 3 ),
505
- (f"{ mem_name } _AWLEN" , 8 ),
506
- (f"{ mem_name } _AWBURST" , 2 ),
507
- (f"{ mem_name } _AWPROT" , 3 ),
508
- (f"{ mem_name } _WVALID" , 1 ),
509
- (f"{ mem_name } _WLAST" , 1 ),
510
- (f"{ mem_name } _WDATA" , mem [width_key ]),
511
- (f"{ mem_name } _BREADY" , 1 ),
498
+ (f"{ prefixed_mem_name } _ARVALID" , 1 ),
499
+ (f"{ prefixed_mem_name } _ARADDR" , 64 ),
500
+ (f"{ prefixed_mem_name } _ARSIZE" , 3 ),
501
+ (f"{ prefixed_mem_name } _ARLEN" , 8 ),
502
+ (f"{ prefixed_mem_name } _ARBURST" , 2 ),
503
+ (f"{ prefixed_mem_name } _RREADY" , 1 ),
504
+ (f"{ prefixed_mem_name } _AWVALID" , 1 ),
505
+ (f"{ prefixed_mem_name } _AWADDR" , 64 ),
506
+ (f"{ prefixed_mem_name } _AWSIZE" , 3 ),
507
+ (f"{ prefixed_mem_name } _AWLEN" , 8 ),
508
+ (f"{ prefixed_mem_name } _AWBURST" , 2 ),
509
+ (f"{ prefixed_mem_name } _AWPROT" , 3 ),
510
+ (f"{ prefixed_mem_name } _WVALID" , 1 ),
511
+ (f"{ prefixed_mem_name } _WLAST" , 1 ),
512
+ (f"{ prefixed_mem_name } _WDATA" , mem [width_key ]),
513
+ (f"{ prefixed_mem_name } _BREADY" , 1 ),
512
514
# ID signals are needed for coco compatability, tied low
513
- (f"{ mem_name } _ARID" , 1 ),
514
- (f"{ mem_name } _AWID" , 1 ),
515
- (f"{ mem_name } _WID" , 1 ),
516
- (f"{ mem_name } _BID" , 1 ),
515
+ (f"{ prefixed_mem_name } _ARID" , 1 ),
516
+ (f"{ prefixed_mem_name } _AWID" , 1 ),
517
+ (f"{ prefixed_mem_name } _WID" , 1 ),
518
+ (f"{ prefixed_mem_name } _BID" , 1 ),
517
519
]
518
520
519
521
add_comp_ports (wrapper_comp , wrapper_inputs , wrapper_outputs )
@@ -547,10 +549,10 @@ def add_main_comp(prog, mems):
547
549
548
550
# Tie IDs low, needed for cocotb compatability. Not used anywhere
549
551
with wrapper_comp .continuous :
550
- wrapper_comp .this ()[f"{ mem_name } _ARID" ] = 0
551
- wrapper_comp .this ()[f"{ mem_name } _AWID" ] = 0
552
- wrapper_comp .this ()[f"{ mem_name } _WID" ] = 0
553
- wrapper_comp .this ()[f"{ mem_name } _BID" ] = 0
552
+ wrapper_comp .this ()[f"{ prefixed_mem_name } _ARID" ] = 0
553
+ wrapper_comp .this ()[f"{ prefixed_mem_name } _AWID" ] = 0
554
+ wrapper_comp .this ()[f"{ prefixed_mem_name } _WID" ] = 0
555
+ wrapper_comp .this ()[f"{ prefixed_mem_name } _BID" ] = 0
554
556
555
557
# No groups needed!
556
558
@@ -562,41 +564,41 @@ def add_main_comp(prog, mems):
562
564
# main_comp.get_cell(f"ar_channel_{mem_name}"),
563
565
wrapper_comp .get_cell (f"ar_channel_{ mem_name } " ),
564
566
ref_curr_addr_axi = curr_addr_axi ,
565
- in_ARESETn = this_component [f"{ mem_name } _ARESETn" ],
566
- in_ARREADY = this_component [f"{ mem_name } _ARREADY" ],
567
- out_ARVALID = this_component [f"{ mem_name } _ARVALID" ],
568
- out_ARADDR = this_component [f"{ mem_name } _ARADDR" ],
569
- out_ARSIZE = this_component [f"{ mem_name } _ARSIZE" ],
570
- out_ARLEN = this_component [f"{ mem_name } _ARLEN" ],
571
- out_ARBURST = this_component [f"{ mem_name } _ARBURST" ],
567
+ in_ARESETn = this_component [f"{ prefixed_mem_name } _ARESETn" ],
568
+ in_ARREADY = this_component [f"{ prefixed_mem_name } _ARREADY" ],
569
+ out_ARVALID = this_component [f"{ prefixed_mem_name } _ARVALID" ],
570
+ out_ARADDR = this_component [f"{ prefixed_mem_name } _ARADDR" ],
571
+ out_ARSIZE = this_component [f"{ prefixed_mem_name } _ARSIZE" ],
572
+ out_ARLEN = this_component [f"{ prefixed_mem_name } _ARLEN" ],
573
+ out_ARBURST = this_component [f"{ prefixed_mem_name } _ARBURST" ],
572
574
)
573
575
574
576
read_channel_invoke = invoke (
575
577
wrapper_comp .get_cell (f"read_channel_{ mem_name } " ),
576
578
ref_mem_ref = internal_mem ,
577
579
ref_curr_addr_internal_mem = curr_addr_internal_mem ,
578
580
ref_curr_addr_axi = curr_addr_axi ,
579
- in_ARESETn = this_component [f"{ mem_name } _ARESETn" ],
580
- in_RVALID = this_component [f"{ mem_name } _RVALID" ],
581
- in_RLAST = this_component [f"{ mem_name } _RLAST" ],
582
- in_RDATA = this_component [f"{ mem_name } _RDATA" ],
581
+ in_ARESETn = this_component [f"{ prefixed_mem_name } _ARESETn" ],
582
+ in_RVALID = this_component [f"{ prefixed_mem_name } _RVALID" ],
583
+ in_RLAST = this_component [f"{ prefixed_mem_name } _RLAST" ],
584
+ in_RDATA = this_component [f"{ prefixed_mem_name } _RDATA" ],
583
585
# TODO: Do we need this? Don't think this goes anywhere
584
- in_RRESP = this_component [f"{ mem_name } _RRESP" ],
585
- out_RREADY = this_component [f"{ mem_name } _RREADY" ],
586
+ in_RRESP = this_component [f"{ prefixed_mem_name } _RRESP" ],
587
+ out_RREADY = this_component [f"{ prefixed_mem_name } _RREADY" ],
586
588
)
587
589
588
590
aw_channel_invoke = invoke (
589
591
wrapper_comp .get_cell (f"aw_channel_{ mem_name } " ),
590
592
ref_curr_addr_axi = curr_addr_axi ,
591
593
ref_max_transfers = max_transfers ,
592
- in_ARESETn = this_component [f"{ mem_name } _ARESETn" ],
593
- in_AWREADY = this_component [f"{ mem_name } _AWREADY" ],
594
- out_AWVALID = this_component [f"{ mem_name } _AWVALID" ],
595
- out_AWADDR = this_component [f"{ mem_name } _AWADDR" ],
596
- out_AWSIZE = this_component [f"{ mem_name } _AWSIZE" ],
597
- out_AWLEN = this_component [f"{ mem_name } _AWLEN" ],
598
- out_AWBURST = this_component [f"{ mem_name } _AWBURST" ],
599
- out_AWPROT = this_component [f"{ mem_name } _AWPROT" ],
594
+ in_ARESETn = this_component [f"{ prefixed_mem_name } _ARESETn" ],
595
+ in_AWREADY = this_component [f"{ prefixed_mem_name } _AWREADY" ],
596
+ out_AWVALID = this_component [f"{ prefixed_mem_name } _AWVALID" ],
597
+ out_AWADDR = this_component [f"{ prefixed_mem_name } _AWADDR" ],
598
+ out_AWSIZE = this_component [f"{ prefixed_mem_name } _AWSIZE" ],
599
+ out_AWLEN = this_component [f"{ prefixed_mem_name } _AWLEN" ],
600
+ out_AWBURST = this_component [f"{ prefixed_mem_name } _AWBURST" ],
601
+ out_AWPROT = this_component [f"{ prefixed_mem_name } _AWPROT" ],
600
602
)
601
603
602
604
write_channel_invoke = invoke (
@@ -605,17 +607,17 @@ def add_main_comp(prog, mems):
605
607
ref_curr_addr_internal_mem = curr_addr_internal_mem ,
606
608
ref_curr_addr_axi = curr_addr_axi ,
607
609
ref_max_transfers = max_transfers ,
608
- in_ARESETn = this_component [f"{ mem_name } _ARESETn" ],
609
- in_WREADY = this_component [f"{ mem_name } _WREADY" ],
610
- out_WVALID = this_component [f"{ mem_name } _WVALID" ],
611
- out_WLAST = this_component [f"{ mem_name } _WLAST" ],
612
- out_WDATA = this_component [f"{ mem_name } _WDATA" ],
610
+ in_ARESETn = this_component [f"{ prefixed_mem_name } _ARESETn" ],
611
+ in_WREADY = this_component [f"{ prefixed_mem_name } _WREADY" ],
612
+ out_WVALID = this_component [f"{ prefixed_mem_name } _WVALID" ],
613
+ out_WLAST = this_component [f"{ prefixed_mem_name } _WLAST" ],
614
+ out_WDATA = this_component [f"{ prefixed_mem_name } _WDATA" ],
613
615
)
614
616
615
617
bresp_channel_invoke = invoke (
616
618
wrapper_comp .get_cell (f"bresp_channel_{ mem_name } " ),
617
- in_BVALID = this_component [f"{ mem_name } _BVALID" ],
618
- out_BREADY = this_component [f"{ mem_name } _BREADY" ],
619
+ in_BVALID = this_component [f"{ prefixed_mem_name } _BVALID" ],
620
+ out_BREADY = this_component [f"{ prefixed_mem_name } _BREADY" ],
619
621
)
620
622
621
623
curr_addr_axi_invoke = invoke (curr_addr_axi , in_in = 0x1000 )
@@ -690,12 +692,12 @@ def build():
690
692
def check_mems_welformed (mems ):
691
693
"""Checks if memories from yxi are well formed. Returns true if they are, false otherwise."""
692
694
for mem in mems :
693
- assert mem [ width_key ] % 8 == 0 , (
694
- "Width must be a multiple of 8 to alow byte addressing to host"
695
- )
696
- assert log2 (mem [ width_key ]). is_integer (), (
697
- "Width must be a power of 2 to be correctly described by xSIZE"
698
- )
695
+ assert (
696
+ mem [ width_key ] % 8 == 0
697
+ ), "Width must be a multiple of 8 to alow byte addressing to host"
698
+ assert log2 (
699
+ mem [ width_key ]
700
+ ). is_integer (), "Width must be a power of 2 to be correctly described by xSIZE"
699
701
assert mem [size_key ] > 0 , "Memory size must be greater than 0"
700
702
701
703
0 commit comments