Skip to content

Instantly share code, notes, and snippets.

@awygle
Last active January 28, 2020 07:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save awygle/00cca56b2d58185f3ab7112739588882 to your computer and use it in GitHub Desktop.
Save awygle/00cca56b2d58185f3ab7112739588882 to your computer and use it in GitHub Desktop.
from nmigen import *
import nmigen.back
from nmigen.cli import main
class MVCE(Elaboratable):
def __init__(self):
self.write_en = Signal()
def elaborate(self, platform):
m = Module()
with m.FSM() as fsm:
with m.State("A"):
with m.If(~self.write_en):
m.next = "B"
m.next = "C" # doesn't exist
with m.State("B"):
with m.If(self.write_en):
m.next = "A"
return m
if __name__ == "__main__":
m = MVCE()
main(m, ports=(m.write_en))
print(nmigen.back.verilog.convert(m, ports=[m.write_en]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment