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

Functions

 DebuggerPacketReceiver_test (dut)
 

Function Documentation

◆ DebuggerPacketReceiver_test()

test_DebuggerPacketReceiver.DebuggerPacketReceiver_test ( dut)
Test DebuggerPacketReceiver module
41async def DebuggerPacketReceiver_test(dut):
42 """Test DebuggerPacketReceiver module"""
43
44 #
45 # Assert initial output is unknown
46 #
47 assert LogicArray(dut.io_rdWrAddr.value) == LogicArray("XXXXXXXXXXXXX")
48 assert LogicArray(dut.io_requestedActionOfThePacketOutput.value) == LogicArray("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
49 assert LogicArray(dut.io_requestedActionOfThePacketOutputValid.value) == LogicArray("X")
50 assert LogicArray(dut.io_dataValidOutput.value) == LogicArray("X")
51 assert LogicArray(dut.io_receivingData.value) == LogicArray("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
52 assert LogicArray(dut.io_finishedReceivingBuffer.value) == LogicArray("X")
53
54 clock = Clock(dut.clock, 10, units="ns") # Create a 10ns period clock on port clock
55
56 #
57 # Start the clock. Start it low to avoid issues on the first RisingEdge
58 #
59 cocotb.start_soon(clock.start(start_high=False))
60
61 dut._log.info("Initialize and reset module")
62
63 #
64 # Initial values
65 #
66 dut.io_en.value = 0
67 dut.io_readNextData.value = 0
68 dut.io_noNewDataReceiver.value = 0
69 dut.io_plInSignal.value = 0
70
71 #
72 # Reset DUT
73 #
74 dut.reset.value = 1
75 for _ in range(10):
76 await Timer(10, units="ns")
77 dut.reset.value = 0
78
79 dut._log.info("Enabling chip")
80
81 #
82 # Enable chip
83 #
84 dut.io_en.value = 1
85
86 for test_number in range(10):
87
88 dut._log.info("Enable receiving data on the chip (" + str(test_number) + ")")
89
90 #
91 # Tell the receiver to start receiving data (This mainly operates based on
92 # a rising-edge detector, so we'll need to make it low)
93 #
94 dut.io_plInSignal.value = 1
95 await Timer(10, units="ns")
96 dut.io_plInSignal.value = 0
97
98 #
99 # Wait until the receive operation is done (finished)
100 #
101 for i in range(30):
102
103 if (dut.io_finishedReceivingBuffer.value == 1):
104 break
105 else:
106 match dut.io_rdWrAddr.value:
107 case 0x0: # checksum
108 dut.io_rdData.value = 0x00001234
109 case 0x8: # indicator
110 dut.io_rdData.value = 0x48595045 # first 32 bits of the indicator
111 case 0x10: # type
112 dut.io_rdData.value = 0x4 # debugger to hardware packet (DEBUGGER_TO_DEBUGGEE_HARDWARE_LEVEL)
113 case 0x14: # requested action
114 dut.io_rdData.value = 0x14141414
115 case 0x18: # General output
116 dut.io_rdData.value = 0x18181818
117 case 0x1c: # General output
118 dut.io_rdData.value = 0x1c1c1c1c
119 case 0x20: # General output
120 dut.io_rdData.value = 0x20202020
121 case 0x24: # General output
122 dut.io_rdData.value = 0x24242424
123 case 0x28: # General output
124 dut.io_rdData.value = 0x28282828
125 case 0x2c: # General output
126 dut.io_rdData.value = 0x2c2c2c2c
127 case 0x30: # General output
128 dut.io_rdData.value = 0x30303030
129 case 0x34: # General output
130 dut.io_rdData.value = 0x34343434
131 case 0x38: # General output
132 dut.io_rdData.value = 0x38383838
133 case 0x3c: # General output
134 dut.io_rdData.value = 0x3c3c3c3c
135 case 0x40: # General output
136 dut.io_rdData.value = 0x40404040
137 case 0x44: # General output
138 dut.io_rdData.value = 0x44444444
139 case 0x48: # General output
140 dut.io_rdData.value = 0x48484848
141 case 0x4c: # General output
142 dut.io_rdData.value = 0x4c4c4c4c
143 case 0x50: # General output
144 dut.io_rdData.value = 0x50505050
145 case _:
146 assert "invalid address in the address line"
147
148 if dut.io_requestedActionOfThePacketOutputValid.value == 1:
149
150 #
151 # No new data needed to be received
152 #
153 if test_number % 3 == 0:
154 dut.io_noNewDataReceiver.value = 1
155 await Timer(10, units="ns")
156 dut.io_noNewDataReceiver.value = 0
157 else:
158 #
159 # Make change to the io_readNextData signal as it operates mainly
160 # based on a rising-edge detector
161 #
162 if dut.io_readNextData.value == 0:
163 dut.io_readNextData.value = 1
164 else:
165 dut.io_readNextData.value = 0
166
167
168 #
169 # Go to the next clock cycle
170 #
171 await Timer(10, units="ns")
172
173 if test_number % 3 != 0:
174 dut.io_noNewDataReceiver.value = 1
175 await Timer(10, units="ns")
176 dut.io_noNewDataReceiver.value = 0
177
178 #
179 # Run extra waiting clocks
180 #
181 for _ in range(10):
182 await Timer(10, units="ns")
183
184 #
185 # Check the final input on the next clock
186 #
187 await Timer(10, units="ns")