-
Notifications
You must be signed in to change notification settings - Fork 0
/
RegIncr2stage.py
44 lines (29 loc) · 948 Bytes
/
RegIncr2stage.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
#=========================================================================
# RegIncr2stage
#=========================================================================
# Two-stage registered incrementer that uses structural composition to
# instantitate and connect two instances of the single-stage registered
# incrementer.
from pymtl import *
from RegIncr import RegIncr
class RegIncr2stage( Model ):
# Constructor
def __init__( s ):
# Port-based interface
s.in_ = InPort ( Bits(8) )
s.out = OutPort ( Bits(8) )
# First stage
s.reg_incr_0 = RegIncr()
s.connect( s.in_, s.reg_incr_0.in_ )
# Second stage
s.reg_incr_1 = RegIncr()
s.connect( s.reg_incr_0.out, s.reg_incr_1.in_ )
s.connect( s.reg_incr_1.out, s.out )
# Line Tracing
def line_trace( s ):
return "{} ({}|{}) {}".format(
s.in_,
s.reg_incr_0.line_trace(),
s.reg_incr_1.line_trace(),
s.out
)