|
10 | 10 | import os
|
11 | 11 | import sys
|
12 | 12 | import math
|
13 |
| -import unittest |
14 | 13 | import tempfile
|
15 | 14 | import subprocess
|
16 | 15 |
|
|
24 | 23 |
|
25 | 24 | from ..stream import StreamInterface
|
26 | 25 | from ..interface.uart import UARTMultibyteTransmitter
|
27 |
| -from ..interface.spi import SPIDeviceInterface, SPIBus, SPIGatewareTestCase |
28 |
| -from ..test.utils import LunaGatewareTestCase, sync_test_case |
| 26 | +from ..interface.spi import SPIDeviceInterface, SPIBus |
29 | 27 |
|
30 | 28 |
|
31 | 29 | class IntegratedLogicAnalyzer(Elaboratable):
|
@@ -172,105 +170,6 @@ def elaborate(self, platform):
|
172 | 170 | return m
|
173 | 171 |
|
174 | 172 |
|
175 |
| -class IntegratedLogicAnalyzerTest(LunaGatewareTestCase): |
176 |
| - |
177 |
| - def instantiate_dut(self): |
178 |
| - self.input_a = Signal() |
179 |
| - self.input_b = Signal(30) |
180 |
| - self.input_c = Signal() |
181 |
| - |
182 |
| - return IntegratedLogicAnalyzer( |
183 |
| - signals=[self.input_a, self.input_b, self.input_c], |
184 |
| - sample_depth = 32 |
185 |
| - ) |
186 |
| - |
187 |
| - |
188 |
| - def initialize_signals(self): |
189 |
| - yield self.input_a .eq(0) |
190 |
| - yield self.input_b .eq(0) |
191 |
| - yield self.input_c .eq(0) |
192 |
| - |
193 |
| - |
194 |
| - def provide_all_signals(self, value): |
195 |
| - all_signals = Cat(self.input_a, self.input_b, self.input_c) |
196 |
| - yield all_signals.eq(value) |
197 |
| - |
198 |
| - |
199 |
| - def assert_sample_value(self, address, value): |
200 |
| - """ Helper that asserts a ILA sample has a given value. """ |
201 |
| - |
202 |
| - yield self.dut.captured_sample_number.eq(address) |
203 |
| - yield |
204 |
| - # Delay a clock to allow the block ram to latch the new value |
205 |
| - yield |
206 |
| - try: |
207 |
| - self.assertEqual((yield self.dut.captured_sample), value) |
208 |
| - return |
209 |
| - except AssertionError: |
210 |
| - pass |
211 |
| - |
212 |
| - # Generate an appropriate exception. |
213 |
| - actual_value = (yield self.dut.captured_sample) |
214 |
| - message = "assertion failed: at address 0x{:08x}: {:08x} != {:08x} (expected)".format(address, actual_value, value) |
215 |
| - raise AssertionError(message) |
216 |
| - |
217 |
| - |
218 |
| - @sync_test_case |
219 |
| - def test_sampling(self): |
220 |
| - |
221 |
| - # Quick helper that generates simple, repetitive samples. |
222 |
| - def sample_value(i): |
223 |
| - return i | (i << 8) | (i << 16) | (0xFF << 24) |
224 |
| - |
225 |
| - yield from self.provide_all_signals(0xDEADBEEF) |
226 |
| - yield |
227 |
| - |
228 |
| - # Before we trigger, we shouldn't be capturing any samples, |
229 |
| - # and we shouldn't be complete. |
230 |
| - self.assertEqual((yield self.dut.sampling), 0) |
231 |
| - self.assertEqual((yield self.dut.complete), 0) |
232 |
| - |
233 |
| - # Advance a bunch of cycles, and ensure we don't start sampling. |
234 |
| - yield from self.advance_cycles(10) |
235 |
| - self.assertEqual((yield self.dut.sampling), 0) |
236 |
| - |
237 |
| - # Set a new piece of data for a couple of cycles. |
238 |
| - yield from self.provide_all_signals(0x01234567) |
239 |
| - yield |
240 |
| - yield from self.provide_all_signals(0x89ABCDEF) |
241 |
| - yield |
242 |
| - |
243 |
| - # Finally, trigger the capture. |
244 |
| - yield from self.provide_all_signals(sample_value(0)) |
245 |
| - yield from self.pulse(self.dut.trigger, step_after=False) |
246 |
| - |
247 |
| - yield from self.provide_all_signals(sample_value(1)) |
248 |
| - yield |
249 |
| - |
250 |
| - # After we pulse our trigger strobe, we should be sampling. |
251 |
| - self.assertEqual((yield self.dut.sampling), 1) |
252 |
| - |
253 |
| - # Populate the memory with a variety of interesting signals; |
254 |
| - # and continue afterwards for a couple of cycles to make sure |
255 |
| - # these don't make it into our sample buffer. |
256 |
| - for i in range(2, 34): |
257 |
| - yield from self.provide_all_signals(sample_value(i)) |
258 |
| - yield |
259 |
| - |
260 |
| - # We now should be done with our sampling. |
261 |
| - self.assertEqual((yield self.dut.sampling), 0) |
262 |
| - self.assertEqual((yield self.dut.complete), 1) |
263 |
| - |
264 |
| - # Validate the memory values that were captured. |
265 |
| - for i in range(32): |
266 |
| - yield from self.assert_sample_value(i, sample_value(i)) |
267 |
| - |
268 |
| - # All of those reads shouldn't change our completeness. |
269 |
| - self.assertEqual((yield self.dut.sampling), 0) |
270 |
| - self.assertEqual((yield self.dut.complete), 1) |
271 |
| - |
272 |
| - |
273 |
| - |
274 | 173 | class SyncSerialILA(Elaboratable):
|
275 | 174 | """ Super-simple ILA that reads samples out over a simple unidirectional SPI.
|
276 | 175 | Create a receiver for this object by calling apollo_fpga.ila_receiver_for(<this>).
|
@@ -430,60 +329,6 @@ def elaborate(self, platform):
|
430 | 329 | return m
|
431 | 330 |
|
432 | 331 |
|
433 |
| -class SyncSerialReadoutILATest(SPIGatewareTestCase): |
434 |
| - |
435 |
| - def instantiate_dut(self): |
436 |
| - self.input_signal = Signal(12) |
437 |
| - return SyncSerialILA( |
438 |
| - signals=[self.input_signal], |
439 |
| - sample_depth=16, |
440 |
| - clock_polarity=1, |
441 |
| - clock_phase=0 |
442 |
| - ) |
443 |
| - |
444 |
| - def initialize_signals(self): |
445 |
| - yield self.input_signal.eq(0xF00) |
446 |
| - |
447 |
| - @sync_test_case |
448 |
| - def test_spi_readout(self): |
449 |
| - input_signal = self.input_signal |
450 |
| - |
451 |
| - # Trigger the test while offering our first sample. |
452 |
| - yield |
453 |
| - yield from self.pulse(self.dut.trigger, step_after=False) |
454 |
| - |
455 |
| - # Provide the remainder of our samples. |
456 |
| - for i in range(1, 16): |
457 |
| - yield input_signal.eq(0xF00 | i) |
458 |
| - yield |
459 |
| - |
460 |
| - # Wait a few cycles to account for delays in |
461 |
| - # the sampling pipeline. |
462 |
| - yield from self.advance_cycles(5) |
463 |
| - |
464 |
| - # We've now captured a full set of samples. |
465 |
| - # We'll test reading them out. |
466 |
| - self.assertEqual((yield self.dut.complete), 1) |
467 |
| - |
468 |
| - # Start the transaction, and exchange 16 bytes of data. |
469 |
| - yield self.dut.spi.cs.eq(1) |
470 |
| - yield |
471 |
| - |
472 |
| - # Read our our result over SPI... |
473 |
| - data = yield from self.spi_exchange_data(b"\0" * 32) |
474 |
| - |
475 |
| - # ... and ensure it matches what was sampled. |
476 |
| - i = 0 |
477 |
| - while data: |
478 |
| - datum = data[0:4] |
479 |
| - del data[0:4] |
480 |
| - |
481 |
| - expected = b"\x00\x00\x0f" + bytes([i]) |
482 |
| - self.assertEqual(datum, expected) |
483 |
| - i += 1 |
484 |
| - |
485 |
| - |
486 |
| - |
487 | 332 |
|
488 | 333 | class StreamILA(Elaboratable):
|
489 | 334 | """ Super-simple ILA that outputs its samples over a Stream.
|
@@ -674,53 +519,6 @@ def elaborate(self, platform):
|
674 | 519 |
|
675 | 520 | return m
|
676 | 521 |
|
677 |
| -class StreamILATest(LunaGatewareTestCase): |
678 |
| - |
679 |
| - def instantiate_dut(self): |
680 |
| - self.input_signal = Signal(12) |
681 |
| - return StreamILA( |
682 |
| - signals=[self.input_signal], |
683 |
| - sample_depth=16 |
684 |
| - ) |
685 |
| - |
686 |
| - def initialize_signals(self): |
687 |
| - yield self.input_signal.eq(0xF00) |
688 |
| - |
689 |
| - @sync_test_case |
690 |
| - def test_stream_readout(self): |
691 |
| - input_signal = self.input_signal |
692 |
| - stream = self.dut.stream |
693 |
| - |
694 |
| - # Trigger the ILA with the first sample |
695 |
| - yield |
696 |
| - yield from self.pulse(self.dut.trigger, step_after=False) |
697 |
| - |
698 |
| - # Fill up the ILA with the remaining samples |
699 |
| - for i in range(1, 16): |
700 |
| - yield input_signal.eq(0xF00 | i) |
701 |
| - yield |
702 |
| - |
703 |
| - # Wait a few cycles to allow the ILA to fully finish processing |
704 |
| - yield from self.advance_cycles(6) |
705 |
| - # Stream should now be presenting valid data |
706 |
| - self.assertEqual((yield stream.valid), 1) |
707 |
| - |
708 |
| - # Now we want to stream out the samples from the ILA |
709 |
| - yield stream.ready.eq(1) |
710 |
| - yield |
711 |
| - self.assertEqual((yield stream.first), 1) |
712 |
| - |
713 |
| - # Read out data from the stream until it signals completion |
714 |
| - data = [] |
715 |
| - while not (yield stream.last): |
716 |
| - if (yield stream.valid): |
717 |
| - data.append((yield stream.payload)) |
718 |
| - yield |
719 |
| - |
720 |
| - # Match read data to what should have been sampled |
721 |
| - for i, datum in enumerate(data): |
722 |
| - self.assertEqual(datum, 0xF00 | i) |
723 |
| - |
724 | 522 |
|
725 | 523 | class AsyncSerialILA(Elaboratable):
|
726 | 524 | """ Super-simple ILA that reads samples out over a UART connection.
|
@@ -1031,7 +829,3 @@ def _read_samples(self):
|
1031 | 829 | # Fetch all of our samples from the given device.
|
1032 | 830 | all_samples = self._port.read(total_to_read)
|
1033 | 831 | return list(self._split_samples(all_samples))
|
1034 |
| - |
1035 |
| - |
1036 |
| -if __name__ == "__main__": |
1037 |
| - unittest.main() |
0 commit comments