Closed rkshthrmsh closed 1 year ago
Figured out there is no need to declare a Wire
. Instead, calling the data type SInt
serves the same purpose.
temp = m.SInt[2]()
with m.when(io.En):
temp @= io.A
with m.otherwise():
temp @= 0
Yes @rkshthrmsh good observation. To follow up on that you should use temp = T()
as you do (with T = m.Sint[2]
in your case, for example). You can use the m.Wire()
primitive, but it is a circuit like any other circuit, so you would have to do:
temp_wire = m.Wire(m.SInt[2])() # note the extra pair of paren's
with m.when(...):
temp_wire.I @= ... # note we do .I to get the input of this primitive
with m.otherwise():
temp_wire.I @= ...
io.O @= temp_wire.O + 1
That being said, there really is no reason to use m.Wire()
primitive. Doing temp = m.Sint[2]()
is definitely preferred.
How to create a (verilog)
wire
to store an intermediate value? The following attempt gives aTypeError: unsupported operand type(s) for @=: 'Wire' and 'SInt[(2, Out(Bit))]'
.The equivalent verilog would be
How can this be done?