Skip to content

Commit d306487

Browse files
committed
fpga/mqnic/Alveo: Rework Alveo parametrization
Signed-off-by: Alex Forencich <[email protected]>
1 parent 495c29f commit d306487

File tree

10 files changed

+2696
-1375
lines changed

10 files changed

+2696
-1375
lines changed

fpga/mqnic/Alveo/fpga_100g/rtl/fpga_au200.v

Lines changed: 223 additions & 304 deletions
Large diffs are not rendered by default.

fpga/mqnic/Alveo/fpga_100g/rtl/fpga_core.v

Lines changed: 221 additions & 293 deletions
Large diffs are not rendered by default.

fpga/mqnic/Alveo/fpga_100g/tb/fpga_core/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ COCOTB_HDL_TIMEUNIT = 1ns
1010
COCOTB_HDL_TIMEPRECISION = 1ps
1111

1212
DUT = fpga_core
13-
TOPLEVEL = $(DUT)
13+
TOPLEVEL = test_$(DUT)
1414
MODULE = test_$(DUT)
15+
VERILOG_SOURCES += $(TOPLEVEL).v
1516
VERILOG_SOURCES += ../../rtl/$(DUT).v
1617
VERILOG_SOURCES += ../../rtl/common/mqnic_core_pcie_us.v
1718
VERILOG_SOURCES += ../../rtl/common/mqnic_core_pcie.v

fpga/mqnic/Alveo/fpga_100g/tb/fpga_core/test_fpga_core.py

Lines changed: 43 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ def __init__(self, dut, msix_count=32):
5151
pcie_link_width=16,
5252
user_clk_frequency=250e6,
5353
alignment="dword",
54-
cq_straddle=len(dut.core_inst.pcie_if_inst.pcie_us_if_cq_inst.rx_req_tlp_valid_reg) > 1,
55-
cc_straddle=len(dut.core_inst.pcie_if_inst.pcie_us_if_cc_inst.out_tlp_valid) > 1,
56-
rq_straddle=len(dut.core_inst.pcie_if_inst.pcie_us_if_rq_inst.out_tlp_valid) > 1,
57-
rc_straddle=len(dut.core_inst.pcie_if_inst.pcie_us_if_rc_inst.rx_cpl_tlp_valid_reg) > 1,
58-
rc_4tlp_straddle=len(dut.core_inst.pcie_if_inst.pcie_us_if_rc_inst.rx_cpl_tlp_valid_reg) > 2,
54+
cq_straddle=len(dut.uut.core_inst.pcie_if_inst.pcie_us_if_cq_inst.rx_req_tlp_valid_reg) > 1,
55+
cc_straddle=len(dut.uut.core_inst.pcie_if_inst.pcie_us_if_cc_inst.out_tlp_valid) > 1,
56+
rq_straddle=len(dut.uut.core_inst.pcie_if_inst.pcie_us_if_rq_inst.out_tlp_valid) > 1,
57+
rc_straddle=len(dut.uut.core_inst.pcie_if_inst.pcie_us_if_rc_inst.rx_cpl_tlp_valid_reg) > 1,
58+
rc_4tlp_straddle=len(dut.uut.core_inst.pcie_if_inst.pcie_us_if_rc_inst.rx_cpl_tlp_valid_reg) > 2,
5959
pf_count=1,
6060
max_payload_size=1024,
6161
enable_client_tag=True,
@@ -267,9 +267,9 @@ def __init__(self, dut, msix_count=32):
267267

268268
self.driver = mqnic.Driver()
269269

270-
self.dev.functions[0].configure_bar(0, 2**len(dut.core_inst.core_pcie_inst.axil_ctrl_araddr), ext=True, prefetch=True)
271-
if hasattr(dut.core_inst.core_pcie_inst, 'pcie_app_ctrl'):
272-
self.dev.functions[0].configure_bar(2, 2**len(dut.core_inst.core_pcie_inst.axil_app_ctrl_araddr), ext=True, prefetch=True)
270+
self.dev.functions[0].configure_bar(0, 2**len(dut.uut.core_inst.core_pcie_inst.axil_ctrl_araddr), ext=True, prefetch=True)
271+
if hasattr(dut.uut.core_inst.core_pcie_inst, 'pcie_app_ctrl'):
272+
self.dev.functions[0].configure_bar(2, 2**len(dut.uut.core_inst.core_pcie_inst.axil_app_ctrl_araddr), ext=True, prefetch=True)
273273

274274
cocotb.start_soon(Clock(dut.ptp_clk, 6.206, units="ns").start())
275275
dut.ptp_rst.setimmediatevalue(0)
@@ -278,38 +278,38 @@ def __init__(self, dut, msix_count=32):
278278
# Ethernet
279279
self.qsfp_mac = []
280280

281-
for k in range(2):
282-
cocotb.start_soon(Clock(getattr(dut, f"qsfp{k}_rx_clk"), 3.102, units="ns").start())
283-
cocotb.start_soon(Clock(getattr(dut, f"qsfp{k}_tx_clk"), 3.102, units="ns").start())
281+
for ch in self.dut.ch:
282+
cocotb.start_soon(Clock(ch.ch_rx_clk, 3.102, units="ns").start())
283+
cocotb.start_soon(Clock(ch.ch_tx_clk, 3.102, units="ns").start())
284284

285285
mac = EthMac(
286-
tx_clk=getattr(dut, f"qsfp{k}_tx_clk"),
287-
tx_rst=getattr(dut, f"qsfp{k}_tx_rst"),
288-
tx_bus=AxiStreamBus.from_prefix(dut, f"qsfp{k}_tx_axis"),
289-
tx_ptp_time=getattr(dut, f"qsfp{k}_tx_ptp_time"),
290-
tx_ptp_ts=getattr(dut, f"qsfp{k}_tx_ptp_ts"),
291-
tx_ptp_ts_tag=getattr(dut, f"qsfp{k}_tx_ptp_ts_tag"),
292-
tx_ptp_ts_valid=getattr(dut, f"qsfp{k}_tx_ptp_ts_valid"),
293-
rx_clk=getattr(dut, f"qsfp{k}_rx_clk"),
294-
rx_rst=getattr(dut, f"qsfp{k}_rx_rst"),
295-
rx_bus=AxiStreamBus.from_prefix(dut, f"qsfp{k}_rx_axis"),
296-
rx_ptp_time=getattr(dut, f"qsfp{k}_rx_ptp_time"),
286+
tx_clk=ch.ch_tx_clk,
287+
tx_rst=ch.ch_tx_rst,
288+
tx_bus=AxiStreamBus.from_prefix(ch, "ch_tx_axis"),
289+
tx_ptp_time=ch.ch_tx_ptp_time,
290+
tx_ptp_ts=ch.ch_tx_ptp_ts,
291+
tx_ptp_ts_tag=ch.ch_tx_ptp_ts_tag,
292+
tx_ptp_ts_valid=ch.ch_tx_ptp_ts_valid,
293+
rx_clk=ch.ch_rx_clk,
294+
rx_rst=ch.ch_rx_rst,
295+
rx_bus=AxiStreamBus.from_prefix(ch, "ch_rx_axis"),
296+
rx_ptp_time=ch.ch_rx_ptp_time,
297297
ifg=12, speed=100e9
298298
)
299299

300300
self.qsfp_mac.append(mac)
301301

302-
getattr(dut, f"qsfp{k}_rx_status").setimmediatevalue(1)
303-
getattr(dut, f"qsfp{k}_rx_lfc_req").setimmediatevalue(0)
304-
getattr(dut, f"qsfp{k}_rx_pfc_req").setimmediatevalue(0)
302+
ch.ch_rx_status.setimmediatevalue(1)
303+
ch.ch_rx_lfc_req.setimmediatevalue(0)
304+
ch.ch_rx_pfc_req.setimmediatevalue(0)
305305

306-
cocotb.start_soon(Clock(getattr(dut, f"qsfp{k}_drp_clk"), 8, units="ns").start())
307-
getattr(dut, f"qsfp{k}_drp_rst").setimmediatevalue(0)
308-
getattr(dut, f"qsfp{k}_drp_do").setimmediatevalue(0)
309-
getattr(dut, f"qsfp{k}_drp_rdy").setimmediatevalue(0)
306+
cocotb.start_soon(Clock(dut.qsfp_drp_clk, 8, units="ns").start())
307+
dut.qsfp_drp_rst.setimmediatevalue(0)
308+
dut.qsfp_drp_do.setimmediatevalue(0)
309+
dut.qsfp_drp_rdy.setimmediatevalue(0)
310310

311-
getattr(dut, f"qsfp{k}_modprsl").setimmediatevalue(0)
312-
getattr(dut, f"qsfp{k}_intl").setimmediatevalue(1)
311+
dut.qsfp_modprsl.setimmediatevalue(0)
312+
dut.qsfp_intl.setimmediatevalue(1)
313313

314314
dut.sw.setimmediatevalue(0)
315315

@@ -326,17 +326,17 @@ def __init__(self, dut, msix_count=32):
326326
async def init(self):
327327

328328
self.dut.ptp_rst.setimmediatevalue(0)
329-
for k in range(2):
330-
getattr(self.dut, f"qsfp{k}_rx_rst").setimmediatevalue(0)
331-
getattr(self.dut, f"qsfp{k}_tx_rst").setimmediatevalue(0)
329+
for ch in self.dut.ch:
330+
ch.ch_rx_rst.setimmediatevalue(0)
331+
ch.ch_tx_rst.setimmediatevalue(0)
332332

333333
await RisingEdge(self.dut.clk_250mhz)
334334
await RisingEdge(self.dut.clk_250mhz)
335335

336336
self.dut.ptp_rst.setimmediatevalue(1)
337-
for k in range(2):
338-
getattr(self.dut, f"qsfp{k}_rx_rst").setimmediatevalue(1)
339-
getattr(self.dut, f"qsfp{k}_tx_rst").setimmediatevalue(1)
337+
for ch in self.dut.ch:
338+
ch.ch_rx_rst.setimmediatevalue(1)
339+
ch.ch_tx_rst.setimmediatevalue(1)
340340

341341
await FallingEdge(self.dut.rst_250mhz)
342342
await Timer(100, 'ns')
@@ -345,9 +345,9 @@ async def init(self):
345345
await RisingEdge(self.dut.clk_250mhz)
346346

347347
self.dut.ptp_rst.setimmediatevalue(0)
348-
for k in range(2):
349-
getattr(self.dut, f"qsfp{k}_rx_rst").setimmediatevalue(0)
350-
getattr(self.dut, f"qsfp{k}_tx_rst").setimmediatevalue(0)
348+
for ch in self.dut.ch:
349+
ch.ch_rx_rst.setimmediatevalue(0)
350+
ch.ch_tx_rst.setimmediatevalue(0)
351351

352352
await self.rc.enumerate()
353353

@@ -364,7 +364,7 @@ async def _run_loopback(self):
364364
@cocotb.test()
365365
async def run_test_nic(dut):
366366

367-
tb = TB(dut, msix_count=2**len(dut.core_inst.core_pcie_inst.irq_index))
367+
tb = TB(dut, msix_count=2**len(dut.uut.core_inst.core_pcie_inst.irq_index))
368368

369369
await tb.init()
370370

@@ -572,9 +572,10 @@ async def run_test_nic(dut):
572572
def test_fpga_core(request):
573573
dut = "fpga_core"
574574
module = os.path.splitext(os.path.basename(__file__))[0]
575-
toplevel = dut
575+
toplevel = f"test_{dut}"
576576

577577
verilog_sources = [
578+
os.path.join(tests_dir, f"{toplevel}.v"),
578579
os.path.join(rtl_dir, f"{dut}.v"),
579580
os.path.join(rtl_dir, "common", "mqnic_core_pcie_us.v"),
580581
os.path.join(rtl_dir, "common", "mqnic_core_pcie.v"),

0 commit comments

Comments
 (0)