41async def DebuggerPacketReceiver_test(dut):
42 """Test DebuggerPacketReceiver module"""
43
44
45
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")
55
56
57
58
59 cocotb.start_soon(clock.start(start_high=False))
60
61 dut._log.info("Initialize and reset module")
62
63
64
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
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
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
92
93
94 dut.io_plInSignal.value = 1
95 await Timer(10, units="ns")
96 dut.io_plInSignal.value = 0
97
98
99
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:
108 dut.io_rdData.value = 0x00001234
109 case 0x8:
110 dut.io_rdData.value = 0x48595045
111 case 0x10:
112 dut.io_rdData.value = 0x4
113 case 0x14:
114 dut.io_rdData.value = 0x14141414
115 case 0x18:
116 dut.io_rdData.value = 0x18181818
117 case 0x1c:
118 dut.io_rdData.value = 0x1c1c1c1c
119 case 0x20:
120 dut.io_rdData.value = 0x20202020
121 case 0x24:
122 dut.io_rdData.value = 0x24242424
123 case 0x28:
124 dut.io_rdData.value = 0x28282828
125 case 0x2c:
126 dut.io_rdData.value = 0x2c2c2c2c
127 case 0x30:
128 dut.io_rdData.value = 0x30303030
129 case 0x34:
130 dut.io_rdData.value = 0x34343434
131 case 0x38:
132 dut.io_rdData.value = 0x38383838
133 case 0x3c:
134 dut.io_rdData.value = 0x3c3c3c3c
135 case 0x40:
136 dut.io_rdData.value = 0x40404040
137 case 0x44:
138 dut.io_rdData.value = 0x44444444
139 case 0x48:
140 dut.io_rdData.value = 0x48484848
141 case 0x4c:
142 dut.io_rdData.value = 0x4c4c4c4c
143 case 0x50:
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
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
160
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
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
180
181 for _ in range(10):
182 await Timer(10, units="ns")
183
184
185
186
187 await Timer(10, units="ns")