From 5bc9a0b38345c145f2bacf2442a076cfe0f7e37f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20J=C3=B6rdens?= Date: Mon, 22 Jul 2013 02:09:12 -0600 Subject: [PATCH] fsm.py: set reset_state --- migen/genlib/fsm.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/migen/genlib/fsm.py b/migen/genlib/fsm.py index 7765f1521..5fa577d97 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)