|
15 | 15 | from cocotbext.ofm.ver.generators import random_packets
|
16 | 16 | from cocotb_bus.drivers import BitDriver
|
17 | 17 | from cocotb_bus.scoreboard import Scoreboard
|
| 18 | +from cocotbext.ofm.utils.throughput_probe import ThroughputProbe, ThroughputProbeMfbInterface |
18 | 19 |
|
19 | 20 |
|
20 | 21 | class testbench():
|
21 | 22 | def __init__(self, dut):
|
22 | 23 | self.dut = dut
|
23 |
| - self.RX_MFB = MFBDriver(dut, "RX", dut.CLK) |
| 24 | + |
| 25 | + mfb_params = { |
| 26 | + "regions" : dut.REGIONS.value, |
| 27 | + "region_size" : dut.REGION_SIZE.value, |
| 28 | + "block_size" : dut.BLOCK_SIZE.value, |
| 29 | + "item_width" : dut.ITEM_WIDTH.value |
| 30 | + } |
| 31 | + |
| 32 | + self.RX_MFB = MFBDriver(dut, "RX", dut.CLK, mfb_params=mfb_params) |
24 | 33 | self.backpressure = BitDriver(dut.TX_DST_RDY, dut.CLK)
|
25 |
| - self.TX_MFB = MFBMonitor(dut, "TX", dut.CLK) |
| 34 | + self.TX_MFB = MFBMonitor(dut, "TX", dut.CLK, mfb_params=mfb_params) |
| 35 | + |
| 36 | + # setting up the probe measuring throughput |
| 37 | + self.throughput_probe = ThroughputProbe(ThroughputProbeMfbInterface(self.TX_MFB), throughput_units="bits") |
| 38 | + self.throughput_probe.add_log_interval(0, None) |
| 39 | + self.throughput_probe.set_log_period(10) |
26 | 40 |
|
27 | 41 | # Create a scoreboard on the TX_MFB bus
|
28 | 42 | self.expected_output = []
|
@@ -66,4 +80,8 @@ async def run_test(dut, pkt_count=10000, frame_size_min=60, frame_size_max=512):
|
66 | 80 | # print("RX: %d/%d" % (tb.RX_MFB.frame_cnt, pkt_count))
|
67 | 81 | # print("TX: %d/%d" % (tb.TX_MFB.frame_cnt, pkt_count))
|
68 | 82 |
|
| 83 | + # logging values measured by throughput probe |
| 84 | + tb.throughput_probe.log_max_throughput() |
| 85 | + tb.throughput_probe.log_average_throughput() |
| 86 | + |
69 | 87 | raise tb.scoreboard.result
|
0 commit comments