Skip to content

Commit

Permalink
cocotb: [TEST] add issue1
Browse files Browse the repository at this point in the history
Unexpected transaction are generated after pcie reset on DMA DOWN MVB/MFB
  • Loading branch information
martinspinler committed Jun 13, 2024
1 parent a2310fe commit 62cc6fb
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tests/cocotb/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,9 @@ ROOT_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))

all:
make TARGET=$(SIM) -C $(CARD_DIR) PYTHONPATH=$$PYTHONPATH:$(ROOT_DIR) TOP_LEVEL_ENT=fpga

issues:
make COCOTB_MODULE=$(COCOTB_MODULE) TARGET=$(SIM) -C $(CARD_DIR) PYTHONPATH=$$PYTHONPATH:$(ROOT_DIR) TOP_LEVEL_ENT=fpga

issue1:
make issues COCOTB_MODULE=issues.$@ CARD=n6010
91 changes: 91 additions & 0 deletions tests/cocotb/issues/issue1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
import sys
import logging

import cocotb
import cocotb.utils
from cocotb.triggers import Timer, RisingEdge, Combine, Join, First, with_timeout

import cocotbext.ofm.utils.sim.modelsim as ms
import cocotbext.ofm.utils.sim.modelsim as ms

from cocotbext.ofm.utils.sim.bus import *
from cocotbext.ofm.utils.scapy import simple_tcp_bytes

from ndk_core import NFBDevice

print = ms.print

e = cocotb.external
st = cocotb.utils.get_sim_time

core = NFBDevice.core_instance_from_top(cocotb.top)


async def get_dev_init(dut):
dev = NFBDevice(dut)
await dev.init()
return dev, dev.nfb


async def _rx_pkts(dev, nfb):
for eth in nfb.eth:
await e(eth.rxmac.enable)()

await e(nfb.ndp.rx[0].start)()
await dev.dma.rx[0]._push_desc()

await Timer(2, units='us')

pkt = simple_tcp_bytes()

for i in range(10):
await dev._eth_rx_driver[0].write_packet(list(pkt))

@cocotb.test()
async def reset_pci_inside_pkt_rx(dut):
dev, nfb = await get_dev_init(dut)

for eth in nfb.eth:
await e(eth.rxmac.enable)()

await _rx_pkts(dev, nfb)
await dev._reset()
await _rx_pkts(dev, nfb)


pci_core = core.pcie_i.pcie_core_i
ms.cmd(f"log -recursive {ms.cocotb2path(core)}/*")

ms.add_wave(core.global_reset)
ms.add_wave(pci_core.PCIE_USER_RESET)
ms.add_wave(pci_core.PCIE_USER_CLK)

ms.add_wave(core.pcie_i.MI_CLK)
ms.add_wave(core.pcie_i.MI_RESET)

#ms.add_wave(core.dma_i.MI_CLK)
#ms.add_wave(core.dma_i.MI_RESET)

ms.add_wave(core.dma_i.DMA_CLK)
ms.add_wave(core.dma_i.DMA_RESET)

ms.add_wave(core.dma_i.USR_CLK)
ms.add_wave(core.dma_i.USR_RESET)

#ms.add_wave(core.dma_i.CROX_CLK)
#ms.add_wave(core.dma_i.CROX_RESET)


MfbBus(core.dma_i, 'RX_USR_MFB', 0, label='DMA RX_MFB').add_wave()
#MfbBus(core.dma_i, 'TX_USR_MFB', 0).add_wave()

#DmaUpMvbBus(core.dma_i, 'PCIE_RQ_MVB', 0).add_wave()
#MfbBus(core.dma_i, 'PCIE_RQ_MFB', 0).add_wave()

DmaDownMvbBus(core.dma_i, 'PCIE_RC_MVB', 0).add_wave()
MfbBus(core.dma_i, 'PCIE_RC_MFB', 0).add_wave()

#MfbBus(pci_core, 'RC_MFB', 0).add_wave()
#MfbBus(pci_core, 'RQ_MFB', 0).add_wave()
#MfbBus(pci_core, 'CC_MFB', 0).add_wave()
#MfbBus(pci_core, 'CQ_MFB', 0).add_wave()
1 change: 1 addition & 0 deletions tests/cocotb/prepare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ source venv-cocotb/bin/activate

python -m pip install cython wheel setuptools
python -m pip install pylibfdt fdt
python -m pip install scapy
python -m pip install $PKG_PYNFB
python -m pip install $PKG_LIBNFBEXT_PYTHON
python -m pip install $PKG_COCOTBEXT_OFM
Expand Down

0 comments on commit 62cc6fb

Please sign in to comment.