litex/examples/basic/fsm.py

16 lines
454 B
Python
Raw Normal View History

2012-01-09 10:28:48 -05:00
from migen.fhdl.structure import *
2013-03-12 11:45:28 -04:00
from migen.fhdl.module import Module
2012-01-09 10:28:48 -05:00
from migen.fhdl import verilog
2013-02-22 17:19:37 -05:00
from migen.genlib.fsm import FSM
2012-01-09 10:28:48 -05:00
2013-03-12 11:45:28 -04:00
class Example(Module):
def __init__(self):
self.s = Signal()
myfsm = FSM("FOO", "BAR")
self.submodules += myfsm
myfsm.act(myfsm.FOO, self.s.eq(1), myfsm.next_state(myfsm.BAR))
myfsm.act(myfsm.BAR, self.s.eq(0), myfsm.next_state(myfsm.FOO))
example = Example()
print(verilog.convert(example, {example.s}))