Re: [myhdl-list] enums and non-local
Brought to you by:
jandecaluwe
From: Henry G. <he...@ca...> - 2015-02-11 16:17:56
|
On 11/02/15 15:47, Jose M. Gomez Cama wrote: > This is a piece of code that does not work. I think it is more or less equivalent to yours. > > > from myhdl import * > > def test(clk, reset, a, b): > t_state = enum("WAIT", "CALC") > state = Signal(t_state.WAIT) > @always_seq(clk.posedge, reset) > def fsm(): > if state == t_state.WAIT: > b.next = 0 > state.next = t_state.CALC > elif state == t_state.CALC: > a.next = b > state = t_state.WAIT > return fsm > > clk = Signal(intbv(0)[1:]) > reset = ResetSignal(1, active=1, async=False) > a = Signal(intbv(0)[1:]) > b = Signal(intbv(0)[1:]) > > toVHDL(test, clk, reset, a, b) > > The error is: > > Local variable may be referenced before assignment: state You're trying to assign state here: elif state == t_state.CALC: a.next = b state = t_state.WAIT Perhaps you want `state.next = t_state.WAIT`? Henry |