-
Notifications
You must be signed in to change notification settings - Fork 0
/
RegIncr.py
37 lines (25 loc) · 831 Bytes
/
RegIncr.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
#=========================================================================
# RegIncr
#=========================================================================
# This is a simple model for a registered incrementer. An eight-bit value
# is read from the input port, registered, incremented by one, and
# finally written to the output port.
from pymtl import *
class RegIncr( Model ):
# Constructor
def __init__( s ):
# Port-based interface
s.in_ = InPort ( Bits(8) )
s.out = OutPort ( Bits(8) )
# Concurrent block modeling register
s.reg_out = Wire( Bits(8) )
@s.tick
def block1():
if s.reset:
s.reg_out.next = 0
else:
s.reg_out.next = s.in_
# Concurrent block modeling incrementer
@s.combinational
def block2():
s.out.value = s.reg_out + 1