33
33
)
34
34
35
35
36
- def dut_mmap_tcl (
36
+ def dut_hbm_mmap_tcl (
37
37
mmap_ports : dict [str , dict [str , int ]],
38
- hbm : bool ,
39
38
hbm_init_file : str ,
40
39
) -> list [str ]:
41
- """Adds DUT's MMAP ports related tcl commands to the block design.
40
+ """Adds DUT's HBM- MMAP related tcl commands to the block design.
42
41
43
42
Returns a list of tcl commands.
44
43
"""
45
44
tcl = []
46
- if hbm :
47
- num_hbm_nmu = sum (1 for v in mmap_ports .values () if v .get ("noc" ) is None )
48
- tcl += [
49
- f"""
45
+ num_hbm_nmu = sum (1 for v in mmap_ports .values () if v .get ("noc" ) is None )
46
+ tcl += [
47
+ f"""
50
48
startgroup
51
49
52
50
set_property -dict [list \
53
51
CONFIG.NUM_HBM_BLI {{{ num_hbm_nmu } }} \
54
- CONFIG.NUM_SI {{{ 8 + len (mmap_ports ) - num_hbm_nmu } }} \
55
- CONFIG.NUM_CLKS {{9 }} \
52
+ CONFIG.NUM_SI {{{ len (mmap_ports ) - num_hbm_nmu } }} \
53
+ CONFIG.NUM_CLKS {{1 }} \
56
54
CONFIG.HBM_MEM_BACKDOOR_WRITE {{true}} \
57
55
CONFIG.HBM_MEM_INIT_FILE {{{ hbm_init_file } }} \
58
56
] $axi_noc_dut
59
57
"""
60
- ]
58
+ ]
61
59
62
- # counters for each HBM PC to balance the usage of the HBM ports
63
- # initialize with CIPS connections
64
- def get_hbm_noc_port (bank : int ) -> str :
65
- # bank 0 = HBM PC 0 port 0 = port_idx 0
66
- # bank 0 = HBM PC 0 port 1 = port_idx 1
67
- # bank 1 = HBM PC 1 port 0 = port_idx 2
68
- # bank 1 = HBM PC 1 port 1 = port_idx 3
69
- port_idx = bank % 2 * 2 + hbm_bank_cnt [bank ] % 2
70
- # Note: hbm_bank_cnt is STATIC!
71
- hbm_bank_cnt [bank ] += 1
72
- return f"HBM{ bank // 2 } _PORT{ port_idx } "
73
-
74
- hbm_bank_cnt = {i : 1 for i in range (32 )}
75
- else :
76
- tcl += [
77
- f"""
78
- # Create mmap noc
79
- startgroup
80
- set axi_noc_dut [ create_bd_cell -type ip -vlnv xilinx.com:ip:axi_noc:1.1 axi_noc_dut ]
60
+ # counters for each HBM PC to balance the usage of the HBM ports
61
+ # initialize with CIPS connections
62
+ def get_hbm_noc_port (bank : int ) -> str :
63
+ # bank 0 = HBM PC 0 port 0 = port_idx 0
64
+ # bank 0 = HBM PC 0 port 1 = port_idx 1
65
+ # bank 1 = HBM PC 1 port 0 = port_idx 2
66
+ # bank 1 = HBM PC 1 port 1 = port_idx 3
67
+ port_idx = bank % 2 * 2 + hbm_bank_cnt [bank ] % 2
68
+ # Note: hbm_bank_cnt is STATIC!
69
+ hbm_bank_cnt [bank ] += 1
70
+ return f"HBM{ bank // 2 } _PORT{ port_idx } "
81
71
82
- set_property -dict [list \
83
- CONFIG.NUM_CLKS {{1}} \
84
- CONFIG.NUM_MI {{0}} \
85
- CONFIG.NUM_NMI {{1}} \
86
- CONFIG.NUM_NSI {{0}} \
87
- CONFIG.NUM_SI {{{ len (mmap_ports )} }} \
88
- ] $axi_noc_dut
89
- """
90
- ]
72
+ hbm_bank_cnt = {i : 1 for i in range (32 )}
91
73
92
74
# Configure and connect mmap noc
93
75
all_busif_ports = []
94
76
nmu_port_cnt = {"reg" : 0 , "hbm" : 0 }
95
77
for i , (port , attr ) in enumerate (mmap_ports .items ()):
96
- if not hbm :
97
- noc_s_port = f"S{ i :02d} _AXI" # DDR
98
78
# for HBM, mmap ports use dedicated HBM NMU nodes if attr["noc"] is not set
99
79
# else, use regular NMU nodes
100
- elif attr .get ("noc" ) is None :
80
+ if attr .get ("noc" ) is None :
101
81
noc_s_port = f"HBM{ nmu_port_cnt ['hbm' ]:02d} _AXI" # HBM NMU
102
82
nmu_port_cnt ["hbm" ] += 1
103
83
else :
104
84
noc_s_port = f"S{ (nmu_port_cnt ['reg' ] + 8 ):02d} _AXI" # regular NMU
105
85
nmu_port_cnt ["reg" ] += 1
106
86
107
- noc_m_port = get_hbm_noc_port (attr ["bank" ]) if hbm else "M00_INI"
87
+ noc_m_port = get_hbm_noc_port (attr ["bank" ])
108
88
109
89
tcl += [
110
90
f"""
@@ -114,7 +94,7 @@ def get_hbm_noc_port(bank: int) -> str:
114
94
read_avg_burst {{8}} \
115
95
write_avg_burst {{8}} \\
116
96
# excl_group {{{ '' if attr .get ("noc" ) is None else i } }} \\
117
- sep_rt_group {{{ i } }} \\
97
+ sep_rt_group {{{ i } }} \
118
98
}}}}] [get_bd_intf_pins /axi_noc_dut/{ noc_s_port } ]
119
99
connect_bd_intf_net [get_bd_intf_pins $dut/{ port } ] \
120
100
[get_bd_intf_pins /axi_noc_dut/{ noc_s_port } ]
@@ -124,15 +104,71 @@ def get_hbm_noc_port(bank: int) -> str:
124
104
125
105
s_busif_ports = ":" .join (all_busif_ports )
126
106
127
- if hbm :
107
+ tcl += [
108
+ f"set_property -dict [list CONFIG.ASSOCIATED_BUSIF {{{ s_busif_ports } }}] \
109
+ [get_bd_pins /axi_noc_dut/aclk0]"
110
+ ]
111
+
112
+ tcl += ["endgroup" ]
113
+ return tcl
114
+
115
+
116
+ def dut_ddr_mmap_tcl (mmap_ports : dict [str , dict [str , int ]]) -> list [str ]:
117
+ """Adds DUT's MMAP-DDR related tcl commands to the block design.
118
+
119
+ Returns a list of tcl commands.
120
+ """
121
+ tcl = []
122
+
123
+ ddr_mc_cnt = [0 , 0 , 0 ]
124
+ for attr in mmap_ports .values ():
125
+ mc = attr ["bank" ] // 4
126
+ ddr_mc_cnt [mc ] += 1
127
+
128
+ for i , cnt in enumerate (ddr_mc_cnt ):
128
129
tcl += [
129
- f"set_property -dict [list CONFIG.ASSOCIATED_BUSIF {{{ s_busif_ports } }}] \
130
- [get_bd_pins /axi_noc_dut/aclk8]"
130
+ f"""
131
+ # Create mmap noc
132
+ startgroup
133
+ set_property -dict [list \
134
+ CONFIG.NUM_SI {{{ cnt } }} \
135
+ ] $axi_noc_dut_{ i + 1 }
136
+ """
131
137
]
132
- else :
138
+
139
+ # Configure and connect mmap noc
140
+ all_busif_ports : list [list [str ]] = [[], [], []]
141
+ ddr_mc_cnt = [0 , 0 , 0 ]
142
+ for i , (port , attr ) in enumerate (mmap_ports .items ()):
143
+ mc = attr ["bank" ] // 4
144
+ noc_s_port = f"S{ ddr_mc_cnt [mc ]:02d} _AXI" # DDR
145
+ noc_m_port = f"MC_{ attr ['bank' ] % 4 } "
146
+ ddr_mc_cnt [mc ] += 1
147
+
148
+ tcl += [
149
+ f"""
150
+ set_property -dict [list CONFIG.CONNECTIONS {{{ noc_m_port } {{ \
151
+ read_bw {{{ attr ['read_bw' ] - 100 } }} \
152
+ write_bw {{{ attr ['write_bw' ] - 100 } }} \
153
+ read_avg_burst {{8}} \
154
+ write_avg_burst {{8}} \\
155
+ # excl_group {{{ '' if attr .get ("noc" ) is None else i } }} \\
156
+ sep_rt_group {{{ i } }} \\
157
+ }}}}] [get_bd_intf_pins /axi_noc_dut_{ mc + 1 } /{ noc_s_port } ]
158
+ connect_bd_intf_net [get_bd_intf_pins $dut/{ port } ] \
159
+ [get_bd_intf_pins /axi_noc_dut_{ mc + 1 } /{ noc_s_port } ]
160
+ """
161
+ ]
162
+ all_busif_ports [mc ].append (noc_s_port )
163
+
164
+ for i , busif in enumerate (all_busif_ports ):
165
+ if not busif :
166
+ continue
167
+ s_busif_ports = ":" .join (busif )
168
+
133
169
tcl += [
134
170
f"set_property -dict [list CONFIG.ASSOCIATED_BUSIF {{{ s_busif_ports } }}] \
135
- [get_bd_pins /axi_noc_dut /aclk0]"
171
+ [get_bd_pins /axi_noc_dut_ { i + 1 } /aclk0]"
136
172
]
137
173
138
174
tcl += ["endgroup" ]
@@ -259,54 +295,36 @@ def dut_tcl(
259
295
"""
260
296
]
261
297
262
- tcl += dut_mmap_tcl (mmap_ports , hbm , hbm_init_file )
298
+ if hbm :
299
+ tcl += dut_hbm_mmap_tcl (mmap_ports , hbm_init_file )
300
+ else :
301
+ tcl += dut_ddr_mmap_tcl (mmap_ports )
263
302
264
303
if stream_attr :
265
304
tcl += dut_stream_noc_tcl (stream_attr )
266
305
267
306
return tcl
268
307
269
308
270
- def connect_dut_mb_tcl (stream_attr : dict [str , dict [str , str ]]) -> list [str ]:
271
- """Connects dut in the Microblaze block design.
272
-
273
- Returns a list of tcl commands.
274
- """
275
- tcl = [
276
- """
277
- connect_bd_net [get_bd_pins sim_clk_gen_1/clk] [get_bd_clk_pins $dut]
278
- connect_bd_net [get_bd_pins rst_clk_wiz_100M/peripheral_aresetn] [get_bd_rst_pins $dut]
279
- connect_bd_intf_net [get_bd_intf_pins smartconnect_0/M01_AXI] \
280
- [get_bd_intf_pins dut_0/s_axi_control]
281
- connect_bd_net [get_bd_pins axi_noc_dut/aclk0] [get_bd_pins sim_clk_gen_1/clk]
282
- connect_bd_intf_net [get_bd_intf_pins axi_noc_dut/M00_INI] \
283
- [get_bd_intf_pins axi_noc_0/S00_INI]
284
- """
285
- ]
286
- if stream_attr :
287
- tcl += [
288
- "connect_bd_net [get_bd_pins axis_noc_dut/aclk0] \
289
- [get_bd_pins sim_clk_gen_1/clk]"
290
- ]
291
- return tcl
292
-
293
-
294
309
def connect_dut_arm_ddr_tcl (stream_attr : dict [str , dict [str , str ]]) -> list [str ]:
295
310
"""Connects dut in the ARM-DDR block design.
296
311
297
312
Returns a list of tcl commands.
298
313
"""
299
314
tcl = [
300
315
"""
316
+ # Create external clk port for simulation
317
+ set pl0_ref_clk_0 [ create_bd_port -dir O -type clk pl0_ref_clk_0 ]
318
+ connect_bd_net [get_bd_pins CIPS_0/pl0_ref_clk] [get_bd_ports pl0_ref_clk_0]
319
+
301
320
# connect_bd_net [get_bd_pins clk_wizard_0/clk_out1] [get_bd_clk_pins $dut] \
302
321
# [get_bd_pins axi_noc_dut/aclk0]
303
322
connect_bd_net [get_bd_pins CIPS_0/pl0_ref_clk] [get_bd_clk_pins $dut] \
304
- [get_bd_pins axi_noc_dut/aclk0]
323
+ [get_bd_pins axi_noc_dut_1/aclk0] [get_bd_pins axi_noc_dut_2/aclk0] \
324
+ [get_bd_pins axi_noc_dut_3/aclk0]
305
325
connect_bd_net [get_bd_pins proc_sys_reset_0/peripheral_aresetn] [get_bd_rst_pins $dut]
306
326
connect_bd_intf_net [get_bd_intf_pins icn_ctrl/M01_AXI] \
307
327
[get_bd_intf_pins dut_0/s_axi_control]
308
- connect_bd_intf_net [get_bd_intf_pins axi_noc_dut/M00_INI] \
309
- [get_bd_intf_pins noc_lpddr4_1/S01_INI]
310
328
connect_bd_net [get_bd_pins dut_0/interrupt] [get_bd_pins axi_intc_0/intr]
311
329
"""
312
330
]
@@ -329,14 +347,12 @@ def connect_dut_arm_hbm_tcl(stream_attr: dict[str, dict[str, str]]) -> list[str]
329
347
"""
330
348
# Create external clk and reset ports for simulation
331
349
set pl0_ref_clk_0 [ create_bd_port -dir O -type clk pl0_ref_clk_0 ]
332
- set pl0_resetn_0 [ create_bd_port -dir O -type rst pl0_resetn_0 ]
333
350
connect_bd_net [get_bd_pins CIPS_0/pl0_ref_clk] [get_bd_ports pl0_ref_clk_0]
334
- connect_bd_net [get_bd_pins CIPS_0/pl0_resetn] [get_bd_ports pl0_resetn_0]
335
351
336
352
# connect_bd_net [get_bd_pins clk_wizard_0/clk_out1] [get_bd_clk_pins $dut] \
337
- # [get_bd_pins $axi_noc_dut/aclk8 ]
353
+ # [get_bd_pins $axi_noc_dut/aclk0 ]
338
354
connect_bd_net [get_bd_pins CIPS_0/pl0_ref_clk] [get_bd_clk_pins $dut] \
339
- [get_bd_pins $axi_noc_dut/aclk8 ]
355
+ [get_bd_pins $axi_noc_dut/aclk0 ]
340
356
connect_bd_net [get_bd_pins proc_sys_reset_0/peripheral_aresetn] [get_bd_rst_pins $dut]
341
357
connect_bd_intf_net [get_bd_intf_pins icn_ctrl/M01_AXI] \
342
358
[get_bd_intf_pins dut_0/s_axi_control]
@@ -388,7 +404,7 @@ def gen_arm_bd_ddr(
388
404
bd_attr ["hbm_init_file" ],
389
405
)
390
406
tcl += connect_dut_arm_ddr_tcl (stream_attr )
391
- tcl += assign_arm_bd_address ()
407
+ tcl += assign_arm_bd_address (False )
392
408
return tcl
393
409
394
410
@@ -428,15 +444,15 @@ def gen_arm_bd_hbm(
428
444
bd_attr ["hbm_init_file" ],
429
445
)
430
446
tcl += connect_dut_arm_hbm_tcl (stream_attr )
431
- tcl += assign_arm_bd_address ()
447
+ tcl += assign_arm_bd_address (True )
432
448
return tcl
433
449
434
450
435
451
if __name__ == "__main__" :
436
452
import json
437
453
438
454
# manually set the following
439
- TEST_DIR = "/home/jakeke/rapidstream-noc/test/serpens32_mmap "
455
+ TEST_DIR = "/home/jakeke/rapidstream-noc/test/tmp2 "
440
456
TOP_MOD_NAME = "Serpens"
441
457
HBM_BD = True
442
458
0 commit comments