This repository has been archived by the owner on May 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1fc8de3
commit 7b1fbef
Showing
7 changed files
with
220 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Makefile | ||
|
||
TOPLEVEL_LANG = verilog | ||
VERILOG_SOURCES = $(shell pwd)/../../../../generated/DebuggerPacketReceiver.sv | ||
TOPLEVEL = DebuggerPacketReceiver | ||
MODULE = test_DebuggerPacketReceiver | ||
|
||
include $(shell cocotb-config --makefiles)/Makefile.sim |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
make SIM=icarus WAVES=1 |
125 changes: 125 additions & 0 deletions
125
sim/hwdbg/communication/DebuggerPacketReceiver/test_DebuggerPacketReceiver.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
## | ||
# @file test_DebuggerPacketReceiver.py | ||
# | ||
# @author Sina Karvandi ([email protected]) | ||
# | ||
# @brief Testing module for DebuggerPacketReceiver | ||
# | ||
# @details | ||
# | ||
# @version 0.1 | ||
# | ||
# @date 2024-04-22 | ||
# | ||
# @copyright This project is released under the GNU Public License v3. | ||
# | ||
|
||
import random | ||
|
||
import cocotb | ||
from cocotb.clock import Clock | ||
from cocotb.triggers import RisingEdge | ||
from cocotb.types import LogicArray | ||
|
||
''' | ||
input clock, | ||
reset, | ||
io_en, | ||
io_plInSignal, | ||
output [12:0] io_rdWrAddr, | ||
input [31:0] io_rdData, | ||
output [31:0] io_requestedActionOfThePacketOutput, | ||
output io_requestedActionOfThePacketOutputValid, | ||
input io_noNewDataReceiver, | ||
io_readNextData, | ||
output io_dataValidOutput, | ||
output [31:0] io_receivingData, | ||
output io_finishedReceivingBuffer | ||
''' | ||
|
||
@cocotb.test() | ||
async def DebuggerPacketReceiver_test(dut): | ||
"""Test DebuggerPacketReceiver module""" | ||
|
||
# | ||
# Assert initial output is unknown | ||
# | ||
assert LogicArray(dut.io_rdWrAddr.value) == LogicArray("XXXXXXXXXXXXX") | ||
assert LogicArray(dut.io_requestedActionOfThePacketOutput.value) == LogicArray("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX") | ||
assert LogicArray(dut.io_requestedActionOfThePacketOutputValid.value) == LogicArray("X") | ||
assert LogicArray(dut.io_dataValidOutput.value) == LogicArray("X") | ||
assert LogicArray(dut.io_receivingData.value) == LogicArray("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX") | ||
assert LogicArray(dut.io_finishedReceivingBuffer.value) == LogicArray("X") | ||
|
||
clock = Clock(dut.clock, 10, units="ns") # Create a 10ns period clock on port clock | ||
|
||
# | ||
# Start the clock. Start it low to avoid issues on the first RisingEdge | ||
# | ||
cocotb.start_soon(clock.start(start_high=False)) | ||
|
||
dut._log.info("Initialize and reset module") | ||
|
||
# | ||
# Initial values | ||
# | ||
dut.io_en.value = 0 | ||
dut.io_plInSignal.value = 0 | ||
|
||
# | ||
# Reset DUT | ||
# | ||
dut.reset.value = 1 | ||
for _ in range(10): | ||
await RisingEdge(dut.clock) | ||
dut.reset.value = 0 | ||
|
||
dut._log.info("Enabling chip") | ||
|
||
# | ||
# Enable chip | ||
# | ||
dut.io_en.value = 1 | ||
|
||
for test_number in range(10): | ||
|
||
dut._log.info("Enable receiving data on the chip (" + str(test_number) + ")") | ||
|
||
# | ||
# Tell the receiver to start receiving data (This mainly operates based on | ||
# a rising-edge detector, so we'll need to make it low) | ||
# | ||
dut.io_plInSignal.value = 1 | ||
await RisingEdge(dut.clock) | ||
dut.io_plInSignal.value = 0 | ||
|
||
# | ||
# Wait until the data is received | ||
# | ||
for _ in range(1000): | ||
if (dut.io_dataValidOutput.value == 1): | ||
break | ||
else: | ||
match dut.io_rdWrAddr.value: | ||
case 0x0: # checksum | ||
dut.io_rdData.value = 0x00001234 | ||
case 0x8: # indicator | ||
dut.io_rdData.value = 0x88888888 | ||
case 0x10: # type | ||
dut.io_rdData.value = 0x10101010 | ||
case 0x14: # requested action | ||
dut.io_rdData.value = 0x14141414 | ||
case _: | ||
assert "invalid address in the address line" | ||
await RisingEdge(dut.clock) | ||
|
||
# | ||
# Run extra waiting clocks | ||
# | ||
for _ in range(10): | ||
await RisingEdge(dut.clock) | ||
|
||
# | ||
# Check the final input on the next clock | ||
# | ||
await RisingEdge(dut.clock) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.