vendor.lattice_{ecp5,machxo_2_3l}: remove -forceAll from Diamond scripts.
[nmigen.git] / examples / basic / ctr.py
1 from nmigen import *
2 from nmigen.cli import main
3
4
5 class Counter(Elaboratable):
6 def __init__(self, width):
7 self.v = Signal(width, reset=2**width-1)
8 self.o = Signal()
9
10 def elaborate(self, platform):
11 m = Module()
12 m.d.sync += self.v.eq(self.v + 1)
13 m.d.comb += self.o.eq(self.v[-1])
14 return m
15
16
17 ctr = Counter(width=16)
18 if __name__ == "__main__":
19 main(ctr, ports=[ctr.o])