From d6fc68947b5e539e07640ad95cb2785006c0acf5 Mon Sep 17 00:00:00 2001 From: Alex Forencich Date: Thu, 27 Jul 2023 20:25:08 -0700 Subject: [PATCH] Procedural generation of testbench drivers Signed-off-by: Alex Forencich --- .../fpga_10g/tb/fpga_core/test_fpga_core.py | 208 +---- .../fpga_25g/tb/fpga_core/test_fpga_core.py | 120 +-- .../fpga_25g/tb/fpga_core/test_fpga_core.py | 120 +-- .../fpga_25g/tb/fpga_core/test_fpga_core.py | 120 +-- .../fpga_25g/tb/fpga_core/test_fpga_core.py | 120 +-- .../fpga_25g/tb/fpga_core/test_fpga_core.py | 68 +- .../fpga/tb/fpga_core/test_fpga_core.py | 25 +- .../fpga/tb/fpga_core/test_fpga_core.py | 46 +- .../fpga_25g/tb/fpga_core/test_fpga_core.py | 46 +- .../fpga/tb/fpga_core/test_fpga_core.py | 90 +-- .../tb/fpga_core/test_fpga_core.py | 92 +-- .../fpga_25g/tb/fpga_core/test_fpga_core.py | 428 +---------- .../tb/fpga_core/test_fpga_core.py | 716 ++---------------- .../fpga/tb/fpga_core/test_fpga_core.py | 68 +- .../fpga_10g/tb/fpga_core/test_fpga_core.py | 186 +---- .../fpga_10g/tb/fpga_core/test_fpga_core.py | 120 +-- .../fpga_10g/tb/fpga_core/test_fpga_core.py | 76 +- .../fpga_25g/tb/fpga_core/test_fpga_core.py | 128 +--- .../tb/fpga_core/test_fpga_core.py | 416 ++-------- .../fpga_25g/tb/fpga_core/test_fpga_core.py | 120 +-- .../fpga/tb/fpga_core/test_fpga_core.py | 68 +- .../fpga/tb/fpga_core/test_fpga_core.py | 46 +- .../fpga_25g/tb/fpga_core/test_fpga_core.py | 120 +-- 23 files changed, 658 insertions(+), 2889 deletions(-) diff --git a/example/520N_MX/fpga_10g/tb/fpga_core/test_fpga_core.py b/example/520N_MX/fpga_10g/tb/fpga_core/test_fpga_core.py index ef7224c09..df2b0cc67 100644 --- a/example/520N_MX/fpga_10g/tb/fpga_core/test_fpga_core.py +++ b/example/520N_MX/fpga_10g/tb/fpga_core/test_fpga_core.py @@ -48,195 +48,47 @@ class TB: cocotb.start_soon(Clock(dut.clk, 6.4, units="ns").start()) # Ethernet - cocotb.start_soon(Clock(dut.qsfp0_rx_clk_1, 6.4, units="ns").start()) - self.qsfp0_1_source = XgmiiSource(dut.qsfp0_rxd_1, dut.qsfp0_rxc_1, dut.qsfp0_rx_clk_1, dut.qsfp0_rx_rst_1) - cocotb.start_soon(Clock(dut.qsfp0_tx_clk_1, 6.4, units="ns").start()) - self.qsfp0_1_sink = XgmiiSink(dut.qsfp0_txd_1, dut.qsfp0_txc_1, dut.qsfp0_tx_clk_1, dut.qsfp0_tx_rst_1) + self.qsfp_source = [] + self.qsfp_sink = [] - cocotb.start_soon(Clock(dut.qsfp0_rx_clk_2, 6.4, units="ns").start()) - self.qsfp0_2_source = XgmiiSource(dut.qsfp0_rxd_2, dut.qsfp0_rxc_2, dut.qsfp0_rx_clk_2, dut.qsfp0_rx_rst_2) - cocotb.start_soon(Clock(dut.qsfp0_tx_clk_2, 6.4, units="ns").start()) - self.qsfp0_2_sink = XgmiiSink(dut.qsfp0_txd_2, dut.qsfp0_txc_2, dut.qsfp0_tx_clk_2, dut.qsfp0_tx_rst_2) - - cocotb.start_soon(Clock(dut.qsfp0_rx_clk_3, 6.4, units="ns").start()) - self.qsfp0_3_source = XgmiiSource(dut.qsfp0_rxd_3, dut.qsfp0_rxc_3, dut.qsfp0_rx_clk_3, dut.qsfp0_rx_rst_3) - cocotb.start_soon(Clock(dut.qsfp0_tx_clk_3, 6.4, units="ns").start()) - self.qsfp0_3_sink = XgmiiSink(dut.qsfp0_txd_3, dut.qsfp0_txc_3, dut.qsfp0_tx_clk_3, dut.qsfp0_tx_rst_3) - - cocotb.start_soon(Clock(dut.qsfp0_rx_clk_4, 6.4, units="ns").start()) - self.qsfp0_4_source = XgmiiSource(dut.qsfp0_rxd_4, dut.qsfp0_rxc_4, dut.qsfp0_rx_clk_4, dut.qsfp0_rx_rst_4) - cocotb.start_soon(Clock(dut.qsfp0_tx_clk_4, 6.4, units="ns").start()) - self.qsfp0_4_sink = XgmiiSink(dut.qsfp0_txd_4, dut.qsfp0_txc_4, dut.qsfp0_tx_clk_4, dut.qsfp0_tx_rst_4) - - cocotb.start_soon(Clock(dut.qsfp1_rx_clk_1, 6.4, units="ns").start()) - self.qsfp1_1_source = XgmiiSource(dut.qsfp1_rxd_1, dut.qsfp1_rxc_1, dut.qsfp1_rx_clk_1, dut.qsfp1_rx_rst_1) - cocotb.start_soon(Clock(dut.qsfp1_tx_clk_1, 6.4, units="ns").start()) - self.qsfp1_1_sink = XgmiiSink(dut.qsfp1_txd_1, dut.qsfp1_txc_1, dut.qsfp1_tx_clk_1, dut.qsfp1_tx_rst_1) - - cocotb.start_soon(Clock(dut.qsfp1_rx_clk_2, 6.4, units="ns").start()) - self.qsfp1_2_source = XgmiiSource(dut.qsfp1_rxd_2, dut.qsfp1_rxc_2, dut.qsfp1_rx_clk_2, dut.qsfp1_rx_rst_2) - cocotb.start_soon(Clock(dut.qsfp1_tx_clk_2, 6.4, units="ns").start()) - self.qsfp1_2_sink = XgmiiSink(dut.qsfp1_txd_2, dut.qsfp1_txc_2, dut.qsfp1_tx_clk_2, dut.qsfp1_tx_rst_2) - - cocotb.start_soon(Clock(dut.qsfp1_rx_clk_3, 6.4, units="ns").start()) - self.qsfp1_3_source = XgmiiSource(dut.qsfp1_rxd_3, dut.qsfp1_rxc_3, dut.qsfp1_rx_clk_3, dut.qsfp1_rx_rst_3) - cocotb.start_soon(Clock(dut.qsfp1_tx_clk_3, 6.4, units="ns").start()) - self.qsfp1_3_sink = XgmiiSink(dut.qsfp1_txd_3, dut.qsfp1_txc_3, dut.qsfp1_tx_clk_3, dut.qsfp1_tx_rst_3) - - cocotb.start_soon(Clock(dut.qsfp1_rx_clk_4, 6.4, units="ns").start()) - self.qsfp1_4_source = XgmiiSource(dut.qsfp1_rxd_4, dut.qsfp1_rxc_4, dut.qsfp1_rx_clk_4, dut.qsfp1_rx_rst_4) - cocotb.start_soon(Clock(dut.qsfp1_tx_clk_4, 6.4, units="ns").start()) - self.qsfp1_4_sink = XgmiiSink(dut.qsfp1_txd_4, dut.qsfp1_txc_4, dut.qsfp1_tx_clk_4, dut.qsfp1_tx_rst_4) - - cocotb.start_soon(Clock(dut.qsfp2_rx_clk_1, 6.4, units="ns").start()) - self.qsfp2_1_source = XgmiiSource(dut.qsfp2_rxd_1, dut.qsfp2_rxc_1, dut.qsfp2_rx_clk_1, dut.qsfp2_rx_rst_1) - cocotb.start_soon(Clock(dut.qsfp2_tx_clk_1, 6.4, units="ns").start()) - self.qsfp2_1_sink = XgmiiSink(dut.qsfp2_txd_1, dut.qsfp2_txc_1, dut.qsfp2_tx_clk_1, dut.qsfp2_tx_rst_1) - - cocotb.start_soon(Clock(dut.qsfp2_rx_clk_2, 6.4, units="ns").start()) - self.qsfp2_2_source = XgmiiSource(dut.qsfp2_rxd_2, dut.qsfp2_rxc_2, dut.qsfp2_rx_clk_2, dut.qsfp2_rx_rst_2) - cocotb.start_soon(Clock(dut.qsfp2_tx_clk_2, 6.4, units="ns").start()) - self.qsfp2_2_sink = XgmiiSink(dut.qsfp2_txd_2, dut.qsfp2_txc_2, dut.qsfp2_tx_clk_2, dut.qsfp2_tx_rst_2) - - cocotb.start_soon(Clock(dut.qsfp2_rx_clk_3, 6.4, units="ns").start()) - self.qsfp2_3_source = XgmiiSource(dut.qsfp2_rxd_3, dut.qsfp2_rxc_3, dut.qsfp2_rx_clk_3, dut.qsfp2_rx_rst_3) - cocotb.start_soon(Clock(dut.qsfp2_tx_clk_3, 6.4, units="ns").start()) - self.qsfp2_3_sink = XgmiiSink(dut.qsfp2_txd_3, dut.qsfp2_txc_3, dut.qsfp2_tx_clk_3, dut.qsfp2_tx_rst_3) - - cocotb.start_soon(Clock(dut.qsfp2_rx_clk_4, 6.4, units="ns").start()) - self.qsfp2_4_source = XgmiiSource(dut.qsfp2_rxd_4, dut.qsfp2_rxc_4, dut.qsfp2_rx_clk_4, dut.qsfp2_rx_rst_4) - cocotb.start_soon(Clock(dut.qsfp2_tx_clk_4, 6.4, units="ns").start()) - self.qsfp2_4_sink = XgmiiSink(dut.qsfp2_txd_4, dut.qsfp2_txc_4, dut.qsfp2_tx_clk_4, dut.qsfp2_tx_rst_4) - - cocotb.start_soon(Clock(dut.qsfp3_rx_clk_1, 6.4, units="ns").start()) - self.qsfp3_1_source = XgmiiSource(dut.qsfp3_rxd_1, dut.qsfp3_rxc_1, dut.qsfp3_rx_clk_1, dut.qsfp3_rx_rst_1) - cocotb.start_soon(Clock(dut.qsfp3_tx_clk_1, 6.4, units="ns").start()) - self.qsfp3_1_sink = XgmiiSink(dut.qsfp3_txd_1, dut.qsfp3_txc_1, dut.qsfp3_tx_clk_1, dut.qsfp3_tx_rst_1) - - cocotb.start_soon(Clock(dut.qsfp3_rx_clk_2, 6.4, units="ns").start()) - self.qsfp3_2_source = XgmiiSource(dut.qsfp3_rxd_2, dut.qsfp3_rxc_2, dut.qsfp3_rx_clk_2, dut.qsfp3_rx_rst_2) - cocotb.start_soon(Clock(dut.qsfp3_tx_clk_2, 6.4, units="ns").start()) - self.qsfp3_2_sink = XgmiiSink(dut.qsfp3_txd_2, dut.qsfp3_txc_2, dut.qsfp3_tx_clk_2, dut.qsfp3_tx_rst_2) - - cocotb.start_soon(Clock(dut.qsfp3_rx_clk_3, 6.4, units="ns").start()) - self.qsfp3_3_source = XgmiiSource(dut.qsfp3_rxd_3, dut.qsfp3_rxc_3, dut.qsfp3_rx_clk_3, dut.qsfp3_rx_rst_3) - cocotb.start_soon(Clock(dut.qsfp3_tx_clk_3, 6.4, units="ns").start()) - self.qsfp3_3_sink = XgmiiSink(dut.qsfp3_txd_3, dut.qsfp3_txc_3, dut.qsfp3_tx_clk_3, dut.qsfp3_tx_rst_3) - - cocotb.start_soon(Clock(dut.qsfp3_rx_clk_4, 6.4, units="ns").start()) - self.qsfp3_4_source = XgmiiSource(dut.qsfp3_rxd_4, dut.qsfp3_rxc_4, dut.qsfp3_rx_clk_4, dut.qsfp3_rx_rst_4) - cocotb.start_soon(Clock(dut.qsfp3_tx_clk_4, 6.4, units="ns").start()) - self.qsfp3_4_sink = XgmiiSink(dut.qsfp3_txd_4, dut.qsfp3_txc_4, dut.qsfp3_tx_clk_4, dut.qsfp3_tx_rst_4) + for x in range(4): + sources = [] + sinks = [] + for y in range(1, 5): + cocotb.start_soon(Clock(getattr(dut, f"qsfp{x}_rx_clk_{y}"), 6.4, units="ns").start()) + source = XgmiiSource(getattr(dut, f"qsfp{x}_rxd_{y}"), getattr(dut, f"qsfp{x}_rxc_{y}"), getattr(dut, f"qsfp{x}_rx_clk_{y}"), getattr(dut, f"qsfp{x}_rx_rst_{y}")) + sources.append(source) + cocotb.start_soon(Clock(getattr(dut, f"qsfp{x}_tx_clk_{y}"), 6.4, units="ns").start()) + sink = XgmiiSink(getattr(dut, f"qsfp{x}_txd_{y}"), getattr(dut, f"qsfp{x}_txc_{y}"), getattr(dut, f"qsfp{x}_tx_clk_{y}"), getattr(dut, f"qsfp{x}_tx_rst_{y}")) + sinks.append(sink) + self.qsfp_source.append(sources) + self.qsfp_sink.append(sinks) async def init(self): self.dut.rst.setimmediatevalue(0) - self.dut.qsfp0_rx_rst_1.setimmediatevalue(0) - self.dut.qsfp0_tx_rst_1.setimmediatevalue(0) - self.dut.qsfp0_rx_rst_2.setimmediatevalue(0) - self.dut.qsfp0_tx_rst_2.setimmediatevalue(0) - self.dut.qsfp0_rx_rst_3.setimmediatevalue(0) - self.dut.qsfp0_tx_rst_3.setimmediatevalue(0) - self.dut.qsfp0_rx_rst_4.setimmediatevalue(0) - self.dut.qsfp0_tx_rst_4.setimmediatevalue(0) - self.dut.qsfp1_rx_rst_1.setimmediatevalue(0) - self.dut.qsfp1_tx_rst_1.setimmediatevalue(0) - self.dut.qsfp1_rx_rst_2.setimmediatevalue(0) - self.dut.qsfp1_tx_rst_2.setimmediatevalue(0) - self.dut.qsfp1_rx_rst_3.setimmediatevalue(0) - self.dut.qsfp1_tx_rst_3.setimmediatevalue(0) - self.dut.qsfp1_rx_rst_4.setimmediatevalue(0) - self.dut.qsfp1_tx_rst_4.setimmediatevalue(0) - self.dut.qsfp2_rx_rst_1.setimmediatevalue(0) - self.dut.qsfp2_tx_rst_1.setimmediatevalue(0) - self.dut.qsfp2_rx_rst_2.setimmediatevalue(0) - self.dut.qsfp2_tx_rst_2.setimmediatevalue(0) - self.dut.qsfp2_rx_rst_3.setimmediatevalue(0) - self.dut.qsfp2_tx_rst_3.setimmediatevalue(0) - self.dut.qsfp2_rx_rst_4.setimmediatevalue(0) - self.dut.qsfp2_tx_rst_4.setimmediatevalue(0) - self.dut.qsfp3_rx_rst_1.setimmediatevalue(0) - self.dut.qsfp3_tx_rst_1.setimmediatevalue(0) - self.dut.qsfp3_rx_rst_2.setimmediatevalue(0) - self.dut.qsfp3_tx_rst_2.setimmediatevalue(0) - self.dut.qsfp3_rx_rst_3.setimmediatevalue(0) - self.dut.qsfp3_tx_rst_3.setimmediatevalue(0) - self.dut.qsfp3_rx_rst_4.setimmediatevalue(0) - self.dut.qsfp3_tx_rst_4.setimmediatevalue(0) + for x in range(4): + for y in range(1, 5): + getattr(self.dut, f"qsfp{x}_rx_rst_{y}").setimmediatevalue(0) + getattr(self.dut, f"qsfp{x}_tx_rst_{y}").setimmediatevalue(0) for k in range(10): await RisingEdge(self.dut.clk) self.dut.rst.value = 1 - self.dut.qsfp0_rx_rst_1.value = 1 - self.dut.qsfp0_tx_rst_1.value = 1 - self.dut.qsfp0_rx_rst_2.value = 1 - self.dut.qsfp0_tx_rst_2.value = 1 - self.dut.qsfp0_rx_rst_3.value = 1 - self.dut.qsfp0_tx_rst_3.value = 1 - self.dut.qsfp0_rx_rst_4.value = 1 - self.dut.qsfp0_tx_rst_4.value = 1 - self.dut.qsfp1_rx_rst_1.value = 1 - self.dut.qsfp1_tx_rst_1.value = 1 - self.dut.qsfp1_rx_rst_2.value = 1 - self.dut.qsfp1_tx_rst_2.value = 1 - self.dut.qsfp1_rx_rst_3.value = 1 - self.dut.qsfp1_tx_rst_3.value = 1 - self.dut.qsfp1_rx_rst_4.value = 1 - self.dut.qsfp1_tx_rst_4.value = 1 - self.dut.qsfp2_rx_rst_1.value = 1 - self.dut.qsfp2_tx_rst_1.value = 1 - self.dut.qsfp2_rx_rst_2.value = 1 - self.dut.qsfp2_tx_rst_2.value = 1 - self.dut.qsfp2_rx_rst_3.value = 1 - self.dut.qsfp2_tx_rst_3.value = 1 - self.dut.qsfp2_rx_rst_4.value = 1 - self.dut.qsfp2_tx_rst_4.value = 1 - self.dut.qsfp3_rx_rst_1.value = 1 - self.dut.qsfp3_tx_rst_1.value = 1 - self.dut.qsfp3_rx_rst_2.value = 1 - self.dut.qsfp3_tx_rst_2.value = 1 - self.dut.qsfp3_rx_rst_3.value = 1 - self.dut.qsfp3_tx_rst_3.value = 1 - self.dut.qsfp3_rx_rst_4.value = 1 - self.dut.qsfp3_tx_rst_4.value = 1 + for x in range(4): + for y in range(1, 5): + getattr(self.dut, f"qsfp{x}_rx_rst_{y}").value = 1 + getattr(self.dut, f"qsfp{x}_tx_rst_{y}").value = 1 for k in range(10): await RisingEdge(self.dut.clk) self.dut.rst.value = 0 - self.dut.qsfp0_rx_rst_1.value = 0 - self.dut.qsfp0_tx_rst_1.value = 0 - self.dut.qsfp0_rx_rst_2.value = 0 - self.dut.qsfp0_tx_rst_2.value = 0 - self.dut.qsfp0_rx_rst_3.value = 0 - self.dut.qsfp0_tx_rst_3.value = 0 - self.dut.qsfp0_rx_rst_4.value = 0 - self.dut.qsfp0_tx_rst_4.value = 0 - self.dut.qsfp1_rx_rst_1.value = 0 - self.dut.qsfp1_tx_rst_1.value = 0 - self.dut.qsfp1_rx_rst_2.value = 0 - self.dut.qsfp1_tx_rst_2.value = 0 - self.dut.qsfp1_rx_rst_3.value = 0 - self.dut.qsfp1_tx_rst_3.value = 0 - self.dut.qsfp1_rx_rst_4.value = 0 - self.dut.qsfp1_tx_rst_4.value = 0 - self.dut.qsfp2_rx_rst_1.value = 0 - self.dut.qsfp2_tx_rst_1.value = 0 - self.dut.qsfp2_rx_rst_2.value = 0 - self.dut.qsfp2_tx_rst_2.value = 0 - self.dut.qsfp2_rx_rst_3.value = 0 - self.dut.qsfp2_tx_rst_3.value = 0 - self.dut.qsfp2_rx_rst_4.value = 0 - self.dut.qsfp2_tx_rst_4.value = 0 - self.dut.qsfp3_rx_rst_1.value = 0 - self.dut.qsfp3_tx_rst_1.value = 0 - self.dut.qsfp3_rx_rst_2.value = 0 - self.dut.qsfp3_tx_rst_2.value = 0 - self.dut.qsfp3_rx_rst_3.value = 0 - self.dut.qsfp3_tx_rst_3.value = 0 - self.dut.qsfp3_rx_rst_4.value = 0 - self.dut.qsfp3_tx_rst_4.value = 0 + for x in range(4): + for y in range(1, 5): + getattr(self.dut, f"qsfp{x}_rx_rst_{y}").value = 0 + getattr(self.dut, f"qsfp{x}_tx_rst_{y}").value = 0 @cocotb.test() @@ -256,11 +108,11 @@ async def run_test(dut): test_frame = XgmiiFrame.from_payload(test_pkt.build()) - await tb.qsfp0_1_source.send(test_frame) + await tb.qsfp_source[0][0].send(test_frame) tb.log.info("receive ARP request") - rx_frame = await tb.qsfp0_1_sink.recv() + rx_frame = await tb.qsfp_sink[0][0].recv() rx_pkt = Ether(bytes(rx_frame.get_payload())) @@ -288,11 +140,11 @@ async def run_test(dut): resp_frame = XgmiiFrame.from_payload(resp_pkt.build()) - await tb.qsfp0_1_source.send(resp_frame) + await tb.qsfp_source[0][0].send(resp_frame) tb.log.info("receive UDP packet") - rx_frame = await tb.qsfp0_1_sink.recv() + rx_frame = await tb.qsfp_sink[0][0].recv() rx_pkt = Ether(bytes(rx_frame.get_payload())) diff --git a/example/ADM_PCIE_9V3/fpga_25g/tb/fpga_core/test_fpga_core.py b/example/ADM_PCIE_9V3/fpga_25g/tb/fpga_core/test_fpga_core.py index 78e9eb932..423eb9f12 100644 --- a/example/ADM_PCIE_9V3/fpga_25g/tb/fpga_core/test_fpga_core.py +++ b/example/ADM_PCIE_9V3/fpga_25g/tb/fpga_core/test_fpga_core.py @@ -48,109 +48,49 @@ class TB: cocotb.start_soon(Clock(dut.clk, 2.56, units="ns").start()) # Ethernet - cocotb.start_soon(Clock(dut.qsfp_0_rx_clk_0, 2.56, units="ns").start()) - self.qsfp_0_0_source = XgmiiSource(dut.qsfp_0_rxd_0, dut.qsfp_0_rxc_0, dut.qsfp_0_rx_clk_0, dut.qsfp_0_rx_rst_0) - cocotb.start_soon(Clock(dut.qsfp_0_tx_clk_0, 2.56, units="ns").start()) - self.qsfp_0_0_sink = XgmiiSink(dut.qsfp_0_txd_0, dut.qsfp_0_txc_0, dut.qsfp_0_tx_clk_0, dut.qsfp_0_tx_rst_0) + self.qsfp_source = [] + self.qsfp_sink = [] - cocotb.start_soon(Clock(dut.qsfp_0_rx_clk_1, 2.56, units="ns").start()) - self.qsfp_0_1_source = XgmiiSource(dut.qsfp_0_rxd_1, dut.qsfp_0_rxc_1, dut.qsfp_0_rx_clk_1, dut.qsfp_0_rx_rst_1) - cocotb.start_soon(Clock(dut.qsfp_0_tx_clk_1, 2.56, units="ns").start()) - self.qsfp_0_1_sink = XgmiiSink(dut.qsfp_0_txd_1, dut.qsfp_0_txc_1, dut.qsfp_0_tx_clk_1, dut.qsfp_0_tx_rst_1) - - cocotb.start_soon(Clock(dut.qsfp_0_rx_clk_2, 2.56, units="ns").start()) - self.qsfp_0_2_source = XgmiiSource(dut.qsfp_0_rxd_2, dut.qsfp_0_rxc_2, dut.qsfp_0_rx_clk_2, dut.qsfp_0_rx_rst_2) - cocotb.start_soon(Clock(dut.qsfp_0_tx_clk_2, 2.56, units="ns").start()) - self.qsfp_0_2_sink = XgmiiSink(dut.qsfp_0_txd_2, dut.qsfp_0_txc_2, dut.qsfp_0_tx_clk_2, dut.qsfp_0_tx_rst_2) - - cocotb.start_soon(Clock(dut.qsfp_0_rx_clk_3, 2.56, units="ns").start()) - self.qsfp_0_3_source = XgmiiSource(dut.qsfp_0_rxd_3, dut.qsfp_0_rxc_3, dut.qsfp_0_rx_clk_3, dut.qsfp_0_rx_rst_3) - cocotb.start_soon(Clock(dut.qsfp_0_tx_clk_3, 2.56, units="ns").start()) - self.qsfp_0_3_sink = XgmiiSink(dut.qsfp_0_txd_3, dut.qsfp_0_txc_3, dut.qsfp_0_tx_clk_3, dut.qsfp_0_tx_rst_3) - - cocotb.start_soon(Clock(dut.qsfp_1_rx_clk_0, 2.56, units="ns").start()) - self.qsfp_1_0_source = XgmiiSource(dut.qsfp_1_rxd_0, dut.qsfp_1_rxc_0, dut.qsfp_1_rx_clk_0, dut.qsfp_1_rx_rst_0) - cocotb.start_soon(Clock(dut.qsfp_1_tx_clk_0, 2.56, units="ns").start()) - self.qsfp_1_0_sink = XgmiiSink(dut.qsfp_1_txd_0, dut.qsfp_1_txc_0, dut.qsfp_1_tx_clk_0, dut.qsfp_1_tx_rst_0) - - cocotb.start_soon(Clock(dut.qsfp_1_rx_clk_1, 2.56, units="ns").start()) - self.qsfp_1_1_source = XgmiiSource(dut.qsfp_1_rxd_1, dut.qsfp_1_rxc_1, dut.qsfp_1_rx_clk_1, dut.qsfp_1_rx_rst_1) - cocotb.start_soon(Clock(dut.qsfp_1_tx_clk_1, 2.56, units="ns").start()) - self.qsfp_1_1_sink = XgmiiSink(dut.qsfp_1_txd_1, dut.qsfp_1_txc_1, dut.qsfp_1_tx_clk_1, dut.qsfp_1_tx_rst_1) - - cocotb.start_soon(Clock(dut.qsfp_1_rx_clk_2, 2.56, units="ns").start()) - self.qsfp_1_2_source = XgmiiSource(dut.qsfp_1_rxd_2, dut.qsfp_1_rxc_2, dut.qsfp_1_rx_clk_2, dut.qsfp_1_rx_rst_2) - cocotb.start_soon(Clock(dut.qsfp_1_tx_clk_2, 2.56, units="ns").start()) - self.qsfp_1_2_sink = XgmiiSink(dut.qsfp_1_txd_2, dut.qsfp_1_txc_2, dut.qsfp_1_tx_clk_2, dut.qsfp_1_tx_rst_2) - - cocotb.start_soon(Clock(dut.qsfp_1_rx_clk_3, 2.56, units="ns").start()) - self.qsfp_1_3_source = XgmiiSource(dut.qsfp_1_rxd_3, dut.qsfp_1_rxc_3, dut.qsfp_1_rx_clk_3, dut.qsfp_1_rx_rst_3) - cocotb.start_soon(Clock(dut.qsfp_1_tx_clk_3, 2.56, units="ns").start()) - self.qsfp_1_3_sink = XgmiiSink(dut.qsfp_1_txd_3, dut.qsfp_1_txc_3, dut.qsfp_1_tx_clk_3, dut.qsfp_1_tx_rst_3) + for x in range(2): + sources = [] + sinks = [] + for y in range(4): + cocotb.start_soon(Clock(getattr(dut, f"qsfp_{x}_rx_clk_{y}"), 2.56, units="ns").start()) + source = XgmiiSource(getattr(dut, f"qsfp_{x}_rxd_{y}"), getattr(dut, f"qsfp_{x}_rxc_{y}"), getattr(dut, f"qsfp_{x}_rx_clk_{y}"), getattr(dut, f"qsfp_{x}_rx_rst_{y}")) + sources.append(source) + cocotb.start_soon(Clock(getattr(dut, f"qsfp_{x}_tx_clk_{y}"), 2.56, units="ns").start()) + sink = XgmiiSink(getattr(dut, f"qsfp_{x}_txd_{y}"), getattr(dut, f"qsfp_{x}_txc_{y}"), getattr(dut, f"qsfp_{x}_tx_clk_{y}"), getattr(dut, f"qsfp_{x}_tx_rst_{y}")) + sinks.append(sink) + self.qsfp_source.append(sources) + self.qsfp_sink.append(sinks) dut.user_sw.setimmediatevalue(0) async def init(self): self.dut.rst.setimmediatevalue(0) - self.dut.qsfp_0_rx_rst_0.setimmediatevalue(0) - self.dut.qsfp_0_tx_rst_0.setimmediatevalue(0) - self.dut.qsfp_0_rx_rst_1.setimmediatevalue(0) - self.dut.qsfp_0_tx_rst_1.setimmediatevalue(0) - self.dut.qsfp_0_rx_rst_2.setimmediatevalue(0) - self.dut.qsfp_0_tx_rst_2.setimmediatevalue(0) - self.dut.qsfp_0_rx_rst_3.setimmediatevalue(0) - self.dut.qsfp_0_tx_rst_3.setimmediatevalue(0) - self.dut.qsfp_1_rx_rst_0.setimmediatevalue(0) - self.dut.qsfp_1_tx_rst_0.setimmediatevalue(0) - self.dut.qsfp_1_rx_rst_1.setimmediatevalue(0) - self.dut.qsfp_1_tx_rst_1.setimmediatevalue(0) - self.dut.qsfp_1_rx_rst_2.setimmediatevalue(0) - self.dut.qsfp_1_tx_rst_2.setimmediatevalue(0) - self.dut.qsfp_1_rx_rst_3.setimmediatevalue(0) - self.dut.qsfp_1_tx_rst_3.setimmediatevalue(0) + for x in range(2): + for y in range(4): + getattr(self.dut, f"qsfp_{x}_rx_rst_{y}").setimmediatevalue(0) + getattr(self.dut, f"qsfp_{x}_tx_rst_{y}").setimmediatevalue(0) for k in range(10): await RisingEdge(self.dut.clk) self.dut.rst.value = 1 - self.dut.qsfp_0_rx_rst_0.value = 1 - self.dut.qsfp_0_tx_rst_0.value = 1 - self.dut.qsfp_0_rx_rst_1.value = 1 - self.dut.qsfp_0_tx_rst_1.value = 1 - self.dut.qsfp_0_rx_rst_2.value = 1 - self.dut.qsfp_0_tx_rst_2.value = 1 - self.dut.qsfp_0_rx_rst_3.value = 1 - self.dut.qsfp_0_tx_rst_3.value = 1 - self.dut.qsfp_1_rx_rst_0.value = 1 - self.dut.qsfp_1_tx_rst_0.value = 1 - self.dut.qsfp_1_rx_rst_1.value = 1 - self.dut.qsfp_1_tx_rst_1.value = 1 - self.dut.qsfp_1_rx_rst_2.value = 1 - self.dut.qsfp_1_tx_rst_2.value = 1 - self.dut.qsfp_1_rx_rst_3.value = 1 - self.dut.qsfp_1_tx_rst_3.value = 1 + for x in range(2): + for y in range(4): + getattr(self.dut, f"qsfp_{x}_rx_rst_{y}").value = 1 + getattr(self.dut, f"qsfp_{x}_tx_rst_{y}").value = 1 for k in range(10): await RisingEdge(self.dut.clk) self.dut.rst.value = 0 - self.dut.qsfp_0_rx_rst_0.value = 0 - self.dut.qsfp_0_tx_rst_0.value = 0 - self.dut.qsfp_0_rx_rst_1.value = 0 - self.dut.qsfp_0_tx_rst_1.value = 0 - self.dut.qsfp_0_rx_rst_2.value = 0 - self.dut.qsfp_0_tx_rst_2.value = 0 - self.dut.qsfp_0_rx_rst_3.value = 0 - self.dut.qsfp_0_tx_rst_3.value = 0 - self.dut.qsfp_1_rx_rst_0.value = 0 - self.dut.qsfp_1_tx_rst_0.value = 0 - self.dut.qsfp_1_rx_rst_1.value = 0 - self.dut.qsfp_1_tx_rst_1.value = 0 - self.dut.qsfp_1_rx_rst_2.value = 0 - self.dut.qsfp_1_tx_rst_2.value = 0 - self.dut.qsfp_1_rx_rst_3.value = 0 - self.dut.qsfp_1_tx_rst_3.value = 0 + for x in range(2): + for y in range(4): + getattr(self.dut, f"qsfp_{x}_rx_rst_{y}").value = 0 + getattr(self.dut, f"qsfp_{x}_tx_rst_{y}").value = 0 @cocotb.test() @@ -170,11 +110,11 @@ async def run_test(dut): test_frame = XgmiiFrame.from_payload(test_pkt.build()) - await tb.qsfp_0_0_source.send(test_frame) + await tb.qsfp_source[0][0].send(test_frame) tb.log.info("receive ARP request") - rx_frame = await tb.qsfp_0_0_sink.recv() + rx_frame = await tb.qsfp_sink[0][0].recv() rx_pkt = Ether(bytes(rx_frame.get_payload())) @@ -202,11 +142,11 @@ async def run_test(dut): resp_frame = XgmiiFrame.from_payload(resp_pkt.build()) - await tb.qsfp_0_0_source.send(resp_frame) + await tb.qsfp_source[0][0].send(resp_frame) tb.log.info("receive UDP packet") - rx_frame = await tb.qsfp_0_0_sink.recv() + rx_frame = await tb.qsfp_sink[0][0].recv() rx_pkt = Ether(bytes(rx_frame.get_payload())) diff --git a/example/AU200/fpga_25g/tb/fpga_core/test_fpga_core.py b/example/AU200/fpga_25g/tb/fpga_core/test_fpga_core.py index 2e392bcb9..d90e185ee 100644 --- a/example/AU200/fpga_25g/tb/fpga_core/test_fpga_core.py +++ b/example/AU200/fpga_25g/tb/fpga_core/test_fpga_core.py @@ -48,109 +48,49 @@ class TB: cocotb.start_soon(Clock(dut.clk, 2.56, units="ns").start()) # Ethernet - cocotb.start_soon(Clock(dut.qsfp0_rx_clk_1, 2.56, units="ns").start()) - self.qsfp0_1_source = XgmiiSource(dut.qsfp0_rxd_1, dut.qsfp0_rxc_1, dut.qsfp0_rx_clk_1, dut.qsfp0_rx_rst_1) - cocotb.start_soon(Clock(dut.qsfp0_tx_clk_1, 2.56, units="ns").start()) - self.qsfp0_1_sink = XgmiiSink(dut.qsfp0_txd_1, dut.qsfp0_txc_1, dut.qsfp0_tx_clk_1, dut.qsfp0_tx_rst_1) + self.qsfp_source = [] + self.qsfp_sink = [] - cocotb.start_soon(Clock(dut.qsfp0_rx_clk_2, 2.56, units="ns").start()) - self.qsfp0_2_source = XgmiiSource(dut.qsfp0_rxd_2, dut.qsfp0_rxc_2, dut.qsfp0_rx_clk_2, dut.qsfp0_rx_rst_2) - cocotb.start_soon(Clock(dut.qsfp0_tx_clk_2, 2.56, units="ns").start()) - self.qsfp0_2_sink = XgmiiSink(dut.qsfp0_txd_2, dut.qsfp0_txc_2, dut.qsfp0_tx_clk_2, dut.qsfp0_tx_rst_2) - - cocotb.start_soon(Clock(dut.qsfp0_rx_clk_3, 2.56, units="ns").start()) - self.qsfp0_3_source = XgmiiSource(dut.qsfp0_rxd_3, dut.qsfp0_rxc_3, dut.qsfp0_rx_clk_3, dut.qsfp0_rx_rst_3) - cocotb.start_soon(Clock(dut.qsfp0_tx_clk_3, 2.56, units="ns").start()) - self.qsfp0_3_sink = XgmiiSink(dut.qsfp0_txd_3, dut.qsfp0_txc_3, dut.qsfp0_tx_clk_3, dut.qsfp0_tx_rst_3) - - cocotb.start_soon(Clock(dut.qsfp0_rx_clk_4, 2.56, units="ns").start()) - self.qsfp0_4_source = XgmiiSource(dut.qsfp0_rxd_4, dut.qsfp0_rxc_4, dut.qsfp0_rx_clk_4, dut.qsfp0_rx_rst_4) - cocotb.start_soon(Clock(dut.qsfp0_tx_clk_4, 2.56, units="ns").start()) - self.qsfp0_4_sink = XgmiiSink(dut.qsfp0_txd_4, dut.qsfp0_txc_4, dut.qsfp0_tx_clk_4, dut.qsfp0_tx_rst_4) - - cocotb.start_soon(Clock(dut.qsfp1_rx_clk_1, 2.56, units="ns").start()) - self.qsfp1_1_source = XgmiiSource(dut.qsfp1_rxd_1, dut.qsfp1_rxc_1, dut.qsfp1_rx_clk_1, dut.qsfp1_rx_rst_1) - cocotb.start_soon(Clock(dut.qsfp1_tx_clk_1, 2.56, units="ns").start()) - self.qsfp1_1_sink = XgmiiSink(dut.qsfp1_txd_1, dut.qsfp1_txc_1, dut.qsfp1_tx_clk_1, dut.qsfp1_tx_rst_1) - - cocotb.start_soon(Clock(dut.qsfp1_rx_clk_2, 2.56, units="ns").start()) - self.qsfp1_2_source = XgmiiSource(dut.qsfp1_rxd_2, dut.qsfp1_rxc_2, dut.qsfp1_rx_clk_2, dut.qsfp1_rx_rst_2) - cocotb.start_soon(Clock(dut.qsfp1_tx_clk_2, 2.56, units="ns").start()) - self.qsfp1_2_sink = XgmiiSink(dut.qsfp1_txd_2, dut.qsfp1_txc_2, dut.qsfp1_tx_clk_2, dut.qsfp1_tx_rst_2) - - cocotb.start_soon(Clock(dut.qsfp1_rx_clk_3, 2.56, units="ns").start()) - self.qsfp1_3_source = XgmiiSource(dut.qsfp1_rxd_3, dut.qsfp1_rxc_3, dut.qsfp1_rx_clk_3, dut.qsfp1_rx_rst_3) - cocotb.start_soon(Clock(dut.qsfp1_tx_clk_3, 2.56, units="ns").start()) - self.qsfp1_3_sink = XgmiiSink(dut.qsfp1_txd_3, dut.qsfp1_txc_3, dut.qsfp1_tx_clk_3, dut.qsfp1_tx_rst_3) - - cocotb.start_soon(Clock(dut.qsfp1_rx_clk_4, 2.56, units="ns").start()) - self.qsfp1_4_source = XgmiiSource(dut.qsfp1_rxd_4, dut.qsfp1_rxc_4, dut.qsfp1_rx_clk_4, dut.qsfp1_rx_rst_4) - cocotb.start_soon(Clock(dut.qsfp1_tx_clk_4, 2.56, units="ns").start()) - self.qsfp1_4_sink = XgmiiSink(dut.qsfp1_txd_4, dut.qsfp1_txc_4, dut.qsfp1_tx_clk_4, dut.qsfp1_tx_rst_4) + for x in range(2): + sources = [] + sinks = [] + for y in range(1, 5): + cocotb.start_soon(Clock(getattr(dut, f"qsfp{x}_rx_clk_{y}"), 2.56, units="ns").start()) + source = XgmiiSource(getattr(dut, f"qsfp{x}_rxd_{y}"), getattr(dut, f"qsfp{x}_rxc_{y}"), getattr(dut, f"qsfp{x}_rx_clk_{y}"), getattr(dut, f"qsfp{x}_rx_rst_{y}")) + sources.append(source) + cocotb.start_soon(Clock(getattr(dut, f"qsfp{x}_tx_clk_{y}"), 2.56, units="ns").start()) + sink = XgmiiSink(getattr(dut, f"qsfp{x}_txd_{y}"), getattr(dut, f"qsfp{x}_txc_{y}"), getattr(dut, f"qsfp{x}_tx_clk_{y}"), getattr(dut, f"qsfp{x}_tx_rst_{y}")) + sinks.append(sink) + self.qsfp_source.append(sources) + self.qsfp_sink.append(sinks) dut.sw.setimmediatevalue(0) async def init(self): self.dut.rst.setimmediatevalue(0) - self.dut.qsfp0_rx_rst_1.setimmediatevalue(0) - self.dut.qsfp0_tx_rst_1.setimmediatevalue(0) - self.dut.qsfp0_rx_rst_2.setimmediatevalue(0) - self.dut.qsfp0_tx_rst_2.setimmediatevalue(0) - self.dut.qsfp0_rx_rst_3.setimmediatevalue(0) - self.dut.qsfp0_tx_rst_3.setimmediatevalue(0) - self.dut.qsfp0_rx_rst_4.setimmediatevalue(0) - self.dut.qsfp0_tx_rst_4.setimmediatevalue(0) - self.dut.qsfp1_rx_rst_1.setimmediatevalue(0) - self.dut.qsfp1_tx_rst_1.setimmediatevalue(0) - self.dut.qsfp1_rx_rst_2.setimmediatevalue(0) - self.dut.qsfp1_tx_rst_2.setimmediatevalue(0) - self.dut.qsfp1_rx_rst_3.setimmediatevalue(0) - self.dut.qsfp1_tx_rst_3.setimmediatevalue(0) - self.dut.qsfp1_rx_rst_4.setimmediatevalue(0) - self.dut.qsfp1_tx_rst_4.setimmediatevalue(0) + for x in range(2): + for y in range(1, 5): + getattr(self.dut, f"qsfp{x}_rx_rst_{y}").setimmediatevalue(0) + getattr(self.dut, f"qsfp{x}_tx_rst_{y}").setimmediatevalue(0) for k in range(10): await RisingEdge(self.dut.clk) self.dut.rst.value = 1 - self.dut.qsfp0_rx_rst_1.value = 1 - self.dut.qsfp0_tx_rst_1.value = 1 - self.dut.qsfp0_rx_rst_2.value = 1 - self.dut.qsfp0_tx_rst_2.value = 1 - self.dut.qsfp0_rx_rst_3.value = 1 - self.dut.qsfp0_tx_rst_3.value = 1 - self.dut.qsfp0_rx_rst_4.value = 1 - self.dut.qsfp0_tx_rst_4.value = 1 - self.dut.qsfp1_rx_rst_1.value = 1 - self.dut.qsfp1_tx_rst_1.value = 1 - self.dut.qsfp1_rx_rst_2.value = 1 - self.dut.qsfp1_tx_rst_2.value = 1 - self.dut.qsfp1_rx_rst_3.value = 1 - self.dut.qsfp1_tx_rst_3.value = 1 - self.dut.qsfp1_rx_rst_4.value = 1 - self.dut.qsfp1_tx_rst_4.value = 1 + for x in range(2): + for y in range(1, 5): + getattr(self.dut, f"qsfp{x}_rx_rst_{y}").value = 1 + getattr(self.dut, f"qsfp{x}_tx_rst_{y}").value = 1 for k in range(10): await RisingEdge(self.dut.clk) self.dut.rst.value = 0 - self.dut.qsfp0_rx_rst_1.value = 0 - self.dut.qsfp0_tx_rst_1.value = 0 - self.dut.qsfp0_rx_rst_2.value = 0 - self.dut.qsfp0_tx_rst_2.value = 0 - self.dut.qsfp0_rx_rst_3.value = 0 - self.dut.qsfp0_tx_rst_3.value = 0 - self.dut.qsfp0_rx_rst_4.value = 0 - self.dut.qsfp0_tx_rst_4.value = 0 - self.dut.qsfp1_rx_rst_1.value = 0 - self.dut.qsfp1_tx_rst_1.value = 0 - self.dut.qsfp1_rx_rst_2.value = 0 - self.dut.qsfp1_tx_rst_2.value = 0 - self.dut.qsfp1_rx_rst_3.value = 0 - self.dut.qsfp1_tx_rst_3.value = 0 - self.dut.qsfp1_rx_rst_4.value = 0 - self.dut.qsfp1_tx_rst_4.value = 0 + for x in range(2): + for y in range(1, 5): + getattr(self.dut, f"qsfp{x}_rx_rst_{y}").value = 0 + getattr(self.dut, f"qsfp{x}_tx_rst_{y}").value = 0 @cocotb.test() @@ -170,11 +110,11 @@ async def run_test(dut): test_frame = XgmiiFrame.from_payload(test_pkt.build()) - await tb.qsfp0_1_source.send(test_frame) + await tb.qsfp_source[0][0].send(test_frame) tb.log.info("receive ARP request") - rx_frame = await tb.qsfp0_1_sink.recv() + rx_frame = await tb.qsfp_sink[0][0].recv() rx_pkt = Ether(bytes(rx_frame.get_payload())) @@ -202,11 +142,11 @@ async def run_test(dut): resp_frame = XgmiiFrame.from_payload(resp_pkt.build()) - await tb.qsfp0_1_source.send(resp_frame) + await tb.qsfp_source[0][0].send(resp_frame) tb.log.info("receive UDP packet") - rx_frame = await tb.qsfp0_1_sink.recv() + rx_frame = await tb.qsfp_sink[0][0].recv() rx_pkt = Ether(bytes(rx_frame.get_payload())) diff --git a/example/AU250/fpga_25g/tb/fpga_core/test_fpga_core.py b/example/AU250/fpga_25g/tb/fpga_core/test_fpga_core.py index 2e392bcb9..d90e185ee 100644 --- a/example/AU250/fpga_25g/tb/fpga_core/test_fpga_core.py +++ b/example/AU250/fpga_25g/tb/fpga_core/test_fpga_core.py @@ -48,109 +48,49 @@ class TB: cocotb.start_soon(Clock(dut.clk, 2.56, units="ns").start()) # Ethernet - cocotb.start_soon(Clock(dut.qsfp0_rx_clk_1, 2.56, units="ns").start()) - self.qsfp0_1_source = XgmiiSource(dut.qsfp0_rxd_1, dut.qsfp0_rxc_1, dut.qsfp0_rx_clk_1, dut.qsfp0_rx_rst_1) - cocotb.start_soon(Clock(dut.qsfp0_tx_clk_1, 2.56, units="ns").start()) - self.qsfp0_1_sink = XgmiiSink(dut.qsfp0_txd_1, dut.qsfp0_txc_1, dut.qsfp0_tx_clk_1, dut.qsfp0_tx_rst_1) + self.qsfp_source = [] + self.qsfp_sink = [] - cocotb.start_soon(Clock(dut.qsfp0_rx_clk_2, 2.56, units="ns").start()) - self.qsfp0_2_source = XgmiiSource(dut.qsfp0_rxd_2, dut.qsfp0_rxc_2, dut.qsfp0_rx_clk_2, dut.qsfp0_rx_rst_2) - cocotb.start_soon(Clock(dut.qsfp0_tx_clk_2, 2.56, units="ns").start()) - self.qsfp0_2_sink = XgmiiSink(dut.qsfp0_txd_2, dut.qsfp0_txc_2, dut.qsfp0_tx_clk_2, dut.qsfp0_tx_rst_2) - - cocotb.start_soon(Clock(dut.qsfp0_rx_clk_3, 2.56, units="ns").start()) - self.qsfp0_3_source = XgmiiSource(dut.qsfp0_rxd_3, dut.qsfp0_rxc_3, dut.qsfp0_rx_clk_3, dut.qsfp0_rx_rst_3) - cocotb.start_soon(Clock(dut.qsfp0_tx_clk_3, 2.56, units="ns").start()) - self.qsfp0_3_sink = XgmiiSink(dut.qsfp0_txd_3, dut.qsfp0_txc_3, dut.qsfp0_tx_clk_3, dut.qsfp0_tx_rst_3) - - cocotb.start_soon(Clock(dut.qsfp0_rx_clk_4, 2.56, units="ns").start()) - self.qsfp0_4_source = XgmiiSource(dut.qsfp0_rxd_4, dut.qsfp0_rxc_4, dut.qsfp0_rx_clk_4, dut.qsfp0_rx_rst_4) - cocotb.start_soon(Clock(dut.qsfp0_tx_clk_4, 2.56, units="ns").start()) - self.qsfp0_4_sink = XgmiiSink(dut.qsfp0_txd_4, dut.qsfp0_txc_4, dut.qsfp0_tx_clk_4, dut.qsfp0_tx_rst_4) - - cocotb.start_soon(Clock(dut.qsfp1_rx_clk_1, 2.56, units="ns").start()) - self.qsfp1_1_source = XgmiiSource(dut.qsfp1_rxd_1, dut.qsfp1_rxc_1, dut.qsfp1_rx_clk_1, dut.qsfp1_rx_rst_1) - cocotb.start_soon(Clock(dut.qsfp1_tx_clk_1, 2.56, units="ns").start()) - self.qsfp1_1_sink = XgmiiSink(dut.qsfp1_txd_1, dut.qsfp1_txc_1, dut.qsfp1_tx_clk_1, dut.qsfp1_tx_rst_1) - - cocotb.start_soon(Clock(dut.qsfp1_rx_clk_2, 2.56, units="ns").start()) - self.qsfp1_2_source = XgmiiSource(dut.qsfp1_rxd_2, dut.qsfp1_rxc_2, dut.qsfp1_rx_clk_2, dut.qsfp1_rx_rst_2) - cocotb.start_soon(Clock(dut.qsfp1_tx_clk_2, 2.56, units="ns").start()) - self.qsfp1_2_sink = XgmiiSink(dut.qsfp1_txd_2, dut.qsfp1_txc_2, dut.qsfp1_tx_clk_2, dut.qsfp1_tx_rst_2) - - cocotb.start_soon(Clock(dut.qsfp1_rx_clk_3, 2.56, units="ns").start()) - self.qsfp1_3_source = XgmiiSource(dut.qsfp1_rxd_3, dut.qsfp1_rxc_3, dut.qsfp1_rx_clk_3, dut.qsfp1_rx_rst_3) - cocotb.start_soon(Clock(dut.qsfp1_tx_clk_3, 2.56, units="ns").start()) - self.qsfp1_3_sink = XgmiiSink(dut.qsfp1_txd_3, dut.qsfp1_txc_3, dut.qsfp1_tx_clk_3, dut.qsfp1_tx_rst_3) - - cocotb.start_soon(Clock(dut.qsfp1_rx_clk_4, 2.56, units="ns").start()) - self.qsfp1_4_source = XgmiiSource(dut.qsfp1_rxd_4, dut.qsfp1_rxc_4, dut.qsfp1_rx_clk_4, dut.qsfp1_rx_rst_4) - cocotb.start_soon(Clock(dut.qsfp1_tx_clk_4, 2.56, units="ns").start()) - self.qsfp1_4_sink = XgmiiSink(dut.qsfp1_txd_4, dut.qsfp1_txc_4, dut.qsfp1_tx_clk_4, dut.qsfp1_tx_rst_4) + for x in range(2): + sources = [] + sinks = [] + for y in range(1, 5): + cocotb.start_soon(Clock(getattr(dut, f"qsfp{x}_rx_clk_{y}"), 2.56, units="ns").start()) + source = XgmiiSource(getattr(dut, f"qsfp{x}_rxd_{y}"), getattr(dut, f"qsfp{x}_rxc_{y}"), getattr(dut, f"qsfp{x}_rx_clk_{y}"), getattr(dut, f"qsfp{x}_rx_rst_{y}")) + sources.append(source) + cocotb.start_soon(Clock(getattr(dut, f"qsfp{x}_tx_clk_{y}"), 2.56, units="ns").start()) + sink = XgmiiSink(getattr(dut, f"qsfp{x}_txd_{y}"), getattr(dut, f"qsfp{x}_txc_{y}"), getattr(dut, f"qsfp{x}_tx_clk_{y}"), getattr(dut, f"qsfp{x}_tx_rst_{y}")) + sinks.append(sink) + self.qsfp_source.append(sources) + self.qsfp_sink.append(sinks) dut.sw.setimmediatevalue(0) async def init(self): self.dut.rst.setimmediatevalue(0) - self.dut.qsfp0_rx_rst_1.setimmediatevalue(0) - self.dut.qsfp0_tx_rst_1.setimmediatevalue(0) - self.dut.qsfp0_rx_rst_2.setimmediatevalue(0) - self.dut.qsfp0_tx_rst_2.setimmediatevalue(0) - self.dut.qsfp0_rx_rst_3.setimmediatevalue(0) - self.dut.qsfp0_tx_rst_3.setimmediatevalue(0) - self.dut.qsfp0_rx_rst_4.setimmediatevalue(0) - self.dut.qsfp0_tx_rst_4.setimmediatevalue(0) - self.dut.qsfp1_rx_rst_1.setimmediatevalue(0) - self.dut.qsfp1_tx_rst_1.setimmediatevalue(0) - self.dut.qsfp1_rx_rst_2.setimmediatevalue(0) - self.dut.qsfp1_tx_rst_2.setimmediatevalue(0) - self.dut.qsfp1_rx_rst_3.setimmediatevalue(0) - self.dut.qsfp1_tx_rst_3.setimmediatevalue(0) - self.dut.qsfp1_rx_rst_4.setimmediatevalue(0) - self.dut.qsfp1_tx_rst_4.setimmediatevalue(0) + for x in range(2): + for y in range(1, 5): + getattr(self.dut, f"qsfp{x}_rx_rst_{y}").setimmediatevalue(0) + getattr(self.dut, f"qsfp{x}_tx_rst_{y}").setimmediatevalue(0) for k in range(10): await RisingEdge(self.dut.clk) self.dut.rst.value = 1 - self.dut.qsfp0_rx_rst_1.value = 1 - self.dut.qsfp0_tx_rst_1.value = 1 - self.dut.qsfp0_rx_rst_2.value = 1 - self.dut.qsfp0_tx_rst_2.value = 1 - self.dut.qsfp0_rx_rst_3.value = 1 - self.dut.qsfp0_tx_rst_3.value = 1 - self.dut.qsfp0_rx_rst_4.value = 1 - self.dut.qsfp0_tx_rst_4.value = 1 - self.dut.qsfp1_rx_rst_1.value = 1 - self.dut.qsfp1_tx_rst_1.value = 1 - self.dut.qsfp1_rx_rst_2.value = 1 - self.dut.qsfp1_tx_rst_2.value = 1 - self.dut.qsfp1_rx_rst_3.value = 1 - self.dut.qsfp1_tx_rst_3.value = 1 - self.dut.qsfp1_rx_rst_4.value = 1 - self.dut.qsfp1_tx_rst_4.value = 1 + for x in range(2): + for y in range(1, 5): + getattr(self.dut, f"qsfp{x}_rx_rst_{y}").value = 1 + getattr(self.dut, f"qsfp{x}_tx_rst_{y}").value = 1 for k in range(10): await RisingEdge(self.dut.clk) self.dut.rst.value = 0 - self.dut.qsfp0_rx_rst_1.value = 0 - self.dut.qsfp0_tx_rst_1.value = 0 - self.dut.qsfp0_rx_rst_2.value = 0 - self.dut.qsfp0_tx_rst_2.value = 0 - self.dut.qsfp0_rx_rst_3.value = 0 - self.dut.qsfp0_tx_rst_3.value = 0 - self.dut.qsfp0_rx_rst_4.value = 0 - self.dut.qsfp0_tx_rst_4.value = 0 - self.dut.qsfp1_rx_rst_1.value = 0 - self.dut.qsfp1_tx_rst_1.value = 0 - self.dut.qsfp1_rx_rst_2.value = 0 - self.dut.qsfp1_tx_rst_2.value = 0 - self.dut.qsfp1_rx_rst_3.value = 0 - self.dut.qsfp1_tx_rst_3.value = 0 - self.dut.qsfp1_rx_rst_4.value = 0 - self.dut.qsfp1_tx_rst_4.value = 0 + for x in range(2): + for y in range(1, 5): + getattr(self.dut, f"qsfp{x}_rx_rst_{y}").value = 0 + getattr(self.dut, f"qsfp{x}_tx_rst_{y}").value = 0 @cocotb.test() @@ -170,11 +110,11 @@ async def run_test(dut): test_frame = XgmiiFrame.from_payload(test_pkt.build()) - await tb.qsfp0_1_source.send(test_frame) + await tb.qsfp_source[0][0].send(test_frame) tb.log.info("receive ARP request") - rx_frame = await tb.qsfp0_1_sink.recv() + rx_frame = await tb.qsfp_sink[0][0].recv() rx_pkt = Ether(bytes(rx_frame.get_payload())) @@ -202,11 +142,11 @@ async def run_test(dut): resp_frame = XgmiiFrame.from_payload(resp_pkt.build()) - await tb.qsfp0_1_source.send(resp_frame) + await tb.qsfp_source[0][0].send(resp_frame) tb.log.info("receive UDP packet") - rx_frame = await tb.qsfp0_1_sink.recv() + rx_frame = await tb.qsfp_sink[0][0].recv() rx_pkt = Ether(bytes(rx_frame.get_payload())) diff --git a/example/AU280/fpga_25g/tb/fpga_core/test_fpga_core.py b/example/AU280/fpga_25g/tb/fpga_core/test_fpga_core.py index 00f270c20..ef36bbec9 100644 --- a/example/AU280/fpga_25g/tb/fpga_core/test_fpga_core.py +++ b/example/AU280/fpga_25g/tb/fpga_core/test_fpga_core.py @@ -48,107 +48,47 @@ class TB: cocotb.start_soon(Clock(dut.clk, 2.56, units="ns").start()) # Ethernet - cocotb.start_soon(Clock(dut.qsfp0_rx_clk_1, 2.56, units="ns").start()) - self.qsfp0_1_source = XgmiiSource(dut.qsfp0_rxd_1, dut.qsfp0_rxc_1, dut.qsfp0_rx_clk_1, dut.qsfp0_rx_rst_1) - cocotb.start_soon(Clock(dut.qsfp0_tx_clk_1, 2.56, units="ns").start()) - self.qsfp0_1_sink = XgmiiSink(dut.qsfp0_txd_1, dut.qsfp0_txc_1, dut.qsfp0_tx_clk_1, dut.qsfp0_tx_rst_1) + self.qsfp_source = [] + self.qsfp_sink = [] - cocotb.start_soon(Clock(dut.qsfp0_rx_clk_2, 2.56, units="ns").start()) - self.qsfp0_2_source = XgmiiSource(dut.qsfp0_rxd_2, dut.qsfp0_rxc_2, dut.qsfp0_rx_clk_2, dut.qsfp0_rx_rst_2) - cocotb.start_soon(Clock(dut.qsfp0_tx_clk_2, 2.56, units="ns").start()) - self.qsfp0_2_sink = XgmiiSink(dut.qsfp0_txd_2, dut.qsfp0_txc_2, dut.qsfp0_tx_clk_2, dut.qsfp0_tx_rst_2) - - cocotb.start_soon(Clock(dut.qsfp0_rx_clk_3, 2.56, units="ns").start()) - self.qsfp0_3_source = XgmiiSource(dut.qsfp0_rxd_3, dut.qsfp0_rxc_3, dut.qsfp0_rx_clk_3, dut.qsfp0_rx_rst_3) - cocotb.start_soon(Clock(dut.qsfp0_tx_clk_3, 2.56, units="ns").start()) - self.qsfp0_3_sink = XgmiiSink(dut.qsfp0_txd_3, dut.qsfp0_txc_3, dut.qsfp0_tx_clk_3, dut.qsfp0_tx_rst_3) - - cocotb.start_soon(Clock(dut.qsfp0_rx_clk_4, 2.56, units="ns").start()) - self.qsfp0_4_source = XgmiiSource(dut.qsfp0_rxd_4, dut.qsfp0_rxc_4, dut.qsfp0_rx_clk_4, dut.qsfp0_rx_rst_4) - cocotb.start_soon(Clock(dut.qsfp0_tx_clk_4, 2.56, units="ns").start()) - self.qsfp0_4_sink = XgmiiSink(dut.qsfp0_txd_4, dut.qsfp0_txc_4, dut.qsfp0_tx_clk_4, dut.qsfp0_tx_rst_4) - - cocotb.start_soon(Clock(dut.qsfp1_rx_clk_1, 2.56, units="ns").start()) - self.qsfp1_1_source = XgmiiSource(dut.qsfp1_rxd_1, dut.qsfp1_rxc_1, dut.qsfp1_rx_clk_1, dut.qsfp1_rx_rst_1) - cocotb.start_soon(Clock(dut.qsfp1_tx_clk_1, 2.56, units="ns").start()) - self.qsfp1_1_sink = XgmiiSink(dut.qsfp1_txd_1, dut.qsfp1_txc_1, dut.qsfp1_tx_clk_1, dut.qsfp1_tx_rst_1) - - cocotb.start_soon(Clock(dut.qsfp1_rx_clk_2, 2.56, units="ns").start()) - self.qsfp1_2_source = XgmiiSource(dut.qsfp1_rxd_2, dut.qsfp1_rxc_2, dut.qsfp1_rx_clk_2, dut.qsfp1_rx_rst_2) - cocotb.start_soon(Clock(dut.qsfp1_tx_clk_2, 2.56, units="ns").start()) - self.qsfp1_2_sink = XgmiiSink(dut.qsfp1_txd_2, dut.qsfp1_txc_2, dut.qsfp1_tx_clk_2, dut.qsfp1_tx_rst_2) - - cocotb.start_soon(Clock(dut.qsfp1_rx_clk_3, 2.56, units="ns").start()) - self.qsfp1_3_source = XgmiiSource(dut.qsfp1_rxd_3, dut.qsfp1_rxc_3, dut.qsfp1_rx_clk_3, dut.qsfp1_rx_rst_3) - cocotb.start_soon(Clock(dut.qsfp1_tx_clk_3, 2.56, units="ns").start()) - self.qsfp1_3_sink = XgmiiSink(dut.qsfp1_txd_3, dut.qsfp1_txc_3, dut.qsfp1_tx_clk_3, dut.qsfp1_tx_rst_3) - - cocotb.start_soon(Clock(dut.qsfp1_rx_clk_4, 2.56, units="ns").start()) - self.qsfp1_4_source = XgmiiSource(dut.qsfp1_rxd_4, dut.qsfp1_rxc_4, dut.qsfp1_rx_clk_4, dut.qsfp1_rx_rst_4) - cocotb.start_soon(Clock(dut.qsfp1_tx_clk_4, 2.56, units="ns").start()) - self.qsfp1_4_sink = XgmiiSink(dut.qsfp1_txd_4, dut.qsfp1_txc_4, dut.qsfp1_tx_clk_4, dut.qsfp1_tx_rst_4) + for x in range(2): + sources = [] + sinks = [] + for y in range(1, 5): + cocotb.start_soon(Clock(getattr(dut, f"qsfp{x}_rx_clk_{y}"), 2.56, units="ns").start()) + source = XgmiiSource(getattr(dut, f"qsfp{x}_rxd_{y}"), getattr(dut, f"qsfp{x}_rxc_{y}"), getattr(dut, f"qsfp{x}_rx_clk_{y}"), getattr(dut, f"qsfp{x}_rx_rst_{y}")) + sources.append(source) + cocotb.start_soon(Clock(getattr(dut, f"qsfp{x}_tx_clk_{y}"), 2.56, units="ns").start()) + sink = XgmiiSink(getattr(dut, f"qsfp{x}_txd_{y}"), getattr(dut, f"qsfp{x}_txc_{y}"), getattr(dut, f"qsfp{x}_tx_clk_{y}"), getattr(dut, f"qsfp{x}_tx_rst_{y}")) + sinks.append(sink) + self.qsfp_source.append(sources) + self.qsfp_sink.append(sinks) async def init(self): self.dut.rst.setimmediatevalue(0) - self.dut.qsfp0_rx_rst_1.setimmediatevalue(0) - self.dut.qsfp0_tx_rst_1.setimmediatevalue(0) - self.dut.qsfp0_rx_rst_2.setimmediatevalue(0) - self.dut.qsfp0_tx_rst_2.setimmediatevalue(0) - self.dut.qsfp0_rx_rst_3.setimmediatevalue(0) - self.dut.qsfp0_tx_rst_3.setimmediatevalue(0) - self.dut.qsfp0_rx_rst_4.setimmediatevalue(0) - self.dut.qsfp0_tx_rst_4.setimmediatevalue(0) - self.dut.qsfp1_rx_rst_1.setimmediatevalue(0) - self.dut.qsfp1_tx_rst_1.setimmediatevalue(0) - self.dut.qsfp1_rx_rst_2.setimmediatevalue(0) - self.dut.qsfp1_tx_rst_2.setimmediatevalue(0) - self.dut.qsfp1_rx_rst_3.setimmediatevalue(0) - self.dut.qsfp1_tx_rst_3.setimmediatevalue(0) - self.dut.qsfp1_rx_rst_4.setimmediatevalue(0) - self.dut.qsfp1_tx_rst_4.setimmediatevalue(0) + for x in range(2): + for y in range(1, 5): + getattr(self.dut, f"qsfp{x}_rx_rst_{y}").setimmediatevalue(0) + getattr(self.dut, f"qsfp{x}_tx_rst_{y}").setimmediatevalue(0) for k in range(10): await RisingEdge(self.dut.clk) self.dut.rst.value = 1 - self.dut.qsfp0_rx_rst_1.value = 1 - self.dut.qsfp0_tx_rst_1.value = 1 - self.dut.qsfp0_rx_rst_2.value = 1 - self.dut.qsfp0_tx_rst_2.value = 1 - self.dut.qsfp0_rx_rst_3.value = 1 - self.dut.qsfp0_tx_rst_3.value = 1 - self.dut.qsfp0_rx_rst_4.value = 1 - self.dut.qsfp0_tx_rst_4.value = 1 - self.dut.qsfp1_rx_rst_1.value = 1 - self.dut.qsfp1_tx_rst_1.value = 1 - self.dut.qsfp1_rx_rst_2.value = 1 - self.dut.qsfp1_tx_rst_2.value = 1 - self.dut.qsfp1_rx_rst_3.value = 1 - self.dut.qsfp1_tx_rst_3.value = 1 - self.dut.qsfp1_rx_rst_4.value = 1 - self.dut.qsfp1_tx_rst_4.value = 1 + for x in range(2): + for y in range(1, 5): + getattr(self.dut, f"qsfp{x}_rx_rst_{y}").value = 1 + getattr(self.dut, f"qsfp{x}_tx_rst_{y}").value = 1 for k in range(10): await RisingEdge(self.dut.clk) self.dut.rst.value = 0 - self.dut.qsfp0_rx_rst_1.value = 0 - self.dut.qsfp0_tx_rst_1.value = 0 - self.dut.qsfp0_rx_rst_2.value = 0 - self.dut.qsfp0_tx_rst_2.value = 0 - self.dut.qsfp0_rx_rst_3.value = 0 - self.dut.qsfp0_tx_rst_3.value = 0 - self.dut.qsfp0_rx_rst_4.value = 0 - self.dut.qsfp0_tx_rst_4.value = 0 - self.dut.qsfp1_rx_rst_1.value = 0 - self.dut.qsfp1_tx_rst_1.value = 0 - self.dut.qsfp1_rx_rst_2.value = 0 - self.dut.qsfp1_tx_rst_2.value = 0 - self.dut.qsfp1_rx_rst_3.value = 0 - self.dut.qsfp1_tx_rst_3.value = 0 - self.dut.qsfp1_rx_rst_4.value = 0 - self.dut.qsfp1_tx_rst_4.value = 0 + for x in range(2): + for y in range(1, 5): + getattr(self.dut, f"qsfp{x}_rx_rst_{y}").value = 0 + getattr(self.dut, f"qsfp{x}_tx_rst_{y}").value = 0 @cocotb.test() @@ -168,11 +108,11 @@ async def run_test(dut): test_frame = XgmiiFrame.from_payload(test_pkt.build()) - await tb.qsfp0_1_source.send(test_frame) + await tb.qsfp_source[0][0].send(test_frame) tb.log.info("receive ARP request") - rx_frame = await tb.qsfp0_1_sink.recv() + rx_frame = await tb.qsfp_sink[0][0].recv() rx_pkt = Ether(bytes(rx_frame.get_payload())) @@ -200,11 +140,11 @@ async def run_test(dut): resp_frame = XgmiiFrame.from_payload(resp_pkt.build()) - await tb.qsfp0_1_source.send(resp_frame) + await tb.qsfp_source[0][0].send(resp_frame) tb.log.info("receive UDP packet") - rx_frame = await tb.qsfp0_1_sink.recv() + rx_frame = await tb.qsfp_sink[0][0].recv() rx_pkt = Ether(bytes(rx_frame.get_payload())) diff --git a/example/AU50/fpga_25g/tb/fpga_core/test_fpga_core.py b/example/AU50/fpga_25g/tb/fpga_core/test_fpga_core.py index e58f78854..73fa052a2 100644 --- a/example/AU50/fpga_25g/tb/fpga_core/test_fpga_core.py +++ b/example/AU50/fpga_25g/tb/fpga_core/test_fpga_core.py @@ -48,63 +48,39 @@ class TB: cocotb.start_soon(Clock(dut.clk, 2.56, units="ns").start()) # Ethernet - cocotb.start_soon(Clock(dut.qsfp_rx_clk_1, 2.56, units="ns").start()) - self.qsfp_1_source = XgmiiSource(dut.qsfp_rxd_1, dut.qsfp_rxc_1, dut.qsfp_rx_clk_1, dut.qsfp_rx_rst_1) - cocotb.start_soon(Clock(dut.qsfp_tx_clk_1, 2.56, units="ns").start()) - self.qsfp_1_sink = XgmiiSink(dut.qsfp_txd_1, dut.qsfp_txc_1, dut.qsfp_tx_clk_1, dut.qsfp_tx_rst_1) + self.qsfp_source = [] + self.qsfp_sink = [] - cocotb.start_soon(Clock(dut.qsfp_rx_clk_2, 2.56, units="ns").start()) - self.qsfp_2_source = XgmiiSource(dut.qsfp_rxd_2, dut.qsfp_rxc_2, dut.qsfp_rx_clk_2, dut.qsfp_rx_rst_2) - cocotb.start_soon(Clock(dut.qsfp_tx_clk_2, 2.56, units="ns").start()) - self.qsfp_2_sink = XgmiiSink(dut.qsfp_txd_2, dut.qsfp_txc_2, dut.qsfp_tx_clk_2, dut.qsfp_tx_rst_2) - - cocotb.start_soon(Clock(dut.qsfp_rx_clk_3, 2.56, units="ns").start()) - self.qsfp_3_source = XgmiiSource(dut.qsfp_rxd_3, dut.qsfp_rxc_3, dut.qsfp_rx_clk_3, dut.qsfp_rx_rst_3) - cocotb.start_soon(Clock(dut.qsfp_tx_clk_3, 2.56, units="ns").start()) - self.qsfp_3_sink = XgmiiSink(dut.qsfp_txd_3, dut.qsfp_txc_3, dut.qsfp_tx_clk_3, dut.qsfp_tx_rst_3) - - cocotb.start_soon(Clock(dut.qsfp_rx_clk_4, 2.56, units="ns").start()) - self.qsfp_4_source = XgmiiSource(dut.qsfp_rxd_4, dut.qsfp_rxc_4, dut.qsfp_rx_clk_4, dut.qsfp_rx_rst_4) - cocotb.start_soon(Clock(dut.qsfp_tx_clk_4, 2.56, units="ns").start()) - self.qsfp_4_sink = XgmiiSink(dut.qsfp_txd_4, dut.qsfp_txc_4, dut.qsfp_tx_clk_4, dut.qsfp_tx_rst_4) + for y in range(1, 5): + cocotb.start_soon(Clock(getattr(dut, f"qsfp_rx_clk_{y}"), 2.56, units="ns").start()) + source = XgmiiSource(getattr(dut, f"qsfp_rxd_{y}"), getattr(dut, f"qsfp_rxc_{y}"), getattr(dut, f"qsfp_rx_clk_{y}"), getattr(dut, f"qsfp_rx_rst_{y}")) + self.qsfp_source.append(source) + cocotb.start_soon(Clock(getattr(dut, f"qsfp_tx_clk_{y}"), 2.56, units="ns").start()) + sink = XgmiiSink(getattr(dut, f"qsfp_txd_{y}"), getattr(dut, f"qsfp_txc_{y}"), getattr(dut, f"qsfp_tx_clk_{y}"), getattr(dut, f"qsfp_tx_rst_{y}")) + self.qsfp_sink.append(sink) async def init(self): self.dut.rst.setimmediatevalue(0) - self.dut.qsfp_rx_rst_1.setimmediatevalue(0) - self.dut.qsfp_tx_rst_1.setimmediatevalue(0) - self.dut.qsfp_rx_rst_2.setimmediatevalue(0) - self.dut.qsfp_tx_rst_2.setimmediatevalue(0) - self.dut.qsfp_rx_rst_3.setimmediatevalue(0) - self.dut.qsfp_tx_rst_3.setimmediatevalue(0) - self.dut.qsfp_rx_rst_4.setimmediatevalue(0) - self.dut.qsfp_tx_rst_4.setimmediatevalue(0) + for y in range(1, 5): + getattr(self.dut, f"qsfp_rx_rst_{y}").setimmediatevalue(0) + getattr(self.dut, f"qsfp_tx_rst_{y}").setimmediatevalue(0) for k in range(10): await RisingEdge(self.dut.clk) self.dut.rst.value = 1 - self.dut.qsfp_rx_rst_1.value = 1 - self.dut.qsfp_tx_rst_1.value = 1 - self.dut.qsfp_rx_rst_2.value = 1 - self.dut.qsfp_tx_rst_2.value = 1 - self.dut.qsfp_rx_rst_3.value = 1 - self.dut.qsfp_tx_rst_3.value = 1 - self.dut.qsfp_rx_rst_4.value = 1 - self.dut.qsfp_tx_rst_4.value = 1 + for y in range(1, 5): + getattr(self.dut, f"qsfp_rx_rst_{y}").value = 1 + getattr(self.dut, f"qsfp_tx_rst_{y}").value = 1 for k in range(10): await RisingEdge(self.dut.clk) self.dut.rst.value = 0 - self.dut.qsfp_rx_rst_1.value = 0 - self.dut.qsfp_tx_rst_1.value = 0 - self.dut.qsfp_rx_rst_2.value = 0 - self.dut.qsfp_tx_rst_2.value = 0 - self.dut.qsfp_rx_rst_3.value = 0 - self.dut.qsfp_tx_rst_3.value = 0 - self.dut.qsfp_rx_rst_4.value = 0 - self.dut.qsfp_tx_rst_4.value = 0 + for y in range(1, 5): + getattr(self.dut, f"qsfp_rx_rst_{y}").value = 0 + getattr(self.dut, f"qsfp_tx_rst_{y}").value = 0 @cocotb.test() @@ -124,11 +100,11 @@ async def run_test(dut): test_frame = XgmiiFrame.from_payload(test_pkt.build()) - await tb.qsfp_1_source.send(test_frame) + await tb.qsfp_source[0].send(test_frame) tb.log.info("receive ARP request") - rx_frame = await tb.qsfp_1_sink.recv() + rx_frame = await tb.qsfp_sink[0].recv() rx_pkt = Ether(bytes(rx_frame.get_payload())) @@ -156,11 +132,11 @@ async def run_test(dut): resp_frame = XgmiiFrame.from_payload(resp_pkt.build()) - await tb.qsfp_1_source.send(resp_frame) + await tb.qsfp_source[0].send(resp_frame) tb.log.info("receive UDP packet") - rx_frame = await tb.qsfp_1_sink.recv() + rx_frame = await tb.qsfp_sink[0].recv() rx_pkt = Ether(bytes(rx_frame.get_payload())) diff --git a/example/DE5-Net/fpga/tb/fpga_core/test_fpga_core.py b/example/DE5-Net/fpga/tb/fpga_core/test_fpga_core.py index 95b1238af..b2ec8a162 100644 --- a/example/DE5-Net/fpga/tb/fpga_core/test_fpga_core.py +++ b/example/DE5-Net/fpga/tb/fpga_core/test_fpga_core.py @@ -48,17 +48,14 @@ class TB: cocotb.start_soon(Clock(dut.clk, 6.4, units="ns").start()) # Ethernet - self.sfp_a_source = XgmiiSource(dut.sfp_a_rxd, dut.sfp_a_rxc, dut.clk, dut.rst) - self.sfp_a_sink = XgmiiSink(dut.sfp_a_txd, dut.sfp_a_txc, dut.clk, dut.rst) + self.sfp_source = [] + self.sfp_sink = [] - self.sfp_b_source = XgmiiSource(dut.sfp_b_rxd, dut.sfp_b_rxc, dut.clk, dut.rst) - self.sfp_b_sink = XgmiiSink(dut.sfp_b_txd, dut.sfp_b_txc, dut.clk, dut.rst) - - self.sfp_c_source = XgmiiSource(dut.sfp_c_rxd, dut.sfp_c_rxc, dut.clk, dut.rst) - self.sfp_c_sink = XgmiiSink(dut.sfp_c_txd, dut.sfp_c_txc, dut.clk, dut.rst) - - self.sfp_d_source = XgmiiSource(dut.sfp_d_rxd, dut.sfp_d_rxc, dut.clk, dut.rst) - self.sfp_d_sink = XgmiiSink(dut.sfp_d_txd, dut.sfp_d_txc, dut.clk, dut.rst) + for x in "abcd": + source = XgmiiSource(getattr(dut, f"sfp_{x}_rxd"), getattr(dut, f"sfp_{x}_rxc"), dut.clk, dut.rst) + self.sfp_source.append(source) + sink = XgmiiSink(getattr(dut, f"sfp_{x}_txd"), getattr(dut, f"sfp_{x}_txc"), dut.clk, dut.rst) + self.sfp_sink.append(sink) dut.btn.setimmediatevalue(0) dut.sw.setimmediatevalue(0) @@ -95,11 +92,11 @@ async def run_test(dut): test_frame = XgmiiFrame.from_payload(test_pkt.build()) - await tb.sfp_a_source.send(test_frame) + await tb.sfp_source[0].send(test_frame) tb.log.info("receive ARP request") - rx_frame = await tb.sfp_a_sink.recv() + rx_frame = await tb.sfp_sink[0].recv() rx_pkt = Ether(bytes(rx_frame.get_payload())) @@ -127,11 +124,11 @@ async def run_test(dut): resp_frame = XgmiiFrame.from_payload(resp_pkt.build()) - await tb.sfp_a_source.send(resp_frame) + await tb.sfp_source[0].send(resp_frame) tb.log.info("receive UDP packet") - rx_frame = await tb.sfp_a_sink.recv() + rx_frame = await tb.sfp_sink[0].recv() rx_pkt = Ether(bytes(rx_frame.get_payload())) diff --git a/example/ExaNIC_X10/fpga/tb/fpga_core/test_fpga_core.py b/example/ExaNIC_X10/fpga/tb/fpga_core/test_fpga_core.py index d4370edac..ea6269f55 100644 --- a/example/ExaNIC_X10/fpga/tb/fpga_core/test_fpga_core.py +++ b/example/ExaNIC_X10/fpga/tb/fpga_core/test_fpga_core.py @@ -48,41 +48,39 @@ class TB: cocotb.start_soon(Clock(dut.clk, 6.4, units="ns").start()) # Ethernet - cocotb.start_soon(Clock(dut.sfp_1_rx_clk, 6.4, units="ns").start()) - self.sfp_1_source = XgmiiSource(dut.sfp_1_rxd, dut.sfp_1_rxc, dut.sfp_1_rx_clk, dut.sfp_1_rx_rst) - cocotb.start_soon(Clock(dut.sfp_1_tx_clk, 6.4, units="ns").start()) - self.sfp_1_sink = XgmiiSink(dut.sfp_1_txd, dut.sfp_1_txc, dut.sfp_1_tx_clk, dut.sfp_1_tx_rst) + self.sfp_source = [] + self.sfp_sink = [] - cocotb.start_soon(Clock(dut.sfp_2_rx_clk, 6.4, units="ns").start()) - self.sfp_2_source = XgmiiSource(dut.sfp_2_rxd, dut.sfp_2_rxc, dut.sfp_2_rx_clk, dut.sfp_2_rx_rst) - cocotb.start_soon(Clock(dut.sfp_2_tx_clk, 6.4, units="ns").start()) - self.sfp_2_sink = XgmiiSink(dut.sfp_2_txd, dut.sfp_2_txc, dut.sfp_2_tx_clk, dut.sfp_2_tx_rst) + for y in range(1, 3): + cocotb.start_soon(Clock(getattr(dut, f"sfp_{y}_rx_clk"), 6.4, units="ns").start()) + source = XgmiiSource(getattr(dut, f"sfp_{y}_rxd"), getattr(dut, f"sfp_{y}_rxc"), getattr(dut, f"sfp_{y}_rx_clk"), getattr(dut, f"sfp_{y}_rx_rst")) + self.sfp_source.append(source) + cocotb.start_soon(Clock(getattr(dut, f"sfp_{y}_tx_clk"), 6.4, units="ns").start()) + sink = XgmiiSink(getattr(dut, f"sfp_{y}_txd"), getattr(dut, f"sfp_{y}_txc"), getattr(dut, f"sfp_{y}_tx_clk"), getattr(dut, f"sfp_{y}_tx_rst")) + self.sfp_sink.append(sink) async def init(self): self.dut.rst.setimmediatevalue(0) - self.dut.sfp_1_rx_rst.setimmediatevalue(0) - self.dut.sfp_1_tx_rst.setimmediatevalue(0) - self.dut.sfp_2_rx_rst.setimmediatevalue(0) - self.dut.sfp_2_tx_rst.setimmediatevalue(0) + for y in range(1, 3): + getattr(self.dut, f"sfp_{y}_rx_rst").setimmediatevalue(0) + getattr(self.dut, f"sfp_{y}_tx_rst").setimmediatevalue(0) for k in range(10): await RisingEdge(self.dut.clk) self.dut.rst.value = 1 - self.dut.sfp_1_rx_rst.value = 1 - self.dut.sfp_1_tx_rst.value = 1 - self.dut.sfp_2_rx_rst.value = 1 - self.dut.sfp_2_tx_rst.value = 1 + for y in range(1, 3): + getattr(self.dut, f"sfp_{y}_rx_rst").value = 1 + getattr(self.dut, f"sfp_{y}_tx_rst").value = 1 for k in range(10): await RisingEdge(self.dut.clk) self.dut.rst.value = 0 - self.dut.sfp_1_rx_rst.value = 0 - self.dut.sfp_1_tx_rst.value = 0 - self.dut.sfp_2_rx_rst.value = 0 - self.dut.sfp_2_tx_rst.value = 0 + for y in range(1, 3): + getattr(self.dut, f"sfp_{y}_rx_rst").value = 0 + getattr(self.dut, f"sfp_{y}_tx_rst").value = 0 @cocotb.test() @@ -102,11 +100,11 @@ async def run_test(dut): test_frame = XgmiiFrame.from_payload(test_pkt.build()) - await tb.sfp_1_source.send(test_frame) + await tb.sfp_source[0].send(test_frame) tb.log.info("receive ARP request") - rx_frame = await tb.sfp_1_sink.recv() + rx_frame = await tb.sfp_sink[0].recv() rx_pkt = Ether(bytes(rx_frame.get_payload())) @@ -134,11 +132,11 @@ async def run_test(dut): resp_frame = XgmiiFrame.from_payload(resp_pkt.build()) - await tb.sfp_1_source.send(resp_frame) + await tb.sfp_source[0].send(resp_frame) tb.log.info("receive UDP packet") - rx_frame = await tb.sfp_1_sink.recv() + rx_frame = await tb.sfp_sink[0].recv() rx_pkt = Ether(bytes(rx_frame.get_payload())) diff --git a/example/ExaNIC_X25/fpga_25g/tb/fpga_core/test_fpga_core.py b/example/ExaNIC_X25/fpga_25g/tb/fpga_core/test_fpga_core.py index 1dcbf3131..16c91df3b 100644 --- a/example/ExaNIC_X25/fpga_25g/tb/fpga_core/test_fpga_core.py +++ b/example/ExaNIC_X25/fpga_25g/tb/fpga_core/test_fpga_core.py @@ -48,41 +48,39 @@ class TB: cocotb.start_soon(Clock(dut.clk, 2.56, units="ns").start()) # Ethernet - cocotb.start_soon(Clock(dut.sfp_1_rx_clk, 2.56, units="ns").start()) - self.sfp_1_source = XgmiiSource(dut.sfp_1_rxd, dut.sfp_1_rxc, dut.sfp_1_rx_clk, dut.sfp_1_rx_rst) - cocotb.start_soon(Clock(dut.sfp_1_tx_clk, 2.56, units="ns").start()) - self.sfp_1_sink = XgmiiSink(dut.sfp_1_txd, dut.sfp_1_txc, dut.sfp_1_tx_clk, dut.sfp_1_tx_rst) + self.sfp_source = [] + self.sfp_sink = [] - cocotb.start_soon(Clock(dut.sfp_2_rx_clk, 2.56, units="ns").start()) - self.sfp_2_source = XgmiiSource(dut.sfp_2_rxd, dut.sfp_2_rxc, dut.sfp_2_rx_clk, dut.sfp_2_rx_rst) - cocotb.start_soon(Clock(dut.sfp_2_tx_clk, 2.56, units="ns").start()) - self.sfp_2_sink = XgmiiSink(dut.sfp_2_txd, dut.sfp_2_txc, dut.sfp_2_tx_clk, dut.sfp_2_tx_rst) + for y in range(1, 3): + cocotb.start_soon(Clock(getattr(dut, f"sfp_{y}_rx_clk"), 2.56, units="ns").start()) + source = XgmiiSource(getattr(dut, f"sfp_{y}_rxd"), getattr(dut, f"sfp_{y}_rxc"), getattr(dut, f"sfp_{y}_rx_clk"), getattr(dut, f"sfp_{y}_rx_rst")) + self.sfp_source.append(source) + cocotb.start_soon(Clock(getattr(dut, f"sfp_{y}_tx_clk"), 2.56, units="ns").start()) + sink = XgmiiSink(getattr(dut, f"sfp_{y}_txd"), getattr(dut, f"sfp_{y}_txc"), getattr(dut, f"sfp_{y}_tx_clk"), getattr(dut, f"sfp_{y}_tx_rst")) + self.sfp_sink.append(sink) async def init(self): self.dut.rst.setimmediatevalue(0) - self.dut.sfp_1_rx_rst.setimmediatevalue(0) - self.dut.sfp_1_tx_rst.setimmediatevalue(0) - self.dut.sfp_2_rx_rst.setimmediatevalue(0) - self.dut.sfp_2_tx_rst.setimmediatevalue(0) + for y in range(1, 3): + getattr(self.dut, f"sfp_{y}_rx_rst").setimmediatevalue(0) + getattr(self.dut, f"sfp_{y}_tx_rst").setimmediatevalue(0) for k in range(10): await RisingEdge(self.dut.clk) self.dut.rst.value = 1 - self.dut.sfp_1_rx_rst.value = 1 - self.dut.sfp_1_tx_rst.value = 1 - self.dut.sfp_2_rx_rst.value = 1 - self.dut.sfp_2_tx_rst.value = 1 + for y in range(1, 3): + getattr(self.dut, f"sfp_{y}_rx_rst").value = 1 + getattr(self.dut, f"sfp_{y}_tx_rst").value = 1 for k in range(10): await RisingEdge(self.dut.clk) self.dut.rst.value = 0 - self.dut.sfp_1_rx_rst.value = 0 - self.dut.sfp_1_tx_rst.value = 0 - self.dut.sfp_2_rx_rst.value = 0 - self.dut.sfp_2_tx_rst.value = 0 + for y in range(1, 3): + getattr(self.dut, f"sfp_{y}_rx_rst").value = 0 + getattr(self.dut, f"sfp_{y}_tx_rst").value = 0 @cocotb.test() @@ -102,11 +100,11 @@ async def run_test(dut): test_frame = XgmiiFrame.from_payload(test_pkt.build()) - await tb.sfp_1_source.send(test_frame) + await tb.sfp_source[0].send(test_frame) tb.log.info("receive ARP request") - rx_frame = await tb.sfp_1_sink.recv() + rx_frame = await tb.sfp_sink[0].recv() rx_pkt = Ether(bytes(rx_frame.get_payload())) @@ -134,11 +132,11 @@ async def run_test(dut): resp_frame = XgmiiFrame.from_payload(resp_pkt.build()) - await tb.sfp_1_source.send(resp_frame) + await tb.sfp_source[0].send(resp_frame) tb.log.info("receive UDP packet") - rx_frame = await tb.sfp_1_sink.recv() + rx_frame = await tb.sfp_sink[0].recv() rx_pkt = Ether(bytes(rx_frame.get_payload())) diff --git a/example/HTG640/fpga/tb/fpga_core/test_fpga_core.py b/example/HTG640/fpga/tb/fpga_core/test_fpga_core.py index a4698680d..4f841d926 100644 --- a/example/HTG640/fpga/tb/fpga_core/test_fpga_core.py +++ b/example/HTG640/fpga/tb/fpga_core/test_fpga_core.py @@ -48,77 +48,23 @@ class TB: cocotb.start_soon(Clock(dut.clk, 6.4, units="ns").start()) # Ethernet - self.eth_r0_source = XgmiiSource(dut.eth_r0_rxd, dut.eth_r0_rxc, dut.clk, dut.rst) - self.eth_r0_sink = XgmiiSink(dut.eth_r0_txd, dut.eth_r0_txc, dut.clk, dut.rst) + self.eth_r_source = [] + self.eth_r_sink = [] - self.eth_r1_source = XgmiiSource(dut.eth_r1_rxd, dut.eth_r1_rxc, dut.clk, dut.rst) - self.eth_r1_sink = XgmiiSink(dut.eth_r1_txd, dut.eth_r1_txc, dut.clk, dut.rst) + for x in range(12): + source = XgmiiSource(getattr(dut, f"eth_r{x}_rxd"), getattr(dut, f"eth_r{x}_rxc"), dut.clk, dut.rst) + self.eth_r_source.append(source) + sink = XgmiiSink(getattr(dut, f"eth_r{x}_txd"), getattr(dut, f"eth_r{x}_txc"), dut.clk, dut.rst) + self.eth_r_sink.append(sink) - self.eth_r2_source = XgmiiSource(dut.eth_r2_rxd, dut.eth_r2_rxc, dut.clk, dut.rst) - self.eth_r2_sink = XgmiiSink(dut.eth_r2_txd, dut.eth_r2_txc, dut.clk, dut.rst) + self.eth_l_source = [] + self.eth_l_sink = [] - self.eth_r3_source = XgmiiSource(dut.eth_r3_rxd, dut.eth_r3_rxc, dut.clk, dut.rst) - self.eth_r3_sink = XgmiiSink(dut.eth_r3_txd, dut.eth_r3_txc, dut.clk, dut.rst) - - self.eth_r4_source = XgmiiSource(dut.eth_r4_rxd, dut.eth_r4_rxc, dut.clk, dut.rst) - self.eth_r4_sink = XgmiiSink(dut.eth_r4_txd, dut.eth_r4_txc, dut.clk, dut.rst) - - self.eth_r5_source = XgmiiSource(dut.eth_r5_rxd, dut.eth_r5_rxc, dut.clk, dut.rst) - self.eth_r5_sink = XgmiiSink(dut.eth_r5_txd, dut.eth_r5_txc, dut.clk, dut.rst) - - self.eth_r6_source = XgmiiSource(dut.eth_r6_rxd, dut.eth_r6_rxc, dut.clk, dut.rst) - self.eth_r6_sink = XgmiiSink(dut.eth_r6_txd, dut.eth_r6_txc, dut.clk, dut.rst) - - self.eth_r7_source = XgmiiSource(dut.eth_r7_rxd, dut.eth_r7_rxc, dut.clk, dut.rst) - self.eth_r7_sink = XgmiiSink(dut.eth_r7_txd, dut.eth_r7_txc, dut.clk, dut.rst) - - self.eth_r8_source = XgmiiSource(dut.eth_r8_rxd, dut.eth_r8_rxc, dut.clk, dut.rst) - self.eth_r8_sink = XgmiiSink(dut.eth_r8_txd, dut.eth_r8_txc, dut.clk, dut.rst) - - self.eth_r9_source = XgmiiSource(dut.eth_r9_rxd, dut.eth_r9_rxc, dut.clk, dut.rst) - self.eth_r9_sink = XgmiiSink(dut.eth_r9_txd, dut.eth_r9_txc, dut.clk, dut.rst) - - self.eth_r10_source = XgmiiSource(dut.eth_r10_rxd, dut.eth_r10_rxc, dut.clk, dut.rst) - self.eth_r10_sink = XgmiiSink(dut.eth_r10_txd, dut.eth_r10_txc, dut.clk, dut.rst) - - self.eth_r11_source = XgmiiSource(dut.eth_r11_rxd, dut.eth_r11_rxc, dut.clk, dut.rst) - self.eth_r11_sink = XgmiiSink(dut.eth_r11_txd, dut.eth_r11_txc, dut.clk, dut.rst) - - self.eth_l0_source = XgmiiSource(dut.eth_l0_rxd, dut.eth_l0_rxc, dut.clk, dut.rst) - self.eth_l0_sink = XgmiiSink(dut.eth_l0_txd, dut.eth_l0_txc, dut.clk, dut.rst) - - self.eth_l1_source = XgmiiSource(dut.eth_l1_rxd, dut.eth_l1_rxc, dut.clk, dut.rst) - self.eth_l1_sink = XgmiiSink(dut.eth_l1_txd, dut.eth_l1_txc, dut.clk, dut.rst) - - self.eth_l2_source = XgmiiSource(dut.eth_l2_rxd, dut.eth_l2_rxc, dut.clk, dut.rst) - self.eth_l2_sink = XgmiiSink(dut.eth_l2_txd, dut.eth_l2_txc, dut.clk, dut.rst) - - self.eth_l3_source = XgmiiSource(dut.eth_l3_rxd, dut.eth_l3_rxc, dut.clk, dut.rst) - self.eth_l3_sink = XgmiiSink(dut.eth_l3_txd, dut.eth_l3_txc, dut.clk, dut.rst) - - self.eth_l4_source = XgmiiSource(dut.eth_l4_rxd, dut.eth_l4_rxc, dut.clk, dut.rst) - self.eth_l4_sink = XgmiiSink(dut.eth_l4_txd, dut.eth_l4_txc, dut.clk, dut.rst) - - self.eth_l5_source = XgmiiSource(dut.eth_l5_rxd, dut.eth_l5_rxc, dut.clk, dut.rst) - self.eth_l5_sink = XgmiiSink(dut.eth_l5_txd, dut.eth_l5_txc, dut.clk, dut.rst) - - self.eth_l6_source = XgmiiSource(dut.eth_l6_rxd, dut.eth_l6_rxc, dut.clk, dut.rst) - self.eth_l6_sink = XgmiiSink(dut.eth_l6_txd, dut.eth_l6_txc, dut.clk, dut.rst) - - self.eth_l7_source = XgmiiSource(dut.eth_l7_rxd, dut.eth_l7_rxc, dut.clk, dut.rst) - self.eth_l7_sink = XgmiiSink(dut.eth_l7_txd, dut.eth_l7_txc, dut.clk, dut.rst) - - self.eth_l8_source = XgmiiSource(dut.eth_l8_rxd, dut.eth_l8_rxc, dut.clk, dut.rst) - self.eth_l8_sink = XgmiiSink(dut.eth_l8_txd, dut.eth_l8_txc, dut.clk, dut.rst) - - self.eth_l9_source = XgmiiSource(dut.eth_l9_rxd, dut.eth_l9_rxc, dut.clk, dut.rst) - self.eth_l9_sink = XgmiiSink(dut.eth_l9_txd, dut.eth_l9_txc, dut.clk, dut.rst) - - self.eth_l10_source = XgmiiSource(dut.eth_l10_rxd, dut.eth_l10_rxc, dut.clk, dut.rst) - self.eth_l10_sink = XgmiiSink(dut.eth_l10_txd, dut.eth_l10_txc, dut.clk, dut.rst) - - self.eth_l11_source = XgmiiSource(dut.eth_l11_rxd, dut.eth_l11_rxc, dut.clk, dut.rst) - self.eth_l11_sink = XgmiiSink(dut.eth_l11_txd, dut.eth_l11_txc, dut.clk, dut.rst) + for x in range(12): + source = XgmiiSource(getattr(dut, f"eth_l{x}_rxd"), getattr(dut, f"eth_l{x}_rxc"), dut.clk, dut.rst) + self.eth_l_source.append(source) + sink = XgmiiSink(getattr(dut, f"eth_l{x}_txd"), getattr(dut, f"eth_l{x}_txc"), dut.clk, dut.rst) + self.eth_l_sink.append(sink) dut.sw.setimmediatevalue(0) dut.jp.setimmediatevalue(0) @@ -161,11 +107,11 @@ async def run_test(dut): test_frame = XgmiiFrame.from_payload(test_pkt.build()) - await tb.eth_l0_source.send(test_frame) + await tb.eth_l_source[0].send(test_frame) tb.log.info("receive ARP request") - rx_frame = await tb.eth_l0_sink.recv() + rx_frame = await tb.eth_l_sink[0].recv() rx_pkt = Ether(bytes(rx_frame.get_payload())) @@ -193,11 +139,11 @@ async def run_test(dut): resp_frame = XgmiiFrame.from_payload(resp_pkt.build()) - await tb.eth_l0_source.send(resp_frame) + await tb.eth_l_source[0].send(resp_frame) tb.log.info("receive UDP packet") - rx_frame = await tb.eth_l0_sink.recv() + rx_frame = await tb.eth_l_sink[0].recv() rx_pkt = Ether(bytes(rx_frame.get_payload())) diff --git a/example/HTG640/fpga_cxpt16/tb/fpga_core/test_fpga_core.py b/example/HTG640/fpga_cxpt16/tb/fpga_core/test_fpga_core.py index 7f3e94ed8..6ff9520d4 100644 --- a/example/HTG640/fpga_cxpt16/tb/fpga_core/test_fpga_core.py +++ b/example/HTG640/fpga_cxpt16/tb/fpga_core/test_fpga_core.py @@ -47,77 +47,23 @@ class TB: cocotb.start_soon(Clock(dut.clk, 6.4, units="ns").start()) # Ethernet - self.eth_r0_source = XgmiiSource(dut.eth_r0_rxd, dut.eth_r0_rxc, dut.clk, dut.rst) - self.eth_r0_sink = XgmiiSink(dut.eth_r0_txd, dut.eth_r0_txc, dut.clk, dut.rst) + self.eth_r_source = [] + self.eth_r_sink = [] - self.eth_r1_source = XgmiiSource(dut.eth_r1_rxd, dut.eth_r1_rxc, dut.clk, dut.rst) - self.eth_r1_sink = XgmiiSink(dut.eth_r1_txd, dut.eth_r1_txc, dut.clk, dut.rst) + for x in range(12): + source = XgmiiSource(getattr(dut, f"eth_r{x}_rxd"), getattr(dut, f"eth_r{x}_rxc"), dut.clk, dut.rst) + self.eth_r_source.append(source) + sink = XgmiiSink(getattr(dut, f"eth_r{x}_txd"), getattr(dut, f"eth_r{x}_txc"), dut.clk, dut.rst) + self.eth_r_sink.append(sink) - self.eth_r2_source = XgmiiSource(dut.eth_r2_rxd, dut.eth_r2_rxc, dut.clk, dut.rst) - self.eth_r2_sink = XgmiiSink(dut.eth_r2_txd, dut.eth_r2_txc, dut.clk, dut.rst) + self.eth_l_source = [] + self.eth_l_sink = [] - self.eth_r3_source = XgmiiSource(dut.eth_r3_rxd, dut.eth_r3_rxc, dut.clk, dut.rst) - self.eth_r3_sink = XgmiiSink(dut.eth_r3_txd, dut.eth_r3_txc, dut.clk, dut.rst) - - self.eth_r4_source = XgmiiSource(dut.eth_r4_rxd, dut.eth_r4_rxc, dut.clk, dut.rst) - self.eth_r4_sink = XgmiiSink(dut.eth_r4_txd, dut.eth_r4_txc, dut.clk, dut.rst) - - self.eth_r5_source = XgmiiSource(dut.eth_r5_rxd, dut.eth_r5_rxc, dut.clk, dut.rst) - self.eth_r5_sink = XgmiiSink(dut.eth_r5_txd, dut.eth_r5_txc, dut.clk, dut.rst) - - self.eth_r6_source = XgmiiSource(dut.eth_r6_rxd, dut.eth_r6_rxc, dut.clk, dut.rst) - self.eth_r6_sink = XgmiiSink(dut.eth_r6_txd, dut.eth_r6_txc, dut.clk, dut.rst) - - self.eth_r7_source = XgmiiSource(dut.eth_r7_rxd, dut.eth_r7_rxc, dut.clk, dut.rst) - self.eth_r7_sink = XgmiiSink(dut.eth_r7_txd, dut.eth_r7_txc, dut.clk, dut.rst) - - self.eth_r8_source = XgmiiSource(dut.eth_r8_rxd, dut.eth_r8_rxc, dut.clk, dut.rst) - self.eth_r8_sink = XgmiiSink(dut.eth_r8_txd, dut.eth_r8_txc, dut.clk, dut.rst) - - self.eth_r9_source = XgmiiSource(dut.eth_r9_rxd, dut.eth_r9_rxc, dut.clk, dut.rst) - self.eth_r9_sink = XgmiiSink(dut.eth_r9_txd, dut.eth_r9_txc, dut.clk, dut.rst) - - self.eth_r10_source = XgmiiSource(dut.eth_r10_rxd, dut.eth_r10_rxc, dut.clk, dut.rst) - self.eth_r10_sink = XgmiiSink(dut.eth_r10_txd, dut.eth_r10_txc, dut.clk, dut.rst) - - self.eth_r11_source = XgmiiSource(dut.eth_r11_rxd, dut.eth_r11_rxc, dut.clk, dut.rst) - self.eth_r11_sink = XgmiiSink(dut.eth_r11_txd, dut.eth_r11_txc, dut.clk, dut.rst) - - self.eth_l0_source = XgmiiSource(dut.eth_l0_rxd, dut.eth_l0_rxc, dut.clk, dut.rst) - self.eth_l0_sink = XgmiiSink(dut.eth_l0_txd, dut.eth_l0_txc, dut.clk, dut.rst) - - self.eth_l1_source = XgmiiSource(dut.eth_l1_rxd, dut.eth_l1_rxc, dut.clk, dut.rst) - self.eth_l1_sink = XgmiiSink(dut.eth_l1_txd, dut.eth_l1_txc, dut.clk, dut.rst) - - self.eth_l2_source = XgmiiSource(dut.eth_l2_rxd, dut.eth_l2_rxc, dut.clk, dut.rst) - self.eth_l2_sink = XgmiiSink(dut.eth_l2_txd, dut.eth_l2_txc, dut.clk, dut.rst) - - self.eth_l3_source = XgmiiSource(dut.eth_l3_rxd, dut.eth_l3_rxc, dut.clk, dut.rst) - self.eth_l3_sink = XgmiiSink(dut.eth_l3_txd, dut.eth_l3_txc, dut.clk, dut.rst) - - self.eth_l4_source = XgmiiSource(dut.eth_l4_rxd, dut.eth_l4_rxc, dut.clk, dut.rst) - self.eth_l4_sink = XgmiiSink(dut.eth_l4_txd, dut.eth_l4_txc, dut.clk, dut.rst) - - self.eth_l5_source = XgmiiSource(dut.eth_l5_rxd, dut.eth_l5_rxc, dut.clk, dut.rst) - self.eth_l5_sink = XgmiiSink(dut.eth_l5_txd, dut.eth_l5_txc, dut.clk, dut.rst) - - self.eth_l6_source = XgmiiSource(dut.eth_l6_rxd, dut.eth_l6_rxc, dut.clk, dut.rst) - self.eth_l6_sink = XgmiiSink(dut.eth_l6_txd, dut.eth_l6_txc, dut.clk, dut.rst) - - self.eth_l7_source = XgmiiSource(dut.eth_l7_rxd, dut.eth_l7_rxc, dut.clk, dut.rst) - self.eth_l7_sink = XgmiiSink(dut.eth_l7_txd, dut.eth_l7_txc, dut.clk, dut.rst) - - self.eth_l8_source = XgmiiSource(dut.eth_l8_rxd, dut.eth_l8_rxc, dut.clk, dut.rst) - self.eth_l8_sink = XgmiiSink(dut.eth_l8_txd, dut.eth_l8_txc, dut.clk, dut.rst) - - self.eth_l9_source = XgmiiSource(dut.eth_l9_rxd, dut.eth_l9_rxc, dut.clk, dut.rst) - self.eth_l9_sink = XgmiiSink(dut.eth_l9_txd, dut.eth_l9_txc, dut.clk, dut.rst) - - self.eth_l10_source = XgmiiSource(dut.eth_l10_rxd, dut.eth_l10_rxc, dut.clk, dut.rst) - self.eth_l10_sink = XgmiiSink(dut.eth_l10_txd, dut.eth_l10_txc, dut.clk, dut.rst) - - self.eth_l11_source = XgmiiSource(dut.eth_l11_rxd, dut.eth_l11_rxc, dut.clk, dut.rst) - self.eth_l11_sink = XgmiiSink(dut.eth_l11_txd, dut.eth_l11_txc, dut.clk, dut.rst) + for x in range(12): + source = XgmiiSource(getattr(dut, f"eth_l{x}_rxd"), getattr(dut, f"eth_l{x}_rxc"), dut.clk, dut.rst) + self.eth_l_source.append(source) + sink = XgmiiSink(getattr(dut, f"eth_l{x}_txd"), getattr(dut, f"eth_l{x}_txc"), dut.clk, dut.rst) + self.eth_l_sink.append(sink) dut.sw.setimmediatevalue(0) dut.jp.setimmediatevalue(0) @@ -158,9 +104,9 @@ async def run_test(dut): test_frame = XgmiiFrame.from_payload(test_pkt.build()) - await tb.eth_l0_source.send(test_frame) + await tb.eth_l_source[0].send(test_frame) - rx_frame = await tb.eth_l0_sink.recv() + rx_frame = await tb.eth_l_sink[0].recv() rx_pkt = Ether(bytes(rx_frame.get_payload())) @@ -176,7 +122,7 @@ async def run_test(dut): test_frame = XgmiiFrame.from_payload(test_pkt.build()) - await tb.eth_l11_source.send(test_frame) + await tb.eth_l_source[11].send(test_frame) await Timer(400, 'ns') @@ -188,9 +134,9 @@ async def run_test(dut): test_frame = XgmiiFrame.from_payload(test_pkt.build()) - await tb.eth_l0_source.send(test_frame) + await tb.eth_l_source[0].send(test_frame) - rx_frame = await tb.eth_r7_sink.recv() + rx_frame = await tb.eth_r_sink[7].recv() rx_pkt = Ether(bytes(rx_frame.get_payload())) diff --git a/example/HTG9200/fpga_25g/tb/fpga_core/test_fpga_core.py b/example/HTG9200/fpga_25g/tb/fpga_core/test_fpga_core.py index 58c6ec2ee..035693d12 100644 --- a/example/HTG9200/fpga_25g/tb/fpga_core/test_fpga_core.py +++ b/example/HTG9200/fpga_25g/tb/fpga_core/test_fpga_core.py @@ -54,415 +54,47 @@ class TB: dut.uart_rts.setimmediatevalue(1) # Ethernet - cocotb.start_soon(Clock(dut.qsfp_1_rx_clk_1, 2.56, units="ns").start()) - self.qsfp_1_1_source = XgmiiSource(dut.qsfp_1_rxd_1, dut.qsfp_1_rxc_1, dut.qsfp_1_rx_clk_1, dut.qsfp_1_rx_rst_1) - cocotb.start_soon(Clock(dut.qsfp_1_tx_clk_1, 2.56, units="ns").start()) - self.qsfp_1_1_sink = XgmiiSink(dut.qsfp_1_txd_1, dut.qsfp_1_txc_1, dut.qsfp_1_tx_clk_1, dut.qsfp_1_tx_rst_1) + self.qsfp_source = [] + self.qsfp_sink = [] - cocotb.start_soon(Clock(dut.qsfp_1_rx_clk_2, 2.56, units="ns").start()) - self.qsfp_1_2_source = XgmiiSource(dut.qsfp_1_rxd_2, dut.qsfp_1_rxc_2, dut.qsfp_1_rx_clk_2, dut.qsfp_1_rx_rst_2) - cocotb.start_soon(Clock(dut.qsfp_1_tx_clk_2, 2.56, units="ns").start()) - self.qsfp_1_2_sink = XgmiiSink(dut.qsfp_1_txd_2, dut.qsfp_1_txc_2, dut.qsfp_1_tx_clk_2, dut.qsfp_1_tx_rst_2) - - cocotb.start_soon(Clock(dut.qsfp_1_rx_clk_3, 2.56, units="ns").start()) - self.qsfp_1_3_source = XgmiiSource(dut.qsfp_1_rxd_3, dut.qsfp_1_rxc_3, dut.qsfp_1_rx_clk_3, dut.qsfp_1_rx_rst_3) - cocotb.start_soon(Clock(dut.qsfp_1_tx_clk_3, 2.56, units="ns").start()) - self.qsfp_1_3_sink = XgmiiSink(dut.qsfp_1_txd_3, dut.qsfp_1_txc_3, dut.qsfp_1_tx_clk_3, dut.qsfp_1_tx_rst_3) - - cocotb.start_soon(Clock(dut.qsfp_1_rx_clk_4, 2.56, units="ns").start()) - self.qsfp_1_4_source = XgmiiSource(dut.qsfp_1_rxd_4, dut.qsfp_1_rxc_4, dut.qsfp_1_rx_clk_4, dut.qsfp_1_rx_rst_4) - cocotb.start_soon(Clock(dut.qsfp_1_tx_clk_4, 2.56, units="ns").start()) - self.qsfp_1_4_sink = XgmiiSink(dut.qsfp_1_txd_4, dut.qsfp_1_txc_4, dut.qsfp_1_tx_clk_4, dut.qsfp_1_tx_rst_4) - - cocotb.start_soon(Clock(dut.qsfp_2_rx_clk_1, 2.56, units="ns").start()) - self.qsfp_2_1_source = XgmiiSource(dut.qsfp_2_rxd_1, dut.qsfp_2_rxc_1, dut.qsfp_2_rx_clk_1, dut.qsfp_2_rx_rst_1) - cocotb.start_soon(Clock(dut.qsfp_2_tx_clk_1, 2.56, units="ns").start()) - self.qsfp_2_1_sink = XgmiiSink(dut.qsfp_2_txd_1, dut.qsfp_2_txc_1, dut.qsfp_2_tx_clk_1, dut.qsfp_2_tx_rst_1) - - cocotb.start_soon(Clock(dut.qsfp_2_rx_clk_2, 2.56, units="ns").start()) - self.qsfp_2_2_source = XgmiiSource(dut.qsfp_2_rxd_2, dut.qsfp_2_rxc_2, dut.qsfp_2_rx_clk_2, dut.qsfp_2_rx_rst_2) - cocotb.start_soon(Clock(dut.qsfp_2_tx_clk_2, 2.56, units="ns").start()) - self.qsfp_2_2_sink = XgmiiSink(dut.qsfp_2_txd_2, dut.qsfp_2_txc_2, dut.qsfp_2_tx_clk_2, dut.qsfp_2_tx_rst_2) - - cocotb.start_soon(Clock(dut.qsfp_2_rx_clk_3, 2.56, units="ns").start()) - self.qsfp_2_3_source = XgmiiSource(dut.qsfp_2_rxd_3, dut.qsfp_2_rxc_3, dut.qsfp_2_rx_clk_3, dut.qsfp_2_rx_rst_3) - cocotb.start_soon(Clock(dut.qsfp_2_tx_clk_3, 2.56, units="ns").start()) - self.qsfp_2_3_sink = XgmiiSink(dut.qsfp_2_txd_3, dut.qsfp_2_txc_3, dut.qsfp_2_tx_clk_3, dut.qsfp_2_tx_rst_3) - - cocotb.start_soon(Clock(dut.qsfp_2_rx_clk_4, 2.56, units="ns").start()) - self.qsfp_2_4_source = XgmiiSource(dut.qsfp_2_rxd_4, dut.qsfp_2_rxc_4, dut.qsfp_2_rx_clk_4, dut.qsfp_2_rx_rst_4) - cocotb.start_soon(Clock(dut.qsfp_2_tx_clk_4, 2.56, units="ns").start()) - self.qsfp_2_4_sink = XgmiiSink(dut.qsfp_2_txd_4, dut.qsfp_2_txc_4, dut.qsfp_2_tx_clk_4, dut.qsfp_2_tx_rst_4) - - cocotb.start_soon(Clock(dut.qsfp_3_rx_clk_1, 2.56, units="ns").start()) - self.qsfp_3_1_source = XgmiiSource(dut.qsfp_3_rxd_1, dut.qsfp_3_rxc_1, dut.qsfp_3_rx_clk_1, dut.qsfp_3_rx_rst_1) - cocotb.start_soon(Clock(dut.qsfp_3_tx_clk_1, 2.56, units="ns").start()) - self.qsfp_3_1_sink = XgmiiSink(dut.qsfp_3_txd_1, dut.qsfp_3_txc_1, dut.qsfp_3_tx_clk_1, dut.qsfp_3_tx_rst_1) - - cocotb.start_soon(Clock(dut.qsfp_3_rx_clk_2, 2.56, units="ns").start()) - self.qsfp_3_2_source = XgmiiSource(dut.qsfp_3_rxd_2, dut.qsfp_3_rxc_2, dut.qsfp_3_rx_clk_2, dut.qsfp_3_rx_rst_2) - cocotb.start_soon(Clock(dut.qsfp_3_tx_clk_2, 2.56, units="ns").start()) - self.qsfp_3_2_sink = XgmiiSink(dut.qsfp_3_txd_2, dut.qsfp_3_txc_2, dut.qsfp_3_tx_clk_2, dut.qsfp_3_tx_rst_2) - - cocotb.start_soon(Clock(dut.qsfp_3_rx_clk_3, 2.56, units="ns").start()) - self.qsfp_3_3_source = XgmiiSource(dut.qsfp_3_rxd_3, dut.qsfp_3_rxc_3, dut.qsfp_3_rx_clk_3, dut.qsfp_3_rx_rst_3) - cocotb.start_soon(Clock(dut.qsfp_3_tx_clk_3, 2.56, units="ns").start()) - self.qsfp_3_3_sink = XgmiiSink(dut.qsfp_3_txd_3, dut.qsfp_3_txc_3, dut.qsfp_3_tx_clk_3, dut.qsfp_3_tx_rst_3) - - cocotb.start_soon(Clock(dut.qsfp_3_rx_clk_4, 2.56, units="ns").start()) - self.qsfp_3_4_source = XgmiiSource(dut.qsfp_3_rxd_4, dut.qsfp_3_rxc_4, dut.qsfp_3_rx_clk_4, dut.qsfp_3_rx_rst_4) - cocotb.start_soon(Clock(dut.qsfp_3_tx_clk_4, 2.56, units="ns").start()) - self.qsfp_3_4_sink = XgmiiSink(dut.qsfp_3_txd_4, dut.qsfp_3_txc_4, dut.qsfp_3_tx_clk_4, dut.qsfp_3_tx_rst_4) - - cocotb.start_soon(Clock(dut.qsfp_4_rx_clk_1, 2.56, units="ns").start()) - self.qsfp_4_1_source = XgmiiSource(dut.qsfp_4_rxd_1, dut.qsfp_4_rxc_1, dut.qsfp_4_rx_clk_1, dut.qsfp_4_rx_rst_1) - cocotb.start_soon(Clock(dut.qsfp_4_tx_clk_1, 2.56, units="ns").start()) - self.qsfp_4_1_sink = XgmiiSink(dut.qsfp_4_txd_1, dut.qsfp_4_txc_1, dut.qsfp_4_tx_clk_1, dut.qsfp_4_tx_rst_1) - - cocotb.start_soon(Clock(dut.qsfp_4_rx_clk_2, 2.56, units="ns").start()) - self.qsfp_4_2_source = XgmiiSource(dut.qsfp_4_rxd_2, dut.qsfp_4_rxc_2, dut.qsfp_4_rx_clk_2, dut.qsfp_4_rx_rst_2) - cocotb.start_soon(Clock(dut.qsfp_4_tx_clk_2, 2.56, units="ns").start()) - self.qsfp_4_2_sink = XgmiiSink(dut.qsfp_4_txd_2, dut.qsfp_4_txc_2, dut.qsfp_4_tx_clk_2, dut.qsfp_4_tx_rst_2) - - cocotb.start_soon(Clock(dut.qsfp_4_rx_clk_3, 2.56, units="ns").start()) - self.qsfp_4_3_source = XgmiiSource(dut.qsfp_4_rxd_3, dut.qsfp_4_rxc_3, dut.qsfp_4_rx_clk_3, dut.qsfp_4_rx_rst_3) - cocotb.start_soon(Clock(dut.qsfp_4_tx_clk_3, 2.56, units="ns").start()) - self.qsfp_4_3_sink = XgmiiSink(dut.qsfp_4_txd_3, dut.qsfp_4_txc_3, dut.qsfp_4_tx_clk_3, dut.qsfp_4_tx_rst_3) - - cocotb.start_soon(Clock(dut.qsfp_4_rx_clk_4, 2.56, units="ns").start()) - self.qsfp_4_4_source = XgmiiSource(dut.qsfp_4_rxd_4, dut.qsfp_4_rxc_4, dut.qsfp_4_rx_clk_4, dut.qsfp_4_rx_rst_4) - cocotb.start_soon(Clock(dut.qsfp_4_tx_clk_4, 2.56, units="ns").start()) - self.qsfp_4_4_sink = XgmiiSink(dut.qsfp_4_txd_4, dut.qsfp_4_txc_4, dut.qsfp_4_tx_clk_4, dut.qsfp_4_tx_rst_4) - - cocotb.start_soon(Clock(dut.qsfp_5_rx_clk_1, 2.56, units="ns").start()) - self.qsfp_5_1_source = XgmiiSource(dut.qsfp_5_rxd_1, dut.qsfp_5_rxc_1, dut.qsfp_5_rx_clk_1, dut.qsfp_5_rx_rst_1) - cocotb.start_soon(Clock(dut.qsfp_5_tx_clk_1, 2.56, units="ns").start()) - self.qsfp_5_1_sink = XgmiiSink(dut.qsfp_5_txd_1, dut.qsfp_5_txc_1, dut.qsfp_5_tx_clk_1, dut.qsfp_5_tx_rst_1) - - cocotb.start_soon(Clock(dut.qsfp_5_rx_clk_2, 2.56, units="ns").start()) - self.qsfp_5_2_source = XgmiiSource(dut.qsfp_5_rxd_2, dut.qsfp_5_rxc_2, dut.qsfp_5_rx_clk_2, dut.qsfp_5_rx_rst_2) - cocotb.start_soon(Clock(dut.qsfp_5_tx_clk_2, 2.56, units="ns").start()) - self.qsfp_5_2_sink = XgmiiSink(dut.qsfp_5_txd_2, dut.qsfp_5_txc_2, dut.qsfp_5_tx_clk_2, dut.qsfp_5_tx_rst_2) - - cocotb.start_soon(Clock(dut.qsfp_5_rx_clk_3, 2.56, units="ns").start()) - self.qsfp_5_3_source = XgmiiSource(dut.qsfp_5_rxd_3, dut.qsfp_5_rxc_3, dut.qsfp_5_rx_clk_3, dut.qsfp_5_rx_rst_3) - cocotb.start_soon(Clock(dut.qsfp_5_tx_clk_3, 2.56, units="ns").start()) - self.qsfp_5_3_sink = XgmiiSink(dut.qsfp_5_txd_3, dut.qsfp_5_txc_3, dut.qsfp_5_tx_clk_3, dut.qsfp_5_tx_rst_3) - - cocotb.start_soon(Clock(dut.qsfp_5_rx_clk_4, 2.56, units="ns").start()) - self.qsfp_5_4_source = XgmiiSource(dut.qsfp_5_rxd_4, dut.qsfp_5_rxc_4, dut.qsfp_5_rx_clk_4, dut.qsfp_5_rx_rst_4) - cocotb.start_soon(Clock(dut.qsfp_5_tx_clk_4, 2.56, units="ns").start()) - self.qsfp_5_4_sink = XgmiiSink(dut.qsfp_5_txd_4, dut.qsfp_5_txc_4, dut.qsfp_5_tx_clk_4, dut.qsfp_5_tx_rst_4) - - cocotb.start_soon(Clock(dut.qsfp_6_rx_clk_1, 2.56, units="ns").start()) - self.qsfp_6_1_source = XgmiiSource(dut.qsfp_6_rxd_1, dut.qsfp_6_rxc_1, dut.qsfp_6_rx_clk_1, dut.qsfp_6_rx_rst_1) - cocotb.start_soon(Clock(dut.qsfp_6_tx_clk_1, 2.56, units="ns").start()) - self.qsfp_6_1_sink = XgmiiSink(dut.qsfp_6_txd_1, dut.qsfp_6_txc_1, dut.qsfp_6_tx_clk_1, dut.qsfp_6_tx_rst_1) - - cocotb.start_soon(Clock(dut.qsfp_6_rx_clk_2, 2.56, units="ns").start()) - self.qsfp_6_2_source = XgmiiSource(dut.qsfp_6_rxd_2, dut.qsfp_6_rxc_2, dut.qsfp_6_rx_clk_2, dut.qsfp_6_rx_rst_2) - cocotb.start_soon(Clock(dut.qsfp_6_tx_clk_2, 2.56, units="ns").start()) - self.qsfp_6_2_sink = XgmiiSink(dut.qsfp_6_txd_2, dut.qsfp_6_txc_2, dut.qsfp_6_tx_clk_2, dut.qsfp_6_tx_rst_2) - - cocotb.start_soon(Clock(dut.qsfp_6_rx_clk_3, 2.56, units="ns").start()) - self.qsfp_6_3_source = XgmiiSource(dut.qsfp_6_rxd_3, dut.qsfp_6_rxc_3, dut.qsfp_6_rx_clk_3, dut.qsfp_6_rx_rst_3) - cocotb.start_soon(Clock(dut.qsfp_6_tx_clk_3, 2.56, units="ns").start()) - self.qsfp_6_3_sink = XgmiiSink(dut.qsfp_6_txd_3, dut.qsfp_6_txc_3, dut.qsfp_6_tx_clk_3, dut.qsfp_6_tx_rst_3) - - cocotb.start_soon(Clock(dut.qsfp_6_rx_clk_4, 2.56, units="ns").start()) - self.qsfp_6_4_source = XgmiiSource(dut.qsfp_6_rxd_4, dut.qsfp_6_rxc_4, dut.qsfp_6_rx_clk_4, dut.qsfp_6_rx_rst_4) - cocotb.start_soon(Clock(dut.qsfp_6_tx_clk_4, 2.56, units="ns").start()) - self.qsfp_6_4_sink = XgmiiSink(dut.qsfp_6_txd_4, dut.qsfp_6_txc_4, dut.qsfp_6_tx_clk_4, dut.qsfp_6_tx_rst_4) - - cocotb.start_soon(Clock(dut.qsfp_7_rx_clk_1, 2.56, units="ns").start()) - self.qsfp_7_1_source = XgmiiSource(dut.qsfp_7_rxd_1, dut.qsfp_7_rxc_1, dut.qsfp_7_rx_clk_1, dut.qsfp_7_rx_rst_1) - cocotb.start_soon(Clock(dut.qsfp_7_tx_clk_1, 2.56, units="ns").start()) - self.qsfp_7_1_sink = XgmiiSink(dut.qsfp_7_txd_1, dut.qsfp_7_txc_1, dut.qsfp_7_tx_clk_1, dut.qsfp_7_tx_rst_1) - - cocotb.start_soon(Clock(dut.qsfp_7_rx_clk_2, 2.56, units="ns").start()) - self.qsfp_7_2_source = XgmiiSource(dut.qsfp_7_rxd_2, dut.qsfp_7_rxc_2, dut.qsfp_7_rx_clk_2, dut.qsfp_7_rx_rst_2) - cocotb.start_soon(Clock(dut.qsfp_7_tx_clk_2, 2.56, units="ns").start()) - self.qsfp_7_2_sink = XgmiiSink(dut.qsfp_7_txd_2, dut.qsfp_7_txc_2, dut.qsfp_7_tx_clk_2, dut.qsfp_7_tx_rst_2) - - cocotb.start_soon(Clock(dut.qsfp_7_rx_clk_3, 2.56, units="ns").start()) - self.qsfp_7_3_source = XgmiiSource(dut.qsfp_7_rxd_3, dut.qsfp_7_rxc_3, dut.qsfp_7_rx_clk_3, dut.qsfp_7_rx_rst_3) - cocotb.start_soon(Clock(dut.qsfp_7_tx_clk_3, 2.56, units="ns").start()) - self.qsfp_7_3_sink = XgmiiSink(dut.qsfp_7_txd_3, dut.qsfp_7_txc_3, dut.qsfp_7_tx_clk_3, dut.qsfp_7_tx_rst_3) - - cocotb.start_soon(Clock(dut.qsfp_7_rx_clk_4, 2.56, units="ns").start()) - self.qsfp_7_4_source = XgmiiSource(dut.qsfp_7_rxd_4, dut.qsfp_7_rxc_4, dut.qsfp_7_rx_clk_4, dut.qsfp_7_rx_rst_4) - cocotb.start_soon(Clock(dut.qsfp_7_tx_clk_4, 2.56, units="ns").start()) - self.qsfp_7_4_sink = XgmiiSink(dut.qsfp_7_txd_4, dut.qsfp_7_txc_4, dut.qsfp_7_tx_clk_4, dut.qsfp_7_tx_rst_4) - - cocotb.start_soon(Clock(dut.qsfp_8_rx_clk_1, 2.56, units="ns").start()) - self.qsfp_8_1_source = XgmiiSource(dut.qsfp_8_rxd_1, dut.qsfp_8_rxc_1, dut.qsfp_8_rx_clk_1, dut.qsfp_8_rx_rst_1) - cocotb.start_soon(Clock(dut.qsfp_8_tx_clk_1, 2.56, units="ns").start()) - self.qsfp_8_1_sink = XgmiiSink(dut.qsfp_8_txd_1, dut.qsfp_8_txc_1, dut.qsfp_8_tx_clk_1, dut.qsfp_8_tx_rst_1) - - cocotb.start_soon(Clock(dut.qsfp_8_rx_clk_2, 2.56, units="ns").start()) - self.qsfp_8_2_source = XgmiiSource(dut.qsfp_8_rxd_2, dut.qsfp_8_rxc_2, dut.qsfp_8_rx_clk_2, dut.qsfp_8_rx_rst_2) - cocotb.start_soon(Clock(dut.qsfp_8_tx_clk_2, 2.56, units="ns").start()) - self.qsfp_8_2_sink = XgmiiSink(dut.qsfp_8_txd_2, dut.qsfp_8_txc_2, dut.qsfp_8_tx_clk_2, dut.qsfp_8_tx_rst_2) - - cocotb.start_soon(Clock(dut.qsfp_8_rx_clk_3, 2.56, units="ns").start()) - self.qsfp_8_3_source = XgmiiSource(dut.qsfp_8_rxd_3, dut.qsfp_8_rxc_3, dut.qsfp_8_rx_clk_3, dut.qsfp_8_rx_rst_3) - cocotb.start_soon(Clock(dut.qsfp_8_tx_clk_3, 2.56, units="ns").start()) - self.qsfp_8_3_sink = XgmiiSink(dut.qsfp_8_txd_3, dut.qsfp_8_txc_3, dut.qsfp_8_tx_clk_3, dut.qsfp_8_tx_rst_3) - - cocotb.start_soon(Clock(dut.qsfp_8_rx_clk_4, 2.56, units="ns").start()) - self.qsfp_8_4_source = XgmiiSource(dut.qsfp_8_rxd_4, dut.qsfp_8_rxc_4, dut.qsfp_8_rx_clk_4, dut.qsfp_8_rx_rst_4) - cocotb.start_soon(Clock(dut.qsfp_8_tx_clk_4, 2.56, units="ns").start()) - self.qsfp_8_4_sink = XgmiiSink(dut.qsfp_8_txd_4, dut.qsfp_8_txc_4, dut.qsfp_8_tx_clk_4, dut.qsfp_8_tx_rst_4) - - cocotb.start_soon(Clock(dut.qsfp_9_rx_clk_1, 2.56, units="ns").start()) - self.qsfp_9_1_source = XgmiiSource(dut.qsfp_9_rxd_1, dut.qsfp_9_rxc_1, dut.qsfp_9_rx_clk_1, dut.qsfp_9_rx_rst_1) - cocotb.start_soon(Clock(dut.qsfp_9_tx_clk_1, 2.56, units="ns").start()) - self.qsfp_9_1_sink = XgmiiSink(dut.qsfp_9_txd_1, dut.qsfp_9_txc_1, dut.qsfp_9_tx_clk_1, dut.qsfp_9_tx_rst_1) - - cocotb.start_soon(Clock(dut.qsfp_9_rx_clk_2, 2.56, units="ns").start()) - self.qsfp_9_2_source = XgmiiSource(dut.qsfp_9_rxd_2, dut.qsfp_9_rxc_2, dut.qsfp_9_rx_clk_2, dut.qsfp_9_rx_rst_2) - cocotb.start_soon(Clock(dut.qsfp_9_tx_clk_2, 2.56, units="ns").start()) - self.qsfp_9_2_sink = XgmiiSink(dut.qsfp_9_txd_2, dut.qsfp_9_txc_2, dut.qsfp_9_tx_clk_2, dut.qsfp_9_tx_rst_2) - - cocotb.start_soon(Clock(dut.qsfp_9_rx_clk_3, 2.56, units="ns").start()) - self.qsfp_9_3_source = XgmiiSource(dut.qsfp_9_rxd_3, dut.qsfp_9_rxc_3, dut.qsfp_9_rx_clk_3, dut.qsfp_9_rx_rst_3) - cocotb.start_soon(Clock(dut.qsfp_9_tx_clk_3, 2.56, units="ns").start()) - self.qsfp_9_3_sink = XgmiiSink(dut.qsfp_9_txd_3, dut.qsfp_9_txc_3, dut.qsfp_9_tx_clk_3, dut.qsfp_9_tx_rst_3) - - cocotb.start_soon(Clock(dut.qsfp_9_rx_clk_4, 2.56, units="ns").start()) - self.qsfp_9_4_source = XgmiiSource(dut.qsfp_9_rxd_4, dut.qsfp_9_rxc_4, dut.qsfp_9_rx_clk_4, dut.qsfp_9_rx_rst_4) - cocotb.start_soon(Clock(dut.qsfp_9_tx_clk_4, 2.56, units="ns").start()) - self.qsfp_9_4_sink = XgmiiSink(dut.qsfp_9_txd_4, dut.qsfp_9_txc_4, dut.qsfp_9_tx_clk_4, dut.qsfp_9_tx_rst_4) + for x in range(1, 10): + sources = [] + sinks = [] + for y in range(1, 5): + cocotb.start_soon(Clock(getattr(dut, f"qsfp_{x}_rx_clk_{y}"), 2.56, units="ns").start()) + source = XgmiiSource(getattr(dut, f"qsfp_{x}_rxd_{y}"), getattr(dut, f"qsfp_{x}_rxc_{y}"), getattr(dut, f"qsfp_{x}_rx_clk_{y}"), getattr(dut, f"qsfp_{x}_rx_rst_{y}")) + sources.append(source) + cocotb.start_soon(Clock(getattr(dut, f"qsfp_{x}_tx_clk_{y}"), 2.56, units="ns").start()) + sink = XgmiiSink(getattr(dut, f"qsfp_{x}_txd_{y}"), getattr(dut, f"qsfp_{x}_txc_{y}"), getattr(dut, f"qsfp_{x}_tx_clk_{y}"), getattr(dut, f"qsfp_{x}_tx_rst_{y}")) + sinks.append(sink) + self.qsfp_source.append(sources) + self.qsfp_sink.append(sinks) async def init(self): self.dut.rst.setimmediatevalue(0) - self.dut.qsfp_1_rx_rst_1.setimmediatevalue(0) - self.dut.qsfp_1_tx_rst_1.setimmediatevalue(0) - self.dut.qsfp_1_rx_rst_2.setimmediatevalue(0) - self.dut.qsfp_1_tx_rst_2.setimmediatevalue(0) - self.dut.qsfp_1_rx_rst_3.setimmediatevalue(0) - self.dut.qsfp_1_tx_rst_3.setimmediatevalue(0) - self.dut.qsfp_1_rx_rst_4.setimmediatevalue(0) - self.dut.qsfp_1_tx_rst_4.setimmediatevalue(0) - self.dut.qsfp_2_rx_rst_1.setimmediatevalue(0) - self.dut.qsfp_2_tx_rst_1.setimmediatevalue(0) - self.dut.qsfp_2_rx_rst_2.setimmediatevalue(0) - self.dut.qsfp_2_tx_rst_2.setimmediatevalue(0) - self.dut.qsfp_2_rx_rst_3.setimmediatevalue(0) - self.dut.qsfp_2_tx_rst_3.setimmediatevalue(0) - self.dut.qsfp_2_rx_rst_4.setimmediatevalue(0) - self.dut.qsfp_2_tx_rst_4.setimmediatevalue(0) - self.dut.qsfp_3_rx_rst_1.setimmediatevalue(0) - self.dut.qsfp_3_tx_rst_1.setimmediatevalue(0) - self.dut.qsfp_3_rx_rst_2.setimmediatevalue(0) - self.dut.qsfp_3_tx_rst_2.setimmediatevalue(0) - self.dut.qsfp_3_rx_rst_3.setimmediatevalue(0) - self.dut.qsfp_3_tx_rst_3.setimmediatevalue(0) - self.dut.qsfp_3_rx_rst_4.setimmediatevalue(0) - self.dut.qsfp_3_tx_rst_4.setimmediatevalue(0) - self.dut.qsfp_4_rx_rst_1.setimmediatevalue(0) - self.dut.qsfp_4_tx_rst_1.setimmediatevalue(0) - self.dut.qsfp_4_rx_rst_2.setimmediatevalue(0) - self.dut.qsfp_4_tx_rst_2.setimmediatevalue(0) - self.dut.qsfp_4_rx_rst_3.setimmediatevalue(0) - self.dut.qsfp_4_tx_rst_3.setimmediatevalue(0) - self.dut.qsfp_4_rx_rst_4.setimmediatevalue(0) - self.dut.qsfp_4_tx_rst_4.setimmediatevalue(0) - self.dut.qsfp_5_rx_rst_1.setimmediatevalue(0) - self.dut.qsfp_5_tx_rst_1.setimmediatevalue(0) - self.dut.qsfp_5_rx_rst_2.setimmediatevalue(0) - self.dut.qsfp_5_tx_rst_2.setimmediatevalue(0) - self.dut.qsfp_5_rx_rst_3.setimmediatevalue(0) - self.dut.qsfp_5_tx_rst_3.setimmediatevalue(0) - self.dut.qsfp_5_rx_rst_4.setimmediatevalue(0) - self.dut.qsfp_5_tx_rst_4.setimmediatevalue(0) - self.dut.qsfp_6_rx_rst_1.setimmediatevalue(0) - self.dut.qsfp_6_tx_rst_1.setimmediatevalue(0) - self.dut.qsfp_6_rx_rst_2.setimmediatevalue(0) - self.dut.qsfp_6_tx_rst_2.setimmediatevalue(0) - self.dut.qsfp_6_rx_rst_3.setimmediatevalue(0) - self.dut.qsfp_6_tx_rst_3.setimmediatevalue(0) - self.dut.qsfp_6_rx_rst_4.setimmediatevalue(0) - self.dut.qsfp_6_tx_rst_4.setimmediatevalue(0) - self.dut.qsfp_7_rx_rst_1.setimmediatevalue(0) - self.dut.qsfp_7_tx_rst_1.setimmediatevalue(0) - self.dut.qsfp_7_rx_rst_2.setimmediatevalue(0) - self.dut.qsfp_7_tx_rst_2.setimmediatevalue(0) - self.dut.qsfp_7_rx_rst_3.setimmediatevalue(0) - self.dut.qsfp_7_tx_rst_3.setimmediatevalue(0) - self.dut.qsfp_7_rx_rst_4.setimmediatevalue(0) - self.dut.qsfp_7_tx_rst_4.setimmediatevalue(0) - self.dut.qsfp_8_rx_rst_1.setimmediatevalue(0) - self.dut.qsfp_8_tx_rst_1.setimmediatevalue(0) - self.dut.qsfp_8_rx_rst_2.setimmediatevalue(0) - self.dut.qsfp_8_tx_rst_2.setimmediatevalue(0) - self.dut.qsfp_8_rx_rst_3.setimmediatevalue(0) - self.dut.qsfp_8_tx_rst_3.setimmediatevalue(0) - self.dut.qsfp_8_rx_rst_4.setimmediatevalue(0) - self.dut.qsfp_8_tx_rst_4.setimmediatevalue(0) - self.dut.qsfp_9_rx_rst_1.setimmediatevalue(0) - self.dut.qsfp_9_tx_rst_1.setimmediatevalue(0) - self.dut.qsfp_9_rx_rst_2.setimmediatevalue(0) - self.dut.qsfp_9_tx_rst_2.setimmediatevalue(0) - self.dut.qsfp_9_rx_rst_3.setimmediatevalue(0) - self.dut.qsfp_9_tx_rst_3.setimmediatevalue(0) - self.dut.qsfp_9_rx_rst_4.setimmediatevalue(0) - self.dut.qsfp_9_tx_rst_4.setimmediatevalue(0) + for x in range(1, 10): + for y in range(1, 5): + getattr(self.dut, f"qsfp_{x}_rx_rst_{y}").setimmediatevalue(0) + getattr(self.dut, f"qsfp_{x}_tx_rst_{y}").setimmediatevalue(0) for k in range(10): await RisingEdge(self.dut.clk) self.dut.rst.value = 1 - self.dut.qsfp_1_rx_rst_1.value = 1 - self.dut.qsfp_1_tx_rst_1.value = 1 - self.dut.qsfp_1_rx_rst_2.value = 1 - self.dut.qsfp_1_tx_rst_2.value = 1 - self.dut.qsfp_1_rx_rst_3.value = 1 - self.dut.qsfp_1_tx_rst_3.value = 1 - self.dut.qsfp_1_rx_rst_4.value = 1 - self.dut.qsfp_1_tx_rst_4.value = 1 - self.dut.qsfp_2_rx_rst_1.value = 1 - self.dut.qsfp_2_tx_rst_1.value = 1 - self.dut.qsfp_2_rx_rst_2.value = 1 - self.dut.qsfp_2_tx_rst_2.value = 1 - self.dut.qsfp_2_rx_rst_3.value = 1 - self.dut.qsfp_2_tx_rst_3.value = 1 - self.dut.qsfp_2_rx_rst_4.value = 1 - self.dut.qsfp_2_tx_rst_4.value = 1 - self.dut.qsfp_3_rx_rst_1.value = 1 - self.dut.qsfp_3_tx_rst_1.value = 1 - self.dut.qsfp_3_rx_rst_2.value = 1 - self.dut.qsfp_3_tx_rst_2.value = 1 - self.dut.qsfp_3_rx_rst_3.value = 1 - self.dut.qsfp_3_tx_rst_3.value = 1 - self.dut.qsfp_3_rx_rst_4.value = 1 - self.dut.qsfp_3_tx_rst_4.value = 1 - self.dut.qsfp_4_rx_rst_1.value = 1 - self.dut.qsfp_4_tx_rst_1.value = 1 - self.dut.qsfp_4_rx_rst_2.value = 1 - self.dut.qsfp_4_tx_rst_2.value = 1 - self.dut.qsfp_4_rx_rst_3.value = 1 - self.dut.qsfp_4_tx_rst_3.value = 1 - self.dut.qsfp_4_rx_rst_4.value = 1 - self.dut.qsfp_4_tx_rst_4.value = 1 - self.dut.qsfp_5_rx_rst_1.value = 1 - self.dut.qsfp_5_tx_rst_1.value = 1 - self.dut.qsfp_5_rx_rst_2.value = 1 - self.dut.qsfp_5_tx_rst_2.value = 1 - self.dut.qsfp_5_rx_rst_3.value = 1 - self.dut.qsfp_5_tx_rst_3.value = 1 - self.dut.qsfp_5_rx_rst_4.value = 1 - self.dut.qsfp_5_tx_rst_4.value = 1 - self.dut.qsfp_6_rx_rst_1.value = 1 - self.dut.qsfp_6_tx_rst_1.value = 1 - self.dut.qsfp_6_rx_rst_2.value = 1 - self.dut.qsfp_6_tx_rst_2.value = 1 - self.dut.qsfp_6_rx_rst_3.value = 1 - self.dut.qsfp_6_tx_rst_3.value = 1 - self.dut.qsfp_6_rx_rst_4.value = 1 - self.dut.qsfp_6_tx_rst_4.value = 1 - self.dut.qsfp_7_rx_rst_1.value = 1 - self.dut.qsfp_7_tx_rst_1.value = 1 - self.dut.qsfp_7_rx_rst_2.value = 1 - self.dut.qsfp_7_tx_rst_2.value = 1 - self.dut.qsfp_7_rx_rst_3.value = 1 - self.dut.qsfp_7_tx_rst_3.value = 1 - self.dut.qsfp_7_rx_rst_4.value = 1 - self.dut.qsfp_7_tx_rst_4.value = 1 - self.dut.qsfp_8_rx_rst_1.value = 1 - self.dut.qsfp_8_tx_rst_1.value = 1 - self.dut.qsfp_8_rx_rst_2.value = 1 - self.dut.qsfp_8_tx_rst_2.value = 1 - self.dut.qsfp_8_rx_rst_3.value = 1 - self.dut.qsfp_8_tx_rst_3.value = 1 - self.dut.qsfp_8_rx_rst_4.value = 1 - self.dut.qsfp_8_tx_rst_4.value = 1 - self.dut.qsfp_9_rx_rst_1.value = 1 - self.dut.qsfp_9_tx_rst_1.value = 1 - self.dut.qsfp_9_rx_rst_2.value = 1 - self.dut.qsfp_9_tx_rst_2.value = 1 - self.dut.qsfp_9_rx_rst_3.value = 1 - self.dut.qsfp_9_tx_rst_3.value = 1 - self.dut.qsfp_9_rx_rst_4.value = 1 - self.dut.qsfp_9_tx_rst_4.value = 1 + for x in range(1, 10): + for y in range(1, 5): + getattr(self.dut, f"qsfp_{x}_rx_rst_{y}").value = 1 + getattr(self.dut, f"qsfp_{x}_tx_rst_{y}").value = 1 for k in range(10): await RisingEdge(self.dut.clk) self.dut.rst.value = 0 - self.dut.qsfp_1_rx_rst_1.value = 0 - self.dut.qsfp_1_tx_rst_1.value = 0 - self.dut.qsfp_1_rx_rst_2.value = 0 - self.dut.qsfp_1_tx_rst_2.value = 0 - self.dut.qsfp_1_rx_rst_3.value = 0 - self.dut.qsfp_1_tx_rst_3.value = 0 - self.dut.qsfp_1_rx_rst_4.value = 0 - self.dut.qsfp_1_tx_rst_4.value = 0 - self.dut.qsfp_2_rx_rst_1.value = 0 - self.dut.qsfp_2_tx_rst_1.value = 0 - self.dut.qsfp_2_rx_rst_2.value = 0 - self.dut.qsfp_2_tx_rst_2.value = 0 - self.dut.qsfp_2_rx_rst_3.value = 0 - self.dut.qsfp_2_tx_rst_3.value = 0 - self.dut.qsfp_2_rx_rst_4.value = 0 - self.dut.qsfp_2_tx_rst_4.value = 0 - self.dut.qsfp_3_rx_rst_1.value = 0 - self.dut.qsfp_3_tx_rst_1.value = 0 - self.dut.qsfp_3_rx_rst_2.value = 0 - self.dut.qsfp_3_tx_rst_2.value = 0 - self.dut.qsfp_3_rx_rst_3.value = 0 - self.dut.qsfp_3_tx_rst_3.value = 0 - self.dut.qsfp_3_rx_rst_4.value = 0 - self.dut.qsfp_3_tx_rst_4.value = 0 - self.dut.qsfp_4_rx_rst_1.value = 0 - self.dut.qsfp_4_tx_rst_1.value = 0 - self.dut.qsfp_4_rx_rst_2.value = 0 - self.dut.qsfp_4_tx_rst_2.value = 0 - self.dut.qsfp_4_rx_rst_3.value = 0 - self.dut.qsfp_4_tx_rst_3.value = 0 - self.dut.qsfp_4_rx_rst_4.value = 0 - self.dut.qsfp_4_tx_rst_4.value = 0 - self.dut.qsfp_5_rx_rst_1.value = 0 - self.dut.qsfp_5_tx_rst_1.value = 0 - self.dut.qsfp_5_rx_rst_2.value = 0 - self.dut.qsfp_5_tx_rst_2.value = 0 - self.dut.qsfp_5_rx_rst_3.value = 0 - self.dut.qsfp_5_tx_rst_3.value = 0 - self.dut.qsfp_5_rx_rst_4.value = 0 - self.dut.qsfp_5_tx_rst_4.value = 0 - self.dut.qsfp_6_rx_rst_1.value = 0 - self.dut.qsfp_6_tx_rst_1.value = 0 - self.dut.qsfp_6_rx_rst_2.value = 0 - self.dut.qsfp_6_tx_rst_2.value = 0 - self.dut.qsfp_6_rx_rst_3.value = 0 - self.dut.qsfp_6_tx_rst_3.value = 0 - self.dut.qsfp_6_rx_rst_4.value = 0 - self.dut.qsfp_6_tx_rst_4.value = 0 - self.dut.qsfp_7_rx_rst_1.value = 0 - self.dut.qsfp_7_tx_rst_1.value = 0 - self.dut.qsfp_7_rx_rst_2.value = 0 - self.dut.qsfp_7_tx_rst_2.value = 0 - self.dut.qsfp_7_rx_rst_3.value = 0 - self.dut.qsfp_7_tx_rst_3.value = 0 - self.dut.qsfp_7_rx_rst_4.value = 0 - self.dut.qsfp_7_tx_rst_4.value = 0 - self.dut.qsfp_8_rx_rst_1.value = 0 - self.dut.qsfp_8_tx_rst_1.value = 0 - self.dut.qsfp_8_rx_rst_2.value = 0 - self.dut.qsfp_8_tx_rst_2.value = 0 - self.dut.qsfp_8_rx_rst_3.value = 0 - self.dut.qsfp_8_tx_rst_3.value = 0 - self.dut.qsfp_8_rx_rst_4.value = 0 - self.dut.qsfp_8_tx_rst_4.value = 0 - self.dut.qsfp_9_rx_rst_1.value = 0 - self.dut.qsfp_9_tx_rst_1.value = 0 - self.dut.qsfp_9_rx_rst_2.value = 0 - self.dut.qsfp_9_tx_rst_2.value = 0 - self.dut.qsfp_9_rx_rst_3.value = 0 - self.dut.qsfp_9_tx_rst_3.value = 0 - self.dut.qsfp_9_rx_rst_4.value = 0 - self.dut.qsfp_9_tx_rst_4.value = 0 + for x in range(1, 10): + for y in range(1, 5): + getattr(self.dut, f"qsfp_{x}_rx_rst_{y}").value = 0 + getattr(self.dut, f"qsfp_{x}_tx_rst_{y}").value = 0 @cocotb.test() @@ -482,11 +114,11 @@ async def run_test(dut): test_frame = XgmiiFrame.from_payload(test_pkt.build()) - await tb.qsfp_1_1_source.send(test_frame) + await tb.qsfp_source[0][0].send(test_frame) tb.log.info("receive ARP request") - rx_frame = await tb.qsfp_1_1_sink.recv() + rx_frame = await tb.qsfp_sink[0][0].recv() rx_pkt = Ether(bytes(rx_frame.get_payload())) @@ -514,11 +146,11 @@ async def run_test(dut): resp_frame = XgmiiFrame.from_payload(resp_pkt.build()) - await tb.qsfp_1_1_source.send(resp_frame) + await tb.qsfp_source[0][0].send(resp_frame) tb.log.info("receive UDP packet") - rx_frame = await tb.qsfp_1_1_sink.recv() + rx_frame = await tb.qsfp_sink[0][0].recv() rx_pkt = Ether(bytes(rx_frame.get_payload())) diff --git a/example/HTG9200/fpga_fmc_htg_6qsfp_25g/tb/fpga_core/test_fpga_core.py b/example/HTG9200/fpga_fmc_htg_6qsfp_25g/tb/fpga_core/test_fpga_core.py index 73d701d9b..11a30cd4a 100644 --- a/example/HTG9200/fpga_fmc_htg_6qsfp_25g/tb/fpga_core/test_fpga_core.py +++ b/example/HTG9200/fpga_fmc_htg_6qsfp_25g/tb/fpga_core/test_fpga_core.py @@ -54,679 +54,75 @@ class TB: dut.uart_rts.setimmediatevalue(1) # Ethernet - cocotb.start_soon(Clock(dut.qsfp_1_rx_clk_1, 2.56, units="ns").start()) - self.qsfp_1_1_source = XgmiiSource(dut.qsfp_1_rxd_1, dut.qsfp_1_rxc_1, dut.qsfp_1_rx_clk_1, dut.qsfp_1_rx_rst_1) - cocotb.start_soon(Clock(dut.qsfp_1_tx_clk_1, 2.56, units="ns").start()) - self.qsfp_1_1_sink = XgmiiSink(dut.qsfp_1_txd_1, dut.qsfp_1_txc_1, dut.qsfp_1_tx_clk_1, dut.qsfp_1_tx_rst_1) + self.qsfp_source = [] + self.qsfp_sink = [] - cocotb.start_soon(Clock(dut.qsfp_1_rx_clk_2, 2.56, units="ns").start()) - self.qsfp_1_2_source = XgmiiSource(dut.qsfp_1_rxd_2, dut.qsfp_1_rxc_2, dut.qsfp_1_rx_clk_2, dut.qsfp_1_rx_rst_2) - cocotb.start_soon(Clock(dut.qsfp_1_tx_clk_2, 2.56, units="ns").start()) - self.qsfp_1_2_sink = XgmiiSink(dut.qsfp_1_txd_2, dut.qsfp_1_txc_2, dut.qsfp_1_tx_clk_2, dut.qsfp_1_tx_rst_2) + for x in range(1, 10): + sources = [] + sinks = [] + for y in range(1, 5): + cocotb.start_soon(Clock(getattr(dut, f"qsfp_{x}_rx_clk_{y}"), 2.56, units="ns").start()) + source = XgmiiSource(getattr(dut, f"qsfp_{x}_rxd_{y}"), getattr(dut, f"qsfp_{x}_rxc_{y}"), getattr(dut, f"qsfp_{x}_rx_clk_{y}"), getattr(dut, f"qsfp_{x}_rx_rst_{y}")) + sources.append(source) + cocotb.start_soon(Clock(getattr(dut, f"qsfp_{x}_tx_clk_{y}"), 2.56, units="ns").start()) + sink = XgmiiSink(getattr(dut, f"qsfp_{x}_txd_{y}"), getattr(dut, f"qsfp_{x}_txc_{y}"), getattr(dut, f"qsfp_{x}_tx_clk_{y}"), getattr(dut, f"qsfp_{x}_tx_rst_{y}")) + sinks.append(sink) + self.qsfp_source.append(sources) + self.qsfp_sink.append(sinks) - cocotb.start_soon(Clock(dut.qsfp_1_rx_clk_3, 2.56, units="ns").start()) - self.qsfp_1_3_source = XgmiiSource(dut.qsfp_1_rxd_3, dut.qsfp_1_rxc_3, dut.qsfp_1_rx_clk_3, dut.qsfp_1_rx_rst_3) - cocotb.start_soon(Clock(dut.qsfp_1_tx_clk_3, 2.56, units="ns").start()) - self.qsfp_1_3_sink = XgmiiSink(dut.qsfp_1_txd_3, dut.qsfp_1_txc_3, dut.qsfp_1_tx_clk_3, dut.qsfp_1_tx_rst_3) + self.fmc_qsfp_source = [] + self.fmc_qsfp_sink = [] - cocotb.start_soon(Clock(dut.qsfp_1_rx_clk_4, 2.56, units="ns").start()) - self.qsfp_1_4_source = XgmiiSource(dut.qsfp_1_rxd_4, dut.qsfp_1_rxc_4, dut.qsfp_1_rx_clk_4, dut.qsfp_1_rx_rst_4) - cocotb.start_soon(Clock(dut.qsfp_1_tx_clk_4, 2.56, units="ns").start()) - self.qsfp_1_4_sink = XgmiiSink(dut.qsfp_1_txd_4, dut.qsfp_1_txc_4, dut.qsfp_1_tx_clk_4, dut.qsfp_1_tx_rst_4) - - cocotb.start_soon(Clock(dut.qsfp_2_rx_clk_1, 2.56, units="ns").start()) - self.qsfp_2_1_source = XgmiiSource(dut.qsfp_2_rxd_1, dut.qsfp_2_rxc_1, dut.qsfp_2_rx_clk_1, dut.qsfp_2_rx_rst_1) - cocotb.start_soon(Clock(dut.qsfp_2_tx_clk_1, 2.56, units="ns").start()) - self.qsfp_2_1_sink = XgmiiSink(dut.qsfp_2_txd_1, dut.qsfp_2_txc_1, dut.qsfp_2_tx_clk_1, dut.qsfp_2_tx_rst_1) - - cocotb.start_soon(Clock(dut.qsfp_2_rx_clk_2, 2.56, units="ns").start()) - self.qsfp_2_2_source = XgmiiSource(dut.qsfp_2_rxd_2, dut.qsfp_2_rxc_2, dut.qsfp_2_rx_clk_2, dut.qsfp_2_rx_rst_2) - cocotb.start_soon(Clock(dut.qsfp_2_tx_clk_2, 2.56, units="ns").start()) - self.qsfp_2_2_sink = XgmiiSink(dut.qsfp_2_txd_2, dut.qsfp_2_txc_2, dut.qsfp_2_tx_clk_2, dut.qsfp_2_tx_rst_2) - - cocotb.start_soon(Clock(dut.qsfp_2_rx_clk_3, 2.56, units="ns").start()) - self.qsfp_2_3_source = XgmiiSource(dut.qsfp_2_rxd_3, dut.qsfp_2_rxc_3, dut.qsfp_2_rx_clk_3, dut.qsfp_2_rx_rst_3) - cocotb.start_soon(Clock(dut.qsfp_2_tx_clk_3, 2.56, units="ns").start()) - self.qsfp_2_3_sink = XgmiiSink(dut.qsfp_2_txd_3, dut.qsfp_2_txc_3, dut.qsfp_2_tx_clk_3, dut.qsfp_2_tx_rst_3) - - cocotb.start_soon(Clock(dut.qsfp_2_rx_clk_4, 2.56, units="ns").start()) - self.qsfp_2_4_source = XgmiiSource(dut.qsfp_2_rxd_4, dut.qsfp_2_rxc_4, dut.qsfp_2_rx_clk_4, dut.qsfp_2_rx_rst_4) - cocotb.start_soon(Clock(dut.qsfp_2_tx_clk_4, 2.56, units="ns").start()) - self.qsfp_2_4_sink = XgmiiSink(dut.qsfp_2_txd_4, dut.qsfp_2_txc_4, dut.qsfp_2_tx_clk_4, dut.qsfp_2_tx_rst_4) - - cocotb.start_soon(Clock(dut.qsfp_3_rx_clk_1, 2.56, units="ns").start()) - self.qsfp_3_1_source = XgmiiSource(dut.qsfp_3_rxd_1, dut.qsfp_3_rxc_1, dut.qsfp_3_rx_clk_1, dut.qsfp_3_rx_rst_1) - cocotb.start_soon(Clock(dut.qsfp_3_tx_clk_1, 2.56, units="ns").start()) - self.qsfp_3_1_sink = XgmiiSink(dut.qsfp_3_txd_1, dut.qsfp_3_txc_1, dut.qsfp_3_tx_clk_1, dut.qsfp_3_tx_rst_1) - - cocotb.start_soon(Clock(dut.qsfp_3_rx_clk_2, 2.56, units="ns").start()) - self.qsfp_3_2_source = XgmiiSource(dut.qsfp_3_rxd_2, dut.qsfp_3_rxc_2, dut.qsfp_3_rx_clk_2, dut.qsfp_3_rx_rst_2) - cocotb.start_soon(Clock(dut.qsfp_3_tx_clk_2, 2.56, units="ns").start()) - self.qsfp_3_2_sink = XgmiiSink(dut.qsfp_3_txd_2, dut.qsfp_3_txc_2, dut.qsfp_3_tx_clk_2, dut.qsfp_3_tx_rst_2) - - cocotb.start_soon(Clock(dut.qsfp_3_rx_clk_3, 2.56, units="ns").start()) - self.qsfp_3_3_source = XgmiiSource(dut.qsfp_3_rxd_3, dut.qsfp_3_rxc_3, dut.qsfp_3_rx_clk_3, dut.qsfp_3_rx_rst_3) - cocotb.start_soon(Clock(dut.qsfp_3_tx_clk_3, 2.56, units="ns").start()) - self.qsfp_3_3_sink = XgmiiSink(dut.qsfp_3_txd_3, dut.qsfp_3_txc_3, dut.qsfp_3_tx_clk_3, dut.qsfp_3_tx_rst_3) - - cocotb.start_soon(Clock(dut.qsfp_3_rx_clk_4, 2.56, units="ns").start()) - self.qsfp_3_4_source = XgmiiSource(dut.qsfp_3_rxd_4, dut.qsfp_3_rxc_4, dut.qsfp_3_rx_clk_4, dut.qsfp_3_rx_rst_4) - cocotb.start_soon(Clock(dut.qsfp_3_tx_clk_4, 2.56, units="ns").start()) - self.qsfp_3_4_sink = XgmiiSink(dut.qsfp_3_txd_4, dut.qsfp_3_txc_4, dut.qsfp_3_tx_clk_4, dut.qsfp_3_tx_rst_4) - - cocotb.start_soon(Clock(dut.qsfp_4_rx_clk_1, 2.56, units="ns").start()) - self.qsfp_4_1_source = XgmiiSource(dut.qsfp_4_rxd_1, dut.qsfp_4_rxc_1, dut.qsfp_4_rx_clk_1, dut.qsfp_4_rx_rst_1) - cocotb.start_soon(Clock(dut.qsfp_4_tx_clk_1, 2.56, units="ns").start()) - self.qsfp_4_1_sink = XgmiiSink(dut.qsfp_4_txd_1, dut.qsfp_4_txc_1, dut.qsfp_4_tx_clk_1, dut.qsfp_4_tx_rst_1) - - cocotb.start_soon(Clock(dut.qsfp_4_rx_clk_2, 2.56, units="ns").start()) - self.qsfp_4_2_source = XgmiiSource(dut.qsfp_4_rxd_2, dut.qsfp_4_rxc_2, dut.qsfp_4_rx_clk_2, dut.qsfp_4_rx_rst_2) - cocotb.start_soon(Clock(dut.qsfp_4_tx_clk_2, 2.56, units="ns").start()) - self.qsfp_4_2_sink = XgmiiSink(dut.qsfp_4_txd_2, dut.qsfp_4_txc_2, dut.qsfp_4_tx_clk_2, dut.qsfp_4_tx_rst_2) - - cocotb.start_soon(Clock(dut.qsfp_4_rx_clk_3, 2.56, units="ns").start()) - self.qsfp_4_3_source = XgmiiSource(dut.qsfp_4_rxd_3, dut.qsfp_4_rxc_3, dut.qsfp_4_rx_clk_3, dut.qsfp_4_rx_rst_3) - cocotb.start_soon(Clock(dut.qsfp_4_tx_clk_3, 2.56, units="ns").start()) - self.qsfp_4_3_sink = XgmiiSink(dut.qsfp_4_txd_3, dut.qsfp_4_txc_3, dut.qsfp_4_tx_clk_3, dut.qsfp_4_tx_rst_3) - - cocotb.start_soon(Clock(dut.qsfp_4_rx_clk_4, 2.56, units="ns").start()) - self.qsfp_4_4_source = XgmiiSource(dut.qsfp_4_rxd_4, dut.qsfp_4_rxc_4, dut.qsfp_4_rx_clk_4, dut.qsfp_4_rx_rst_4) - cocotb.start_soon(Clock(dut.qsfp_4_tx_clk_4, 2.56, units="ns").start()) - self.qsfp_4_4_sink = XgmiiSink(dut.qsfp_4_txd_4, dut.qsfp_4_txc_4, dut.qsfp_4_tx_clk_4, dut.qsfp_4_tx_rst_4) - - cocotb.start_soon(Clock(dut.qsfp_5_rx_clk_1, 2.56, units="ns").start()) - self.qsfp_5_1_source = XgmiiSource(dut.qsfp_5_rxd_1, dut.qsfp_5_rxc_1, dut.qsfp_5_rx_clk_1, dut.qsfp_5_rx_rst_1) - cocotb.start_soon(Clock(dut.qsfp_5_tx_clk_1, 2.56, units="ns").start()) - self.qsfp_5_1_sink = XgmiiSink(dut.qsfp_5_txd_1, dut.qsfp_5_txc_1, dut.qsfp_5_tx_clk_1, dut.qsfp_5_tx_rst_1) - - cocotb.start_soon(Clock(dut.qsfp_5_rx_clk_2, 2.56, units="ns").start()) - self.qsfp_5_2_source = XgmiiSource(dut.qsfp_5_rxd_2, dut.qsfp_5_rxc_2, dut.qsfp_5_rx_clk_2, dut.qsfp_5_rx_rst_2) - cocotb.start_soon(Clock(dut.qsfp_5_tx_clk_2, 2.56, units="ns").start()) - self.qsfp_5_2_sink = XgmiiSink(dut.qsfp_5_txd_2, dut.qsfp_5_txc_2, dut.qsfp_5_tx_clk_2, dut.qsfp_5_tx_rst_2) - - cocotb.start_soon(Clock(dut.qsfp_5_rx_clk_3, 2.56, units="ns").start()) - self.qsfp_5_3_source = XgmiiSource(dut.qsfp_5_rxd_3, dut.qsfp_5_rxc_3, dut.qsfp_5_rx_clk_3, dut.qsfp_5_rx_rst_3) - cocotb.start_soon(Clock(dut.qsfp_5_tx_clk_3, 2.56, units="ns").start()) - self.qsfp_5_3_sink = XgmiiSink(dut.qsfp_5_txd_3, dut.qsfp_5_txc_3, dut.qsfp_5_tx_clk_3, dut.qsfp_5_tx_rst_3) - - cocotb.start_soon(Clock(dut.qsfp_5_rx_clk_4, 2.56, units="ns").start()) - self.qsfp_5_4_source = XgmiiSource(dut.qsfp_5_rxd_4, dut.qsfp_5_rxc_4, dut.qsfp_5_rx_clk_4, dut.qsfp_5_rx_rst_4) - cocotb.start_soon(Clock(dut.qsfp_5_tx_clk_4, 2.56, units="ns").start()) - self.qsfp_5_4_sink = XgmiiSink(dut.qsfp_5_txd_4, dut.qsfp_5_txc_4, dut.qsfp_5_tx_clk_4, dut.qsfp_5_tx_rst_4) - - cocotb.start_soon(Clock(dut.qsfp_6_rx_clk_1, 2.56, units="ns").start()) - self.qsfp_6_1_source = XgmiiSource(dut.qsfp_6_rxd_1, dut.qsfp_6_rxc_1, dut.qsfp_6_rx_clk_1, dut.qsfp_6_rx_rst_1) - cocotb.start_soon(Clock(dut.qsfp_6_tx_clk_1, 2.56, units="ns").start()) - self.qsfp_6_1_sink = XgmiiSink(dut.qsfp_6_txd_1, dut.qsfp_6_txc_1, dut.qsfp_6_tx_clk_1, dut.qsfp_6_tx_rst_1) - - cocotb.start_soon(Clock(dut.qsfp_6_rx_clk_2, 2.56, units="ns").start()) - self.qsfp_6_2_source = XgmiiSource(dut.qsfp_6_rxd_2, dut.qsfp_6_rxc_2, dut.qsfp_6_rx_clk_2, dut.qsfp_6_rx_rst_2) - cocotb.start_soon(Clock(dut.qsfp_6_tx_clk_2, 2.56, units="ns").start()) - self.qsfp_6_2_sink = XgmiiSink(dut.qsfp_6_txd_2, dut.qsfp_6_txc_2, dut.qsfp_6_tx_clk_2, dut.qsfp_6_tx_rst_2) - - cocotb.start_soon(Clock(dut.qsfp_6_rx_clk_3, 2.56, units="ns").start()) - self.qsfp_6_3_source = XgmiiSource(dut.qsfp_6_rxd_3, dut.qsfp_6_rxc_3, dut.qsfp_6_rx_clk_3, dut.qsfp_6_rx_rst_3) - cocotb.start_soon(Clock(dut.qsfp_6_tx_clk_3, 2.56, units="ns").start()) - self.qsfp_6_3_sink = XgmiiSink(dut.qsfp_6_txd_3, dut.qsfp_6_txc_3, dut.qsfp_6_tx_clk_3, dut.qsfp_6_tx_rst_3) - - cocotb.start_soon(Clock(dut.qsfp_6_rx_clk_4, 2.56, units="ns").start()) - self.qsfp_6_4_source = XgmiiSource(dut.qsfp_6_rxd_4, dut.qsfp_6_rxc_4, dut.qsfp_6_rx_clk_4, dut.qsfp_6_rx_rst_4) - cocotb.start_soon(Clock(dut.qsfp_6_tx_clk_4, 2.56, units="ns").start()) - self.qsfp_6_4_sink = XgmiiSink(dut.qsfp_6_txd_4, dut.qsfp_6_txc_4, dut.qsfp_6_tx_clk_4, dut.qsfp_6_tx_rst_4) - - cocotb.start_soon(Clock(dut.qsfp_7_rx_clk_1, 2.56, units="ns").start()) - self.qsfp_7_1_source = XgmiiSource(dut.qsfp_7_rxd_1, dut.qsfp_7_rxc_1, dut.qsfp_7_rx_clk_1, dut.qsfp_7_rx_rst_1) - cocotb.start_soon(Clock(dut.qsfp_7_tx_clk_1, 2.56, units="ns").start()) - self.qsfp_7_1_sink = XgmiiSink(dut.qsfp_7_txd_1, dut.qsfp_7_txc_1, dut.qsfp_7_tx_clk_1, dut.qsfp_7_tx_rst_1) - - cocotb.start_soon(Clock(dut.qsfp_7_rx_clk_2, 2.56, units="ns").start()) - self.qsfp_7_2_source = XgmiiSource(dut.qsfp_7_rxd_2, dut.qsfp_7_rxc_2, dut.qsfp_7_rx_clk_2, dut.qsfp_7_rx_rst_2) - cocotb.start_soon(Clock(dut.qsfp_7_tx_clk_2, 2.56, units="ns").start()) - self.qsfp_7_2_sink = XgmiiSink(dut.qsfp_7_txd_2, dut.qsfp_7_txc_2, dut.qsfp_7_tx_clk_2, dut.qsfp_7_tx_rst_2) - - cocotb.start_soon(Clock(dut.qsfp_7_rx_clk_3, 2.56, units="ns").start()) - self.qsfp_7_3_source = XgmiiSource(dut.qsfp_7_rxd_3, dut.qsfp_7_rxc_3, dut.qsfp_7_rx_clk_3, dut.qsfp_7_rx_rst_3) - cocotb.start_soon(Clock(dut.qsfp_7_tx_clk_3, 2.56, units="ns").start()) - self.qsfp_7_3_sink = XgmiiSink(dut.qsfp_7_txd_3, dut.qsfp_7_txc_3, dut.qsfp_7_tx_clk_3, dut.qsfp_7_tx_rst_3) - - cocotb.start_soon(Clock(dut.qsfp_7_rx_clk_4, 2.56, units="ns").start()) - self.qsfp_7_4_source = XgmiiSource(dut.qsfp_7_rxd_4, dut.qsfp_7_rxc_4, dut.qsfp_7_rx_clk_4, dut.qsfp_7_rx_rst_4) - cocotb.start_soon(Clock(dut.qsfp_7_tx_clk_4, 2.56, units="ns").start()) - self.qsfp_7_4_sink = XgmiiSink(dut.qsfp_7_txd_4, dut.qsfp_7_txc_4, dut.qsfp_7_tx_clk_4, dut.qsfp_7_tx_rst_4) - - cocotb.start_soon(Clock(dut.qsfp_8_rx_clk_1, 2.56, units="ns").start()) - self.qsfp_8_1_source = XgmiiSource(dut.qsfp_8_rxd_1, dut.qsfp_8_rxc_1, dut.qsfp_8_rx_clk_1, dut.qsfp_8_rx_rst_1) - cocotb.start_soon(Clock(dut.qsfp_8_tx_clk_1, 2.56, units="ns").start()) - self.qsfp_8_1_sink = XgmiiSink(dut.qsfp_8_txd_1, dut.qsfp_8_txc_1, dut.qsfp_8_tx_clk_1, dut.qsfp_8_tx_rst_1) - - cocotb.start_soon(Clock(dut.qsfp_8_rx_clk_2, 2.56, units="ns").start()) - self.qsfp_8_2_source = XgmiiSource(dut.qsfp_8_rxd_2, dut.qsfp_8_rxc_2, dut.qsfp_8_rx_clk_2, dut.qsfp_8_rx_rst_2) - cocotb.start_soon(Clock(dut.qsfp_8_tx_clk_2, 2.56, units="ns").start()) - self.qsfp_8_2_sink = XgmiiSink(dut.qsfp_8_txd_2, dut.qsfp_8_txc_2, dut.qsfp_8_tx_clk_2, dut.qsfp_8_tx_rst_2) - - cocotb.start_soon(Clock(dut.qsfp_8_rx_clk_3, 2.56, units="ns").start()) - self.qsfp_8_3_source = XgmiiSource(dut.qsfp_8_rxd_3, dut.qsfp_8_rxc_3, dut.qsfp_8_rx_clk_3, dut.qsfp_8_rx_rst_3) - cocotb.start_soon(Clock(dut.qsfp_8_tx_clk_3, 2.56, units="ns").start()) - self.qsfp_8_3_sink = XgmiiSink(dut.qsfp_8_txd_3, dut.qsfp_8_txc_3, dut.qsfp_8_tx_clk_3, dut.qsfp_8_tx_rst_3) - - cocotb.start_soon(Clock(dut.qsfp_8_rx_clk_4, 2.56, units="ns").start()) - self.qsfp_8_4_source = XgmiiSource(dut.qsfp_8_rxd_4, dut.qsfp_8_rxc_4, dut.qsfp_8_rx_clk_4, dut.qsfp_8_rx_rst_4) - cocotb.start_soon(Clock(dut.qsfp_8_tx_clk_4, 2.56, units="ns").start()) - self.qsfp_8_4_sink = XgmiiSink(dut.qsfp_8_txd_4, dut.qsfp_8_txc_4, dut.qsfp_8_tx_clk_4, dut.qsfp_8_tx_rst_4) - - cocotb.start_soon(Clock(dut.qsfp_9_rx_clk_1, 2.56, units="ns").start()) - self.qsfp_9_1_source = XgmiiSource(dut.qsfp_9_rxd_1, dut.qsfp_9_rxc_1, dut.qsfp_9_rx_clk_1, dut.qsfp_9_rx_rst_1) - cocotb.start_soon(Clock(dut.qsfp_9_tx_clk_1, 2.56, units="ns").start()) - self.qsfp_9_1_sink = XgmiiSink(dut.qsfp_9_txd_1, dut.qsfp_9_txc_1, dut.qsfp_9_tx_clk_1, dut.qsfp_9_tx_rst_1) - - cocotb.start_soon(Clock(dut.qsfp_9_rx_clk_2, 2.56, units="ns").start()) - self.qsfp_9_2_source = XgmiiSource(dut.qsfp_9_rxd_2, dut.qsfp_9_rxc_2, dut.qsfp_9_rx_clk_2, dut.qsfp_9_rx_rst_2) - cocotb.start_soon(Clock(dut.qsfp_9_tx_clk_2, 2.56, units="ns").start()) - self.qsfp_9_2_sink = XgmiiSink(dut.qsfp_9_txd_2, dut.qsfp_9_txc_2, dut.qsfp_9_tx_clk_2, dut.qsfp_9_tx_rst_2) - - cocotb.start_soon(Clock(dut.qsfp_9_rx_clk_3, 2.56, units="ns").start()) - self.qsfp_9_3_source = XgmiiSource(dut.qsfp_9_rxd_3, dut.qsfp_9_rxc_3, dut.qsfp_9_rx_clk_3, dut.qsfp_9_rx_rst_3) - cocotb.start_soon(Clock(dut.qsfp_9_tx_clk_3, 2.56, units="ns").start()) - self.qsfp_9_3_sink = XgmiiSink(dut.qsfp_9_txd_3, dut.qsfp_9_txc_3, dut.qsfp_9_tx_clk_3, dut.qsfp_9_tx_rst_3) - - cocotb.start_soon(Clock(dut.qsfp_9_rx_clk_4, 2.56, units="ns").start()) - self.qsfp_9_4_source = XgmiiSource(dut.qsfp_9_rxd_4, dut.qsfp_9_rxc_4, dut.qsfp_9_rx_clk_4, dut.qsfp_9_rx_rst_4) - cocotb.start_soon(Clock(dut.qsfp_9_tx_clk_4, 2.56, units="ns").start()) - self.qsfp_9_4_sink = XgmiiSink(dut.qsfp_9_txd_4, dut.qsfp_9_txc_4, dut.qsfp_9_tx_clk_4, dut.qsfp_9_tx_rst_4) - - cocotb.start_soon(Clock(dut.fmc_qsfp_1_rx_clk_1, 2.56, units="ns").start()) - self.fmc_qsfp_1_1_source = XgmiiSource(dut.fmc_qsfp_1_rxd_1, dut.fmc_qsfp_1_rxc_1, dut.fmc_qsfp_1_rx_clk_1, dut.fmc_qsfp_1_rx_rst_1) - cocotb.start_soon(Clock(dut.fmc_qsfp_1_tx_clk_1, 2.56, units="ns").start()) - self.fmc_qsfp_1_1_sink = XgmiiSink(dut.fmc_qsfp_1_txd_1, dut.fmc_qsfp_1_txc_1, dut.fmc_qsfp_1_tx_clk_1, dut.fmc_qsfp_1_tx_rst_1) - - cocotb.start_soon(Clock(dut.fmc_qsfp_1_rx_clk_2, 2.56, units="ns").start()) - self.fmc_qsfp_1_2_source = XgmiiSource(dut.fmc_qsfp_1_rxd_2, dut.fmc_qsfp_1_rxc_2, dut.fmc_qsfp_1_rx_clk_2, dut.fmc_qsfp_1_rx_rst_2) - cocotb.start_soon(Clock(dut.fmc_qsfp_1_tx_clk_2, 2.56, units="ns").start()) - self.fmc_qsfp_1_2_sink = XgmiiSink(dut.fmc_qsfp_1_txd_2, dut.fmc_qsfp_1_txc_2, dut.fmc_qsfp_1_tx_clk_2, dut.fmc_qsfp_1_tx_rst_2) - - cocotb.start_soon(Clock(dut.fmc_qsfp_1_rx_clk_3, 2.56, units="ns").start()) - self.fmc_qsfp_1_3_source = XgmiiSource(dut.fmc_qsfp_1_rxd_3, dut.fmc_qsfp_1_rxc_3, dut.fmc_qsfp_1_rx_clk_3, dut.fmc_qsfp_1_rx_rst_3) - cocotb.start_soon(Clock(dut.fmc_qsfp_1_tx_clk_3, 2.56, units="ns").start()) - self.fmc_qsfp_1_3_sink = XgmiiSink(dut.fmc_qsfp_1_txd_3, dut.fmc_qsfp_1_txc_3, dut.fmc_qsfp_1_tx_clk_3, dut.fmc_qsfp_1_tx_rst_3) - - cocotb.start_soon(Clock(dut.fmc_qsfp_1_rx_clk_4, 2.56, units="ns").start()) - self.fmc_qsfp_1_4_source = XgmiiSource(dut.fmc_qsfp_1_rxd_4, dut.fmc_qsfp_1_rxc_4, dut.fmc_qsfp_1_rx_clk_4, dut.fmc_qsfp_1_rx_rst_4) - cocotb.start_soon(Clock(dut.fmc_qsfp_1_tx_clk_4, 2.56, units="ns").start()) - self.fmc_qsfp_1_4_sink = XgmiiSink(dut.fmc_qsfp_1_txd_4, dut.fmc_qsfp_1_txc_4, dut.fmc_qsfp_1_tx_clk_4, dut.fmc_qsfp_1_tx_rst_4) - - cocotb.start_soon(Clock(dut.fmc_qsfp_2_rx_clk_1, 2.56, units="ns").start()) - self.fmc_qsfp_2_1_source = XgmiiSource(dut.fmc_qsfp_2_rxd_1, dut.fmc_qsfp_2_rxc_1, dut.fmc_qsfp_2_rx_clk_1, dut.fmc_qsfp_2_rx_rst_1) - cocotb.start_soon(Clock(dut.fmc_qsfp_2_tx_clk_1, 2.56, units="ns").start()) - self.fmc_qsfp_2_1_sink = XgmiiSink(dut.fmc_qsfp_2_txd_1, dut.fmc_qsfp_2_txc_1, dut.fmc_qsfp_2_tx_clk_1, dut.fmc_qsfp_2_tx_rst_1) - - cocotb.start_soon(Clock(dut.fmc_qsfp_2_rx_clk_2, 2.56, units="ns").start()) - self.fmc_qsfp_2_2_source = XgmiiSource(dut.fmc_qsfp_2_rxd_2, dut.fmc_qsfp_2_rxc_2, dut.fmc_qsfp_2_rx_clk_2, dut.fmc_qsfp_2_rx_rst_2) - cocotb.start_soon(Clock(dut.fmc_qsfp_2_tx_clk_2, 2.56, units="ns").start()) - self.fmc_qsfp_2_2_sink = XgmiiSink(dut.fmc_qsfp_2_txd_2, dut.fmc_qsfp_2_txc_2, dut.fmc_qsfp_2_tx_clk_2, dut.fmc_qsfp_2_tx_rst_2) - - cocotb.start_soon(Clock(dut.fmc_qsfp_2_rx_clk_3, 2.56, units="ns").start()) - self.fmc_qsfp_2_3_source = XgmiiSource(dut.fmc_qsfp_2_rxd_3, dut.fmc_qsfp_2_rxc_3, dut.fmc_qsfp_2_rx_clk_3, dut.fmc_qsfp_2_rx_rst_3) - cocotb.start_soon(Clock(dut.fmc_qsfp_2_tx_clk_3, 2.56, units="ns").start()) - self.fmc_qsfp_2_3_sink = XgmiiSink(dut.fmc_qsfp_2_txd_3, dut.fmc_qsfp_2_txc_3, dut.fmc_qsfp_2_tx_clk_3, dut.fmc_qsfp_2_tx_rst_3) - - cocotb.start_soon(Clock(dut.fmc_qsfp_2_rx_clk_4, 2.56, units="ns").start()) - self.fmc_qsfp_2_4_source = XgmiiSource(dut.fmc_qsfp_2_rxd_4, dut.fmc_qsfp_2_rxc_4, dut.fmc_qsfp_2_rx_clk_4, dut.fmc_qsfp_2_rx_rst_4) - cocotb.start_soon(Clock(dut.fmc_qsfp_2_tx_clk_4, 2.56, units="ns").start()) - self.fmc_qsfp_2_4_sink = XgmiiSink(dut.fmc_qsfp_2_txd_4, dut.fmc_qsfp_2_txc_4, dut.fmc_qsfp_2_tx_clk_4, dut.fmc_qsfp_2_tx_rst_4) - - cocotb.start_soon(Clock(dut.fmc_qsfp_3_rx_clk_1, 2.56, units="ns").start()) - self.fmc_qsfp_3_1_source = XgmiiSource(dut.fmc_qsfp_3_rxd_1, dut.fmc_qsfp_3_rxc_1, dut.fmc_qsfp_3_rx_clk_1, dut.fmc_qsfp_3_rx_rst_1) - cocotb.start_soon(Clock(dut.fmc_qsfp_3_tx_clk_1, 2.56, units="ns").start()) - self.fmc_qsfp_3_1_sink = XgmiiSink(dut.fmc_qsfp_3_txd_1, dut.fmc_qsfp_3_txc_1, dut.fmc_qsfp_3_tx_clk_1, dut.fmc_qsfp_3_tx_rst_1) - - cocotb.start_soon(Clock(dut.fmc_qsfp_3_rx_clk_2, 2.56, units="ns").start()) - self.fmc_qsfp_3_2_source = XgmiiSource(dut.fmc_qsfp_3_rxd_2, dut.fmc_qsfp_3_rxc_2, dut.fmc_qsfp_3_rx_clk_2, dut.fmc_qsfp_3_rx_rst_2) - cocotb.start_soon(Clock(dut.fmc_qsfp_3_tx_clk_2, 2.56, units="ns").start()) - self.fmc_qsfp_3_2_sink = XgmiiSink(dut.fmc_qsfp_3_txd_2, dut.fmc_qsfp_3_txc_2, dut.fmc_qsfp_3_tx_clk_2, dut.fmc_qsfp_3_tx_rst_2) - - cocotb.start_soon(Clock(dut.fmc_qsfp_3_rx_clk_3, 2.56, units="ns").start()) - self.fmc_qsfp_3_3_source = XgmiiSource(dut.fmc_qsfp_3_rxd_3, dut.fmc_qsfp_3_rxc_3, dut.fmc_qsfp_3_rx_clk_3, dut.fmc_qsfp_3_rx_rst_3) - cocotb.start_soon(Clock(dut.fmc_qsfp_3_tx_clk_3, 2.56, units="ns").start()) - self.fmc_qsfp_3_3_sink = XgmiiSink(dut.fmc_qsfp_3_txd_3, dut.fmc_qsfp_3_txc_3, dut.fmc_qsfp_3_tx_clk_3, dut.fmc_qsfp_3_tx_rst_3) - - cocotb.start_soon(Clock(dut.fmc_qsfp_3_rx_clk_4, 2.56, units="ns").start()) - self.fmc_qsfp_3_4_source = XgmiiSource(dut.fmc_qsfp_3_rxd_4, dut.fmc_qsfp_3_rxc_4, dut.fmc_qsfp_3_rx_clk_4, dut.fmc_qsfp_3_rx_rst_4) - cocotb.start_soon(Clock(dut.fmc_qsfp_3_tx_clk_4, 2.56, units="ns").start()) - self.fmc_qsfp_3_4_sink = XgmiiSink(dut.fmc_qsfp_3_txd_4, dut.fmc_qsfp_3_txc_4, dut.fmc_qsfp_3_tx_clk_4, dut.fmc_qsfp_3_tx_rst_4) - - cocotb.start_soon(Clock(dut.fmc_qsfp_4_rx_clk_1, 2.56, units="ns").start()) - self.fmc_qsfp_4_1_source = XgmiiSource(dut.fmc_qsfp_4_rxd_1, dut.fmc_qsfp_4_rxc_1, dut.fmc_qsfp_4_rx_clk_1, dut.fmc_qsfp_4_rx_rst_1) - cocotb.start_soon(Clock(dut.fmc_qsfp_4_tx_clk_1, 2.56, units="ns").start()) - self.fmc_qsfp_4_1_sink = XgmiiSink(dut.fmc_qsfp_4_txd_1, dut.fmc_qsfp_4_txc_1, dut.fmc_qsfp_4_tx_clk_1, dut.fmc_qsfp_4_tx_rst_1) - - cocotb.start_soon(Clock(dut.fmc_qsfp_4_rx_clk_2, 2.56, units="ns").start()) - self.fmc_qsfp_4_2_source = XgmiiSource(dut.fmc_qsfp_4_rxd_2, dut.fmc_qsfp_4_rxc_2, dut.fmc_qsfp_4_rx_clk_2, dut.fmc_qsfp_4_rx_rst_2) - cocotb.start_soon(Clock(dut.fmc_qsfp_4_tx_clk_2, 2.56, units="ns").start()) - self.fmc_qsfp_4_2_sink = XgmiiSink(dut.fmc_qsfp_4_txd_2, dut.fmc_qsfp_4_txc_2, dut.fmc_qsfp_4_tx_clk_2, dut.fmc_qsfp_4_tx_rst_2) - - cocotb.start_soon(Clock(dut.fmc_qsfp_4_rx_clk_3, 2.56, units="ns").start()) - self.fmc_qsfp_4_3_source = XgmiiSource(dut.fmc_qsfp_4_rxd_3, dut.fmc_qsfp_4_rxc_3, dut.fmc_qsfp_4_rx_clk_3, dut.fmc_qsfp_4_rx_rst_3) - cocotb.start_soon(Clock(dut.fmc_qsfp_4_tx_clk_3, 2.56, units="ns").start()) - self.fmc_qsfp_4_3_sink = XgmiiSink(dut.fmc_qsfp_4_txd_3, dut.fmc_qsfp_4_txc_3, dut.fmc_qsfp_4_tx_clk_3, dut.fmc_qsfp_4_tx_rst_3) - - cocotb.start_soon(Clock(dut.fmc_qsfp_4_rx_clk_4, 2.56, units="ns").start()) - self.fmc_qsfp_4_4_source = XgmiiSource(dut.fmc_qsfp_4_rxd_4, dut.fmc_qsfp_4_rxc_4, dut.fmc_qsfp_4_rx_clk_4, dut.fmc_qsfp_4_rx_rst_4) - cocotb.start_soon(Clock(dut.fmc_qsfp_4_tx_clk_4, 2.56, units="ns").start()) - self.fmc_qsfp_4_4_sink = XgmiiSink(dut.fmc_qsfp_4_txd_4, dut.fmc_qsfp_4_txc_4, dut.fmc_qsfp_4_tx_clk_4, dut.fmc_qsfp_4_tx_rst_4) - - cocotb.start_soon(Clock(dut.fmc_qsfp_5_rx_clk_1, 2.56, units="ns").start()) - self.fmc_qsfp_5_1_source = XgmiiSource(dut.fmc_qsfp_5_rxd_1, dut.fmc_qsfp_5_rxc_1, dut.fmc_qsfp_5_rx_clk_1, dut.fmc_qsfp_5_rx_rst_1) - cocotb.start_soon(Clock(dut.fmc_qsfp_5_tx_clk_1, 2.56, units="ns").start()) - self.fmc_qsfp_5_1_sink = XgmiiSink(dut.fmc_qsfp_5_txd_1, dut.fmc_qsfp_5_txc_1, dut.fmc_qsfp_5_tx_clk_1, dut.fmc_qsfp_5_tx_rst_1) - - cocotb.start_soon(Clock(dut.fmc_qsfp_5_rx_clk_2, 2.56, units="ns").start()) - self.fmc_qsfp_5_2_source = XgmiiSource(dut.fmc_qsfp_5_rxd_2, dut.fmc_qsfp_5_rxc_2, dut.fmc_qsfp_5_rx_clk_2, dut.fmc_qsfp_5_rx_rst_2) - cocotb.start_soon(Clock(dut.fmc_qsfp_5_tx_clk_2, 2.56, units="ns").start()) - self.fmc_qsfp_5_2_sink = XgmiiSink(dut.fmc_qsfp_5_txd_2, dut.fmc_qsfp_5_txc_2, dut.fmc_qsfp_5_tx_clk_2, dut.fmc_qsfp_5_tx_rst_2) - - cocotb.start_soon(Clock(dut.fmc_qsfp_5_rx_clk_3, 2.56, units="ns").start()) - self.fmc_qsfp_5_3_source = XgmiiSource(dut.fmc_qsfp_5_rxd_3, dut.fmc_qsfp_5_rxc_3, dut.fmc_qsfp_5_rx_clk_3, dut.fmc_qsfp_5_rx_rst_3) - cocotb.start_soon(Clock(dut.fmc_qsfp_5_tx_clk_3, 2.56, units="ns").start()) - self.fmc_qsfp_5_3_sink = XgmiiSink(dut.fmc_qsfp_5_txd_3, dut.fmc_qsfp_5_txc_3, dut.fmc_qsfp_5_tx_clk_3, dut.fmc_qsfp_5_tx_rst_3) - - cocotb.start_soon(Clock(dut.fmc_qsfp_5_rx_clk_4, 2.56, units="ns").start()) - self.fmc_qsfp_5_4_source = XgmiiSource(dut.fmc_qsfp_5_rxd_4, dut.fmc_qsfp_5_rxc_4, dut.fmc_qsfp_5_rx_clk_4, dut.fmc_qsfp_5_rx_rst_4) - cocotb.start_soon(Clock(dut.fmc_qsfp_5_tx_clk_4, 2.56, units="ns").start()) - self.fmc_qsfp_5_4_sink = XgmiiSink(dut.fmc_qsfp_5_txd_4, dut.fmc_qsfp_5_txc_4, dut.fmc_qsfp_5_tx_clk_4, dut.fmc_qsfp_5_tx_rst_4) - - cocotb.start_soon(Clock(dut.fmc_qsfp_6_rx_clk_1, 2.56, units="ns").start()) - self.fmc_qsfp_6_1_source = XgmiiSource(dut.fmc_qsfp_6_rxd_1, dut.fmc_qsfp_6_rxc_1, dut.fmc_qsfp_6_rx_clk_1, dut.fmc_qsfp_6_rx_rst_1) - cocotb.start_soon(Clock(dut.fmc_qsfp_6_tx_clk_1, 2.56, units="ns").start()) - self.fmc_qsfp_6_1_sink = XgmiiSink(dut.fmc_qsfp_6_txd_1, dut.fmc_qsfp_6_txc_1, dut.fmc_qsfp_6_tx_clk_1, dut.fmc_qsfp_6_tx_rst_1) - - cocotb.start_soon(Clock(dut.fmc_qsfp_6_rx_clk_2, 2.56, units="ns").start()) - self.fmc_qsfp_6_2_source = XgmiiSource(dut.fmc_qsfp_6_rxd_2, dut.fmc_qsfp_6_rxc_2, dut.fmc_qsfp_6_rx_clk_2, dut.fmc_qsfp_6_rx_rst_2) - cocotb.start_soon(Clock(dut.fmc_qsfp_6_tx_clk_2, 2.56, units="ns").start()) - self.fmc_qsfp_6_2_sink = XgmiiSink(dut.fmc_qsfp_6_txd_2, dut.fmc_qsfp_6_txc_2, dut.fmc_qsfp_6_tx_clk_2, dut.fmc_qsfp_6_tx_rst_2) - - cocotb.start_soon(Clock(dut.fmc_qsfp_6_rx_clk_3, 2.56, units="ns").start()) - self.fmc_qsfp_6_3_source = XgmiiSource(dut.fmc_qsfp_6_rxd_3, dut.fmc_qsfp_6_rxc_3, dut.fmc_qsfp_6_rx_clk_3, dut.fmc_qsfp_6_rx_rst_3) - cocotb.start_soon(Clock(dut.fmc_qsfp_6_tx_clk_3, 2.56, units="ns").start()) - self.fmc_qsfp_6_3_sink = XgmiiSink(dut.fmc_qsfp_6_txd_3, dut.fmc_qsfp_6_txc_3, dut.fmc_qsfp_6_tx_clk_3, dut.fmc_qsfp_6_tx_rst_3) - - cocotb.start_soon(Clock(dut.fmc_qsfp_6_rx_clk_4, 2.56, units="ns").start()) - self.fmc_qsfp_6_4_source = XgmiiSource(dut.fmc_qsfp_6_rxd_4, dut.fmc_qsfp_6_rxc_4, dut.fmc_qsfp_6_rx_clk_4, dut.fmc_qsfp_6_rx_rst_4) - cocotb.start_soon(Clock(dut.fmc_qsfp_6_tx_clk_4, 2.56, units="ns").start()) - self.fmc_qsfp_6_4_sink = XgmiiSink(dut.fmc_qsfp_6_txd_4, dut.fmc_qsfp_6_txc_4, dut.fmc_qsfp_6_tx_clk_4, dut.fmc_qsfp_6_tx_rst_4) + for x in range(1, 7): + sources = [] + sinks = [] + for y in range(1, 5): + cocotb.start_soon(Clock(getattr(dut, f"fmc_qsfp_{x}_rx_clk_{y}"), 2.56, units="ns").start()) + source = XgmiiSource(getattr(dut, f"fmc_qsfp_{x}_rxd_{y}"), getattr(dut, f"fmc_qsfp_{x}_rxc_{y}"), getattr(dut, f"fmc_qsfp_{x}_rx_clk_{y}"), getattr(dut, f"fmc_qsfp_{x}_rx_rst_{y}")) + sources.append(source) + cocotb.start_soon(Clock(getattr(dut, f"fmc_qsfp_{x}_tx_clk_{y}"), 2.56, units="ns").start()) + sink = XgmiiSink(getattr(dut, f"fmc_qsfp_{x}_txd_{y}"), getattr(dut, f"fmc_qsfp_{x}_txc_{y}"), getattr(dut, f"fmc_qsfp_{x}_tx_clk_{y}"), getattr(dut, f"fmc_qsfp_{x}_tx_rst_{y}")) + sinks.append(sink) + self.qsfp_source.append(sources) + self.qsfp_sink.append(sinks) async def init(self): self.dut.rst.setimmediatevalue(0) - self.dut.qsfp_1_rx_rst_1.setimmediatevalue(0) - self.dut.qsfp_1_tx_rst_1.setimmediatevalue(0) - self.dut.qsfp_1_rx_rst_2.setimmediatevalue(0) - self.dut.qsfp_1_tx_rst_2.setimmediatevalue(0) - self.dut.qsfp_1_rx_rst_3.setimmediatevalue(0) - self.dut.qsfp_1_tx_rst_3.setimmediatevalue(0) - self.dut.qsfp_1_rx_rst_4.setimmediatevalue(0) - self.dut.qsfp_1_tx_rst_4.setimmediatevalue(0) - self.dut.qsfp_2_rx_rst_1.setimmediatevalue(0) - self.dut.qsfp_2_tx_rst_1.setimmediatevalue(0) - self.dut.qsfp_2_rx_rst_2.setimmediatevalue(0) - self.dut.qsfp_2_tx_rst_2.setimmediatevalue(0) - self.dut.qsfp_2_rx_rst_3.setimmediatevalue(0) - self.dut.qsfp_2_tx_rst_3.setimmediatevalue(0) - self.dut.qsfp_2_rx_rst_4.setimmediatevalue(0) - self.dut.qsfp_2_tx_rst_4.setimmediatevalue(0) - self.dut.qsfp_3_rx_rst_1.setimmediatevalue(0) - self.dut.qsfp_3_tx_rst_1.setimmediatevalue(0) - self.dut.qsfp_3_rx_rst_2.setimmediatevalue(0) - self.dut.qsfp_3_tx_rst_2.setimmediatevalue(0) - self.dut.qsfp_3_rx_rst_3.setimmediatevalue(0) - self.dut.qsfp_3_tx_rst_3.setimmediatevalue(0) - self.dut.qsfp_3_rx_rst_4.setimmediatevalue(0) - self.dut.qsfp_3_tx_rst_4.setimmediatevalue(0) - self.dut.qsfp_4_rx_rst_1.setimmediatevalue(0) - self.dut.qsfp_4_tx_rst_1.setimmediatevalue(0) - self.dut.qsfp_4_rx_rst_2.setimmediatevalue(0) - self.dut.qsfp_4_tx_rst_2.setimmediatevalue(0) - self.dut.qsfp_4_rx_rst_3.setimmediatevalue(0) - self.dut.qsfp_4_tx_rst_3.setimmediatevalue(0) - self.dut.qsfp_4_rx_rst_4.setimmediatevalue(0) - self.dut.qsfp_4_tx_rst_4.setimmediatevalue(0) - self.dut.qsfp_5_rx_rst_1.setimmediatevalue(0) - self.dut.qsfp_5_tx_rst_1.setimmediatevalue(0) - self.dut.qsfp_5_rx_rst_2.setimmediatevalue(0) - self.dut.qsfp_5_tx_rst_2.setimmediatevalue(0) - self.dut.qsfp_5_rx_rst_3.setimmediatevalue(0) - self.dut.qsfp_5_tx_rst_3.setimmediatevalue(0) - self.dut.qsfp_5_rx_rst_4.setimmediatevalue(0) - self.dut.qsfp_5_tx_rst_4.setimmediatevalue(0) - self.dut.qsfp_6_rx_rst_1.setimmediatevalue(0) - self.dut.qsfp_6_tx_rst_1.setimmediatevalue(0) - self.dut.qsfp_6_rx_rst_2.setimmediatevalue(0) - self.dut.qsfp_6_tx_rst_2.setimmediatevalue(0) - self.dut.qsfp_6_rx_rst_3.setimmediatevalue(0) - self.dut.qsfp_6_tx_rst_3.setimmediatevalue(0) - self.dut.qsfp_6_rx_rst_4.setimmediatevalue(0) - self.dut.qsfp_6_tx_rst_4.setimmediatevalue(0) - self.dut.qsfp_7_rx_rst_1.setimmediatevalue(0) - self.dut.qsfp_7_tx_rst_1.setimmediatevalue(0) - self.dut.qsfp_7_rx_rst_2.setimmediatevalue(0) - self.dut.qsfp_7_tx_rst_2.setimmediatevalue(0) - self.dut.qsfp_7_rx_rst_3.setimmediatevalue(0) - self.dut.qsfp_7_tx_rst_3.setimmediatevalue(0) - self.dut.qsfp_7_rx_rst_4.setimmediatevalue(0) - self.dut.qsfp_7_tx_rst_4.setimmediatevalue(0) - self.dut.qsfp_8_rx_rst_1.setimmediatevalue(0) - self.dut.qsfp_8_tx_rst_1.setimmediatevalue(0) - self.dut.qsfp_8_rx_rst_2.setimmediatevalue(0) - self.dut.qsfp_8_tx_rst_2.setimmediatevalue(0) - self.dut.qsfp_8_rx_rst_3.setimmediatevalue(0) - self.dut.qsfp_8_tx_rst_3.setimmediatevalue(0) - self.dut.qsfp_8_rx_rst_4.setimmediatevalue(0) - self.dut.qsfp_8_tx_rst_4.setimmediatevalue(0) - self.dut.qsfp_9_rx_rst_1.setimmediatevalue(0) - self.dut.qsfp_9_tx_rst_1.setimmediatevalue(0) - self.dut.qsfp_9_rx_rst_2.setimmediatevalue(0) - self.dut.qsfp_9_tx_rst_2.setimmediatevalue(0) - self.dut.qsfp_9_rx_rst_3.setimmediatevalue(0) - self.dut.qsfp_9_tx_rst_3.setimmediatevalue(0) - self.dut.qsfp_9_rx_rst_4.setimmediatevalue(0) - self.dut.qsfp_9_tx_rst_4.setimmediatevalue(0) - self.dut.fmc_qsfp_1_rx_rst_1.setimmediatevalue(0) - self.dut.fmc_qsfp_1_tx_rst_1.setimmediatevalue(0) - self.dut.fmc_qsfp_1_rx_rst_2.setimmediatevalue(0) - self.dut.fmc_qsfp_1_tx_rst_2.setimmediatevalue(0) - self.dut.fmc_qsfp_1_rx_rst_3.setimmediatevalue(0) - self.dut.fmc_qsfp_1_tx_rst_3.setimmediatevalue(0) - self.dut.fmc_qsfp_1_rx_rst_4.setimmediatevalue(0) - self.dut.fmc_qsfp_1_tx_rst_4.setimmediatevalue(0) - self.dut.fmc_qsfp_2_rx_rst_1.setimmediatevalue(0) - self.dut.fmc_qsfp_2_tx_rst_1.setimmediatevalue(0) - self.dut.fmc_qsfp_2_rx_rst_2.setimmediatevalue(0) - self.dut.fmc_qsfp_2_tx_rst_2.setimmediatevalue(0) - self.dut.fmc_qsfp_2_rx_rst_3.setimmediatevalue(0) - self.dut.fmc_qsfp_2_tx_rst_3.setimmediatevalue(0) - self.dut.fmc_qsfp_2_rx_rst_4.setimmediatevalue(0) - self.dut.fmc_qsfp_2_tx_rst_4.setimmediatevalue(0) - self.dut.fmc_qsfp_3_rx_rst_1.setimmediatevalue(0) - self.dut.fmc_qsfp_3_tx_rst_1.setimmediatevalue(0) - self.dut.fmc_qsfp_3_rx_rst_2.setimmediatevalue(0) - self.dut.fmc_qsfp_3_tx_rst_2.setimmediatevalue(0) - self.dut.fmc_qsfp_3_rx_rst_3.setimmediatevalue(0) - self.dut.fmc_qsfp_3_tx_rst_3.setimmediatevalue(0) - self.dut.fmc_qsfp_3_rx_rst_4.setimmediatevalue(0) - self.dut.fmc_qsfp_3_tx_rst_4.setimmediatevalue(0) - self.dut.fmc_qsfp_4_rx_rst_1.setimmediatevalue(0) - self.dut.fmc_qsfp_4_tx_rst_1.setimmediatevalue(0) - self.dut.fmc_qsfp_4_rx_rst_2.setimmediatevalue(0) - self.dut.fmc_qsfp_4_tx_rst_2.setimmediatevalue(0) - self.dut.fmc_qsfp_4_rx_rst_3.setimmediatevalue(0) - self.dut.fmc_qsfp_4_tx_rst_3.setimmediatevalue(0) - self.dut.fmc_qsfp_4_rx_rst_4.setimmediatevalue(0) - self.dut.fmc_qsfp_4_tx_rst_4.setimmediatevalue(0) - self.dut.fmc_qsfp_5_rx_rst_1.setimmediatevalue(0) - self.dut.fmc_qsfp_5_tx_rst_1.setimmediatevalue(0) - self.dut.fmc_qsfp_5_rx_rst_2.setimmediatevalue(0) - self.dut.fmc_qsfp_5_tx_rst_2.setimmediatevalue(0) - self.dut.fmc_qsfp_5_rx_rst_3.setimmediatevalue(0) - self.dut.fmc_qsfp_5_tx_rst_3.setimmediatevalue(0) - self.dut.fmc_qsfp_5_rx_rst_4.setimmediatevalue(0) - self.dut.fmc_qsfp_5_tx_rst_4.setimmediatevalue(0) - self.dut.fmc_qsfp_6_rx_rst_1.setimmediatevalue(0) - self.dut.fmc_qsfp_6_tx_rst_1.setimmediatevalue(0) - self.dut.fmc_qsfp_6_rx_rst_2.setimmediatevalue(0) - self.dut.fmc_qsfp_6_tx_rst_2.setimmediatevalue(0) - self.dut.fmc_qsfp_6_rx_rst_3.setimmediatevalue(0) - self.dut.fmc_qsfp_6_tx_rst_3.setimmediatevalue(0) - self.dut.fmc_qsfp_6_rx_rst_4.setimmediatevalue(0) - self.dut.fmc_qsfp_6_tx_rst_4.setimmediatevalue(0) + for x in range(1, 10): + for y in range(1, 5): + getattr(self.dut, f"qsfp_{x}_rx_rst_{y}").setimmediatevalue(0) + getattr(self.dut, f"qsfp_{x}_tx_rst_{y}").setimmediatevalue(0) + for x in range(1, 7): + for y in range(1, 5): + getattr(self.dut, f"fmc_qsfp_{x}_rx_rst_{y}").setimmediatevalue(0) + getattr(self.dut, f"fmc_qsfp_{x}_tx_rst_{y}").setimmediatevalue(0) for k in range(10): await RisingEdge(self.dut.clk) self.dut.rst.value = 1 - self.dut.qsfp_1_rx_rst_1.value = 1 - self.dut.qsfp_1_tx_rst_1.value = 1 - self.dut.qsfp_1_rx_rst_2.value = 1 - self.dut.qsfp_1_tx_rst_2.value = 1 - self.dut.qsfp_1_rx_rst_3.value = 1 - self.dut.qsfp_1_tx_rst_3.value = 1 - self.dut.qsfp_1_rx_rst_4.value = 1 - self.dut.qsfp_1_tx_rst_4.value = 1 - self.dut.qsfp_2_rx_rst_1.value = 1 - self.dut.qsfp_2_tx_rst_1.value = 1 - self.dut.qsfp_2_rx_rst_2.value = 1 - self.dut.qsfp_2_tx_rst_2.value = 1 - self.dut.qsfp_2_rx_rst_3.value = 1 - self.dut.qsfp_2_tx_rst_3.value = 1 - self.dut.qsfp_2_rx_rst_4.value = 1 - self.dut.qsfp_2_tx_rst_4.value = 1 - self.dut.qsfp_3_rx_rst_1.value = 1 - self.dut.qsfp_3_tx_rst_1.value = 1 - self.dut.qsfp_3_rx_rst_2.value = 1 - self.dut.qsfp_3_tx_rst_2.value = 1 - self.dut.qsfp_3_rx_rst_3.value = 1 - self.dut.qsfp_3_tx_rst_3.value = 1 - self.dut.qsfp_3_rx_rst_4.value = 1 - self.dut.qsfp_3_tx_rst_4.value = 1 - self.dut.qsfp_4_rx_rst_1.value = 1 - self.dut.qsfp_4_tx_rst_1.value = 1 - self.dut.qsfp_4_rx_rst_2.value = 1 - self.dut.qsfp_4_tx_rst_2.value = 1 - self.dut.qsfp_4_rx_rst_3.value = 1 - self.dut.qsfp_4_tx_rst_3.value = 1 - self.dut.qsfp_4_rx_rst_4.value = 1 - self.dut.qsfp_4_tx_rst_4.value = 1 - self.dut.qsfp_5_rx_rst_1.value = 1 - self.dut.qsfp_5_tx_rst_1.value = 1 - self.dut.qsfp_5_rx_rst_2.value = 1 - self.dut.qsfp_5_tx_rst_2.value = 1 - self.dut.qsfp_5_rx_rst_3.value = 1 - self.dut.qsfp_5_tx_rst_3.value = 1 - self.dut.qsfp_5_rx_rst_4.value = 1 - self.dut.qsfp_5_tx_rst_4.value = 1 - self.dut.qsfp_6_rx_rst_1.value = 1 - self.dut.qsfp_6_tx_rst_1.value = 1 - self.dut.qsfp_6_rx_rst_2.value = 1 - self.dut.qsfp_6_tx_rst_2.value = 1 - self.dut.qsfp_6_rx_rst_3.value = 1 - self.dut.qsfp_6_tx_rst_3.value = 1 - self.dut.qsfp_6_rx_rst_4.value = 1 - self.dut.qsfp_6_tx_rst_4.value = 1 - self.dut.qsfp_7_rx_rst_1.value = 1 - self.dut.qsfp_7_tx_rst_1.value = 1 - self.dut.qsfp_7_rx_rst_2.value = 1 - self.dut.qsfp_7_tx_rst_2.value = 1 - self.dut.qsfp_7_rx_rst_3.value = 1 - self.dut.qsfp_7_tx_rst_3.value = 1 - self.dut.qsfp_7_rx_rst_4.value = 1 - self.dut.qsfp_7_tx_rst_4.value = 1 - self.dut.qsfp_8_rx_rst_1.value = 1 - self.dut.qsfp_8_tx_rst_1.value = 1 - self.dut.qsfp_8_rx_rst_2.value = 1 - self.dut.qsfp_8_tx_rst_2.value = 1 - self.dut.qsfp_8_rx_rst_3.value = 1 - self.dut.qsfp_8_tx_rst_3.value = 1 - self.dut.qsfp_8_rx_rst_4.value = 1 - self.dut.qsfp_8_tx_rst_4.value = 1 - self.dut.qsfp_9_rx_rst_1.value = 1 - self.dut.qsfp_9_tx_rst_1.value = 1 - self.dut.qsfp_9_rx_rst_2.value = 1 - self.dut.qsfp_9_tx_rst_2.value = 1 - self.dut.qsfp_9_rx_rst_3.value = 1 - self.dut.qsfp_9_tx_rst_3.value = 1 - self.dut.qsfp_9_rx_rst_4.value = 1 - self.dut.qsfp_9_tx_rst_4.value = 1 - self.dut.fmc_qsfp_1_rx_rst_1.value = 1 - self.dut.fmc_qsfp_1_tx_rst_1.value = 1 - self.dut.fmc_qsfp_1_rx_rst_2.value = 1 - self.dut.fmc_qsfp_1_tx_rst_2.value = 1 - self.dut.fmc_qsfp_1_rx_rst_3.value = 1 - self.dut.fmc_qsfp_1_tx_rst_3.value = 1 - self.dut.fmc_qsfp_1_rx_rst_4.value = 1 - self.dut.fmc_qsfp_1_tx_rst_4.value = 1 - self.dut.fmc_qsfp_2_rx_rst_1.value = 1 - self.dut.fmc_qsfp_2_tx_rst_1.value = 1 - self.dut.fmc_qsfp_2_rx_rst_2.value = 1 - self.dut.fmc_qsfp_2_tx_rst_2.value = 1 - self.dut.fmc_qsfp_2_rx_rst_3.value = 1 - self.dut.fmc_qsfp_2_tx_rst_3.value = 1 - self.dut.fmc_qsfp_2_rx_rst_4.value = 1 - self.dut.fmc_qsfp_2_tx_rst_4.value = 1 - self.dut.fmc_qsfp_3_rx_rst_1.value = 1 - self.dut.fmc_qsfp_3_tx_rst_1.value = 1 - self.dut.fmc_qsfp_3_rx_rst_2.value = 1 - self.dut.fmc_qsfp_3_tx_rst_2.value = 1 - self.dut.fmc_qsfp_3_rx_rst_3.value = 1 - self.dut.fmc_qsfp_3_tx_rst_3.value = 1 - self.dut.fmc_qsfp_3_rx_rst_4.value = 1 - self.dut.fmc_qsfp_3_tx_rst_4.value = 1 - self.dut.fmc_qsfp_4_rx_rst_1.value = 1 - self.dut.fmc_qsfp_4_tx_rst_1.value = 1 - self.dut.fmc_qsfp_4_rx_rst_2.value = 1 - self.dut.fmc_qsfp_4_tx_rst_2.value = 1 - self.dut.fmc_qsfp_4_rx_rst_3.value = 1 - self.dut.fmc_qsfp_4_tx_rst_3.value = 1 - self.dut.fmc_qsfp_4_rx_rst_4.value = 1 - self.dut.fmc_qsfp_4_tx_rst_4.value = 1 - self.dut.fmc_qsfp_5_rx_rst_1.value = 1 - self.dut.fmc_qsfp_5_tx_rst_1.value = 1 - self.dut.fmc_qsfp_5_rx_rst_2.value = 1 - self.dut.fmc_qsfp_5_tx_rst_2.value = 1 - self.dut.fmc_qsfp_5_rx_rst_3.value = 1 - self.dut.fmc_qsfp_5_tx_rst_3.value = 1 - self.dut.fmc_qsfp_5_rx_rst_4.value = 1 - self.dut.fmc_qsfp_5_tx_rst_4.value = 1 - self.dut.fmc_qsfp_6_rx_rst_1.value = 1 - self.dut.fmc_qsfp_6_tx_rst_1.value = 1 - self.dut.fmc_qsfp_6_rx_rst_2.value = 1 - self.dut.fmc_qsfp_6_tx_rst_2.value = 1 - self.dut.fmc_qsfp_6_rx_rst_3.value = 1 - self.dut.fmc_qsfp_6_tx_rst_3.value = 1 - self.dut.fmc_qsfp_6_rx_rst_4.value = 1 - self.dut.fmc_qsfp_6_tx_rst_4.value = 1 + for x in range(1, 10): + for y in range(1, 5): + getattr(self.dut, f"qsfp_{x}_rx_rst_{y}").value = 1 + getattr(self.dut, f"qsfp_{x}_tx_rst_{y}").value = 1 + for x in range(1, 7): + for y in range(1, 5): + getattr(self.dut, f"fmc_qsfp_{x}_rx_rst_{y}").value = 1 + getattr(self.dut, f"fmc_qsfp_{x}_tx_rst_{y}").value = 1 for k in range(10): await RisingEdge(self.dut.clk) self.dut.rst.value = 0 - self.dut.qsfp_1_rx_rst_1.value = 0 - self.dut.qsfp_1_tx_rst_1.value = 0 - self.dut.qsfp_1_rx_rst_2.value = 0 - self.dut.qsfp_1_tx_rst_2.value = 0 - self.dut.qsfp_1_rx_rst_3.value = 0 - self.dut.qsfp_1_tx_rst_3.value = 0 - self.dut.qsfp_1_rx_rst_4.value = 0 - self.dut.qsfp_1_tx_rst_4.value = 0 - self.dut.qsfp_2_rx_rst_1.value = 0 - self.dut.qsfp_2_tx_rst_1.value = 0 - self.dut.qsfp_2_rx_rst_2.value = 0 - self.dut.qsfp_2_tx_rst_2.value = 0 - self.dut.qsfp_2_rx_rst_3.value = 0 - self.dut.qsfp_2_tx_rst_3.value = 0 - self.dut.qsfp_2_rx_rst_4.value = 0 - self.dut.qsfp_2_tx_rst_4.value = 0 - self.dut.qsfp_3_rx_rst_1.value = 0 - self.dut.qsfp_3_tx_rst_1.value = 0 - self.dut.qsfp_3_rx_rst_2.value = 0 - self.dut.qsfp_3_tx_rst_2.value = 0 - self.dut.qsfp_3_rx_rst_3.value = 0 - self.dut.qsfp_3_tx_rst_3.value = 0 - self.dut.qsfp_3_rx_rst_4.value = 0 - self.dut.qsfp_3_tx_rst_4.value = 0 - self.dut.qsfp_4_rx_rst_1.value = 0 - self.dut.qsfp_4_tx_rst_1.value = 0 - self.dut.qsfp_4_rx_rst_2.value = 0 - self.dut.qsfp_4_tx_rst_2.value = 0 - self.dut.qsfp_4_rx_rst_3.value = 0 - self.dut.qsfp_4_tx_rst_3.value = 0 - self.dut.qsfp_4_rx_rst_4.value = 0 - self.dut.qsfp_4_tx_rst_4.value = 0 - self.dut.qsfp_5_rx_rst_1.value = 0 - self.dut.qsfp_5_tx_rst_1.value = 0 - self.dut.qsfp_5_rx_rst_2.value = 0 - self.dut.qsfp_5_tx_rst_2.value = 0 - self.dut.qsfp_5_rx_rst_3.value = 0 - self.dut.qsfp_5_tx_rst_3.value = 0 - self.dut.qsfp_5_rx_rst_4.value = 0 - self.dut.qsfp_5_tx_rst_4.value = 0 - self.dut.qsfp_6_rx_rst_1.value = 0 - self.dut.qsfp_6_tx_rst_1.value = 0 - self.dut.qsfp_6_rx_rst_2.value = 0 - self.dut.qsfp_6_tx_rst_2.value = 0 - self.dut.qsfp_6_rx_rst_3.value = 0 - self.dut.qsfp_6_tx_rst_3.value = 0 - self.dut.qsfp_6_rx_rst_4.value = 0 - self.dut.qsfp_6_tx_rst_4.value = 0 - self.dut.qsfp_7_rx_rst_1.value = 0 - self.dut.qsfp_7_tx_rst_1.value = 0 - self.dut.qsfp_7_rx_rst_2.value = 0 - self.dut.qsfp_7_tx_rst_2.value = 0 - self.dut.qsfp_7_rx_rst_3.value = 0 - self.dut.qsfp_7_tx_rst_3.value = 0 - self.dut.qsfp_7_rx_rst_4.value = 0 - self.dut.qsfp_7_tx_rst_4.value = 0 - self.dut.qsfp_8_rx_rst_1.value = 0 - self.dut.qsfp_8_tx_rst_1.value = 0 - self.dut.qsfp_8_rx_rst_2.value = 0 - self.dut.qsfp_8_tx_rst_2.value = 0 - self.dut.qsfp_8_rx_rst_3.value = 0 - self.dut.qsfp_8_tx_rst_3.value = 0 - self.dut.qsfp_8_rx_rst_4.value = 0 - self.dut.qsfp_8_tx_rst_4.value = 0 - self.dut.qsfp_9_rx_rst_1.value = 0 - self.dut.qsfp_9_tx_rst_1.value = 0 - self.dut.qsfp_9_rx_rst_2.value = 0 - self.dut.qsfp_9_tx_rst_2.value = 0 - self.dut.qsfp_9_rx_rst_3.value = 0 - self.dut.qsfp_9_tx_rst_3.value = 0 - self.dut.qsfp_9_rx_rst_4.value = 0 - self.dut.qsfp_9_tx_rst_4.value = 0 - self.dut.fmc_qsfp_1_rx_rst_1.value = 0 - self.dut.fmc_qsfp_1_tx_rst_1.value = 0 - self.dut.fmc_qsfp_1_rx_rst_2.value = 0 - self.dut.fmc_qsfp_1_tx_rst_2.value = 0 - self.dut.fmc_qsfp_1_rx_rst_3.value = 0 - self.dut.fmc_qsfp_1_tx_rst_3.value = 0 - self.dut.fmc_qsfp_1_rx_rst_4.value = 0 - self.dut.fmc_qsfp_1_tx_rst_4.value = 0 - self.dut.fmc_qsfp_2_rx_rst_1.value = 0 - self.dut.fmc_qsfp_2_tx_rst_1.value = 0 - self.dut.fmc_qsfp_2_rx_rst_2.value = 0 - self.dut.fmc_qsfp_2_tx_rst_2.value = 0 - self.dut.fmc_qsfp_2_rx_rst_3.value = 0 - self.dut.fmc_qsfp_2_tx_rst_3.value = 0 - self.dut.fmc_qsfp_2_rx_rst_4.value = 0 - self.dut.fmc_qsfp_2_tx_rst_4.value = 0 - self.dut.fmc_qsfp_3_rx_rst_1.value = 0 - self.dut.fmc_qsfp_3_tx_rst_1.value = 0 - self.dut.fmc_qsfp_3_rx_rst_2.value = 0 - self.dut.fmc_qsfp_3_tx_rst_2.value = 0 - self.dut.fmc_qsfp_3_rx_rst_3.value = 0 - self.dut.fmc_qsfp_3_tx_rst_3.value = 0 - self.dut.fmc_qsfp_3_rx_rst_4.value = 0 - self.dut.fmc_qsfp_3_tx_rst_4.value = 0 - self.dut.fmc_qsfp_4_rx_rst_1.value = 0 - self.dut.fmc_qsfp_4_tx_rst_1.value = 0 - self.dut.fmc_qsfp_4_rx_rst_2.value = 0 - self.dut.fmc_qsfp_4_tx_rst_2.value = 0 - self.dut.fmc_qsfp_4_rx_rst_3.value = 0 - self.dut.fmc_qsfp_4_tx_rst_3.value = 0 - self.dut.fmc_qsfp_4_rx_rst_4.value = 0 - self.dut.fmc_qsfp_4_tx_rst_4.value = 0 - self.dut.fmc_qsfp_5_rx_rst_1.value = 0 - self.dut.fmc_qsfp_5_tx_rst_1.value = 0 - self.dut.fmc_qsfp_5_rx_rst_2.value = 0 - self.dut.fmc_qsfp_5_tx_rst_2.value = 0 - self.dut.fmc_qsfp_5_rx_rst_3.value = 0 - self.dut.fmc_qsfp_5_tx_rst_3.value = 0 - self.dut.fmc_qsfp_5_rx_rst_4.value = 0 - self.dut.fmc_qsfp_5_tx_rst_4.value = 0 - self.dut.fmc_qsfp_6_rx_rst_1.value = 0 - self.dut.fmc_qsfp_6_tx_rst_1.value = 0 - self.dut.fmc_qsfp_6_rx_rst_2.value = 0 - self.dut.fmc_qsfp_6_tx_rst_2.value = 0 - self.dut.fmc_qsfp_6_rx_rst_3.value = 0 - self.dut.fmc_qsfp_6_tx_rst_3.value = 0 - self.dut.fmc_qsfp_6_rx_rst_4.value = 0 - self.dut.fmc_qsfp_6_tx_rst_4.value = 0 + for x in range(1, 10): + for y in range(1, 5): + getattr(self.dut, f"qsfp_{x}_rx_rst_{y}").value = 0 + getattr(self.dut, f"qsfp_{x}_tx_rst_{y}").value = 0 + for x in range(1, 7): + for y in range(1, 5): + getattr(self.dut, f"fmc_qsfp_{x}_rx_rst_{y}").value = 0 + getattr(self.dut, f"fmc_qsfp_{x}_tx_rst_{y}").value = 0 @cocotb.test() @@ -746,11 +142,11 @@ async def run_test(dut): test_frame = XgmiiFrame.from_payload(test_pkt.build()) - await tb.qsfp_1_1_source.send(test_frame) + await tb.qsfp_source[0][0].send(test_frame) tb.log.info("receive ARP request") - rx_frame = await tb.qsfp_1_1_sink.recv() + rx_frame = await tb.qsfp_sink[0][0].recv() rx_pkt = Ether(bytes(rx_frame.get_payload())) @@ -778,11 +174,11 @@ async def run_test(dut): resp_frame = XgmiiFrame.from_payload(resp_pkt.build()) - await tb.qsfp_1_1_source.send(resp_frame) + await tb.qsfp_source[0][0].send(resp_frame) tb.log.info("receive UDP packet") - rx_frame = await tb.qsfp_1_1_sink.recv() + rx_frame = await tb.qsfp_sink[0][0].recv() rx_pkt = Ether(bytes(rx_frame.get_payload())) diff --git a/example/NetFPGA_SUME/fpga/tb/fpga_core/test_fpga_core.py b/example/NetFPGA_SUME/fpga/tb/fpga_core/test_fpga_core.py index 4a25a06c1..7b54ab033 100644 --- a/example/NetFPGA_SUME/fpga/tb/fpga_core/test_fpga_core.py +++ b/example/NetFPGA_SUME/fpga/tb/fpga_core/test_fpga_core.py @@ -48,65 +48,41 @@ class TB: cocotb.start_soon(Clock(dut.clk, 6.4, units="ns").start()) # Ethernet - cocotb.start_soon(Clock(dut.sfp_1_rx_clk, 6.4, units="ns").start()) - self.sfp_1_source = XgmiiSource(dut.sfp_1_rxd, dut.sfp_1_rxc, dut.sfp_1_rx_clk, dut.sfp_1_rx_rst) - cocotb.start_soon(Clock(dut.sfp_1_tx_clk, 6.4, units="ns").start()) - self.sfp_1_sink = XgmiiSink(dut.sfp_1_txd, dut.sfp_1_txc, dut.sfp_1_tx_clk, dut.sfp_1_tx_rst) + self.sfp_source = [] + self.sfp_sink = [] - cocotb.start_soon(Clock(dut.sfp_2_rx_clk, 6.4, units="ns").start()) - self.sfp_2_source = XgmiiSource(dut.sfp_2_rxd, dut.sfp_2_rxc, dut.sfp_2_rx_clk, dut.sfp_2_rx_rst) - cocotb.start_soon(Clock(dut.sfp_2_tx_clk, 6.4, units="ns").start()) - self.sfp_2_sink = XgmiiSink(dut.sfp_2_txd, dut.sfp_2_txc, dut.sfp_2_tx_clk, dut.sfp_2_tx_rst) - - cocotb.start_soon(Clock(dut.sfp_3_rx_clk, 6.4, units="ns").start()) - self.sfp_3_source = XgmiiSource(dut.sfp_3_rxd, dut.sfp_3_rxc, dut.sfp_3_rx_clk, dut.sfp_3_rx_rst) - cocotb.start_soon(Clock(dut.sfp_3_tx_clk, 6.4, units="ns").start()) - self.sfp_3_sink = XgmiiSink(dut.sfp_3_txd, dut.sfp_3_txc, dut.sfp_3_tx_clk, dut.sfp_3_tx_rst) - - cocotb.start_soon(Clock(dut.sfp_4_rx_clk, 6.4, units="ns").start()) - self.sfp_4_source = XgmiiSource(dut.sfp_4_rxd, dut.sfp_4_rxc, dut.sfp_4_rx_clk, dut.sfp_4_rx_rst) - cocotb.start_soon(Clock(dut.sfp_4_tx_clk, 6.4, units="ns").start()) - self.sfp_4_sink = XgmiiSink(dut.sfp_4_txd, dut.sfp_4_txc, dut.sfp_4_tx_clk, dut.sfp_4_tx_rst) + for y in range(1, 5): + cocotb.start_soon(Clock(getattr(dut, f"sfp_{y}_rx_clk"), 6.4, units="ns").start()) + source = XgmiiSource(getattr(dut, f"sfp_{y}_rxd"), getattr(dut, f"sfp_{y}_rxc"), getattr(dut, f"sfp_{y}_rx_clk"), getattr(dut, f"sfp_{y}_rx_rst")) + self.sfp_source.append(source) + cocotb.start_soon(Clock(getattr(dut, f"sfp_{y}_tx_clk"), 6.4, units="ns").start()) + sink = XgmiiSink(getattr(dut, f"sfp_{y}_txd"), getattr(dut, f"sfp_{y}_txc"), getattr(dut, f"sfp_{y}_tx_clk"), getattr(dut, f"sfp_{y}_tx_rst")) + self.sfp_sink.append(sink) dut.btn.setimmediatevalue(0) async def init(self): self.dut.rst.setimmediatevalue(0) - self.dut.sfp_1_rx_rst.setimmediatevalue(0) - self.dut.sfp_1_tx_rst.setimmediatevalue(0) - self.dut.sfp_2_rx_rst.setimmediatevalue(0) - self.dut.sfp_2_tx_rst.setimmediatevalue(0) - self.dut.sfp_3_rx_rst.setimmediatevalue(0) - self.dut.sfp_3_tx_rst.setimmediatevalue(0) - self.dut.sfp_4_rx_rst.setimmediatevalue(0) - self.dut.sfp_4_tx_rst.setimmediatevalue(0) + for y in range(1, 5): + getattr(self.dut, f"sfp_{y}_rx_rst").setimmediatevalue(0) + getattr(self.dut, f"sfp_{y}_tx_rst").setimmediatevalue(0) for k in range(10): await RisingEdge(self.dut.clk) self.dut.rst.value = 1 - self.dut.sfp_1_rx_rst.value = 1 - self.dut.sfp_1_tx_rst.value = 1 - self.dut.sfp_2_rx_rst.value = 1 - self.dut.sfp_2_tx_rst.value = 1 - self.dut.sfp_3_rx_rst.value = 1 - self.dut.sfp_3_tx_rst.value = 1 - self.dut.sfp_4_rx_rst.value = 1 - self.dut.sfp_4_tx_rst.value = 1 + for y in range(1, 5): + getattr(self.dut, f"sfp_{y}_rx_rst").value = 1 + getattr(self.dut, f"sfp_{y}_tx_rst").value = 1 for k in range(10): await RisingEdge(self.dut.clk) self.dut.rst.value = 0 - self.dut.sfp_1_rx_rst.value = 0 - self.dut.sfp_1_tx_rst.value = 0 - self.dut.sfp_2_rx_rst.value = 0 - self.dut.sfp_2_tx_rst.value = 0 - self.dut.sfp_3_rx_rst.value = 0 - self.dut.sfp_3_tx_rst.value = 0 - self.dut.sfp_4_rx_rst.value = 0 - self.dut.sfp_4_tx_rst.value = 0 + for y in range(1, 5): + getattr(self.dut, f"sfp_{y}_rx_rst").value = 0 + getattr(self.dut, f"sfp_{y}_tx_rst").value = 0 @cocotb.test() @@ -126,11 +102,11 @@ async def run_test(dut): test_frame = XgmiiFrame.from_payload(test_pkt.build()) - await tb.sfp_1_source.send(test_frame) + await tb.sfp_source[0].send(test_frame) tb.log.info("receive ARP request") - rx_frame = await tb.sfp_1_sink.recv() + rx_frame = await tb.sfp_sink[0].recv() rx_pkt = Ether(bytes(rx_frame.get_payload())) @@ -158,11 +134,11 @@ async def run_test(dut): resp_frame = XgmiiFrame.from_payload(resp_pkt.build()) - await tb.sfp_1_source.send(resp_frame) + await tb.sfp_source[0].send(resp_frame) tb.log.info("receive UDP packet") - rx_frame = await tb.sfp_1_sink.recv() + rx_frame = await tb.sfp_sink[0].recv() rx_pkt = Ether(bytes(rx_frame.get_payload())) diff --git a/example/S10DX_DK/fpga_10g/tb/fpga_core/test_fpga_core.py b/example/S10DX_DK/fpga_10g/tb/fpga_core/test_fpga_core.py index 72d03bd32..0b744bbcd 100644 --- a/example/S10DX_DK/fpga_10g/tb/fpga_core/test_fpga_core.py +++ b/example/S10DX_DK/fpga_10g/tb/fpga_core/test_fpga_core.py @@ -49,173 +49,51 @@ class TB: cocotb.start_soon(Clock(dut.clk, 6.206, units="ns").start()) # Ethernet - cocotb.start_soon(Clock(dut.qsfp1_mac_1_rx_clk, 6.206, units="ns").start()) - cocotb.start_soon(Clock(dut.qsfp1_mac_1_tx_clk, 6.206, units="ns").start()) + self.qsfp_mac = [] - self.qsfp1_mac_1 = EthMac( - tx_clk=dut.qsfp1_mac_1_tx_clk, - tx_rst=dut.qsfp1_mac_1_tx_rst, - tx_bus=AxiStreamBus.from_prefix(dut, "qsfp1_mac_1_tx_axis"), - rx_clk=dut.qsfp1_mac_1_rx_clk, - rx_rst=dut.qsfp1_mac_1_rx_rst, - rx_bus=AxiStreamBus.from_prefix(dut, "qsfp1_mac_1_rx_axis"), - ifg=12, speed=10e9 - ) - - cocotb.start_soon(Clock(dut.qsfp1_mac_2_rx_clk, 6.206, units="ns").start()) - cocotb.start_soon(Clock(dut.qsfp1_mac_2_tx_clk, 6.206, units="ns").start()) - - self.qsfp1_mac_2 = EthMac( - tx_clk=dut.qsfp1_mac_2_tx_clk, - tx_rst=dut.qsfp1_mac_2_tx_rst, - tx_bus=AxiStreamBus.from_prefix(dut, "qsfp1_mac_2_tx_axis"), - rx_clk=dut.qsfp1_mac_2_rx_clk, - rx_rst=dut.qsfp1_mac_2_rx_rst, - rx_bus=AxiStreamBus.from_prefix(dut, "qsfp1_mac_2_rx_axis"), - ifg=12, speed=10e9 - ) - - cocotb.start_soon(Clock(dut.qsfp1_mac_3_rx_clk, 6.206, units="ns").start()) - cocotb.start_soon(Clock(dut.qsfp1_mac_3_tx_clk, 6.206, units="ns").start()) - - self.qsfp1_mac_3 = EthMac( - tx_clk=dut.qsfp1_mac_3_tx_clk, - tx_rst=dut.qsfp1_mac_3_tx_rst, - tx_bus=AxiStreamBus.from_prefix(dut, "qsfp1_mac_3_tx_axis"), - rx_clk=dut.qsfp1_mac_3_rx_clk, - rx_rst=dut.qsfp1_mac_3_rx_rst, - rx_bus=AxiStreamBus.from_prefix(dut, "qsfp1_mac_3_rx_axis"), - ifg=12, speed=10e9 - ) - - cocotb.start_soon(Clock(dut.qsfp1_mac_4_rx_clk, 6.206, units="ns").start()) - cocotb.start_soon(Clock(dut.qsfp1_mac_4_tx_clk, 6.206, units="ns").start()) - - self.qsfp1_mac_4 = EthMac( - tx_clk=dut.qsfp1_mac_4_tx_clk, - tx_rst=dut.qsfp1_mac_4_tx_rst, - tx_bus=AxiStreamBus.from_prefix(dut, "qsfp1_mac_4_tx_axis"), - rx_clk=dut.qsfp1_mac_4_rx_clk, - rx_rst=dut.qsfp1_mac_4_rx_rst, - rx_bus=AxiStreamBus.from_prefix(dut, "qsfp1_mac_4_rx_axis"), - ifg=12, speed=10e9 - ) - - cocotb.start_soon(Clock(dut.qsfp2_mac_1_rx_clk, 6.206, units="ns").start()) - cocotb.start_soon(Clock(dut.qsfp2_mac_1_tx_clk, 6.206, units="ns").start()) - - self.qsfp2_mac_1 = EthMac( - tx_clk=dut.qsfp2_mac_1_tx_clk, - tx_rst=dut.qsfp2_mac_1_tx_rst, - tx_bus=AxiStreamBus.from_prefix(dut, "qsfp2_mac_1_tx_axis"), - rx_clk=dut.qsfp2_mac_1_rx_clk, - rx_rst=dut.qsfp2_mac_1_rx_rst, - rx_bus=AxiStreamBus.from_prefix(dut, "qsfp2_mac_1_rx_axis"), - ifg=12, speed=10e9 - ) - - cocotb.start_soon(Clock(dut.qsfp2_mac_2_rx_clk, 6.206, units="ns").start()) - cocotb.start_soon(Clock(dut.qsfp2_mac_2_tx_clk, 6.206, units="ns").start()) - - self.qsfp2_mac_2 = EthMac( - tx_clk=dut.qsfp2_mac_2_tx_clk, - tx_rst=dut.qsfp2_mac_2_tx_rst, - tx_bus=AxiStreamBus.from_prefix(dut, "qsfp2_mac_2_tx_axis"), - rx_clk=dut.qsfp2_mac_2_rx_clk, - rx_rst=dut.qsfp2_mac_2_rx_rst, - rx_bus=AxiStreamBus.from_prefix(dut, "qsfp2_mac_2_rx_axis"), - ifg=12, speed=10e9 - ) - - cocotb.start_soon(Clock(dut.qsfp2_mac_3_rx_clk, 6.206, units="ns").start()) - cocotb.start_soon(Clock(dut.qsfp2_mac_3_tx_clk, 6.206, units="ns").start()) - - self.qsfp2_mac_3 = EthMac( - tx_clk=dut.qsfp2_mac_3_tx_clk, - tx_rst=dut.qsfp2_mac_3_tx_rst, - tx_bus=AxiStreamBus.from_prefix(dut, "qsfp2_mac_3_tx_axis"), - rx_clk=dut.qsfp2_mac_3_rx_clk, - rx_rst=dut.qsfp2_mac_3_rx_rst, - rx_bus=AxiStreamBus.from_prefix(dut, "qsfp2_mac_3_rx_axis"), - ifg=12, speed=10e9 - ) - - cocotb.start_soon(Clock(dut.qsfp2_mac_4_rx_clk, 6.206, units="ns").start()) - cocotb.start_soon(Clock(dut.qsfp2_mac_4_tx_clk, 6.206, units="ns").start()) - - self.qsfp2_mac_4 = EthMac( - tx_clk=dut.qsfp2_mac_4_tx_clk, - tx_rst=dut.qsfp2_mac_4_tx_rst, - tx_bus=AxiStreamBus.from_prefix(dut, "qsfp2_mac_4_tx_axis"), - rx_clk=dut.qsfp2_mac_4_rx_clk, - rx_rst=dut.qsfp2_mac_4_rx_rst, - rx_bus=AxiStreamBus.from_prefix(dut, "qsfp2_mac_4_rx_axis"), - ifg=12, speed=10e9 - ) + for x in range(1, 3): + macs = [] + for y in range(1, 5): + cocotb.start_soon(Clock(getattr(dut, f"qsfp{x}_mac_{y}_tx_clk"), 6.206, units="ns").start()) + cocotb.start_soon(Clock(getattr(dut, f"qsfp{x}_mac_{y}_rx_clk"), 6.206, units="ns").start()) + macs.append(EthMac( + tx_clk=getattr(dut, f"qsfp{x}_mac_{y}_tx_clk"), + tx_rst=getattr(dut, f"qsfp{x}_mac_{y}_tx_rst"), + tx_bus=AxiStreamBus.from_prefix(dut, f"qsfp{x}_mac_{y}_tx_axis"), + rx_clk=getattr(dut, f"qsfp{x}_mac_{y}_rx_clk"), + rx_rst=getattr(dut, f"qsfp{x}_mac_{y}_rx_rst"), + rx_bus=AxiStreamBus.from_prefix(dut, f"qsfp{x}_mac_{y}_rx_axis"), + ifg=12, speed=10e9 + )) + self.qsfp_mac.append(macs) dut.btn.setimmediatevalue(0) async def init(self): self.dut.rst.setimmediatevalue(0) - self.dut.qsfp1_mac_1_rx_rst.setimmediatevalue(0) - self.dut.qsfp1_mac_1_tx_rst.setimmediatevalue(0) - self.dut.qsfp1_mac_2_rx_rst.setimmediatevalue(0) - self.dut.qsfp1_mac_2_tx_rst.setimmediatevalue(0) - self.dut.qsfp1_mac_3_rx_rst.setimmediatevalue(0) - self.dut.qsfp1_mac_3_tx_rst.setimmediatevalue(0) - self.dut.qsfp1_mac_4_rx_rst.setimmediatevalue(0) - self.dut.qsfp1_mac_4_tx_rst.setimmediatevalue(0) - self.dut.qsfp2_mac_1_rx_rst.setimmediatevalue(0) - self.dut.qsfp2_mac_1_tx_rst.setimmediatevalue(0) - self.dut.qsfp2_mac_2_rx_rst.setimmediatevalue(0) - self.dut.qsfp2_mac_2_tx_rst.setimmediatevalue(0) - self.dut.qsfp2_mac_3_rx_rst.setimmediatevalue(0) - self.dut.qsfp2_mac_3_tx_rst.setimmediatevalue(0) - self.dut.qsfp2_mac_4_rx_rst.setimmediatevalue(0) - self.dut.qsfp2_mac_4_tx_rst.setimmediatevalue(0) + for x in range(1, 3): + for y in range(1, 5): + getattr(self.dut, f"qsfp{x}_mac_{y}_rx_rst").setimmediatevalue(0) + getattr(self.dut, f"qsfp{x}_mac_{y}_tx_rst").setimmediatevalue(0) for k in range(10): await RisingEdge(self.dut.clk) self.dut.rst.value = 1 - self.dut.qsfp1_mac_1_rx_rst.value = 1 - self.dut.qsfp1_mac_1_tx_rst.value = 1 - self.dut.qsfp1_mac_2_rx_rst.value = 1 - self.dut.qsfp1_mac_2_tx_rst.value = 1 - self.dut.qsfp1_mac_3_rx_rst.value = 1 - self.dut.qsfp1_mac_3_tx_rst.value = 1 - self.dut.qsfp1_mac_4_rx_rst.value = 1 - self.dut.qsfp1_mac_4_tx_rst.value = 1 - self.dut.qsfp2_mac_1_rx_rst.value = 1 - self.dut.qsfp2_mac_1_tx_rst.value = 1 - self.dut.qsfp2_mac_2_rx_rst.value = 1 - self.dut.qsfp2_mac_2_tx_rst.value = 1 - self.dut.qsfp2_mac_3_rx_rst.value = 1 - self.dut.qsfp2_mac_3_tx_rst.value = 1 - self.dut.qsfp2_mac_4_rx_rst.value = 1 - self.dut.qsfp2_mac_4_tx_rst.value = 1 + for x in range(1, 3): + for y in range(1, 5): + getattr(self.dut, f"qsfp{x}_mac_{y}_rx_rst").value = 1 + getattr(self.dut, f"qsfp{x}_mac_{y}_tx_rst").value = 1 for k in range(10): await RisingEdge(self.dut.clk) self.dut.rst.value = 0 - self.dut.qsfp1_mac_1_rx_rst.value = 0 - self.dut.qsfp1_mac_1_tx_rst.value = 0 - self.dut.qsfp1_mac_2_rx_rst.value = 0 - self.dut.qsfp1_mac_2_tx_rst.value = 0 - self.dut.qsfp1_mac_3_rx_rst.value = 0 - self.dut.qsfp1_mac_3_tx_rst.value = 0 - self.dut.qsfp1_mac_4_rx_rst.value = 0 - self.dut.qsfp1_mac_4_tx_rst.value = 0 - self.dut.qsfp2_mac_1_rx_rst.value = 0 - self.dut.qsfp2_mac_1_tx_rst.value = 0 - self.dut.qsfp2_mac_2_rx_rst.value = 0 - self.dut.qsfp2_mac_2_tx_rst.value = 0 - self.dut.qsfp2_mac_3_rx_rst.value = 0 - self.dut.qsfp2_mac_3_tx_rst.value = 0 - self.dut.qsfp2_mac_4_rx_rst.value = 0 - self.dut.qsfp2_mac_4_tx_rst.value = 0 + for x in range(1, 3): + for y in range(1, 5): + getattr(self.dut, f"qsfp{x}_mac_{y}_rx_rst").value = 0 + getattr(self.dut, f"qsfp{x}_mac_{y}_tx_rst").value = 0 for k in range(10): await RisingEdge(self.dut.clk) @@ -236,11 +114,11 @@ async def run_test(dut): udp = UDP(sport=5678, dport=1234) test_pkt = eth / ip / udp / payload - await tb.qsfp1_mac_1.rx.send(test_pkt.build()) + await tb.qsfp_mac[0][0].rx.send(test_pkt.build()) tb.log.info("receive ARP request") - rx_frame = await tb.qsfp1_mac_1.tx.recv() + rx_frame = await tb.qsfp_mac[0][0].tx.recv() rx_pkt = Ether(bytes(rx_frame)) @@ -266,11 +144,11 @@ async def run_test(dut): hwdst=test_pkt.dst, pdst=test_pkt[IP].dst) resp_pkt = eth / arp - await tb.qsfp1_mac_1.rx.send(resp_pkt.build()) + await tb.qsfp_mac[0][0].rx.send(resp_pkt.build()) tb.log.info("receive UDP packet") - rx_frame = await tb.qsfp1_mac_1.tx.recv() + rx_frame = await tb.qsfp_mac[0][0].tx.recv() rx_pkt = Ether(bytes(rx_frame)) diff --git a/example/S10MX_DK/fpga_10g/tb/fpga_core/test_fpga_core.py b/example/S10MX_DK/fpga_10g/tb/fpga_core/test_fpga_core.py index 934d967e9..817236beb 100644 --- a/example/S10MX_DK/fpga_10g/tb/fpga_core/test_fpga_core.py +++ b/example/S10MX_DK/fpga_10g/tb/fpga_core/test_fpga_core.py @@ -48,107 +48,47 @@ class TB: cocotb.start_soon(Clock(dut.clk, 6.4, units="ns").start()) # Ethernet - cocotb.start_soon(Clock(dut.qsfp0_rx_clk_1, 6.4, units="ns").start()) - self.qsfp0_1_source = XgmiiSource(dut.qsfp0_rxd_1, dut.qsfp0_rxc_1, dut.qsfp0_rx_clk_1, dut.qsfp0_rx_rst_1) - cocotb.start_soon(Clock(dut.qsfp0_tx_clk_1, 6.4, units="ns").start()) - self.qsfp0_1_sink = XgmiiSink(dut.qsfp0_txd_1, dut.qsfp0_txc_1, dut.qsfp0_tx_clk_1, dut.qsfp0_tx_rst_1) + self.qsfp_source = [] + self.qsfp_sink = [] - cocotb.start_soon(Clock(dut.qsfp0_rx_clk_2, 6.4, units="ns").start()) - self.qsfp0_2_source = XgmiiSource(dut.qsfp0_rxd_2, dut.qsfp0_rxc_2, dut.qsfp0_rx_clk_2, dut.qsfp0_rx_rst_2) - cocotb.start_soon(Clock(dut.qsfp0_tx_clk_2, 6.4, units="ns").start()) - self.qsfp0_2_sink = XgmiiSink(dut.qsfp0_txd_2, dut.qsfp0_txc_2, dut.qsfp0_tx_clk_2, dut.qsfp0_tx_rst_2) - - cocotb.start_soon(Clock(dut.qsfp0_rx_clk_3, 6.4, units="ns").start()) - self.qsfp0_3_source = XgmiiSource(dut.qsfp0_rxd_3, dut.qsfp0_rxc_3, dut.qsfp0_rx_clk_3, dut.qsfp0_rx_rst_3) - cocotb.start_soon(Clock(dut.qsfp0_tx_clk_3, 6.4, units="ns").start()) - self.qsfp0_3_sink = XgmiiSink(dut.qsfp0_txd_3, dut.qsfp0_txc_3, dut.qsfp0_tx_clk_3, dut.qsfp0_tx_rst_3) - - cocotb.start_soon(Clock(dut.qsfp0_rx_clk_4, 6.4, units="ns").start()) - self.qsfp0_4_source = XgmiiSource(dut.qsfp0_rxd_4, dut.qsfp0_rxc_4, dut.qsfp0_rx_clk_4, dut.qsfp0_rx_rst_4) - cocotb.start_soon(Clock(dut.qsfp0_tx_clk_4, 6.4, units="ns").start()) - self.qsfp0_4_sink = XgmiiSink(dut.qsfp0_txd_4, dut.qsfp0_txc_4, dut.qsfp0_tx_clk_4, dut.qsfp0_tx_rst_4) - - cocotb.start_soon(Clock(dut.qsfp1_rx_clk_1, 6.4, units="ns").start()) - self.qsfp1_1_source = XgmiiSource(dut.qsfp1_rxd_1, dut.qsfp1_rxc_1, dut.qsfp1_rx_clk_1, dut.qsfp1_rx_rst_1) - cocotb.start_soon(Clock(dut.qsfp1_tx_clk_1, 6.4, units="ns").start()) - self.qsfp1_1_sink = XgmiiSink(dut.qsfp1_txd_1, dut.qsfp1_txc_1, dut.qsfp1_tx_clk_1, dut.qsfp1_tx_rst_1) - - cocotb.start_soon(Clock(dut.qsfp1_rx_clk_2, 6.4, units="ns").start()) - self.qsfp1_2_source = XgmiiSource(dut.qsfp1_rxd_2, dut.qsfp1_rxc_2, dut.qsfp1_rx_clk_2, dut.qsfp1_rx_rst_2) - cocotb.start_soon(Clock(dut.qsfp1_tx_clk_2, 6.4, units="ns").start()) - self.qsfp1_2_sink = XgmiiSink(dut.qsfp1_txd_2, dut.qsfp1_txc_2, dut.qsfp1_tx_clk_2, dut.qsfp1_tx_rst_2) - - cocotb.start_soon(Clock(dut.qsfp1_rx_clk_3, 6.4, units="ns").start()) - self.qsfp1_3_source = XgmiiSource(dut.qsfp1_rxd_3, dut.qsfp1_rxc_3, dut.qsfp1_rx_clk_3, dut.qsfp1_rx_rst_3) - cocotb.start_soon(Clock(dut.qsfp1_tx_clk_3, 6.4, units="ns").start()) - self.qsfp1_3_sink = XgmiiSink(dut.qsfp1_txd_3, dut.qsfp1_txc_3, dut.qsfp1_tx_clk_3, dut.qsfp1_tx_rst_3) - - cocotb.start_soon(Clock(dut.qsfp1_rx_clk_4, 6.4, units="ns").start()) - self.qsfp1_4_source = XgmiiSource(dut.qsfp1_rxd_4, dut.qsfp1_rxc_4, dut.qsfp1_rx_clk_4, dut.qsfp1_rx_rst_4) - cocotb.start_soon(Clock(dut.qsfp1_tx_clk_4, 6.4, units="ns").start()) - self.qsfp1_4_sink = XgmiiSink(dut.qsfp1_txd_4, dut.qsfp1_txc_4, dut.qsfp1_tx_clk_4, dut.qsfp1_tx_rst_4) + for x in range(2): + sources = [] + sinks = [] + for y in range(1, 5): + cocotb.start_soon(Clock(getattr(dut, f"qsfp{x}_rx_clk_{y}"), 6.4, units="ns").start()) + source = XgmiiSource(getattr(dut, f"qsfp{x}_rxd_{y}"), getattr(dut, f"qsfp{x}_rxc_{y}"), getattr(dut, f"qsfp{x}_rx_clk_{y}"), getattr(dut, f"qsfp{x}_rx_rst_{y}")) + sources.append(source) + cocotb.start_soon(Clock(getattr(dut, f"qsfp{x}_tx_clk_{y}"), 6.4, units="ns").start()) + sink = XgmiiSink(getattr(dut, f"qsfp{x}_txd_{y}"), getattr(dut, f"qsfp{x}_txc_{y}"), getattr(dut, f"qsfp{x}_tx_clk_{y}"), getattr(dut, f"qsfp{x}_tx_rst_{y}")) + sinks.append(sink) + self.qsfp_source.append(sources) + self.qsfp_sink.append(sinks) async def init(self): self.dut.rst.setimmediatevalue(0) - self.dut.qsfp0_rx_rst_1.setimmediatevalue(0) - self.dut.qsfp0_tx_rst_1.setimmediatevalue(0) - self.dut.qsfp0_rx_rst_2.setimmediatevalue(0) - self.dut.qsfp0_tx_rst_2.setimmediatevalue(0) - self.dut.qsfp0_rx_rst_3.setimmediatevalue(0) - self.dut.qsfp0_tx_rst_3.setimmediatevalue(0) - self.dut.qsfp0_rx_rst_4.setimmediatevalue(0) - self.dut.qsfp0_tx_rst_4.setimmediatevalue(0) - self.dut.qsfp1_rx_rst_1.setimmediatevalue(0) - self.dut.qsfp1_tx_rst_1.setimmediatevalue(0) - self.dut.qsfp1_rx_rst_2.setimmediatevalue(0) - self.dut.qsfp1_tx_rst_2.setimmediatevalue(0) - self.dut.qsfp1_rx_rst_3.setimmediatevalue(0) - self.dut.qsfp1_tx_rst_3.setimmediatevalue(0) - self.dut.qsfp1_rx_rst_4.setimmediatevalue(0) - self.dut.qsfp1_tx_rst_4.setimmediatevalue(0) + for x in range(2): + for y in range(1, 5): + getattr(self.dut, f"qsfp{x}_rx_rst_{y}").setimmediatevalue(0) + getattr(self.dut, f"qsfp{x}_tx_rst_{y}").setimmediatevalue(0) for k in range(10): await RisingEdge(self.dut.clk) self.dut.rst.value = 1 - self.dut.qsfp0_rx_rst_1.value = 1 - self.dut.qsfp0_tx_rst_1.value = 1 - self.dut.qsfp0_rx_rst_2.value = 1 - self.dut.qsfp0_tx_rst_2.value = 1 - self.dut.qsfp0_rx_rst_3.value = 1 - self.dut.qsfp0_tx_rst_3.value = 1 - self.dut.qsfp0_rx_rst_4.value = 1 - self.dut.qsfp0_tx_rst_4.value = 1 - self.dut.qsfp1_rx_rst_1.value = 1 - self.dut.qsfp1_tx_rst_1.value = 1 - self.dut.qsfp1_rx_rst_2.value = 1 - self.dut.qsfp1_tx_rst_2.value = 1 - self.dut.qsfp1_rx_rst_3.value = 1 - self.dut.qsfp1_tx_rst_3.value = 1 - self.dut.qsfp1_rx_rst_4.value = 1 - self.dut.qsfp1_tx_rst_4.value = 1 + for x in range(2): + for y in range(1, 5): + getattr(self.dut, f"qsfp{x}_rx_rst_{y}").value = 1 + getattr(self.dut, f"qsfp{x}_tx_rst_{y}").value = 1 for k in range(10): await RisingEdge(self.dut.clk) self.dut.rst.value = 0 - self.dut.qsfp0_rx_rst_1.value = 0 - self.dut.qsfp0_tx_rst_1.value = 0 - self.dut.qsfp0_rx_rst_2.value = 0 - self.dut.qsfp0_tx_rst_2.value = 0 - self.dut.qsfp0_rx_rst_3.value = 0 - self.dut.qsfp0_tx_rst_3.value = 0 - self.dut.qsfp0_rx_rst_4.value = 0 - self.dut.qsfp0_tx_rst_4.value = 0 - self.dut.qsfp1_rx_rst_1.value = 0 - self.dut.qsfp1_tx_rst_1.value = 0 - self.dut.qsfp1_rx_rst_2.value = 0 - self.dut.qsfp1_tx_rst_2.value = 0 - self.dut.qsfp1_rx_rst_3.value = 0 - self.dut.qsfp1_tx_rst_3.value = 0 - self.dut.qsfp1_rx_rst_4.value = 0 - self.dut.qsfp1_tx_rst_4.value = 0 + for x in range(2): + for y in range(1, 5): + getattr(self.dut, f"qsfp{x}_rx_rst_{y}").value = 0 + getattr(self.dut, f"qsfp{x}_tx_rst_{y}").value = 0 @cocotb.test() @@ -168,11 +108,11 @@ async def run_test(dut): test_frame = XgmiiFrame.from_payload(test_pkt.build()) - await tb.qsfp0_1_source.send(test_frame) + await tb.qsfp_source[0][0].send(test_frame) tb.log.info("receive ARP request") - rx_frame = await tb.qsfp0_1_sink.recv() + rx_frame = await tb.qsfp_sink[0][0].recv() rx_pkt = Ether(bytes(rx_frame.get_payload())) @@ -200,11 +140,11 @@ async def run_test(dut): resp_frame = XgmiiFrame.from_payload(resp_pkt.build()) - await tb.qsfp0_1_source.send(resp_frame) + await tb.qsfp_source[0][0].send(resp_frame) tb.log.info("receive UDP packet") - rx_frame = await tb.qsfp0_1_sink.recv() + rx_frame = await tb.qsfp_sink[0][0].recv() rx_pkt = Ether(bytes(rx_frame.get_payload())) diff --git a/example/VCU108/fpga_10g/tb/fpga_core/test_fpga_core.py b/example/VCU108/fpga_10g/tb/fpga_core/test_fpga_core.py index 4ec069372..37c69b5ca 100644 --- a/example/VCU108/fpga_10g/tb/fpga_core/test_fpga_core.py +++ b/example/VCU108/fpga_10g/tb/fpga_core/test_fpga_core.py @@ -58,25 +58,16 @@ class TB: dut.phy_gmii_clk_en.setimmediatevalue(1) - cocotb.start_soon(Clock(dut.qsfp_rx_clk_1, 6.4, units="ns").start()) - self.qsfp_1_source = XgmiiSource(dut.qsfp_rxd_1, dut.qsfp_rxc_1, dut.qsfp_rx_clk_1, dut.qsfp_rx_rst_1) - cocotb.start_soon(Clock(dut.qsfp_tx_clk_1, 6.4, units="ns").start()) - self.qsfp_1_sink = XgmiiSink(dut.qsfp_txd_1, dut.qsfp_txc_1, dut.qsfp_tx_clk_1, dut.qsfp_tx_rst_1) + self.qsfp_source = [] + self.qsfp_sink = [] - cocotb.start_soon(Clock(dut.qsfp_rx_clk_2, 6.4, units="ns").start()) - self.qsfp_2_source = XgmiiSource(dut.qsfp_rxd_2, dut.qsfp_rxc_2, dut.qsfp_rx_clk_2, dut.qsfp_rx_rst_2) - cocotb.start_soon(Clock(dut.qsfp_tx_clk_2, 6.4, units="ns").start()) - self.qsfp_2_sink = XgmiiSink(dut.qsfp_txd_2, dut.qsfp_txc_2, dut.qsfp_tx_clk_2, dut.qsfp_tx_rst_2) - - cocotb.start_soon(Clock(dut.qsfp_rx_clk_3, 6.4, units="ns").start()) - self.qsfp_3_source = XgmiiSource(dut.qsfp_rxd_3, dut.qsfp_rxc_3, dut.qsfp_rx_clk_3, dut.qsfp_rx_rst_3) - cocotb.start_soon(Clock(dut.qsfp_tx_clk_3, 6.4, units="ns").start()) - self.qsfp_3_sink = XgmiiSink(dut.qsfp_txd_3, dut.qsfp_txc_3, dut.qsfp_tx_clk_3, dut.qsfp_tx_rst_3) - - cocotb.start_soon(Clock(dut.qsfp_rx_clk_4, 6.4, units="ns").start()) - self.qsfp_4_source = XgmiiSource(dut.qsfp_rxd_4, dut.qsfp_rxc_4, dut.qsfp_rx_clk_4, dut.qsfp_rx_rst_4) - cocotb.start_soon(Clock(dut.qsfp_tx_clk_4, 6.4, units="ns").start()) - self.qsfp_4_sink = XgmiiSink(dut.qsfp_txd_4, dut.qsfp_txc_4, dut.qsfp_tx_clk_4, dut.qsfp_tx_rst_4) + for y in range(1, 5): + cocotb.start_soon(Clock(getattr(dut, f"qsfp_rx_clk_{y}"), 2.56, units="ns").start()) + source = XgmiiSource(getattr(dut, f"qsfp_rxd_{y}"), getattr(dut, f"qsfp_rxc_{y}"), getattr(dut, f"qsfp_rx_clk_{y}"), getattr(dut, f"qsfp_rx_rst_{y}")) + self.qsfp_source.append(source) + cocotb.start_soon(Clock(getattr(dut, f"qsfp_tx_clk_{y}"), 2.56, units="ns").start()) + sink = XgmiiSink(getattr(dut, f"qsfp_txd_{y}"), getattr(dut, f"qsfp_txc_{y}"), getattr(dut, f"qsfp_tx_clk_{y}"), getattr(dut, f"qsfp_tx_rst_{y}")) + self.qsfp_sink.append(sink) dut.btnu.setimmediatevalue(0) dut.btnl.setimmediatevalue(0) @@ -91,42 +82,27 @@ class TB: self.dut.rst.setimmediatevalue(0) self.dut.phy_gmii_rst.setimmediatevalue(0) - self.dut.qsfp_rx_rst_1.setimmediatevalue(0) - self.dut.qsfp_tx_rst_1.setimmediatevalue(0) - self.dut.qsfp_rx_rst_2.setimmediatevalue(0) - self.dut.qsfp_tx_rst_2.setimmediatevalue(0) - self.dut.qsfp_rx_rst_3.setimmediatevalue(0) - self.dut.qsfp_tx_rst_3.setimmediatevalue(0) - self.dut.qsfp_rx_rst_4.setimmediatevalue(0) - self.dut.qsfp_tx_rst_4.setimmediatevalue(0) + for y in range(1, 5): + getattr(self.dut, f"qsfp_rx_rst_{y}").setimmediatevalue(0) + getattr(self.dut, f"qsfp_tx_rst_{y}").setimmediatevalue(0) for k in range(10): await RisingEdge(self.dut.clk) self.dut.rst.value = 1 self.dut.phy_gmii_rst.value = 1 - self.dut.qsfp_rx_rst_1.value = 1 - self.dut.qsfp_tx_rst_1.value = 1 - self.dut.qsfp_rx_rst_2.value = 1 - self.dut.qsfp_tx_rst_2.value = 1 - self.dut.qsfp_rx_rst_3.value = 1 - self.dut.qsfp_tx_rst_3.value = 1 - self.dut.qsfp_rx_rst_4.value = 1 - self.dut.qsfp_tx_rst_4.value = 1 + for y in range(1, 5): + getattr(self.dut, f"qsfp_rx_rst_{y}").value = 1 + getattr(self.dut, f"qsfp_tx_rst_{y}").value = 1 for k in range(10): await RisingEdge(self.dut.clk) self.dut.rst.value = 0 self.dut.phy_gmii_rst.value = 0 - self.dut.qsfp_rx_rst_1.value = 0 - self.dut.qsfp_tx_rst_1.value = 0 - self.dut.qsfp_rx_rst_2.value = 0 - self.dut.qsfp_tx_rst_2.value = 0 - self.dut.qsfp_rx_rst_3.value = 0 - self.dut.qsfp_tx_rst_3.value = 0 - self.dut.qsfp_rx_rst_4.value = 0 - self.dut.qsfp_tx_rst_4.value = 0 + for y in range(1, 5): + getattr(self.dut, f"qsfp_rx_rst_{y}").value = 0 + getattr(self.dut, f"qsfp_tx_rst_{y}").value = 0 @cocotb.test() @@ -146,11 +122,11 @@ async def run_test(dut): test_frame = XgmiiFrame.from_payload(test_pkt.build()) - await tb.qsfp_1_source.send(test_frame) + await tb.qsfp_source[0].send(test_frame) tb.log.info("receive ARP request") - rx_frame = await tb.qsfp_1_sink.recv() + rx_frame = await tb.qsfp_sink[0].recv() rx_pkt = Ether(bytes(rx_frame.get_payload())) @@ -178,11 +154,11 @@ async def run_test(dut): resp_frame = XgmiiFrame.from_payload(resp_pkt.build()) - await tb.qsfp_1_source.send(resp_frame) + await tb.qsfp_source[0].send(resp_frame) tb.log.info("receive UDP packet") - rx_frame = await tb.qsfp_1_sink.recv() + rx_frame = await tb.qsfp_sink[0].recv() rx_pkt = Ether(bytes(rx_frame.get_payload())) @@ -215,13 +191,13 @@ async def run_test(dut): tb.log.info("loop back packet on XGMII interface") - rx_frame = await tb.qsfp_1_sink.recv() + rx_frame = await tb.qsfp_sink[0].recv() rx_pkt = Ether(bytes(rx_frame.get_payload())) tb.log.info("RX packet: %s", repr(rx_pkt)) - await tb.qsfp_1_source.send(rx_frame) + await tb.qsfp_source[0].send(rx_frame) tb.log.info("receive UDP packet") @@ -258,13 +234,13 @@ async def run_test(dut): tb.log.info("loop back packet on XGMII interface") - rx_frame = await tb.qsfp_1_sink.recv() + rx_frame = await tb.qsfp_sink[0].recv() rx_pkt = Ether(bytes(rx_frame.get_payload())) tb.log.info("RX packet: %s", repr(rx_pkt)) - await tb.qsfp_1_source.send(rx_frame) + await tb.qsfp_source[0].send(rx_frame) tb.log.info("receive UDP packet") diff --git a/example/VCU118/fpga_25g/tb/fpga_core/test_fpga_core.py b/example/VCU118/fpga_25g/tb/fpga_core/test_fpga_core.py index 0b751835f..b2ed1bb51 100644 --- a/example/VCU118/fpga_25g/tb/fpga_core/test_fpga_core.py +++ b/example/VCU118/fpga_25g/tb/fpga_core/test_fpga_core.py @@ -58,45 +58,21 @@ class TB: dut.phy_gmii_clk_en.setimmediatevalue(1) - cocotb.start_soon(Clock(dut.qsfp1_rx_clk_1, 2.56, units="ns").start()) - self.qsfp1_1_source = XgmiiSource(dut.qsfp1_rxd_1, dut.qsfp1_rxc_1, dut.qsfp1_rx_clk_1, dut.qsfp1_rx_rst_1) - cocotb.start_soon(Clock(dut.qsfp1_tx_clk_1, 2.56, units="ns").start()) - self.qsfp1_1_sink = XgmiiSink(dut.qsfp1_txd_1, dut.qsfp1_txc_1, dut.qsfp1_tx_clk_1, dut.qsfp1_tx_rst_1) + self.qsfp_source = [] + self.qsfp_sink = [] - cocotb.start_soon(Clock(dut.qsfp1_rx_clk_2, 2.56, units="ns").start()) - self.qsfp1_2_source = XgmiiSource(dut.qsfp1_rxd_2, dut.qsfp1_rxc_2, dut.qsfp1_rx_clk_2, dut.qsfp1_rx_rst_2) - cocotb.start_soon(Clock(dut.qsfp1_tx_clk_2, 2.56, units="ns").start()) - self.qsfp1_2_sink = XgmiiSink(dut.qsfp1_txd_2, dut.qsfp1_txc_2, dut.qsfp1_tx_clk_2, dut.qsfp1_tx_rst_2) - - cocotb.start_soon(Clock(dut.qsfp1_rx_clk_3, 2.56, units="ns").start()) - self.qsfp1_3_source = XgmiiSource(dut.qsfp1_rxd_3, dut.qsfp1_rxc_3, dut.qsfp1_rx_clk_3, dut.qsfp1_rx_rst_3) - cocotb.start_soon(Clock(dut.qsfp1_tx_clk_3, 2.56, units="ns").start()) - self.qsfp1_3_sink = XgmiiSink(dut.qsfp1_txd_3, dut.qsfp1_txc_3, dut.qsfp1_tx_clk_3, dut.qsfp1_tx_rst_3) - - cocotb.start_soon(Clock(dut.qsfp1_rx_clk_4, 2.56, units="ns").start()) - self.qsfp1_4_source = XgmiiSource(dut.qsfp1_rxd_4, dut.qsfp1_rxc_4, dut.qsfp1_rx_clk_4, dut.qsfp1_rx_rst_4) - cocotb.start_soon(Clock(dut.qsfp1_tx_clk_4, 2.56, units="ns").start()) - self.qsfp1_4_sink = XgmiiSink(dut.qsfp1_txd_4, dut.qsfp1_txc_4, dut.qsfp1_tx_clk_4, dut.qsfp1_tx_rst_4) - - cocotb.start_soon(Clock(dut.qsfp2_rx_clk_1, 2.56, units="ns").start()) - self.qsfp2_1_source = XgmiiSource(dut.qsfp2_rxd_1, dut.qsfp2_rxc_1, dut.qsfp2_rx_clk_1, dut.qsfp2_rx_rst_1) - cocotb.start_soon(Clock(dut.qsfp2_tx_clk_1, 2.56, units="ns").start()) - self.qsfp2_1_sink = XgmiiSink(dut.qsfp2_txd_1, dut.qsfp2_txc_1, dut.qsfp2_tx_clk_1, dut.qsfp2_tx_rst_1) - - cocotb.start_soon(Clock(dut.qsfp2_rx_clk_2, 2.56, units="ns").start()) - self.qsfp2_2_source = XgmiiSource(dut.qsfp2_rxd_2, dut.qsfp2_rxc_2, dut.qsfp2_rx_clk_2, dut.qsfp2_rx_rst_2) - cocotb.start_soon(Clock(dut.qsfp2_tx_clk_2, 2.56, units="ns").start()) - self.qsfp2_2_sink = XgmiiSink(dut.qsfp2_txd_2, dut.qsfp2_txc_2, dut.qsfp2_tx_clk_2, dut.qsfp2_tx_rst_2) - - cocotb.start_soon(Clock(dut.qsfp2_rx_clk_3, 2.56, units="ns").start()) - self.qsfp2_3_source = XgmiiSource(dut.qsfp2_rxd_3, dut.qsfp2_rxc_3, dut.qsfp2_rx_clk_3, dut.qsfp2_rx_rst_3) - cocotb.start_soon(Clock(dut.qsfp2_tx_clk_3, 2.56, units="ns").start()) - self.qsfp2_3_sink = XgmiiSink(dut.qsfp2_txd_3, dut.qsfp2_txc_3, dut.qsfp2_tx_clk_3, dut.qsfp2_tx_rst_3) - - cocotb.start_soon(Clock(dut.qsfp2_rx_clk_4, 2.56, units="ns").start()) - self.qsfp2_4_source = XgmiiSource(dut.qsfp2_rxd_4, dut.qsfp2_rxc_4, dut.qsfp2_rx_clk_4, dut.qsfp2_rx_rst_4) - cocotb.start_soon(Clock(dut.qsfp2_tx_clk_4, 2.56, units="ns").start()) - self.qsfp2_4_sink = XgmiiSink(dut.qsfp2_txd_4, dut.qsfp2_txc_4, dut.qsfp2_tx_clk_4, dut.qsfp2_tx_rst_4) + for x in range(1, 3): + sources = [] + sinks = [] + for y in range(1, 5): + cocotb.start_soon(Clock(getattr(dut, f"qsfp{x}_rx_clk_{y}"), 2.56, units="ns").start()) + source = XgmiiSource(getattr(dut, f"qsfp{x}_rxd_{y}"), getattr(dut, f"qsfp{x}_rxc_{y}"), getattr(dut, f"qsfp{x}_rx_clk_{y}"), getattr(dut, f"qsfp{x}_rx_rst_{y}")) + sources.append(source) + cocotb.start_soon(Clock(getattr(dut, f"qsfp{x}_tx_clk_{y}"), 2.56, units="ns").start()) + sink = XgmiiSink(getattr(dut, f"qsfp{x}_txd_{y}"), getattr(dut, f"qsfp{x}_txc_{y}"), getattr(dut, f"qsfp{x}_tx_clk_{y}"), getattr(dut, f"qsfp{x}_tx_rst_{y}")) + sinks.append(sink) + self.qsfp_source.append(sources) + self.qsfp_sink.append(sinks) dut.btnu.setimmediatevalue(0) dut.btnl.setimmediatevalue(0) @@ -111,66 +87,30 @@ class TB: self.dut.rst.setimmediatevalue(0) self.dut.phy_gmii_rst.setimmediatevalue(0) - self.dut.qsfp1_rx_rst_1.setimmediatevalue(0) - self.dut.qsfp1_tx_rst_1.setimmediatevalue(0) - self.dut.qsfp1_rx_rst_2.setimmediatevalue(0) - self.dut.qsfp1_tx_rst_2.setimmediatevalue(0) - self.dut.qsfp1_rx_rst_3.setimmediatevalue(0) - self.dut.qsfp1_tx_rst_3.setimmediatevalue(0) - self.dut.qsfp1_rx_rst_4.setimmediatevalue(0) - self.dut.qsfp1_tx_rst_4.setimmediatevalue(0) - self.dut.qsfp2_rx_rst_1.setimmediatevalue(0) - self.dut.qsfp2_tx_rst_1.setimmediatevalue(0) - self.dut.qsfp2_rx_rst_2.setimmediatevalue(0) - self.dut.qsfp2_tx_rst_2.setimmediatevalue(0) - self.dut.qsfp2_rx_rst_3.setimmediatevalue(0) - self.dut.qsfp2_tx_rst_3.setimmediatevalue(0) - self.dut.qsfp2_rx_rst_4.setimmediatevalue(0) - self.dut.qsfp2_tx_rst_4.setimmediatevalue(0) + for x in range(1, 3): + for y in range(1, 5): + getattr(self.dut, f"qsfp{x}_rx_rst_{y}").setimmediatevalue(0) + getattr(self.dut, f"qsfp{x}_tx_rst_{y}").setimmediatevalue(0) for k in range(10): await RisingEdge(self.dut.clk) self.dut.rst.value = 1 self.dut.phy_gmii_rst.value = 1 - self.dut.qsfp1_rx_rst_1.value = 1 - self.dut.qsfp1_tx_rst_1.value = 1 - self.dut.qsfp1_rx_rst_2.value = 1 - self.dut.qsfp1_tx_rst_2.value = 1 - self.dut.qsfp1_rx_rst_3.value = 1 - self.dut.qsfp1_tx_rst_3.value = 1 - self.dut.qsfp1_rx_rst_4.value = 1 - self.dut.qsfp1_tx_rst_4.value = 1 - self.dut.qsfp2_rx_rst_1.value = 1 - self.dut.qsfp2_tx_rst_1.value = 1 - self.dut.qsfp2_rx_rst_2.value = 1 - self.dut.qsfp2_tx_rst_2.value = 1 - self.dut.qsfp2_rx_rst_3.value = 1 - self.dut.qsfp2_tx_rst_3.value = 1 - self.dut.qsfp2_rx_rst_4.value = 1 - self.dut.qsfp2_tx_rst_4.value = 1 + for x in range(1, 3): + for y in range(1, 5): + getattr(self.dut, f"qsfp{x}_rx_rst_{y}").value = 1 + getattr(self.dut, f"qsfp{x}_tx_rst_{y}").value = 1 for k in range(10): await RisingEdge(self.dut.clk) self.dut.rst.value = 0 self.dut.phy_gmii_rst.value = 0 - self.dut.qsfp1_rx_rst_1.value = 0 - self.dut.qsfp1_tx_rst_1.value = 0 - self.dut.qsfp1_rx_rst_2.value = 0 - self.dut.qsfp1_tx_rst_2.value = 0 - self.dut.qsfp1_rx_rst_3.value = 0 - self.dut.qsfp1_tx_rst_3.value = 0 - self.dut.qsfp1_rx_rst_4.value = 0 - self.dut.qsfp1_tx_rst_4.value = 0 - self.dut.qsfp2_rx_rst_1.value = 0 - self.dut.qsfp2_tx_rst_1.value = 0 - self.dut.qsfp2_rx_rst_2.value = 0 - self.dut.qsfp2_tx_rst_2.value = 0 - self.dut.qsfp2_rx_rst_3.value = 0 - self.dut.qsfp2_tx_rst_3.value = 0 - self.dut.qsfp2_rx_rst_4.value = 0 - self.dut.qsfp2_tx_rst_4.value = 0 + for x in range(1, 3): + for y in range(1, 5): + getattr(self.dut, f"qsfp{x}_rx_rst_{y}").value = 0 + getattr(self.dut, f"qsfp{x}_tx_rst_{y}").value = 0 @cocotb.test() @@ -190,11 +130,11 @@ async def run_test(dut): test_frame = XgmiiFrame.from_payload(test_pkt.build()) - await tb.qsfp1_1_source.send(test_frame) + await tb.qsfp_source[0][0].send(test_frame) tb.log.info("receive ARP request") - rx_frame = await tb.qsfp1_1_sink.recv() + rx_frame = await tb.qsfp_sink[0][0].recv() rx_pkt = Ether(bytes(rx_frame.get_payload())) @@ -222,11 +162,11 @@ async def run_test(dut): resp_frame = XgmiiFrame.from_payload(resp_pkt.build()) - await tb.qsfp1_1_source.send(resp_frame) + await tb.qsfp_source[0][0].send(resp_frame) tb.log.info("receive UDP packet") - rx_frame = await tb.qsfp1_1_sink.recv() + rx_frame = await tb.qsfp_sink[0][0].recv() rx_pkt = Ether(bytes(rx_frame.get_payload())) @@ -259,13 +199,13 @@ async def run_test(dut): tb.log.info("loop back packet on XGMII interface") - rx_frame = await tb.qsfp1_1_sink.recv() + rx_frame = await tb.qsfp_sink[0][0].recv() rx_pkt = Ether(bytes(rx_frame.get_payload())) tb.log.info("RX packet: %s", repr(rx_pkt)) - await tb.qsfp1_1_source.send(rx_frame) + await tb.qsfp_source[0][0].send(rx_frame) tb.log.info("receive UDP packet") @@ -302,13 +242,13 @@ async def run_test(dut): tb.log.info("loop back packet on XGMII interface") - rx_frame = await tb.qsfp1_1_sink.recv() + rx_frame = await tb.qsfp_sink[0][0].recv() rx_pkt = Ether(bytes(rx_frame.get_payload())) tb.log.info("RX packet: %s", repr(rx_pkt)) - await tb.qsfp1_1_source.send(rx_frame) + await tb.qsfp_source[0][0].send(rx_frame) tb.log.info("receive UDP packet") diff --git a/example/VCU118/fpga_fmc_htg_6qsfp_25g/tb/fpga_core/test_fpga_core.py b/example/VCU118/fpga_fmc_htg_6qsfp_25g/tb/fpga_core/test_fpga_core.py index 55a473303..be990e00a 100644 --- a/example/VCU118/fpga_fmc_htg_6qsfp_25g/tb/fpga_core/test_fpga_core.py +++ b/example/VCU118/fpga_fmc_htg_6qsfp_25g/tb/fpga_core/test_fpga_core.py @@ -58,165 +58,37 @@ class TB: dut.phy_gmii_clk_en.setimmediatevalue(1) - cocotb.start_soon(Clock(dut.qsfp1_rx_clk_1, 2.56, units="ns").start()) - self.qsfp1_1_source = XgmiiSource(dut.qsfp1_rxd_1, dut.qsfp1_rxc_1, dut.qsfp1_rx_clk_1, dut.qsfp1_rx_rst_1) - cocotb.start_soon(Clock(dut.qsfp1_tx_clk_1, 2.56, units="ns").start()) - self.qsfp1_1_sink = XgmiiSink(dut.qsfp1_txd_1, dut.qsfp1_txc_1, dut.qsfp1_tx_clk_1, dut.qsfp1_tx_rst_1) + self.qsfp_source = [] + self.qsfp_sink = [] - cocotb.start_soon(Clock(dut.qsfp1_rx_clk_2, 2.56, units="ns").start()) - self.qsfp1_2_source = XgmiiSource(dut.qsfp1_rxd_2, dut.qsfp1_rxc_2, dut.qsfp1_rx_clk_2, dut.qsfp1_rx_rst_2) - cocotb.start_soon(Clock(dut.qsfp1_tx_clk_2, 2.56, units="ns").start()) - self.qsfp1_2_sink = XgmiiSink(dut.qsfp1_txd_2, dut.qsfp1_txc_2, dut.qsfp1_tx_clk_2, dut.qsfp1_tx_rst_2) + for x in range(1, 3): + sources = [] + sinks = [] + for y in range(1, 5): + cocotb.start_soon(Clock(getattr(dut, f"qsfp{x}_rx_clk_{y}"), 2.56, units="ns").start()) + source = XgmiiSource(getattr(dut, f"qsfp{x}_rxd_{y}"), getattr(dut, f"qsfp{x}_rxc_{y}"), getattr(dut, f"qsfp{x}_rx_clk_{y}"), getattr(dut, f"qsfp{x}_rx_rst_{y}")) + sources.append(source) + cocotb.start_soon(Clock(getattr(dut, f"qsfp{x}_tx_clk_{y}"), 2.56, units="ns").start()) + sink = XgmiiSink(getattr(dut, f"qsfp{x}_txd_{y}"), getattr(dut, f"qsfp{x}_txc_{y}"), getattr(dut, f"qsfp{x}_tx_clk_{y}"), getattr(dut, f"qsfp{x}_tx_rst_{y}")) + sinks.append(sink) + self.qsfp_source.append(sources) + self.qsfp_sink.append(sinks) - cocotb.start_soon(Clock(dut.qsfp1_rx_clk_3, 2.56, units="ns").start()) - self.qsfp1_3_source = XgmiiSource(dut.qsfp1_rxd_3, dut.qsfp1_rxc_3, dut.qsfp1_rx_clk_3, dut.qsfp1_rx_rst_3) - cocotb.start_soon(Clock(dut.qsfp1_tx_clk_3, 2.56, units="ns").start()) - self.qsfp1_3_sink = XgmiiSink(dut.qsfp1_txd_3, dut.qsfp1_txc_3, dut.qsfp1_tx_clk_3, dut.qsfp1_tx_rst_3) + self.fmcp_qsfp_source = [] + self.fmcp_qsfp_sink = [] - cocotb.start_soon(Clock(dut.qsfp1_rx_clk_4, 2.56, units="ns").start()) - self.qsfp1_4_source = XgmiiSource(dut.qsfp1_rxd_4, dut.qsfp1_rxc_4, dut.qsfp1_rx_clk_4, dut.qsfp1_rx_rst_4) - cocotb.start_soon(Clock(dut.qsfp1_tx_clk_4, 2.56, units="ns").start()) - self.qsfp1_4_sink = XgmiiSink(dut.qsfp1_txd_4, dut.qsfp1_txc_4, dut.qsfp1_tx_clk_4, dut.qsfp1_tx_rst_4) - - cocotb.start_soon(Clock(dut.qsfp2_rx_clk_1, 2.56, units="ns").start()) - self.qsfp2_1_source = XgmiiSource(dut.qsfp2_rxd_1, dut.qsfp2_rxc_1, dut.qsfp2_rx_clk_1, dut.qsfp2_rx_rst_1) - cocotb.start_soon(Clock(dut.qsfp2_tx_clk_1, 2.56, units="ns").start()) - self.qsfp2_1_sink = XgmiiSink(dut.qsfp2_txd_1, dut.qsfp2_txc_1, dut.qsfp2_tx_clk_1, dut.qsfp2_tx_rst_1) - - cocotb.start_soon(Clock(dut.qsfp2_rx_clk_2, 2.56, units="ns").start()) - self.qsfp2_2_source = XgmiiSource(dut.qsfp2_rxd_2, dut.qsfp2_rxc_2, dut.qsfp2_rx_clk_2, dut.qsfp2_rx_rst_2) - cocotb.start_soon(Clock(dut.qsfp2_tx_clk_2, 2.56, units="ns").start()) - self.qsfp2_2_sink = XgmiiSink(dut.qsfp2_txd_2, dut.qsfp2_txc_2, dut.qsfp2_tx_clk_2, dut.qsfp2_tx_rst_2) - - cocotb.start_soon(Clock(dut.qsfp2_rx_clk_3, 2.56, units="ns").start()) - self.qsfp2_3_source = XgmiiSource(dut.qsfp2_rxd_3, dut.qsfp2_rxc_3, dut.qsfp2_rx_clk_3, dut.qsfp2_rx_rst_3) - cocotb.start_soon(Clock(dut.qsfp2_tx_clk_3, 2.56, units="ns").start()) - self.qsfp2_3_sink = XgmiiSink(dut.qsfp2_txd_3, dut.qsfp2_txc_3, dut.qsfp2_tx_clk_3, dut.qsfp2_tx_rst_3) - - cocotb.start_soon(Clock(dut.qsfp2_rx_clk_4, 2.56, units="ns").start()) - self.qsfp2_4_source = XgmiiSource(dut.qsfp2_rxd_4, dut.qsfp2_rxc_4, dut.qsfp2_rx_clk_4, dut.qsfp2_rx_rst_4) - cocotb.start_soon(Clock(dut.qsfp2_tx_clk_4, 2.56, units="ns").start()) - self.qsfp2_4_sink = XgmiiSink(dut.qsfp2_txd_4, dut.qsfp2_txc_4, dut.qsfp2_tx_clk_4, dut.qsfp2_tx_rst_4) - - cocotb.start_soon(Clock(dut.fmcp_qsfp1_rx_clk_1, 2.56, units="ns").start()) - self.fmcp_qsfp1_1_source = XgmiiSource(dut.fmcp_qsfp1_rxd_1, dut.fmcp_qsfp1_rxc_1, dut.fmcp_qsfp1_rx_clk_1, dut.fmcp_qsfp1_rx_rst_1) - cocotb.start_soon(Clock(dut.fmcp_qsfp1_tx_clk_1, 2.56, units="ns").start()) - self.fmcp_qsfp1_1_sink = XgmiiSink(dut.fmcp_qsfp1_txd_1, dut.fmcp_qsfp1_txc_1, dut.fmcp_qsfp1_tx_clk_1, dut.fmcp_qsfp1_tx_rst_1) - - cocotb.start_soon(Clock(dut.fmcp_qsfp1_rx_clk_2, 2.56, units="ns").start()) - self.fmcp_qsfp1_2_source = XgmiiSource(dut.fmcp_qsfp1_rxd_2, dut.fmcp_qsfp1_rxc_2, dut.fmcp_qsfp1_rx_clk_2, dut.fmcp_qsfp1_rx_rst_2) - cocotb.start_soon(Clock(dut.fmcp_qsfp1_tx_clk_2, 2.56, units="ns").start()) - self.fmcp_qsfp1_2_sink = XgmiiSink(dut.fmcp_qsfp1_txd_2, dut.fmcp_qsfp1_txc_2, dut.fmcp_qsfp1_tx_clk_2, dut.fmcp_qsfp1_tx_rst_2) - - cocotb.start_soon(Clock(dut.fmcp_qsfp1_rx_clk_3, 2.56, units="ns").start()) - self.fmcp_qsfp1_3_source = XgmiiSource(dut.fmcp_qsfp1_rxd_3, dut.fmcp_qsfp1_rxc_3, dut.fmcp_qsfp1_rx_clk_3, dut.fmcp_qsfp1_rx_rst_3) - cocotb.start_soon(Clock(dut.fmcp_qsfp1_tx_clk_3, 2.56, units="ns").start()) - self.fmcp_qsfp1_3_sink = XgmiiSink(dut.fmcp_qsfp1_txd_3, dut.fmcp_qsfp1_txc_3, dut.fmcp_qsfp1_tx_clk_3, dut.fmcp_qsfp1_tx_rst_3) - - cocotb.start_soon(Clock(dut.fmcp_qsfp1_rx_clk_4, 2.56, units="ns").start()) - self.fmcp_qsfp1_4_source = XgmiiSource(dut.fmcp_qsfp1_rxd_4, dut.fmcp_qsfp1_rxc_4, dut.fmcp_qsfp1_rx_clk_4, dut.fmcp_qsfp1_rx_rst_4) - cocotb.start_soon(Clock(dut.fmcp_qsfp1_tx_clk_4, 2.56, units="ns").start()) - self.fmcp_qsfp1_4_sink = XgmiiSink(dut.fmcp_qsfp1_txd_4, dut.fmcp_qsfp1_txc_4, dut.fmcp_qsfp1_tx_clk_4, dut.fmcp_qsfp1_tx_rst_4) - - cocotb.start_soon(Clock(dut.fmcp_qsfp2_rx_clk_1, 2.56, units="ns").start()) - self.fmcp_qsfp2_1_source = XgmiiSource(dut.fmcp_qsfp2_rxd_1, dut.fmcp_qsfp2_rxc_1, dut.fmcp_qsfp2_rx_clk_1, dut.fmcp_qsfp2_rx_rst_1) - cocotb.start_soon(Clock(dut.fmcp_qsfp2_tx_clk_1, 2.56, units="ns").start()) - self.fmcp_qsfp2_1_sink = XgmiiSink(dut.fmcp_qsfp2_txd_1, dut.fmcp_qsfp2_txc_1, dut.fmcp_qsfp2_tx_clk_1, dut.fmcp_qsfp2_tx_rst_1) - - cocotb.start_soon(Clock(dut.fmcp_qsfp2_rx_clk_2, 2.56, units="ns").start()) - self.fmcp_qsfp2_2_source = XgmiiSource(dut.fmcp_qsfp2_rxd_2, dut.fmcp_qsfp2_rxc_2, dut.fmcp_qsfp2_rx_clk_2, dut.fmcp_qsfp2_rx_rst_2) - cocotb.start_soon(Clock(dut.fmcp_qsfp2_tx_clk_2, 2.56, units="ns").start()) - self.fmcp_qsfp2_2_sink = XgmiiSink(dut.fmcp_qsfp2_txd_2, dut.fmcp_qsfp2_txc_2, dut.fmcp_qsfp2_tx_clk_2, dut.fmcp_qsfp2_tx_rst_2) - - cocotb.start_soon(Clock(dut.fmcp_qsfp2_rx_clk_3, 2.56, units="ns").start()) - self.fmcp_qsfp2_3_source = XgmiiSource(dut.fmcp_qsfp2_rxd_3, dut.fmcp_qsfp2_rxc_3, dut.fmcp_qsfp2_rx_clk_3, dut.fmcp_qsfp2_rx_rst_3) - cocotb.start_soon(Clock(dut.fmcp_qsfp2_tx_clk_3, 2.56, units="ns").start()) - self.fmcp_qsfp2_3_sink = XgmiiSink(dut.fmcp_qsfp2_txd_3, dut.fmcp_qsfp2_txc_3, dut.fmcp_qsfp2_tx_clk_3, dut.fmcp_qsfp2_tx_rst_3) - - cocotb.start_soon(Clock(dut.fmcp_qsfp2_rx_clk_4, 2.56, units="ns").start()) - self.fmcp_qsfp2_4_source = XgmiiSource(dut.fmcp_qsfp2_rxd_4, dut.fmcp_qsfp2_rxc_4, dut.fmcp_qsfp2_rx_clk_4, dut.fmcp_qsfp2_rx_rst_4) - cocotb.start_soon(Clock(dut.fmcp_qsfp2_tx_clk_4, 2.56, units="ns").start()) - self.fmcp_qsfp2_4_sink = XgmiiSink(dut.fmcp_qsfp2_txd_4, dut.fmcp_qsfp2_txc_4, dut.fmcp_qsfp2_tx_clk_4, dut.fmcp_qsfp2_tx_rst_4) - - cocotb.start_soon(Clock(dut.fmcp_qsfp3_rx_clk_1, 2.56, units="ns").start()) - self.fmcp_qsfp3_1_source = XgmiiSource(dut.fmcp_qsfp3_rxd_1, dut.fmcp_qsfp3_rxc_1, dut.fmcp_qsfp3_rx_clk_1, dut.fmcp_qsfp3_rx_rst_1) - cocotb.start_soon(Clock(dut.fmcp_qsfp3_tx_clk_1, 2.56, units="ns").start()) - self.fmcp_qsfp3_1_sink = XgmiiSink(dut.fmcp_qsfp3_txd_1, dut.fmcp_qsfp3_txc_1, dut.fmcp_qsfp3_tx_clk_1, dut.fmcp_qsfp3_tx_rst_1) - - cocotb.start_soon(Clock(dut.fmcp_qsfp3_rx_clk_2, 2.56, units="ns").start()) - self.fmcp_qsfp3_2_source = XgmiiSource(dut.fmcp_qsfp3_rxd_2, dut.fmcp_qsfp3_rxc_2, dut.fmcp_qsfp3_rx_clk_2, dut.fmcp_qsfp3_rx_rst_2) - cocotb.start_soon(Clock(dut.fmcp_qsfp3_tx_clk_2, 2.56, units="ns").start()) - self.fmcp_qsfp3_2_sink = XgmiiSink(dut.fmcp_qsfp3_txd_2, dut.fmcp_qsfp3_txc_2, dut.fmcp_qsfp3_tx_clk_2, dut.fmcp_qsfp3_tx_rst_2) - - cocotb.start_soon(Clock(dut.fmcp_qsfp3_rx_clk_3, 2.56, units="ns").start()) - self.fmcp_qsfp3_3_source = XgmiiSource(dut.fmcp_qsfp3_rxd_3, dut.fmcp_qsfp3_rxc_3, dut.fmcp_qsfp3_rx_clk_3, dut.fmcp_qsfp3_rx_rst_3) - cocotb.start_soon(Clock(dut.fmcp_qsfp3_tx_clk_3, 2.56, units="ns").start()) - self.fmcp_qsfp3_3_sink = XgmiiSink(dut.fmcp_qsfp3_txd_3, dut.fmcp_qsfp3_txc_3, dut.fmcp_qsfp3_tx_clk_3, dut.fmcp_qsfp3_tx_rst_3) - - cocotb.start_soon(Clock(dut.fmcp_qsfp3_rx_clk_4, 2.56, units="ns").start()) - self.fmcp_qsfp3_4_source = XgmiiSource(dut.fmcp_qsfp3_rxd_4, dut.fmcp_qsfp3_rxc_4, dut.fmcp_qsfp3_rx_clk_4, dut.fmcp_qsfp3_rx_rst_4) - cocotb.start_soon(Clock(dut.fmcp_qsfp3_tx_clk_4, 2.56, units="ns").start()) - self.fmcp_qsfp3_4_sink = XgmiiSink(dut.fmcp_qsfp3_txd_4, dut.fmcp_qsfp3_txc_4, dut.fmcp_qsfp3_tx_clk_4, dut.fmcp_qsfp3_tx_rst_4) - - cocotb.start_soon(Clock(dut.fmcp_qsfp4_rx_clk_1, 2.56, units="ns").start()) - self.fmcp_qsfp4_1_source = XgmiiSource(dut.fmcp_qsfp4_rxd_1, dut.fmcp_qsfp4_rxc_1, dut.fmcp_qsfp4_rx_clk_1, dut.fmcp_qsfp4_rx_rst_1) - cocotb.start_soon(Clock(dut.fmcp_qsfp4_tx_clk_1, 2.56, units="ns").start()) - self.fmcp_qsfp4_1_sink = XgmiiSink(dut.fmcp_qsfp4_txd_1, dut.fmcp_qsfp4_txc_1, dut.fmcp_qsfp4_tx_clk_1, dut.fmcp_qsfp4_tx_rst_1) - - cocotb.start_soon(Clock(dut.fmcp_qsfp4_rx_clk_2, 2.56, units="ns").start()) - self.fmcp_qsfp4_2_source = XgmiiSource(dut.fmcp_qsfp4_rxd_2, dut.fmcp_qsfp4_rxc_2, dut.fmcp_qsfp4_rx_clk_2, dut.fmcp_qsfp4_rx_rst_2) - cocotb.start_soon(Clock(dut.fmcp_qsfp4_tx_clk_2, 2.56, units="ns").start()) - self.fmcp_qsfp4_2_sink = XgmiiSink(dut.fmcp_qsfp4_txd_2, dut.fmcp_qsfp4_txc_2, dut.fmcp_qsfp4_tx_clk_2, dut.fmcp_qsfp4_tx_rst_2) - - cocotb.start_soon(Clock(dut.fmcp_qsfp4_rx_clk_3, 2.56, units="ns").start()) - self.fmcp_qsfp4_3_source = XgmiiSource(dut.fmcp_qsfp4_rxd_3, dut.fmcp_qsfp4_rxc_3, dut.fmcp_qsfp4_rx_clk_3, dut.fmcp_qsfp4_rx_rst_3) - cocotb.start_soon(Clock(dut.fmcp_qsfp4_tx_clk_3, 2.56, units="ns").start()) - self.fmcp_qsfp4_3_sink = XgmiiSink(dut.fmcp_qsfp4_txd_3, dut.fmcp_qsfp4_txc_3, dut.fmcp_qsfp4_tx_clk_3, dut.fmcp_qsfp4_tx_rst_3) - - cocotb.start_soon(Clock(dut.fmcp_qsfp4_rx_clk_4, 2.56, units="ns").start()) - self.fmcp_qsfp4_4_source = XgmiiSource(dut.fmcp_qsfp4_rxd_4, dut.fmcp_qsfp4_rxc_4, dut.fmcp_qsfp4_rx_clk_4, dut.fmcp_qsfp4_rx_rst_4) - cocotb.start_soon(Clock(dut.fmcp_qsfp4_tx_clk_4, 2.56, units="ns").start()) - self.fmcp_qsfp4_4_sink = XgmiiSink(dut.fmcp_qsfp4_txd_4, dut.fmcp_qsfp4_txc_4, dut.fmcp_qsfp4_tx_clk_4, dut.fmcp_qsfp4_tx_rst_4) - - cocotb.start_soon(Clock(dut.fmcp_qsfp5_rx_clk_1, 2.56, units="ns").start()) - self.fmcp_qsfp5_1_source = XgmiiSource(dut.fmcp_qsfp5_rxd_1, dut.fmcp_qsfp5_rxc_1, dut.fmcp_qsfp5_rx_clk_1, dut.fmcp_qsfp5_rx_rst_1) - cocotb.start_soon(Clock(dut.fmcp_qsfp5_tx_clk_1, 2.56, units="ns").start()) - self.fmcp_qsfp5_1_sink = XgmiiSink(dut.fmcp_qsfp5_txd_1, dut.fmcp_qsfp5_txc_1, dut.fmcp_qsfp5_tx_clk_1, dut.fmcp_qsfp5_tx_rst_1) - - cocotb.start_soon(Clock(dut.fmcp_qsfp5_rx_clk_2, 2.56, units="ns").start()) - self.fmcp_qsfp5_2_source = XgmiiSource(dut.fmcp_qsfp5_rxd_2, dut.fmcp_qsfp5_rxc_2, dut.fmcp_qsfp5_rx_clk_2, dut.fmcp_qsfp5_rx_rst_2) - cocotb.start_soon(Clock(dut.fmcp_qsfp5_tx_clk_2, 2.56, units="ns").start()) - self.fmcp_qsfp5_2_sink = XgmiiSink(dut.fmcp_qsfp5_txd_2, dut.fmcp_qsfp5_txc_2, dut.fmcp_qsfp5_tx_clk_2, dut.fmcp_qsfp5_tx_rst_2) - - cocotb.start_soon(Clock(dut.fmcp_qsfp5_rx_clk_3, 2.56, units="ns").start()) - self.fmcp_qsfp5_3_source = XgmiiSource(dut.fmcp_qsfp5_rxd_3, dut.fmcp_qsfp5_rxc_3, dut.fmcp_qsfp5_rx_clk_3, dut.fmcp_qsfp5_rx_rst_3) - cocotb.start_soon(Clock(dut.fmcp_qsfp5_tx_clk_3, 2.56, units="ns").start()) - self.fmcp_qsfp5_3_sink = XgmiiSink(dut.fmcp_qsfp5_txd_3, dut.fmcp_qsfp5_txc_3, dut.fmcp_qsfp5_tx_clk_3, dut.fmcp_qsfp5_tx_rst_3) - - cocotb.start_soon(Clock(dut.fmcp_qsfp5_rx_clk_4, 2.56, units="ns").start()) - self.fmcp_qsfp5_4_source = XgmiiSource(dut.fmcp_qsfp5_rxd_4, dut.fmcp_qsfp5_rxc_4, dut.fmcp_qsfp5_rx_clk_4, dut.fmcp_qsfp5_rx_rst_4) - cocotb.start_soon(Clock(dut.fmcp_qsfp5_tx_clk_4, 2.56, units="ns").start()) - self.fmcp_qsfp5_4_sink = XgmiiSink(dut.fmcp_qsfp5_txd_4, dut.fmcp_qsfp5_txc_4, dut.fmcp_qsfp5_tx_clk_4, dut.fmcp_qsfp5_tx_rst_4) - - cocotb.start_soon(Clock(dut.fmcp_qsfp6_rx_clk_1, 2.56, units="ns").start()) - self.fmcp_qsfp6_1_source = XgmiiSource(dut.fmcp_qsfp6_rxd_1, dut.fmcp_qsfp6_rxc_1, dut.fmcp_qsfp6_rx_clk_1, dut.fmcp_qsfp6_rx_rst_1) - cocotb.start_soon(Clock(dut.fmcp_qsfp6_tx_clk_1, 2.56, units="ns").start()) - self.fmcp_qsfp6_1_sink = XgmiiSink(dut.fmcp_qsfp6_txd_1, dut.fmcp_qsfp6_txc_1, dut.fmcp_qsfp6_tx_clk_1, dut.fmcp_qsfp6_tx_rst_1) - - cocotb.start_soon(Clock(dut.fmcp_qsfp6_rx_clk_2, 2.56, units="ns").start()) - self.fmcp_qsfp6_2_source = XgmiiSource(dut.fmcp_qsfp6_rxd_2, dut.fmcp_qsfp6_rxc_2, dut.fmcp_qsfp6_rx_clk_2, dut.fmcp_qsfp6_rx_rst_2) - cocotb.start_soon(Clock(dut.fmcp_qsfp6_tx_clk_2, 2.56, units="ns").start()) - self.fmcp_qsfp6_2_sink = XgmiiSink(dut.fmcp_qsfp6_txd_2, dut.fmcp_qsfp6_txc_2, dut.fmcp_qsfp6_tx_clk_2, dut.fmcp_qsfp6_tx_rst_2) - - cocotb.start_soon(Clock(dut.fmcp_qsfp6_rx_clk_3, 2.56, units="ns").start()) - self.fmcp_qsfp6_3_source = XgmiiSource(dut.fmcp_qsfp6_rxd_3, dut.fmcp_qsfp6_rxc_3, dut.fmcp_qsfp6_rx_clk_3, dut.fmcp_qsfp6_rx_rst_3) - cocotb.start_soon(Clock(dut.fmcp_qsfp6_tx_clk_3, 2.56, units="ns").start()) - self.fmcp_qsfp6_3_sink = XgmiiSink(dut.fmcp_qsfp6_txd_3, dut.fmcp_qsfp6_txc_3, dut.fmcp_qsfp6_tx_clk_3, dut.fmcp_qsfp6_tx_rst_3) - - cocotb.start_soon(Clock(dut.fmcp_qsfp6_rx_clk_4, 2.56, units="ns").start()) - self.fmcp_qsfp6_4_source = XgmiiSource(dut.fmcp_qsfp6_rxd_4, dut.fmcp_qsfp6_rxc_4, dut.fmcp_qsfp6_rx_clk_4, dut.fmcp_qsfp6_rx_rst_4) - cocotb.start_soon(Clock(dut.fmcp_qsfp6_tx_clk_4, 2.56, units="ns").start()) - self.fmcp_qsfp6_4_sink = XgmiiSink(dut.fmcp_qsfp6_txd_4, dut.fmcp_qsfp6_txc_4, dut.fmcp_qsfp6_tx_clk_4, dut.fmcp_qsfp6_tx_rst_4) + for x in range(1, 7): + sources = [] + sinks = [] + for y in range(1, 5): + cocotb.start_soon(Clock(getattr(dut, f"fmcp_qsfp{x}_rx_clk_{y}"), 2.56, units="ns").start()) + source = XgmiiSource(getattr(dut, f"fmcp_qsfp{x}_rxd_{y}"), getattr(dut, f"fmcp_qsfp{x}_rxc_{y}"), getattr(dut, f"fmcp_qsfp{x}_rx_clk_{y}"), getattr(dut, f"fmcp_qsfp{x}_rx_rst_{y}")) + sources.append(source) + cocotb.start_soon(Clock(getattr(dut, f"fmcp_qsfp{x}_tx_clk_{y}"), 2.56, units="ns").start()) + sink = XgmiiSink(getattr(dut, f"fmcp_qsfp{x}_txd_{y}"), getattr(dut, f"fmcp_qsfp{x}_txc_{y}"), getattr(dut, f"fmcp_qsfp{x}_tx_clk_{y}"), getattr(dut, f"fmcp_qsfp{x}_tx_rst_{y}")) + sinks.append(sink) + self.qsfp_source.append(sources) + self.qsfp_sink.append(sinks) dut.btnu.setimmediatevalue(0) dut.btnl.setimmediatevalue(0) @@ -231,210 +103,42 @@ class TB: self.dut.rst.setimmediatevalue(0) self.dut.phy_gmii_rst.setimmediatevalue(0) - self.dut.qsfp1_rx_rst_1.setimmediatevalue(0) - self.dut.qsfp1_tx_rst_1.setimmediatevalue(0) - self.dut.qsfp1_rx_rst_2.setimmediatevalue(0) - self.dut.qsfp1_tx_rst_2.setimmediatevalue(0) - self.dut.qsfp1_rx_rst_3.setimmediatevalue(0) - self.dut.qsfp1_tx_rst_3.setimmediatevalue(0) - self.dut.qsfp1_rx_rst_4.setimmediatevalue(0) - self.dut.qsfp1_tx_rst_4.setimmediatevalue(0) - self.dut.qsfp2_rx_rst_1.setimmediatevalue(0) - self.dut.qsfp2_tx_rst_1.setimmediatevalue(0) - self.dut.qsfp2_rx_rst_2.setimmediatevalue(0) - self.dut.qsfp2_tx_rst_2.setimmediatevalue(0) - self.dut.qsfp2_rx_rst_3.setimmediatevalue(0) - self.dut.qsfp2_tx_rst_3.setimmediatevalue(0) - self.dut.qsfp2_rx_rst_4.setimmediatevalue(0) - self.dut.qsfp2_tx_rst_4.setimmediatevalue(0) - self.dut.fmcp_qsfp1_rx_rst_1.setimmediatevalue(0) - self.dut.fmcp_qsfp1_tx_rst_1.setimmediatevalue(0) - self.dut.fmcp_qsfp1_rx_rst_2.setimmediatevalue(0) - self.dut.fmcp_qsfp1_tx_rst_2.setimmediatevalue(0) - self.dut.fmcp_qsfp1_rx_rst_3.setimmediatevalue(0) - self.dut.fmcp_qsfp1_tx_rst_3.setimmediatevalue(0) - self.dut.fmcp_qsfp1_rx_rst_4.setimmediatevalue(0) - self.dut.fmcp_qsfp1_tx_rst_4.setimmediatevalue(0) - self.dut.fmcp_qsfp2_rx_rst_1.setimmediatevalue(0) - self.dut.fmcp_qsfp2_tx_rst_1.setimmediatevalue(0) - self.dut.fmcp_qsfp2_rx_rst_2.setimmediatevalue(0) - self.dut.fmcp_qsfp2_tx_rst_2.setimmediatevalue(0) - self.dut.fmcp_qsfp2_rx_rst_3.setimmediatevalue(0) - self.dut.fmcp_qsfp2_tx_rst_3.setimmediatevalue(0) - self.dut.fmcp_qsfp2_rx_rst_4.setimmediatevalue(0) - self.dut.fmcp_qsfp2_tx_rst_4.setimmediatevalue(0) - self.dut.fmcp_qsfp3_rx_rst_1.setimmediatevalue(0) - self.dut.fmcp_qsfp3_tx_rst_1.setimmediatevalue(0) - self.dut.fmcp_qsfp3_rx_rst_2.setimmediatevalue(0) - self.dut.fmcp_qsfp3_tx_rst_2.setimmediatevalue(0) - self.dut.fmcp_qsfp3_rx_rst_3.setimmediatevalue(0) - self.dut.fmcp_qsfp3_tx_rst_3.setimmediatevalue(0) - self.dut.fmcp_qsfp3_rx_rst_4.setimmediatevalue(0) - self.dut.fmcp_qsfp3_tx_rst_4.setimmediatevalue(0) - self.dut.fmcp_qsfp4_rx_rst_1.setimmediatevalue(0) - self.dut.fmcp_qsfp4_tx_rst_1.setimmediatevalue(0) - self.dut.fmcp_qsfp4_rx_rst_2.setimmediatevalue(0) - self.dut.fmcp_qsfp4_tx_rst_2.setimmediatevalue(0) - self.dut.fmcp_qsfp4_rx_rst_3.setimmediatevalue(0) - self.dut.fmcp_qsfp4_tx_rst_3.setimmediatevalue(0) - self.dut.fmcp_qsfp4_rx_rst_4.setimmediatevalue(0) - self.dut.fmcp_qsfp4_tx_rst_4.setimmediatevalue(0) - self.dut.fmcp_qsfp5_rx_rst_1.setimmediatevalue(0) - self.dut.fmcp_qsfp5_tx_rst_1.setimmediatevalue(0) - self.dut.fmcp_qsfp5_rx_rst_2.setimmediatevalue(0) - self.dut.fmcp_qsfp5_tx_rst_2.setimmediatevalue(0) - self.dut.fmcp_qsfp5_rx_rst_3.setimmediatevalue(0) - self.dut.fmcp_qsfp5_tx_rst_3.setimmediatevalue(0) - self.dut.fmcp_qsfp5_rx_rst_4.setimmediatevalue(0) - self.dut.fmcp_qsfp5_tx_rst_4.setimmediatevalue(0) - self.dut.fmcp_qsfp6_rx_rst_1.setimmediatevalue(0) - self.dut.fmcp_qsfp6_tx_rst_1.setimmediatevalue(0) - self.dut.fmcp_qsfp6_rx_rst_2.setimmediatevalue(0) - self.dut.fmcp_qsfp6_tx_rst_2.setimmediatevalue(0) - self.dut.fmcp_qsfp6_rx_rst_3.setimmediatevalue(0) - self.dut.fmcp_qsfp6_tx_rst_3.setimmediatevalue(0) - self.dut.fmcp_qsfp6_rx_rst_4.setimmediatevalue(0) - self.dut.fmcp_qsfp6_tx_rst_4.setimmediatevalue(0) + for x in range(1, 3): + for y in range(1, 5): + getattr(self.dut, f"qsfp{x}_rx_rst_{y}").setimmediatevalue(0) + getattr(self.dut, f"qsfp{x}_tx_rst_{y}").setimmediatevalue(0) + for x in range(1, 7): + for y in range(1, 5): + getattr(self.dut, f"fmcp_qsfp{x}_rx_rst_{y}").setimmediatevalue(0) + getattr(self.dut, f"fmcp_qsfp{x}_tx_rst_{y}").setimmediatevalue(0) for k in range(10): await RisingEdge(self.dut.clk) self.dut.rst.value = 1 self.dut.phy_gmii_rst.value = 1 - self.dut.qsfp1_rx_rst_1.value = 1 - self.dut.qsfp1_tx_rst_1.value = 1 - self.dut.qsfp1_rx_rst_2.value = 1 - self.dut.qsfp1_tx_rst_2.value = 1 - self.dut.qsfp1_rx_rst_3.value = 1 - self.dut.qsfp1_tx_rst_3.value = 1 - self.dut.qsfp1_rx_rst_4.value = 1 - self.dut.qsfp1_tx_rst_4.value = 1 - self.dut.qsfp2_rx_rst_1.value = 1 - self.dut.qsfp2_tx_rst_1.value = 1 - self.dut.qsfp2_rx_rst_2.value = 1 - self.dut.qsfp2_tx_rst_2.value = 1 - self.dut.qsfp2_rx_rst_3.value = 1 - self.dut.qsfp2_tx_rst_3.value = 1 - self.dut.qsfp2_rx_rst_4.value = 1 - self.dut.qsfp2_tx_rst_4.value = 1 - self.dut.fmcp_qsfp1_rx_rst_1.value = 1 - self.dut.fmcp_qsfp1_tx_rst_1.value = 1 - self.dut.fmcp_qsfp1_rx_rst_2.value = 1 - self.dut.fmcp_qsfp1_tx_rst_2.value = 1 - self.dut.fmcp_qsfp1_rx_rst_3.value = 1 - self.dut.fmcp_qsfp1_tx_rst_3.value = 1 - self.dut.fmcp_qsfp1_rx_rst_4.value = 1 - self.dut.fmcp_qsfp1_tx_rst_4.value = 1 - self.dut.fmcp_qsfp2_rx_rst_1.value = 1 - self.dut.fmcp_qsfp2_tx_rst_1.value = 1 - self.dut.fmcp_qsfp2_rx_rst_2.value = 1 - self.dut.fmcp_qsfp2_tx_rst_2.value = 1 - self.dut.fmcp_qsfp2_rx_rst_3.value = 1 - self.dut.fmcp_qsfp2_tx_rst_3.value = 1 - self.dut.fmcp_qsfp2_rx_rst_4.value = 1 - self.dut.fmcp_qsfp2_tx_rst_4.value = 1 - self.dut.fmcp_qsfp3_rx_rst_1.value = 1 - self.dut.fmcp_qsfp3_tx_rst_1.value = 1 - self.dut.fmcp_qsfp3_rx_rst_2.value = 1 - self.dut.fmcp_qsfp3_tx_rst_2.value = 1 - self.dut.fmcp_qsfp3_rx_rst_3.value = 1 - self.dut.fmcp_qsfp3_tx_rst_3.value = 1 - self.dut.fmcp_qsfp3_rx_rst_4.value = 1 - self.dut.fmcp_qsfp3_tx_rst_4.value = 1 - self.dut.fmcp_qsfp4_rx_rst_1.value = 1 - self.dut.fmcp_qsfp4_tx_rst_1.value = 1 - self.dut.fmcp_qsfp4_rx_rst_2.value = 1 - self.dut.fmcp_qsfp4_tx_rst_2.value = 1 - self.dut.fmcp_qsfp4_rx_rst_3.value = 1 - self.dut.fmcp_qsfp4_tx_rst_3.value = 1 - self.dut.fmcp_qsfp4_rx_rst_4.value = 1 - self.dut.fmcp_qsfp4_tx_rst_4.value = 1 - self.dut.fmcp_qsfp5_rx_rst_1.value = 1 - self.dut.fmcp_qsfp5_tx_rst_1.value = 1 - self.dut.fmcp_qsfp5_rx_rst_2.value = 1 - self.dut.fmcp_qsfp5_tx_rst_2.value = 1 - self.dut.fmcp_qsfp5_rx_rst_3.value = 1 - self.dut.fmcp_qsfp5_tx_rst_3.value = 1 - self.dut.fmcp_qsfp5_rx_rst_4.value = 1 - self.dut.fmcp_qsfp5_tx_rst_4.value = 1 - self.dut.fmcp_qsfp6_rx_rst_1.value = 1 - self.dut.fmcp_qsfp6_tx_rst_1.value = 1 - self.dut.fmcp_qsfp6_rx_rst_2.value = 1 - self.dut.fmcp_qsfp6_tx_rst_2.value = 1 - self.dut.fmcp_qsfp6_rx_rst_3.value = 1 - self.dut.fmcp_qsfp6_tx_rst_3.value = 1 - self.dut.fmcp_qsfp6_rx_rst_4.value = 1 - self.dut.fmcp_qsfp6_tx_rst_4.value = 1 + for x in range(1, 3): + for y in range(1, 5): + getattr(self.dut, f"qsfp{x}_rx_rst_{y}").value = 1 + getattr(self.dut, f"qsfp{x}_tx_rst_{y}").value = 1 + for x in range(1, 7): + for y in range(1, 5): + getattr(self.dut, f"fmcp_qsfp{x}_rx_rst_{y}").value = 1 + getattr(self.dut, f"fmcp_qsfp{x}_tx_rst_{y}").value = 1 for k in range(10): await RisingEdge(self.dut.clk) self.dut.rst.value = 0 self.dut.phy_gmii_rst.value = 0 - self.dut.qsfp1_rx_rst_1.value = 0 - self.dut.qsfp1_tx_rst_1.value = 0 - self.dut.qsfp1_rx_rst_2.value = 0 - self.dut.qsfp1_tx_rst_2.value = 0 - self.dut.qsfp1_rx_rst_3.value = 0 - self.dut.qsfp1_tx_rst_3.value = 0 - self.dut.qsfp1_rx_rst_4.value = 0 - self.dut.qsfp1_tx_rst_4.value = 0 - self.dut.qsfp2_rx_rst_1.value = 0 - self.dut.qsfp2_tx_rst_1.value = 0 - self.dut.qsfp2_rx_rst_2.value = 0 - self.dut.qsfp2_tx_rst_2.value = 0 - self.dut.qsfp2_rx_rst_3.value = 0 - self.dut.qsfp2_tx_rst_3.value = 0 - self.dut.qsfp2_rx_rst_4.value = 0 - self.dut.qsfp2_tx_rst_4.value = 0 - self.dut.fmcp_qsfp1_rx_rst_1.value = 0 - self.dut.fmcp_qsfp1_tx_rst_1.value = 0 - self.dut.fmcp_qsfp1_rx_rst_2.value = 0 - self.dut.fmcp_qsfp1_tx_rst_2.value = 0 - self.dut.fmcp_qsfp1_rx_rst_3.value = 0 - self.dut.fmcp_qsfp1_tx_rst_3.value = 0 - self.dut.fmcp_qsfp1_rx_rst_4.value = 0 - self.dut.fmcp_qsfp1_tx_rst_4.value = 0 - self.dut.fmcp_qsfp2_rx_rst_1.value = 0 - self.dut.fmcp_qsfp2_tx_rst_1.value = 0 - self.dut.fmcp_qsfp2_rx_rst_2.value = 0 - self.dut.fmcp_qsfp2_tx_rst_2.value = 0 - self.dut.fmcp_qsfp2_rx_rst_3.value = 0 - self.dut.fmcp_qsfp2_tx_rst_3.value = 0 - self.dut.fmcp_qsfp2_rx_rst_4.value = 0 - self.dut.fmcp_qsfp2_tx_rst_4.value = 0 - self.dut.fmcp_qsfp3_rx_rst_1.value = 0 - self.dut.fmcp_qsfp3_tx_rst_1.value = 0 - self.dut.fmcp_qsfp3_rx_rst_2.value = 0 - self.dut.fmcp_qsfp3_tx_rst_2.value = 0 - self.dut.fmcp_qsfp3_rx_rst_3.value = 0 - self.dut.fmcp_qsfp3_tx_rst_3.value = 0 - self.dut.fmcp_qsfp3_rx_rst_4.value = 0 - self.dut.fmcp_qsfp3_tx_rst_4.value = 0 - self.dut.fmcp_qsfp4_rx_rst_1.value = 0 - self.dut.fmcp_qsfp4_tx_rst_1.value = 0 - self.dut.fmcp_qsfp4_rx_rst_2.value = 0 - self.dut.fmcp_qsfp4_tx_rst_2.value = 0 - self.dut.fmcp_qsfp4_rx_rst_3.value = 0 - self.dut.fmcp_qsfp4_tx_rst_3.value = 0 - self.dut.fmcp_qsfp4_rx_rst_4.value = 0 - self.dut.fmcp_qsfp4_tx_rst_4.value = 0 - self.dut.fmcp_qsfp5_rx_rst_1.value = 0 - self.dut.fmcp_qsfp5_tx_rst_1.value = 0 - self.dut.fmcp_qsfp5_rx_rst_2.value = 0 - self.dut.fmcp_qsfp5_tx_rst_2.value = 0 - self.dut.fmcp_qsfp5_rx_rst_3.value = 0 - self.dut.fmcp_qsfp5_tx_rst_3.value = 0 - self.dut.fmcp_qsfp5_rx_rst_4.value = 0 - self.dut.fmcp_qsfp5_tx_rst_4.value = 0 - self.dut.fmcp_qsfp6_rx_rst_1.value = 0 - self.dut.fmcp_qsfp6_tx_rst_1.value = 0 - self.dut.fmcp_qsfp6_rx_rst_2.value = 0 - self.dut.fmcp_qsfp6_tx_rst_2.value = 0 - self.dut.fmcp_qsfp6_rx_rst_3.value = 0 - self.dut.fmcp_qsfp6_tx_rst_3.value = 0 - self.dut.fmcp_qsfp6_rx_rst_4.value = 0 - self.dut.fmcp_qsfp6_tx_rst_4.value = 0 + for x in range(1, 3): + for y in range(1, 5): + getattr(self.dut, f"qsfp{x}_rx_rst_{y}").value = 0 + getattr(self.dut, f"qsfp{x}_tx_rst_{y}").value = 0 + for x in range(1, 7): + for y in range(1, 5): + getattr(self.dut, f"fmcp_qsfp{x}_rx_rst_{y}").value = 0 + getattr(self.dut, f"fmcp_qsfp{x}_tx_rst_{y}").value = 0 @cocotb.test() @@ -454,11 +158,11 @@ async def run_test(dut): test_frame = XgmiiFrame.from_payload(test_pkt.build()) - await tb.qsfp1_1_source.send(test_frame) + await tb.qsfp_source[0][0].send(test_frame) tb.log.info("receive ARP request") - rx_frame = await tb.qsfp1_1_sink.recv() + rx_frame = await tb.qsfp_sink[0][0].recv() rx_pkt = Ether(bytes(rx_frame.get_payload())) @@ -486,11 +190,11 @@ async def run_test(dut): resp_frame = XgmiiFrame.from_payload(resp_pkt.build()) - await tb.qsfp1_1_source.send(resp_frame) + await tb.qsfp_source[0][0].send(resp_frame) tb.log.info("receive UDP packet") - rx_frame = await tb.qsfp1_1_sink.recv() + rx_frame = await tb.qsfp_sink[0][0].recv() rx_pkt = Ether(bytes(rx_frame.get_payload())) @@ -523,13 +227,13 @@ async def run_test(dut): tb.log.info("loop back packet on XGMII interface") - rx_frame = await tb.qsfp1_1_sink.recv() + rx_frame = await tb.qsfp_sink[0][0].recv() rx_pkt = Ether(bytes(rx_frame.get_payload())) tb.log.info("RX packet: %s", repr(rx_pkt)) - await tb.qsfp1_1_source.send(rx_frame) + await tb.qsfp_source[0][0].send(rx_frame) tb.log.info("receive UDP packet") @@ -566,13 +270,13 @@ async def run_test(dut): tb.log.info("loop back packet on XGMII interface") - rx_frame = await tb.qsfp1_1_sink.recv() + rx_frame = await tb.qsfp_sink[0][0].recv() rx_pkt = Ether(bytes(rx_frame.get_payload())) tb.log.info("RX packet: %s", repr(rx_pkt)) - await tb.qsfp1_1_source.send(rx_frame) + await tb.qsfp_source[0][0].send(rx_frame) tb.log.info("receive UDP packet") diff --git a/example/VCU1525/fpga_25g/tb/fpga_core/test_fpga_core.py b/example/VCU1525/fpga_25g/tb/fpga_core/test_fpga_core.py index 2e392bcb9..d90e185ee 100644 --- a/example/VCU1525/fpga_25g/tb/fpga_core/test_fpga_core.py +++ b/example/VCU1525/fpga_25g/tb/fpga_core/test_fpga_core.py @@ -48,109 +48,49 @@ class TB: cocotb.start_soon(Clock(dut.clk, 2.56, units="ns").start()) # Ethernet - cocotb.start_soon(Clock(dut.qsfp0_rx_clk_1, 2.56, units="ns").start()) - self.qsfp0_1_source = XgmiiSource(dut.qsfp0_rxd_1, dut.qsfp0_rxc_1, dut.qsfp0_rx_clk_1, dut.qsfp0_rx_rst_1) - cocotb.start_soon(Clock(dut.qsfp0_tx_clk_1, 2.56, units="ns").start()) - self.qsfp0_1_sink = XgmiiSink(dut.qsfp0_txd_1, dut.qsfp0_txc_1, dut.qsfp0_tx_clk_1, dut.qsfp0_tx_rst_1) + self.qsfp_source = [] + self.qsfp_sink = [] - cocotb.start_soon(Clock(dut.qsfp0_rx_clk_2, 2.56, units="ns").start()) - self.qsfp0_2_source = XgmiiSource(dut.qsfp0_rxd_2, dut.qsfp0_rxc_2, dut.qsfp0_rx_clk_2, dut.qsfp0_rx_rst_2) - cocotb.start_soon(Clock(dut.qsfp0_tx_clk_2, 2.56, units="ns").start()) - self.qsfp0_2_sink = XgmiiSink(dut.qsfp0_txd_2, dut.qsfp0_txc_2, dut.qsfp0_tx_clk_2, dut.qsfp0_tx_rst_2) - - cocotb.start_soon(Clock(dut.qsfp0_rx_clk_3, 2.56, units="ns").start()) - self.qsfp0_3_source = XgmiiSource(dut.qsfp0_rxd_3, dut.qsfp0_rxc_3, dut.qsfp0_rx_clk_3, dut.qsfp0_rx_rst_3) - cocotb.start_soon(Clock(dut.qsfp0_tx_clk_3, 2.56, units="ns").start()) - self.qsfp0_3_sink = XgmiiSink(dut.qsfp0_txd_3, dut.qsfp0_txc_3, dut.qsfp0_tx_clk_3, dut.qsfp0_tx_rst_3) - - cocotb.start_soon(Clock(dut.qsfp0_rx_clk_4, 2.56, units="ns").start()) - self.qsfp0_4_source = XgmiiSource(dut.qsfp0_rxd_4, dut.qsfp0_rxc_4, dut.qsfp0_rx_clk_4, dut.qsfp0_rx_rst_4) - cocotb.start_soon(Clock(dut.qsfp0_tx_clk_4, 2.56, units="ns").start()) - self.qsfp0_4_sink = XgmiiSink(dut.qsfp0_txd_4, dut.qsfp0_txc_4, dut.qsfp0_tx_clk_4, dut.qsfp0_tx_rst_4) - - cocotb.start_soon(Clock(dut.qsfp1_rx_clk_1, 2.56, units="ns").start()) - self.qsfp1_1_source = XgmiiSource(dut.qsfp1_rxd_1, dut.qsfp1_rxc_1, dut.qsfp1_rx_clk_1, dut.qsfp1_rx_rst_1) - cocotb.start_soon(Clock(dut.qsfp1_tx_clk_1, 2.56, units="ns").start()) - self.qsfp1_1_sink = XgmiiSink(dut.qsfp1_txd_1, dut.qsfp1_txc_1, dut.qsfp1_tx_clk_1, dut.qsfp1_tx_rst_1) - - cocotb.start_soon(Clock(dut.qsfp1_rx_clk_2, 2.56, units="ns").start()) - self.qsfp1_2_source = XgmiiSource(dut.qsfp1_rxd_2, dut.qsfp1_rxc_2, dut.qsfp1_rx_clk_2, dut.qsfp1_rx_rst_2) - cocotb.start_soon(Clock(dut.qsfp1_tx_clk_2, 2.56, units="ns").start()) - self.qsfp1_2_sink = XgmiiSink(dut.qsfp1_txd_2, dut.qsfp1_txc_2, dut.qsfp1_tx_clk_2, dut.qsfp1_tx_rst_2) - - cocotb.start_soon(Clock(dut.qsfp1_rx_clk_3, 2.56, units="ns").start()) - self.qsfp1_3_source = XgmiiSource(dut.qsfp1_rxd_3, dut.qsfp1_rxc_3, dut.qsfp1_rx_clk_3, dut.qsfp1_rx_rst_3) - cocotb.start_soon(Clock(dut.qsfp1_tx_clk_3, 2.56, units="ns").start()) - self.qsfp1_3_sink = XgmiiSink(dut.qsfp1_txd_3, dut.qsfp1_txc_3, dut.qsfp1_tx_clk_3, dut.qsfp1_tx_rst_3) - - cocotb.start_soon(Clock(dut.qsfp1_rx_clk_4, 2.56, units="ns").start()) - self.qsfp1_4_source = XgmiiSource(dut.qsfp1_rxd_4, dut.qsfp1_rxc_4, dut.qsfp1_rx_clk_4, dut.qsfp1_rx_rst_4) - cocotb.start_soon(Clock(dut.qsfp1_tx_clk_4, 2.56, units="ns").start()) - self.qsfp1_4_sink = XgmiiSink(dut.qsfp1_txd_4, dut.qsfp1_txc_4, dut.qsfp1_tx_clk_4, dut.qsfp1_tx_rst_4) + for x in range(2): + sources = [] + sinks = [] + for y in range(1, 5): + cocotb.start_soon(Clock(getattr(dut, f"qsfp{x}_rx_clk_{y}"), 2.56, units="ns").start()) + source = XgmiiSource(getattr(dut, f"qsfp{x}_rxd_{y}"), getattr(dut, f"qsfp{x}_rxc_{y}"), getattr(dut, f"qsfp{x}_rx_clk_{y}"), getattr(dut, f"qsfp{x}_rx_rst_{y}")) + sources.append(source) + cocotb.start_soon(Clock(getattr(dut, f"qsfp{x}_tx_clk_{y}"), 2.56, units="ns").start()) + sink = XgmiiSink(getattr(dut, f"qsfp{x}_txd_{y}"), getattr(dut, f"qsfp{x}_txc_{y}"), getattr(dut, f"qsfp{x}_tx_clk_{y}"), getattr(dut, f"qsfp{x}_tx_rst_{y}")) + sinks.append(sink) + self.qsfp_source.append(sources) + self.qsfp_sink.append(sinks) dut.sw.setimmediatevalue(0) async def init(self): self.dut.rst.setimmediatevalue(0) - self.dut.qsfp0_rx_rst_1.setimmediatevalue(0) - self.dut.qsfp0_tx_rst_1.setimmediatevalue(0) - self.dut.qsfp0_rx_rst_2.setimmediatevalue(0) - self.dut.qsfp0_tx_rst_2.setimmediatevalue(0) - self.dut.qsfp0_rx_rst_3.setimmediatevalue(0) - self.dut.qsfp0_tx_rst_3.setimmediatevalue(0) - self.dut.qsfp0_rx_rst_4.setimmediatevalue(0) - self.dut.qsfp0_tx_rst_4.setimmediatevalue(0) - self.dut.qsfp1_rx_rst_1.setimmediatevalue(0) - self.dut.qsfp1_tx_rst_1.setimmediatevalue(0) - self.dut.qsfp1_rx_rst_2.setimmediatevalue(0) - self.dut.qsfp1_tx_rst_2.setimmediatevalue(0) - self.dut.qsfp1_rx_rst_3.setimmediatevalue(0) - self.dut.qsfp1_tx_rst_3.setimmediatevalue(0) - self.dut.qsfp1_rx_rst_4.setimmediatevalue(0) - self.dut.qsfp1_tx_rst_4.setimmediatevalue(0) + for x in range(2): + for y in range(1, 5): + getattr(self.dut, f"qsfp{x}_rx_rst_{y}").setimmediatevalue(0) + getattr(self.dut, f"qsfp{x}_tx_rst_{y}").setimmediatevalue(0) for k in range(10): await RisingEdge(self.dut.clk) self.dut.rst.value = 1 - self.dut.qsfp0_rx_rst_1.value = 1 - self.dut.qsfp0_tx_rst_1.value = 1 - self.dut.qsfp0_rx_rst_2.value = 1 - self.dut.qsfp0_tx_rst_2.value = 1 - self.dut.qsfp0_rx_rst_3.value = 1 - self.dut.qsfp0_tx_rst_3.value = 1 - self.dut.qsfp0_rx_rst_4.value = 1 - self.dut.qsfp0_tx_rst_4.value = 1 - self.dut.qsfp1_rx_rst_1.value = 1 - self.dut.qsfp1_tx_rst_1.value = 1 - self.dut.qsfp1_rx_rst_2.value = 1 - self.dut.qsfp1_tx_rst_2.value = 1 - self.dut.qsfp1_rx_rst_3.value = 1 - self.dut.qsfp1_tx_rst_3.value = 1 - self.dut.qsfp1_rx_rst_4.value = 1 - self.dut.qsfp1_tx_rst_4.value = 1 + for x in range(2): + for y in range(1, 5): + getattr(self.dut, f"qsfp{x}_rx_rst_{y}").value = 1 + getattr(self.dut, f"qsfp{x}_tx_rst_{y}").value = 1 for k in range(10): await RisingEdge(self.dut.clk) self.dut.rst.value = 0 - self.dut.qsfp0_rx_rst_1.value = 0 - self.dut.qsfp0_tx_rst_1.value = 0 - self.dut.qsfp0_rx_rst_2.value = 0 - self.dut.qsfp0_tx_rst_2.value = 0 - self.dut.qsfp0_rx_rst_3.value = 0 - self.dut.qsfp0_tx_rst_3.value = 0 - self.dut.qsfp0_rx_rst_4.value = 0 - self.dut.qsfp0_tx_rst_4.value = 0 - self.dut.qsfp1_rx_rst_1.value = 0 - self.dut.qsfp1_tx_rst_1.value = 0 - self.dut.qsfp1_rx_rst_2.value = 0 - self.dut.qsfp1_tx_rst_2.value = 0 - self.dut.qsfp1_rx_rst_3.value = 0 - self.dut.qsfp1_tx_rst_3.value = 0 - self.dut.qsfp1_rx_rst_4.value = 0 - self.dut.qsfp1_tx_rst_4.value = 0 + for x in range(2): + for y in range(1, 5): + getattr(self.dut, f"qsfp{x}_rx_rst_{y}").value = 0 + getattr(self.dut, f"qsfp{x}_tx_rst_{y}").value = 0 @cocotb.test() @@ -170,11 +110,11 @@ async def run_test(dut): test_frame = XgmiiFrame.from_payload(test_pkt.build()) - await tb.qsfp0_1_source.send(test_frame) + await tb.qsfp_source[0][0].send(test_frame) tb.log.info("receive ARP request") - rx_frame = await tb.qsfp0_1_sink.recv() + rx_frame = await tb.qsfp_sink[0][0].recv() rx_pkt = Ether(bytes(rx_frame.get_payload())) @@ -202,11 +142,11 @@ async def run_test(dut): resp_frame = XgmiiFrame.from_payload(resp_pkt.build()) - await tb.qsfp0_1_source.send(resp_frame) + await tb.qsfp_source[0][0].send(resp_frame) tb.log.info("receive UDP packet") - rx_frame = await tb.qsfp0_1_sink.recv() + rx_frame = await tb.qsfp_sink[0][0].recv() rx_pkt = Ether(bytes(rx_frame.get_payload())) diff --git a/example/ZCU102/fpga/tb/fpga_core/test_fpga_core.py b/example/ZCU102/fpga/tb/fpga_core/test_fpga_core.py index 78aca5d74..3986ebb17 100644 --- a/example/ZCU102/fpga/tb/fpga_core/test_fpga_core.py +++ b/example/ZCU102/fpga/tb/fpga_core/test_fpga_core.py @@ -48,25 +48,16 @@ class TB: cocotb.start_soon(Clock(dut.clk, 6.4, units="ns").start()) # Ethernet - cocotb.start_soon(Clock(dut.sfp0_rx_clk, 6.4, units="ns").start()) - self.sfp0_source = XgmiiSource(dut.sfp0_rxd, dut.sfp0_rxc, dut.sfp0_rx_clk, dut.sfp0_rx_rst) - cocotb.start_soon(Clock(dut.sfp0_tx_clk, 6.4, units="ns").start()) - self.sfp0_sink = XgmiiSink(dut.sfp0_txd, dut.sfp0_txc, dut.sfp0_tx_clk, dut.sfp0_tx_rst) + self.sfp_source = [] + self.sfp_sink = [] - cocotb.start_soon(Clock(dut.sfp1_rx_clk, 6.4, units="ns").start()) - self.sfp1_source = XgmiiSource(dut.sfp1_rxd, dut.sfp1_rxc, dut.sfp1_rx_clk, dut.sfp1_rx_rst) - cocotb.start_soon(Clock(dut.sfp1_tx_clk, 6.4, units="ns").start()) - self.sfp1_sink = XgmiiSink(dut.sfp1_txd, dut.sfp1_txc, dut.sfp1_tx_clk, dut.sfp1_tx_rst) - - cocotb.start_soon(Clock(dut.sfp2_rx_clk, 6.4, units="ns").start()) - self.sfp2_source = XgmiiSource(dut.sfp2_rxd, dut.sfp2_rxc, dut.sfp2_rx_clk, dut.sfp2_rx_rst) - cocotb.start_soon(Clock(dut.sfp2_tx_clk, 6.4, units="ns").start()) - self.sfp2_sink = XgmiiSink(dut.sfp2_txd, dut.sfp2_txc, dut.sfp2_tx_clk, dut.sfp2_tx_rst) - - cocotb.start_soon(Clock(dut.sfp3_rx_clk, 6.4, units="ns").start()) - self.sfp3_source = XgmiiSource(dut.sfp3_rxd, dut.sfp3_rxc, dut.sfp3_rx_clk, dut.sfp3_rx_rst) - cocotb.start_soon(Clock(dut.sfp3_tx_clk, 6.4, units="ns").start()) - self.sfp3_sink = XgmiiSink(dut.sfp3_txd, dut.sfp3_txc, dut.sfp3_tx_clk, dut.sfp3_tx_rst) + for y in range(4): + cocotb.start_soon(Clock(getattr(dut, f"sfp{y}_rx_clk"), 6.4, units="ns").start()) + source = XgmiiSource(getattr(dut, f"sfp{y}_rxd"), getattr(dut, f"sfp{y}_rxc"), getattr(dut, f"sfp{y}_rx_clk"), getattr(dut, f"sfp{y}_rx_rst")) + self.sfp_source.append(source) + cocotb.start_soon(Clock(getattr(dut, f"sfp{y}_tx_clk"), 6.4, units="ns").start()) + sink = XgmiiSink(getattr(dut, f"sfp{y}_txd"), getattr(dut, f"sfp{y}_txc"), getattr(dut, f"sfp{y}_tx_clk"), getattr(dut, f"sfp{y}_tx_rst")) + self.sfp_sink.append(sink) dut.btnu.setimmediatevalue(0) dut.btnl.setimmediatevalue(0) @@ -80,40 +71,25 @@ class TB: async def init(self): self.dut.rst.setimmediatevalue(0) - self.dut.sfp0_rx_rst.setimmediatevalue(0) - self.dut.sfp0_tx_rst.setimmediatevalue(0) - self.dut.sfp1_rx_rst.setimmediatevalue(0) - self.dut.sfp1_tx_rst.setimmediatevalue(0) - self.dut.sfp2_rx_rst.setimmediatevalue(0) - self.dut.sfp2_tx_rst.setimmediatevalue(0) - self.dut.sfp3_rx_rst.setimmediatevalue(0) - self.dut.sfp3_tx_rst.setimmediatevalue(0) + for y in range(4): + getattr(self.dut, f"sfp{y}_rx_rst").setimmediatevalue(0) + getattr(self.dut, f"sfp{y}_tx_rst").setimmediatevalue(0) for k in range(10): await RisingEdge(self.dut.clk) self.dut.rst.value = 1 - self.dut.sfp0_rx_rst.value = 1 - self.dut.sfp0_tx_rst.value = 1 - self.dut.sfp1_rx_rst.value = 1 - self.dut.sfp1_tx_rst.value = 1 - self.dut.sfp2_rx_rst.value = 1 - self.dut.sfp2_tx_rst.value = 1 - self.dut.sfp3_rx_rst.value = 1 - self.dut.sfp3_tx_rst.value = 1 + for y in range(4): + getattr(self.dut, f"sfp{y}_rx_rst").value = 1 + getattr(self.dut, f"sfp{y}_tx_rst").value = 1 for k in range(10): await RisingEdge(self.dut.clk) self.dut.rst.value = 0 - self.dut.sfp0_rx_rst.value = 0 - self.dut.sfp0_tx_rst.value = 0 - self.dut.sfp1_rx_rst.value = 0 - self.dut.sfp1_tx_rst.value = 0 - self.dut.sfp2_rx_rst.value = 0 - self.dut.sfp2_tx_rst.value = 0 - self.dut.sfp3_rx_rst.value = 0 - self.dut.sfp3_tx_rst.value = 0 + for y in range(4): + getattr(self.dut, f"sfp{y}_rx_rst").value = 0 + getattr(self.dut, f"sfp{y}_tx_rst").value = 0 @cocotb.test() @@ -133,11 +109,11 @@ async def run_test(dut): test_frame = XgmiiFrame.from_payload(test_pkt.build()) - await tb.sfp0_source.send(test_frame) + await tb.sfp_source[0].send(test_frame) tb.log.info("receive ARP request") - rx_frame = await tb.sfp0_sink.recv() + rx_frame = await tb.sfp_sink[0].recv() rx_pkt = Ether(bytes(rx_frame.get_payload())) @@ -165,11 +141,11 @@ async def run_test(dut): resp_frame = XgmiiFrame.from_payload(resp_pkt.build()) - await tb.sfp0_source.send(resp_frame) + await tb.sfp_source[0].send(resp_frame) tb.log.info("receive UDP packet") - rx_frame = await tb.sfp0_sink.recv() + rx_frame = await tb.sfp_sink[0].recv() rx_pkt = Ether(bytes(rx_frame.get_payload())) diff --git a/example/ZCU106/fpga/tb/fpga_core/test_fpga_core.py b/example/ZCU106/fpga/tb/fpga_core/test_fpga_core.py index 14a213b12..91d58d39d 100644 --- a/example/ZCU106/fpga/tb/fpga_core/test_fpga_core.py +++ b/example/ZCU106/fpga/tb/fpga_core/test_fpga_core.py @@ -48,15 +48,16 @@ class TB: cocotb.start_soon(Clock(dut.clk, 6.4, units="ns").start()) # Ethernet - cocotb.start_soon(Clock(dut.sfp0_rx_clk, 6.4, units="ns").start()) - self.sfp0_source = XgmiiSource(dut.sfp0_rxd, dut.sfp0_rxc, dut.sfp0_rx_clk, dut.sfp0_rx_rst) - cocotb.start_soon(Clock(dut.sfp0_tx_clk, 6.4, units="ns").start()) - self.sfp0_sink = XgmiiSink(dut.sfp0_txd, dut.sfp0_txc, dut.sfp0_tx_clk, dut.sfp0_tx_rst) + self.sfp_source = [] + self.sfp_sink = [] - cocotb.start_soon(Clock(dut.sfp1_rx_clk, 6.4, units="ns").start()) - self.sfp1_source = XgmiiSource(dut.sfp1_rxd, dut.sfp1_rxc, dut.sfp1_rx_clk, dut.sfp1_rx_rst) - cocotb.start_soon(Clock(dut.sfp1_tx_clk, 6.4, units="ns").start()) - self.sfp1_sink = XgmiiSink(dut.sfp1_txd, dut.sfp1_txc, dut.sfp1_tx_clk, dut.sfp1_tx_rst) + for y in range(2): + cocotb.start_soon(Clock(getattr(dut, f"sfp{y}_rx_clk"), 6.4, units="ns").start()) + source = XgmiiSource(getattr(dut, f"sfp{y}_rxd"), getattr(dut, f"sfp{y}_rxc"), getattr(dut, f"sfp{y}_rx_clk"), getattr(dut, f"sfp{y}_rx_rst")) + self.sfp_source.append(source) + cocotb.start_soon(Clock(getattr(dut, f"sfp{y}_tx_clk"), 6.4, units="ns").start()) + sink = XgmiiSink(getattr(dut, f"sfp{y}_txd"), getattr(dut, f"sfp{y}_txc"), getattr(dut, f"sfp{y}_tx_clk"), getattr(dut, f"sfp{y}_tx_rst")) + self.sfp_sink.append(sink) dut.btnu.setimmediatevalue(0) dut.btnl.setimmediatevalue(0) @@ -70,28 +71,25 @@ class TB: async def init(self): self.dut.rst.setimmediatevalue(0) - self.dut.sfp0_rx_rst.setimmediatevalue(0) - self.dut.sfp0_tx_rst.setimmediatevalue(0) - self.dut.sfp1_rx_rst.setimmediatevalue(0) - self.dut.sfp1_tx_rst.setimmediatevalue(0) + for y in range(2): + getattr(self.dut, f"sfp{y}_rx_rst").setimmediatevalue(0) + getattr(self.dut, f"sfp{y}_tx_rst").setimmediatevalue(0) for k in range(10): await RisingEdge(self.dut.clk) self.dut.rst.value = 1 - self.dut.sfp0_rx_rst.value = 1 - self.dut.sfp0_tx_rst.value = 1 - self.dut.sfp1_rx_rst.value = 1 - self.dut.sfp1_tx_rst.value = 1 + for y in range(2): + getattr(self.dut, f"sfp{y}_rx_rst").value = 1 + getattr(self.dut, f"sfp{y}_tx_rst").value = 1 for k in range(10): await RisingEdge(self.dut.clk) self.dut.rst.value = 0 - self.dut.sfp0_rx_rst.value = 0 - self.dut.sfp0_tx_rst.value = 0 - self.dut.sfp1_rx_rst.value = 0 - self.dut.sfp1_tx_rst.value = 0 + for y in range(2): + getattr(self.dut, f"sfp{y}_rx_rst").value = 0 + getattr(self.dut, f"sfp{y}_tx_rst").value = 0 @cocotb.test() @@ -111,11 +109,11 @@ async def run_test(dut): test_frame = XgmiiFrame.from_payload(test_pkt.build()) - await tb.sfp0_source.send(test_frame) + await tb.sfp_source[0].send(test_frame) tb.log.info("receive ARP request") - rx_frame = await tb.sfp0_sink.recv() + rx_frame = await tb.sfp_sink[0].recv() rx_pkt = Ether(bytes(rx_frame.get_payload())) @@ -143,11 +141,11 @@ async def run_test(dut): resp_frame = XgmiiFrame.from_payload(resp_pkt.build()) - await tb.sfp0_source.send(resp_frame) + await tb.sfp_source[0].send(resp_frame) tb.log.info("receive UDP packet") - rx_frame = await tb.sfp0_sink.recv() + rx_frame = await tb.sfp_sink[0].recv() rx_pkt = Ether(bytes(rx_frame.get_payload())) diff --git a/example/fb2CG/fpga_25g/tb/fpga_core/test_fpga_core.py b/example/fb2CG/fpga_25g/tb/fpga_core/test_fpga_core.py index 8a756fdb1..25b22280c 100644 --- a/example/fb2CG/fpga_25g/tb/fpga_core/test_fpga_core.py +++ b/example/fb2CG/fpga_25g/tb/fpga_core/test_fpga_core.py @@ -48,107 +48,47 @@ class TB: cocotb.start_soon(Clock(dut.clk, 2.56, units="ns").start()) # Ethernet - cocotb.start_soon(Clock(dut.qsfp_0_rx_clk_0, 2.56, units="ns").start()) - self.qsfp_0_0_source = XgmiiSource(dut.qsfp_0_rxd_0, dut.qsfp_0_rxc_0, dut.qsfp_0_rx_clk_0, dut.qsfp_0_rx_rst_0) - cocotb.start_soon(Clock(dut.qsfp_0_tx_clk_0, 2.56, units="ns").start()) - self.qsfp_0_0_sink = XgmiiSink(dut.qsfp_0_txd_0, dut.qsfp_0_txc_0, dut.qsfp_0_tx_clk_0, dut.qsfp_0_tx_rst_0) + self.qsfp_source = [] + self.qsfp_sink = [] - cocotb.start_soon(Clock(dut.qsfp_0_rx_clk_1, 2.56, units="ns").start()) - self.qsfp_0_1_source = XgmiiSource(dut.qsfp_0_rxd_1, dut.qsfp_0_rxc_1, dut.qsfp_0_rx_clk_1, dut.qsfp_0_rx_rst_1) - cocotb.start_soon(Clock(dut.qsfp_0_tx_clk_1, 2.56, units="ns").start()) - self.qsfp_0_1_sink = XgmiiSink(dut.qsfp_0_txd_1, dut.qsfp_0_txc_1, dut.qsfp_0_tx_clk_1, dut.qsfp_0_tx_rst_1) - - cocotb.start_soon(Clock(dut.qsfp_0_rx_clk_2, 2.56, units="ns").start()) - self.qsfp_0_2_source = XgmiiSource(dut.qsfp_0_rxd_2, dut.qsfp_0_rxc_2, dut.qsfp_0_rx_clk_2, dut.qsfp_0_rx_rst_2) - cocotb.start_soon(Clock(dut.qsfp_0_tx_clk_2, 2.56, units="ns").start()) - self.qsfp_0_2_sink = XgmiiSink(dut.qsfp_0_txd_2, dut.qsfp_0_txc_2, dut.qsfp_0_tx_clk_2, dut.qsfp_0_tx_rst_2) - - cocotb.start_soon(Clock(dut.qsfp_0_rx_clk_3, 2.56, units="ns").start()) - self.qsfp_0_3_source = XgmiiSource(dut.qsfp_0_rxd_3, dut.qsfp_0_rxc_3, dut.qsfp_0_rx_clk_3, dut.qsfp_0_rx_rst_3) - cocotb.start_soon(Clock(dut.qsfp_0_tx_clk_3, 2.56, units="ns").start()) - self.qsfp_0_3_sink = XgmiiSink(dut.qsfp_0_txd_3, dut.qsfp_0_txc_3, dut.qsfp_0_tx_clk_3, dut.qsfp_0_tx_rst_3) - - cocotb.start_soon(Clock(dut.qsfp_1_rx_clk_0, 2.56, units="ns").start()) - self.qsfp_1_0_source = XgmiiSource(dut.qsfp_1_rxd_0, dut.qsfp_1_rxc_0, dut.qsfp_1_rx_clk_0, dut.qsfp_1_rx_rst_0) - cocotb.start_soon(Clock(dut.qsfp_1_tx_clk_0, 2.56, units="ns").start()) - self.qsfp_1_0_sink = XgmiiSink(dut.qsfp_1_txd_0, dut.qsfp_1_txc_0, dut.qsfp_1_tx_clk_0, dut.qsfp_1_tx_rst_0) - - cocotb.start_soon(Clock(dut.qsfp_1_rx_clk_1, 2.56, units="ns").start()) - self.qsfp_1_1_source = XgmiiSource(dut.qsfp_1_rxd_1, dut.qsfp_1_rxc_1, dut.qsfp_1_rx_clk_1, dut.qsfp_1_rx_rst_1) - cocotb.start_soon(Clock(dut.qsfp_1_tx_clk_1, 2.56, units="ns").start()) - self.qsfp_1_1_sink = XgmiiSink(dut.qsfp_1_txd_1, dut.qsfp_1_txc_1, dut.qsfp_1_tx_clk_1, dut.qsfp_1_tx_rst_1) - - cocotb.start_soon(Clock(dut.qsfp_1_rx_clk_2, 2.56, units="ns").start()) - self.qsfp_1_2_source = XgmiiSource(dut.qsfp_1_rxd_2, dut.qsfp_1_rxc_2, dut.qsfp_1_rx_clk_2, dut.qsfp_1_rx_rst_2) - cocotb.start_soon(Clock(dut.qsfp_1_tx_clk_2, 2.56, units="ns").start()) - self.qsfp_1_2_sink = XgmiiSink(dut.qsfp_1_txd_2, dut.qsfp_1_txc_2, dut.qsfp_1_tx_clk_2, dut.qsfp_1_tx_rst_2) - - cocotb.start_soon(Clock(dut.qsfp_1_rx_clk_3, 2.56, units="ns").start()) - self.qsfp_1_3_source = XgmiiSource(dut.qsfp_1_rxd_3, dut.qsfp_1_rxc_3, dut.qsfp_1_rx_clk_3, dut.qsfp_1_rx_rst_3) - cocotb.start_soon(Clock(dut.qsfp_1_tx_clk_3, 2.56, units="ns").start()) - self.qsfp_1_3_sink = XgmiiSink(dut.qsfp_1_txd_3, dut.qsfp_1_txc_3, dut.qsfp_1_tx_clk_3, dut.qsfp_1_tx_rst_3) + for x in range(2): + sources = [] + sinks = [] + for y in range(4): + cocotb.start_soon(Clock(getattr(dut, f"qsfp_{x}_rx_clk_{y}"), 2.56, units="ns").start()) + source = XgmiiSource(getattr(dut, f"qsfp_{x}_rxd_{y}"), getattr(dut, f"qsfp_{x}_rxc_{y}"), getattr(dut, f"qsfp_{x}_rx_clk_{y}"), getattr(dut, f"qsfp_{x}_rx_rst_{y}")) + sources.append(source) + cocotb.start_soon(Clock(getattr(dut, f"qsfp_{x}_tx_clk_{y}"), 2.56, units="ns").start()) + sink = XgmiiSink(getattr(dut, f"qsfp_{x}_txd_{y}"), getattr(dut, f"qsfp_{x}_txc_{y}"), getattr(dut, f"qsfp_{x}_tx_clk_{y}"), getattr(dut, f"qsfp_{x}_tx_rst_{y}")) + sinks.append(sink) + self.qsfp_source.append(sources) + self.qsfp_sink.append(sinks) async def init(self): self.dut.rst.setimmediatevalue(0) - self.dut.qsfp_0_rx_rst_0.setimmediatevalue(0) - self.dut.qsfp_0_tx_rst_0.setimmediatevalue(0) - self.dut.qsfp_0_rx_rst_1.setimmediatevalue(0) - self.dut.qsfp_0_tx_rst_1.setimmediatevalue(0) - self.dut.qsfp_0_rx_rst_2.setimmediatevalue(0) - self.dut.qsfp_0_tx_rst_2.setimmediatevalue(0) - self.dut.qsfp_0_rx_rst_3.setimmediatevalue(0) - self.dut.qsfp_0_tx_rst_3.setimmediatevalue(0) - self.dut.qsfp_1_rx_rst_0.setimmediatevalue(0) - self.dut.qsfp_1_tx_rst_0.setimmediatevalue(0) - self.dut.qsfp_1_rx_rst_1.setimmediatevalue(0) - self.dut.qsfp_1_tx_rst_1.setimmediatevalue(0) - self.dut.qsfp_1_rx_rst_2.setimmediatevalue(0) - self.dut.qsfp_1_tx_rst_2.setimmediatevalue(0) - self.dut.qsfp_1_rx_rst_3.setimmediatevalue(0) - self.dut.qsfp_1_tx_rst_3.setimmediatevalue(0) + for x in range(2): + for y in range(4): + getattr(self.dut, f"qsfp_{x}_rx_rst_{y}").setimmediatevalue(0) + getattr(self.dut, f"qsfp_{x}_tx_rst_{y}").setimmediatevalue(0) for k in range(10): await RisingEdge(self.dut.clk) self.dut.rst.value = 1 - self.dut.qsfp_0_rx_rst_0.value = 1 - self.dut.qsfp_0_tx_rst_0.value = 1 - self.dut.qsfp_0_rx_rst_1.value = 1 - self.dut.qsfp_0_tx_rst_1.value = 1 - self.dut.qsfp_0_rx_rst_2.value = 1 - self.dut.qsfp_0_tx_rst_2.value = 1 - self.dut.qsfp_0_rx_rst_3.value = 1 - self.dut.qsfp_0_tx_rst_3.value = 1 - self.dut.qsfp_1_rx_rst_0.value = 1 - self.dut.qsfp_1_tx_rst_0.value = 1 - self.dut.qsfp_1_rx_rst_1.value = 1 - self.dut.qsfp_1_tx_rst_1.value = 1 - self.dut.qsfp_1_rx_rst_2.value = 1 - self.dut.qsfp_1_tx_rst_2.value = 1 - self.dut.qsfp_1_rx_rst_3.value = 1 - self.dut.qsfp_1_tx_rst_3.value = 1 + for x in range(2): + for y in range(4): + getattr(self.dut, f"qsfp_{x}_rx_rst_{y}").value = 1 + getattr(self.dut, f"qsfp_{x}_tx_rst_{y}").value = 1 for k in range(10): await RisingEdge(self.dut.clk) self.dut.rst.value = 0 - self.dut.qsfp_0_rx_rst_0.value = 0 - self.dut.qsfp_0_tx_rst_0.value = 0 - self.dut.qsfp_0_rx_rst_1.value = 0 - self.dut.qsfp_0_tx_rst_1.value = 0 - self.dut.qsfp_0_rx_rst_2.value = 0 - self.dut.qsfp_0_tx_rst_2.value = 0 - self.dut.qsfp_0_rx_rst_3.value = 0 - self.dut.qsfp_0_tx_rst_3.value = 0 - self.dut.qsfp_1_rx_rst_0.value = 0 - self.dut.qsfp_1_tx_rst_0.value = 0 - self.dut.qsfp_1_rx_rst_1.value = 0 - self.dut.qsfp_1_tx_rst_1.value = 0 - self.dut.qsfp_1_rx_rst_2.value = 0 - self.dut.qsfp_1_tx_rst_2.value = 0 - self.dut.qsfp_1_rx_rst_3.value = 0 - self.dut.qsfp_1_tx_rst_3.value = 0 + for x in range(2): + for y in range(4): + getattr(self.dut, f"qsfp_{x}_rx_rst_{y}").value = 0 + getattr(self.dut, f"qsfp_{x}_tx_rst_{y}").value = 0 @cocotb.test() @@ -168,11 +108,11 @@ async def run_test(dut): test_frame = XgmiiFrame.from_payload(test_pkt.build()) - await tb.qsfp_0_0_source.send(test_frame) + await tb.qsfp_source[0][0].send(test_frame) tb.log.info("receive ARP request") - rx_frame = await tb.qsfp_0_0_sink.recv() + rx_frame = await tb.qsfp_sink[0][0].recv() rx_pkt = Ether(bytes(rx_frame.get_payload())) @@ -200,11 +140,11 @@ async def run_test(dut): resp_frame = XgmiiFrame.from_payload(resp_pkt.build()) - await tb.qsfp_0_0_source.send(resp_frame) + await tb.qsfp_source[0][0].send(resp_frame) tb.log.info("receive UDP packet") - rx_frame = await tb.qsfp_0_0_sink.recv() + rx_frame = await tb.qsfp_sink[0][0].recv() rx_pkt = Ether(bytes(rx_frame.get_payload()))