From: Robert Jördens Date: Mon, 22 Jul 2013 08:09:12 +0000 (-0600) Subject: fsm.py: set reset_state X-Git-Tag: 24jan2021_ls180~2099^2~515 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=5bc9a0b38345c145f2bacf2442a076cfe0f7e37f;p=litex.git fsm.py: set reset_state --- diff --git a/migen/genlib/fsm.py b/migen/genlib/fsm.py index 7765f152..5fa577d9 100644 --- a/migen/genlib/fsm.py +++ b/migen/genlib/fsm.py @@ -30,10 +30,10 @@ class _LowerNextState(NodeTransformer): return node class FSM(Module): - def __init__(self): + def __init__(self, reset_state=None): self.actions = OrderedDict() self.state_aliases = dict() - self.reset_state = None + self.reset_state = reset_state def act(self, state, *statements): if self.finalized: @@ -62,6 +62,8 @@ class FSM(Module): self.encoding = dict((s, n) for n, s in enumerate(self.actions.keys())) self.state = Signal(max=nstates) + if self.reset_state is not None: + self.state.reset = self.encoding[self.reset_state] self.next_state = Signal(max=nstates) lns = _LowerNextState(self.next_state, self.encoding, self.state_aliases)