Closed yurivict closed 2 years ago
Thanks for your interest in using PyMTL3! I took a look at your example code. This is what your registered incrementer looks like:
#=========================================================================
# 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 pymtl3 import *
class RegIncr( Component ):
# Constructor
def construct( s ):
# Port-based interface
s.in_ = InPort ( Bits8 )
s.out = OutPort ( Bits8 )
# update_ff block modeling register
s.reg_out = Wire( 8 ) # 8 is the same as Bits8 for Wire/InPort/OutPort
@update_ff
def block1():
if s.reset:
s.reg_out <<= 0
else:
s.reg_out <<= s.in_
# update block modeling incrementer
@update
def block2():
s.out @= s.reg_out + 1
Notice how block2
is not indented correctly ... this is confusing the PyMTL3 framework since block2
is using an update
decorator but is not in a construct
method ... if you indent block2
as in Figure 8 it works:
#=========================================================================
# 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 pymtl3 import *
class RegIncr( Component ):
# Constructor
def construct( s ):
# Port-based interface
s.in_ = InPort ( Bits8 )
s.out = OutPort ( Bits8 )
# update_ff block modeling register
s.reg_out = Wire( 8 ) # 8 is the same as Bits8 for Wire/InPort/OutPort
@update_ff
def block1():
if s.reset:
s.reg_out <<= 0
else:
s.reg_out <<= s.in_
# update block modeling incrementer
@update
def block2():
s.out @= s.reg_out + 1
I'm trying the example from this lecture. Code from Figure 8 and Figure 9 there.
The code fails:
example.zip