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

Functions

 SendReceiveSynchronizer_test (dut)
 

Function Documentation

◆ SendReceiveSynchronizer_test()

test_SendReceiveSynchronizer.SendReceiveSynchronizer_test ( dut)
Test SendReceiveSynchronizer module
49async def SendReceiveSynchronizer_test(dut):
50 """Test SendReceiveSynchronizer module"""
51
52 global DEFAULT_CONFIGURATION_INITIALIZED_MEMORY_SIZE
53
54 #
55 # Assert initial output is unknown
56 #
57 assert LogicArray(dut.io_psOutInterrupt.value) == LogicArray("X")
58 assert LogicArray(dut.io_rdWrAddr.value) == LogicArray("XXXXXXXXXXXXX")
59 assert LogicArray(dut.io_wrEna.value) == LogicArray("X")
60 assert LogicArray(dut.io_wrData.value) == LogicArray("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
61 assert LogicArray(dut.io_requestedActionOfThePacketOutput.value) == LogicArray("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
62 assert LogicArray(dut.io_requestedActionOfThePacketOutputValid.value) == LogicArray("X")
63 assert LogicArray(dut.io_dataValidOutput.value) == LogicArray("X")
64 assert LogicArray(dut.io_receivingData.value) == LogicArray("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
65 assert LogicArray(dut.io_sendWaitForBuffer.value) == LogicArray("X")
66
67 clock = Clock(dut.clock, 10, units="ns") # Create a 10ns period clock on port clock
68
69 #
70 # Start the clock. Start it low to avoid issues on the first RisingEdge
71 #
72 cocotb.start_soon(clock.start(start_high=False))
73
74 dut._log.info("Initialize and reset module")
75
76 #
77 # Initial values
78 #
79 dut.io_en.value = 0
80 dut.io_beginSendingBuffer.value = 0
81 dut.io_noNewDataSender.value = 0
82 dut.io_dataValidInput.value = 0
83 dut.io_readNextData.value = 0
84 dut.io_noNewDataReceiver.value = 0
85 dut.io_plInSignal.value = 0
86 dut.io_requestedActionOfThePacketInput.value = 0
87 dut.io_requestedActionOfThePacketInput.value = 0
88
89 #
90 # Reset DUT
91 #
92 dut.reset.value = 1
93 for _ in range(10):
94 await Timer(10, units="ns")
95 dut.reset.value = 0
96
97 dut._log.info("Enabling chip")
98
99 #
100 # Enable chip
101 #
102 dut.io_en.value = 1
103
104 for test_number in range(10):
105
106
111
112 dut._log.info("Enable receiving data on the chip (" + str(test_number) + ")")
113
114 #
115 # Tell the receiver to start receiving data (This mainly operates based on
116 # a rising-edge detector, so we'll need to make it low)
117 #
118 dut.io_plInSignal.value = 1
119 await Timer(10, units="ns")
120 dut.io_plInSignal.value = 0
121
122 #
123 # Activate sending logic to test whether the chip fails synchronizing signals or not
124 #
125 dut.io_beginSendingBuffer.value = 1
126 await Timer(10, units="ns")
127 dut.io_beginSendingBuffer.value = 0
128
129 #
130 # Wait until the receive operation is done (finished)
131 #
132 for i in range(30):
133
134 match dut.io_rdWrAddr.value:
135
136 #
137 # For the PS data range
138 #
139 case 0x0: # checksum
140 dut.io_rdData.value = 0x00001234
141 case 0x8: # indicator
142 dut.io_rdData.value = 0x48595045 # first 32 bits of the indicator
143 case 0x10: # type
144 dut.io_rdData.value = 0x4 # debugger to hardware packet (DEBUGGER_TO_DEBUGGEE_HARDWARE_LEVEL)
145 case 0x14: # requested action
146 dut.io_rdData.value = 0x14141414
147 case 0x18: # General output
148 dut.io_rdData.value = 0x18181818
149 case 0x1c: # General output
150 dut.io_rdData.value = 0x1c1c1c1c
151 case 0x20: # General output
152 dut.io_rdData.value = 0x20202020
153 case 0x24: # General output
154 dut.io_rdData.value = 0x24242424
155 case 0x28: # General output
156 dut.io_rdData.value = 0x28282828
157 case 0x2c: # General output
158 dut.io_rdData.value = 0x2c2c2c2c
159 case 0x30: # General output
160 dut.io_rdData.value = 0x30303030
161 case 0x34: # General output
162 dut.io_rdData.value = 0x34343434
163 case 0x38: # General output
164 dut.io_rdData.value = 0x38383838
165 case 0x3c: # General output
166 dut.io_rdData.value = 0x3c3c3c3c
167 case 0x40: # General output
168 dut.io_rdData.value = 0x40404040
169 case 0x44: # General output
170 dut.io_rdData.value = 0x44444444
171 case 0x48: # General output
172 dut.io_rdData.value = 0x48484848
173 case 0x4c: # General output
174 dut.io_rdData.value = 0x4c4c4c4c
175 case 0x50: # General output
176 dut.io_rdData.value = 0x50505050
177
178 #
179 # For the PL data range
180 #
181 case 0x1000: # checksum
182 dut.io_rdData.value = 0x10001000
183 case 0x1008: # indicator 1
184 dut.io_rdData.value = 0x48595045 # The first 32 bits of the indicator
185 case 0x100c: # indicator 2
186 dut.io_rdData.value = 0x100c100c # The second 32 bits of the indicator
187 case 0x1010: # type
188 dut.io_rdData.value = 0x4 # debugger to hardware packet (DEBUGGER_TO_DEBUGGEE_HARDWARE_LEVEL)
189 case 0x1014: # requested action
190 dut.io_rdData.value = 0x10141014
191 case 0x1018: # General output
192 dut.io_rdData.value = 0x10181018
193 case 0x101c: # General output
194 dut.io_rdData.value = 0x101c101c
195 case 0x1020: # General output
196 dut.io_rdData.value = 0x10201020
197 case 0x1024: # General output
198 dut.io_rdData.value = 0x10241024
199 case 0x1028: # General output
200 dut.io_rdData.value = 0x10281028
201 case 0x102c: # General output
202 dut.io_rdData.value = 0x102c102c
203 case 0x1030: # General output
204 dut.io_rdData.value = 0x10301030
205 case 0x1034: # General output
206 dut.io_rdData.value = 0x10341034
207 case 0x1038: # General output
208 dut.io_rdData.value = 0x10381038
209 case 0x103c: # General output
210 dut.io_rdData.value = 0x103c103c
211 case 0x1040: # General output
212 dut.io_rdData.value = 0x10401040
213 case 0x1044: # General output
214 dut.io_rdData.value = 0x10441044
215 case 0x1048: # General output
216 dut.io_rdData.value = 0x10481048
217 case 0x104c: # General output
218 dut.io_rdData.value = 0x104c104c
219 case 0x1050: # General output
220 dut.io_rdData.value = 0x10501050
221 case _:
222 assert 1 == 2, "invalid address in the address line"
223
224 if dut.io_requestedActionOfThePacketOutputValid.value == 1:
225
226 #
227 # No new data needed to be received
228 #
229 if test_number % 3 == 0:
230 dut.io_noNewDataReceiver.value = 1
231 await Timer(10, units="ns")
232 dut.io_noNewDataReceiver.value = 0
233 else:
234 #
235 # Make change to the io_readNextData signal as it operates mainly
236 # based on a rising-edge detector
237 #
238 if dut.io_readNextData.value == 0:
239 dut.io_readNextData.value = 1
240 else:
241 dut.io_readNextData.value = 0
242
243 #
244 # Go to the next clock cycle
245 #
246 await Timer(10, units="ns")
247
248
249 if test_number % 3 != 0:
250 dut.io_noNewDataReceiver.value = 1
251 await Timer(10, units="ns")
252 dut.io_noNewDataReceiver.value = 0
253
254 #
255 # Run extra waiting clocks
256 #
257 for _ in range(10):
258 await Timer(10, units="ns")
259
260
265
266 dut._log.info("Enable sending data on the chip (" + str(test_number) + ")")
267
268 #
269 # There is data to send
270 #
271 dut.io_noNewDataSender.value = 0
272 dut.io_beginSendingBuffer.value = 0
273
274 #
275 # Tell the sender to start sending data (This mainly operates based on
276 # a rising-edge detector, so we'll need to make it low)
277 #
278 dut.io_beginSendingBuffer.value = 1
279 await Timer(10, units="ns")
280 dut.io_beginSendingBuffer.value = 0
281
282 #
283 # Activate receiving logic to test whether the chip fails synchronizing signals or not
284 #
285 dut.io_plInSignal.value = 1
286 await Timer(10, units="ns")
287 dut.io_plInSignal.value = 0
288
289 #
290 # No new data at this stage
291 #
292 dut.io_dataValidInput.value = 0
293 dut.io_sendingData.value = 0
294
295 #
296 # Adjust the requested action of the packet
297 #
298 dut.io_requestedActionOfThePacketInput.value = 0x55859555
299
300 #
301 # Synchronize with the clock. This will apply the initial values
302 #
303 await Timer(10, units="ns")
304
305 #
306 # This will change the behavior of the data producer to only
307 # generate extra data for 2 of the test case rounds, the third
308 # test case doesn't have any extra data
309 #
310 if test_number % 3 != 0 :
311 #
312 # Run until the module asks for further buffers
313 #
314 for i in range(100):
315 if dut.io_sendWaitForBuffer.value == 1:
316 val = random.randint(0, 0xffffffff)
317
318 #
319 # Indicate that the data is valid
320 #
321 dut.io_dataValidInput.value = 1
322
323 #
324 # Assign the random value to send as the data
325 #
326 dut.io_sendingData.value = val
327
328 await Timer(10, units="ns")
329
330 #
331 # Now, tell the sender module that there is no longer needed to send data
332 #
333 for i in range(100):
334 if dut.io_sendWaitForBuffer.value == 1:
335 dut.io_noNewDataSender.value = 1
336 await Timer(10, units="ns")
337 dut.io_noNewDataSender.value = 0
338 break
339
340 await Timer(10, units="ns")
341
342
343 #
344 # Run extra waiting clocks
345 #
346 for _ in range(10):
347 await Timer(10, units="ns")
348
349 #
350 # Check the final input on the next clock
351 #
352 await Timer(10, units="ns")