1
0
mirror of https://github.com/myhdl/myhdl.git synced 2025-01-24 21:52:56 +08:00
myhdl/scripts/benchmark/test_lfsr24.py
2016-03-10 20:27:07 +01:00

44 lines
898 B
Python

from __future__ import absolute_import
import myhdl
from myhdl import *
from lfsr24 import lfsr24
def test_lfsr24():
lfsr = Signal(modbv(0)[24:])
enable = Signal(bool())
clock = Signal(bool())
reset = Signal(bool())
dut = lfsr24(lfsr, enable, clock, reset)
@instance
def stimulus():
enable.next = 0
clock.next = 0
reset.next = 0
yield delay(10)
reset.next = 1
yield delay(10)
reset.next = 0
enable.next = 1
for i in range(2**24 - 2):
yield delay(10)
clock.next = 1
yield delay(10)
clock.next = 0
assert lfsr != 1
yield delay(10)
clock.next = 1
yield delay(10)
assert lfsr == 1
return dut, stimulus
if __name__ == '__main__':
tb = Simulation(test_lfsr24())
tb.run()