-
Notifications
You must be signed in to change notification settings - Fork 0
/
RegIncr_test.py
60 lines (38 loc) · 1.23 KB
/
RegIncr_test.py
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#=========================================================================
# RegIncr_test
#=========================================================================
from pymtl import *
from RegIncr import RegIncr
# In py.test, unit tests are simply functions that begin with a "test_"
# prefix. PyMTL is setup to simplify dumping VCD. Simply specify
# "dump_vcd" as an argument to your unit test, and then you can dump VCD
# with the --dump-vcd option to py.test.
def test_basic( dump_vcd ):
# Elaborate the model
model = RegIncr()
model.vcd_file = dump_vcd
model.elaborate()
# Create and reset simulator
sim = SimulationTool( model )
sim.reset()
print ""
# Helper function
def t( in_, out ):
# Write input value to input port
model.in_.value = in_
# Ensure that all combinational concurrent blocks are called
sim.eval_combinational()
# Display a line trace
sim.print_line_trace()
# If reference output is not '?', verify value read from output port
if ( out != '?' ):
assert model.out == out
# Tick simulator one cycle
sim.cycle()
# Cycle-by-cycle tests
t( 0x00, '?' )
t( 0x13, 0x01 )
t( 0x27, 0x14 )
t( 0x00, 0x28 )
t( 0x00, 0x01 )
t( 0x00, 0x01 )