42async def DebuggerPacketSender_test(dut):
43 """Test DebuggerPacketSender module"""
44
45
46
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")
56
57
58
59
60 cocotb.start_soon(clock.start(start_high=False))
61
62 dut._log.info("Initialize and reset module")
63
64
65
66
67 dut.io_en.value = 0
68 dut.io_beginSendingBuffer.value = 0
69
70
71
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
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
91
92 dut.io_noNewDataSender.value = 0
93
94
95
96
97
98 dut.io_beginSendingBuffer.value = 1
99 await Timer(10, units="ns")
100 dut.io_beginSendingBuffer.value = 0
101
102
103
104
105 dut.io_dataValidInput.value = 0
106 dut.io_sendingData.value = 0
107
108
109
110
111 dut.io_requestedActionOfThePacketInput.value = 0x55859555
112
113
114
115
116 await Timer(10, units="ns")
117
118
119
120
121
122
123 if test_number % 3 != 0 :
124
125
126
127 for i in range(100):
128 if dut.io_sendWaitForBuffer.value == 1:
129 val = random.randint(0, 0xffffffff)
130
131
132
133
134 dut.io_dataValidInput.value = 1
135
136
137
138
139 dut.io_sendingData.value = val
140
141 await Timer(10, units="ns")
142
143
144
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
158
159 for _ in range(10):
160 await Timer(10, units="ns")
161
162
163
164
165 await Timer(10, units="ns")