-
Notifications
You must be signed in to change notification settings - Fork 0
/
RegIncrRTL.py
49 lines (35 loc) · 1006 Bytes
/
RegIncrRTL.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
#=========================================================================
# RegIncrRTL
#=========================================================================
from pymtl3 import *
class RegIncrRTL( Component ):
def construct( s, nbits=4, incr_value=1 ):
s.in_ = InPort (nbits)
s.out = OutPort(nbits)
s.tmp = Wire( nbits )
@update_ff
def upblk_ff():
if s.reset:
s.tmp <<= 0
else:
s.tmp <<= s.in_
@update
def upblk_comb():
s.out @= s.tmp + incr_value
def line_trace( s ):
return f"{s.in_}(){s.out}"
#-------------------------------------------------------------------------
# main
#-------------------------------------------------------------------------
if __name__ == "__main__":
dut = RegIncrRTL(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()