HyperDbg Debugger
Loading...
Searching...
No Matches
test_DebuggerPacketSender Namespace Reference

Functions

 DebuggerPacketSender_test (dut)
 

Function Documentation

◆ DebuggerPacketSender_test()

test_DebuggerPacketSender.DebuggerPacketSender_test ( dut)
Test DebuggerPacketSender module
42async def DebuggerPacketSender_test(dut):
43 """Test DebuggerPacketSender module"""
44
45 #
46 # Assert initial output is unknown
47 #
48 assert LogicArray(dut.io_psOutInterrupt.value) == LogicArray("X")
49 assert LogicArray(dut.io_rdWrAddr.value) == LogicArray("XXXXXXXXXXXXX")
50 assert LogicArray(dut.io_wrEna.value) == LogicArray("X")
51 assert LogicArray(dut.io_wrData.value) == LogicArray("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
52 assert LogicArray(dut.io_sendWaitForBuffer.value) == LogicArray("X")
53 assert LogicArray(dut.io_finishedSendingBuffer.value) == LogicArray("X")
54
55 clock = Clock(dut.clock, 10, units="ns") # Create a 10ns period clock on port clock
56
57 #
58 # Start the clock. Start it low to avoid issues on the first RisingEdge
59 #
60 cocotb.start_soon(clock.start(start_high=False))
61
62 dut._log.info("Initialize and reset module")
63
64 #
65 # Initial values
66 #
67 dut.io_en.value = 0
68 dut.io_beginSendingBuffer.value = 0
69
70 #
71 # Reset DUT
72 #
73 dut.reset.value = 1
74 for _ in range(10):
75 await Timer(10, units="ns")
76 dut.reset.value = 0
77
78 dut._log.info("Enabling chip")
79
80 #
81 # Enable chip
82 #
83 dut.io_en.value = 1
84
85 for test_number in range(10):
86
87 dut._log.info("Enable sending data on the chip (" + str(test_number) + ")")
88
89 #
90 # Still there is data to send
91 #
92 dut.io_noNewDataSender.value = 0
93
94 #
95 # Tell the sender to start sending data (This mainly operates based on
96 # a rising-edge detector, so we'll need to make it low)
97 #
98 dut.io_beginSendingBuffer.value = 1
99 await Timer(10, units="ns")
100 dut.io_beginSendingBuffer.value = 0
101
102 #
103 # No new data at this stage
104 #
105 dut.io_dataValidInput.value = 0
106 dut.io_sendingData.value = 0
107
108 #
109 # Adjust the requested action of the packet
110 #
111 dut.io_requestedActionOfThePacketInput.value = 0x55859555
112
113 #
114 # Synchronize with the clock. This will apply the initial values
115 #
116 await Timer(10, units="ns")
117
118 #
119 # This will change the behavior of the data producer to only
120 # generate extra data for 2 of the test case rounds, the third
121 # test case doesn't have any extra data
122 #
123 if test_number % 3 != 0 :
124 #
125 # Run until the module asks for further buffers
126 #
127 for i in range(100):
128 if dut.io_sendWaitForBuffer.value == 1:
129 val = random.randint(0, 0xffffffff)
130
131 #
132 # Indicate that the data is valid
133 #
134 dut.io_dataValidInput.value = 1
135
136 #
137 # Assign the random value to send as the data
138 #
139 dut.io_sendingData.value = val
140
141 await Timer(10, units="ns")
142
143 #
144 # Now, tell the sender module that there is no longer needed to send data
145 #
146 for i in range(100):
147 if dut.io_sendWaitForBuffer.value == 1:
148 dut.io_noNewDataSender.value = 1
149 await Timer(10, units="ns")
150 dut.io_noNewDataSender.value = 0
151 break
152
153 await Timer(10, units="ns")
154
155
156 #
157 # Run extra waiting clocks
158 #
159 for _ in range(10):
160 await Timer(10, units="ns")
161
162 #
163 # Check the final input on the next clock
164 #
165 await Timer(10, units="ns")