Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cxxsim: simulator-only signals not included in VCD and GTKWave files #556

Closed
cestrauss opened this issue Dec 8, 2020 · 4 comments
Closed

Comments

@cestrauss
Copy link

Simulator-only signals (not used in any Module) are useful to me for communicating between parallel processes, say between a main driver and a passive process simulating a RTL module.

They are also useful as a way to display some simulator state on the VCD.

Consider:

from nmigen import Signal, Module
from nmigen.sim import Simulator

m = Module()
s = Signal()
t = Signal()
m.d.sync += s.eq(1)


def process():
    yield t.eq(1)


sim = Simulator(m, engine="cxxsim")
sim.add_clock(1e-6)
sim.add_sync_process(process)
with sim.write_vcd("bug15.vcd", "bug15.gtkw", traces=[t]):
    sim.run()

Firstly, Signal t is absent from the VCD file, unlike pysim.
Secondly, I get the following stack trace:

$ python bug15.py
Traceback (most recent call last):
  File "bug15.py", line 18, in <module>
    sim.run()
  File "/usr/lib/python3.7/contextlib.py", line 119, in __exit__
    next(self.gen)
  File "/home/cstrauss/src/nmigen/nmigen/sim/cxxsim.py", line 279, in write_vcd
    gtkw_save.trace(".".join(self._state.names[signal]) + suffix)
  File "/home/cstrauss/src/nmigen/nmigen/hdl/ast.py", line 1561, in __getitem__
    return self._storage[key]
KeyError: <nmigen.hdl.ast.SignalKey (sig t)>
@whitequark
Copy link
Member

Ah, this was even a part of #324, but I think I accidentally dropped it at some point.

@cestrauss
Copy link
Author

To clarify, they actually work, they are just not included in the VCD file.

@whitequark
Copy link
Member

Yep, I even know the exact change needed to add them to the VCD files, I just forgot to apply it.

@whitequark whitequark added this to the 0.3 milestone Dec 12, 2020
@whitequark
Copy link
Member

whitequark commented Dec 12, 2020

Fixed in the cxxsim branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants