File: test_lfsr24.py

package info (click to toggle)
myhdl 0.11-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 3,728 kB
  • sloc: python: 25,033; ansic: 2,203; makefile: 243; sh: 206
file content (43 lines) | stat: -rw-r--r-- 898 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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()