-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRegIncrGL.py
46 lines (33 loc) · 1.05 KB
/
RegIncrGL.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
#=========================================================================
# RegIncrGL
#=========================================================================
from pymtl3 import *
from RippleCarryAdderGL import RippleCarryAdderGL
from RegGL import RegGL
class RegIncrGL( Component ):
def construct( s, nbits=4, Adder=RippleCarryAdderGL, incr_value=1 ):
s.in_ = InPort (nbits)
s.out = OutPort(nbits)
s.reg_ = RegGL(nbits)
s.incr = Adder(nbits)
s.reg_.in_ //= s.in_
s.incr.in0 //= s.reg_.out
s.incr.in1 //= incr_value
s.out //= s.incr.out
def line_trace( s ):
return f"{s.in_}(){s.out}"
#-------------------------------------------------------------------------
# main
#-------------------------------------------------------------------------
if __name__ == "__main__":
dut = RegIncrGL(incr_value=2)
dut.apply( DefaultPassGroup(textwave=True) )
dut.sim_reset()
dut.in_ @= 0
dut.sim_tick()
dut.in_ @= 4
dut.sim_tick()
dut.in_ @= 6
dut.sim_tick()
dut.sim_tick()
dut.print_textwave()