Skip to content

Commit

Permalink
core: add FSM support (and example)
Browse files Browse the repository at this point in the history
  • Loading branch information
enjoy-digital committed Jul 20, 2018
1 parent 2ca58e4 commit bfd06f8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
13 changes: 13 additions & 0 deletions example_designs/targets/simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,19 @@ def __init__(self, platform):
self.cpu_or_bridge.wishbone
]

# fsm group
fsm = FSM(reset_state="STATE1")
self.submodules += fsm
fsm.act("STATE1",
NextState("STATE2")
)
fsm.act("STATE2",
NextState("STATE1")
)
analyzer_groups[2] = [
fsm
]

# analyzer
self.submodules.analyzer = LiteScopeAnalyzer(analyzer_groups, 512)

Expand Down
4 changes: 4 additions & 0 deletions litescope/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,10 @@ def format_groups(self, groups):
for s in signals:
if isinstance(s, Record):
split_signals.extend(s.flatten())
elif isinstance(s, FSM):
s.do_finalize()
s.finalized = True
split_signals.append(s.state)
else:
split_signals.append(s)
new_groups[n] = split_signals
Expand Down

0 comments on commit bfd06f8

Please sign in to comment.