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

Unusual Display Behaviors #583

Closed
BracketMaster opened this issue Jan 27, 2021 · 4 comments
Closed

Unusual Display Behaviors #583

BracketMaster opened this issue Jan 27, 2021 · 4 comments
Labels

Comments

@BracketMaster
Copy link

Sometimes display will trigger twice(when it should trigger once) or once(when
it should trigger twice).

Below, I present a case where display should fire twice in state two:

from nmigen import Module, Display, Signal

m = Module()

sig = Signal()

with m.FSM(name="simple"):
    with m.State("one"):
        m.d.comb += Display("one")
        m.next = "two"
    with m.State("two"):
        m.d.comb += Display("two")
        m.next = "two"

from nmigen.sim import Simulator, Tick

sim = Simulator(m)
sim.add_clock(1e-6)

def process():
    yield Tick()

sim.add_sync_process(process)
sim.run()

evaluating this produces:

$ python3 test.py
one
two

where we expect:

$ python3 test.py
one
two
two

A counterexample:

By changing the following

    with m.State("two"):
        m.d.comb += Display("two")
        m.next = "two"

to

    with m.State("two"):
        m.d.comb += Display("two")
        m.next = "one"

we observe in the expected behavior of

$ python3 test.py
one
two
one
@BracketMaster
Copy link
Author

after further investigation, it seems that using Display within sync is more reliable

@whitequark
Copy link
Member

This is generally expected behavior for comb Display.

@BracketMaster
Copy link
Author

Alright. I think I agree.

@whitequark
Copy link
Member

Once there is a sink for Display-produced events I think you will be able to post-process them to make sure only one fires during a given simulation time instant.

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

No branches or pull requests

2 participants