litex/examples/basic/graycounter.py

20 lines
463 B
Python
Raw Normal View History

2013-04-24 13:13:36 -04:00
from random import Random
from migen.fhdl.std import *
2013-04-24 13:13:36 -04:00
from migen.genlib.cdc import GrayCounter
from migen.sim import Simulator
2013-04-24 13:13:36 -04:00
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),
flen(dut.q), (yield dut.ce), (yield dut.q_binary)))
yield dut.ce, 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)
Simulator(dut, tb(dut)).run()