def construct(s): s.in_ = [InPort(int) for _ in range(2)] s.sel = InPort(int) s.out = OutPort(int) s.mux1 = Mux(int, 2)( in_={ 0: s.in_[0], 1: s.in_[1] }, sel=s.sel, ) s.mux2 = Mux(int, 2)( in_={ 0: s.in_[0], 1: s.in_[1] }, sel=s.sel, ) s.mux3 = Mux(int, 2)( out=s.out, in_={ 0: s.mux1.out, 1: s.mux2.out }, sel=s.sel, )
def construct(s, Type, ninputs): s.in_ = [InPort(Type) for _ in range(ninputs)] s.sel = InPort(mk_bits(clog2(ninputs))) s.out = OutPort(Type) @update def up_mux(): s.out @= s.in_[s.sel]
def construct( s, Type, ninputs ): s.in_ = [ InPort( Type ) for _ in range(ninputs) ] s.sel = InPort( int if Type is int else mk_bits( clog2(ninputs) ) ) s.out = OutPort( Type ) @s.update def up_mux(): s.out = s.in_[ s.sel ]
def construct(s): s.in_ = [InPort(32) for _ in range(2)] s.sel = InPort(1) s.out = OutPort(32) s.mux = Mux(Bits32, 2) s.mux.in_[0] //= s.in_[0] s.mux.in_[1] //= s.in_[1] s.mux.sel //= s.sel s.out //= s.mux.out
def construct(s): s.y = OutPort(Bits32) s.z = OutPort(Bits32) s.x = InPort(Bits32) s.y //= Bits32(1) s.z //= s.x
def construct(s): s.out = OutPort(int) # Wire is the same s.a = A()(out=s.out) s.in_ = InPort(int) connect(s.out, s.in_)
def construct(s): s.in_ = InPort(SomeMsg1) s.out1 = OutPort(SomeMsg2) s.out2 = OutPort(SomeMsg2) connect(s.in_.a, s.out1.c) connect(s.in_.b[0:8], s.out2.c)
def construct(s): s.in_ = InPort(Bits32) s.out1 = OutPort(Bits8) s.out2 = OutPort(Bits8) connect(s.in_[0:8], s.out1[0:8]) connect(s.in_[0:4], s.out2[0:4])
def construct(s): s.x0 = Wire() s.x1 = InPort() s.x2 = OutPort() assert s.x0._dsl.Type == Bits1 assert s.x1._dsl.Type == Bits1 assert s.x2._dsl.Type == Bits1
def construct(s): s.in_ = InPort(int) s.b = B()(in_=s.in_) @s.update def up_in_read(): print(s.in_)
def construct(s, x): s.in_ = InPort(Bits32) s.out = [OutPort(Bits32) for _ in range(5)] s.xs = [A() for _ in range(5)] for i, m in enumerate(s.xs): m.in_ //= lambda: s.in_ + i m.out //= s.out[i]
def construct(s): s.in_ = InPort(32) s.b = B() s.b.in_ //= s.in_ @update def up_in_read(): print(s.in_)
def construct(s): s.out = OutPort(32) # Wire is the same s.a = A() s.a.out //= s.out s.in_ = InPort(32) connect(s.out, s.in_)
def construct(s, InType, OutType): s.in_ = InPort(InType) s.out = OutPort(OutType) @s.update def adapter_incr(): s.out = s.in_ + OutType(1)
def construct(s): s.a = InPort(Bits10) s.b = Wire(Bits32) connect(s.a, s.b[0:10]) @update def up(): print(s.b[10:32])
def construct( s, DataType=Bits4, incr_value=1 ): s.in_ = InPort ( DataType ) s.out = OutPort( DataType ) s.incr_value = incr_value @update def up_incr(): s.out @= s.in_ + s.incr_value
def construct( s, num_incrs=1, DataType=Bits4() ): s.in_ = [ InPort ( DataType ) for _ in range( num_incrs ) ] s.out = [ OutPort( DataType ) for _ in range( num_incrs ) ] s.incrs = [ Incr( DataType=DataType ) for _ in range( num_incrs ) ] for i in range( num_incrs ): connect( s.in_[i], s.incrs[i].in_ ) connect( s.out[i], s.incrs[i].out )
def construct( s, DataType=Bits4(), incr_value=1 ): s.in_ = InPort ( DataType ) s.out = OutPort( DataType ) s.incr_value = DataType( incr_value ) @s.update def up_incr(): s.out = s.in_ + s.incr_value
def construct(s): s.in_ = [InPort(32) for _ in range(2)] s.sel = InPort(1) s.out = OutPort(32) s.mux1 = Mux(Bits32, 2) s.mux1.in_[0] //= s.in_[0] s.mux1.in_[1] //= s.in_[1] s.mux1.sel //= s.sel s.mux2 = Mux(Bits32, 2) s.mux2.in_[0] //= s.in_[0] s.mux2.in_[1] //= s.in_[1] s.mux2.sel //= s.sel s.mux3 = Mux(Bits32, 2) s.mux3.in_[0] //= s.mux1.out s.mux3.in_[1] //= s.mux2.out s.mux3.sel //= s.sel s.mux3.out //= s.out
def construct(s): s.in_ = InPort(SomeMsg1) s.out1 = OutPort(SomeMsg2) s.out2 = OutPort(SomeMsg2) # connect( s.in_.a, s.out1.c ) # connect( s.in_.b[0:8], s.out2.c ) @update def up_pass(): s.out1.c @= s.in_.a s.out2.c @= s.in_.b[0:8]
def construct(s): s.struct = InPort(B) s.out = OutPort(C) s.out2 = OutPort(Bits16) connect(s.struct.bar[1][4], s.out) connect(s.struct.bar[1][4].bar, s.out2) s.wire = Wire(B) @s.update_ff def ffs(): s.wire.bar <<= 1
def construct( s, InType, OutType ): s.in_ = InPort ( InType ) s.out = OutPort( OutType ) if InType.nbits > OutType.nbits: @update def adapter_incr_zext(): s.out @= zext( s.in_ + 1, InType ) else: @update def adapter_incr_trunc(): s.out @= trunc( s.in_ + 1, OutType )
def construct(s, x): s.in_ = InPort(Bits32) s.out = OutPort(Bits32) s.out2 = OutPort(Bits32) s.out //= lambda: s.in_ + x # TODO throw some better error message when # the implicit name of a lambda function conflicts # with the explicit name of an update block @update def _lambda__s_out(): s.out2 = Bits32(2)
def construct( s, Type, answer ): assert type(answer) == list, "TestSink only accepts a list of outputs!" s.answer = deque( [ x if x == "*" else Type(x) for x in answer ] ) s.in_ = InPort(Type) @s.update def up_sink(): if not s.answer: assert False, "Simulation has ended" else: ref = s.answer.popleft() ans = s.in_ assert ref == ans or ref == "*", "Expect {}, get {} instead".format(ref, ans)
def construct(s): s.in_ = InPort(B) s.out = OutPort(Bits32) # PyMTL mistakenly takes s.in_.foo[1] as a single bit! connect(s.out, s.in_.foo[1])
def construct(s): s.x = InPort(Bits32)
def construct( s, Type ): s.msg = OutPort( Type ) s.val = OutPort() s.rdy = InPort()
def construct( s, Type ): s.recv_msg = InPort( Type ) s.recv_val = InPort( Bits1 ) s.Type = Type
def construct( s ): s.recv_msg = InPort( Bits1 ) s.recv_val = InPort( Bits1 )
def construct(s): s.in_ = InPort(Bits32) @update def up_B_print(): print(s.in_)