Search code examples
pythonmyhdl

Why does this example from the myHDL manual give me different results?


Here is an example that I've copied from the myHDL manual. In my code the generator FSM() never gets invoked so the state is always 'SEARCH'.

I can't figure out why the generator is not getting called.

Edit:

Changing this line from:

reset = ResetSignal(0, active=ACTIVE_LOW, async=True)

to:

reset = ResetSignal(1, active=ACTIVE_LOW, async=True)

I think this is a bug in the example - if reset is ACTIVE_LOW it should be initialized to 1, not 0?

trace from my code

trace for working version


Solution

  • You need to release the reset signal. This line:

    reset = ResetSignal(0, active=ACTIVE_LOW, async=True)
    

    is correct as written in the example. The active low reset is (correctly) low at startup.

    The reason you have no activity is that you do not set the reset high (ie inactive) at any point.

    Update your stimulus function:

    def stimulus():
            for i in range(3):
                yield clk.posedge
            reset.next = 1
            for n in (12, 8, 8, 4):
    

    I would also call the reset signal reset_n to indicate clearly its active low nature.