2013-04-24 13:13:36 -04:00
|
|
|
from random import Random
|
|
|
|
|
2015-09-12 07:34:07 -04:00
|
|
|
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
|
|
|
|
2015-09-12 03:14:21 -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)))
|
2015-09-20 03:04:15 -04:00
|
|
|
yield dut.ce.eq(prng.getrandbits(1))
|
2015-09-12 03:14:21 -04:00
|
|
|
yield
|
2013-04-24 13:13:36 -04:00
|
|
|
|
|
|
|
|
2014-01-26 16:19:43 -05:00
|
|
|
if __name__ == "__main__":
|
2015-09-12 03:14:21 -04:00
|
|
|
dut = GrayCounter(3)
|
2015-09-21 09:20:31 -04:00
|
|
|
run_simulation(dut, tb(dut), vcd_name="graycounter.vcd")
|