litex/examples/basic/graycounter.py

19 lines
451 B
Python
Raw Normal View History

2013-04-24 13:13:36 -04:00
from random import Random
from migen import *
2013-04-24 13:13:36 -04:00
from migen.genlib.cdc import GrayCounter
2015-04-13 14:45:35 -04:00
def tb(dut):
prng = Random(7345)
for i in range(35):
print("{0:0{1}b} CE={2} bin={3}".format((yield dut.q),
2015-09-26 06:45:10 -04:00
len(dut.q), (yield dut.ce), (yield dut.q_binary)))
yield dut.ce.eq(prng.getrandbits(1))
yield
2013-04-24 13:13:36 -04:00
2014-01-26 16:19:43 -05:00
if __name__ == "__main__":
dut = GrayCounter(3)
2015-09-21 09:20:31 -04:00
run_simulation(dut, tb(dut), vcd_name="graycounter.vcd")