2013-05-22 11:11:09 -04:00
|
|
|
from migen.fhdl.std import *
|
2012-01-09 10:28:48 -05:00
|
|
|
from migen.fhdl import verilog
|
2013-06-25 16:17:39 -04:00
|
|
|
from migen.genlib.fsm import FSM, NextState
|
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()
|
2013-06-25 16:17:39 -04:00
|
|
|
myfsm = FSM()
|
2013-03-12 11:45:28 -04:00
|
|
|
self.submodules += myfsm
|
2013-06-25 16:17:39 -04:00
|
|
|
myfsm.act("FOO", self.s.eq(1), NextState("BAR"))
|
|
|
|
myfsm.act("BAR", self.s.eq(0), NextState("FOO"))
|
2013-11-21 14:44:01 -05:00
|
|
|
self.be = myfsm.before_entering("FOO")
|
|
|
|
self.ae = myfsm.after_entering("FOO")
|
|
|
|
self.bl = myfsm.before_leaving("FOO")
|
|
|
|
self.al = myfsm.after_leaving("FOO")
|
2013-03-12 11:45:28 -04:00
|
|
|
|
|
|
|
example = Example()
|
2013-11-21 14:44:01 -05:00
|
|
|
print(verilog.convert(example, {example.s, example.be, example.ae, example.bl, example.al}))
|