Skip to content

ILA frontend print_samples() doesn't work when captured signals are Slices #107

@H-S-S-11

Description

@H-S-S-11

For example: capturing the lower 8 bits of a counter:

        counter = Signal(20)
        trigger = Signal()
        m.d.sync += [
            counter.eq(counter+1),
            trigger.eq(0),
        ]
        with m.If(counter==0):
            m.d.sync += [
                trigger.eq(~trigger),
            ]     
        m.submodules.serial_ila = self.serial_ila = serial_ila = AsyncSerialILA(
            signals=counter[0:8], sample_depth=100, divisor=10000, domain="sync")

When trying to print samples with AsyncSerialILAFrontend, the following error is seen:

>>> ila.print_samples()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\Harry\.pyenv\pyenv-win\versions\3.9.0\lib\site-packages\luna\gateware\debug\ila.py", line 831, in print_samples
    for timestamp, sample in self.enumerate_samples():
  File "C:\Users\Harry\.pyenv\pyenv-win\versions\3.9.0\lib\site-packages\luna\gateware\debug\ila.py", line 816, in enumerate_samples
    self.refresh()
  File "C:\Users\Harry\.pyenv\pyenv-win\versions\3.9.0\lib\site-packages\luna\gateware\debug\ila.py", line 808, in refresh
    self.samples = self._parse_samples(self._read_samples())
  File "C:\Users\Harry\.pyenv\pyenv-win\versions\3.9.0\lib\site-packages\luna\gateware\debug\ila.py", line 803, in _parse_samples
    return [self._parse_sample(sample) for sample in raw_samples]
  File "C:\Users\Harry\.pyenv\pyenv-win\versions\3.9.0\lib\site-packages\luna\gateware\debug\ila.py", line 803, in <listcomp>
    return [self._parse_sample(sample) for sample in raw_samples]
  File "C:\Users\Harry\.pyenv\pyenv-win\versions\3.9.0\lib\site-packages\luna\gateware\debug\ila.py", line 796, in _parse_sample
    sample[signal.name] = signal_bits
AttributeError: 'Slice' object has no attribute 'name'

This can be fixed by doing

count_low = Signal(8)
m.d.comb += count_low.eq(Cat(counter[0:8]))
m.submodules.serial_ila = self.serial_ila = serial_ila = AsyncSerialILA(
            signals=[count_low], sample_depth=100, divisor=10000, domain="sync")

I'm content if the answer is "user should Cat()" but this seems like a slightly non-obvious behaviour, and potentially the AsyncSerialILA could Cat() the signals itself. (Notably, just assigning the slice to it's signal and passing that as the signal to sample doesn't fix this: it has to be concatenated to be a Signal not a Slice)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions