class _Basic(m.Circuit): name = "Basic" io = m.IO( I0=m.In(m.Bits[2]), I1=m.In(m.Bits[2]), I2=m.In(m.Bit), O=m.Out(m.Bits[4])) f = m.register(io.I0) | m.register(io.I1) io.O[0] @= f[0] io.O[1] @= ~io.I0[0] io.O[2] @= io.I2 io.O[3] @= io.I2
def __init__(self, width: int): self.name = f"RegisteredIncrementer{width}" T = m.UInt[width] self.io = m.IO(I0=m.In(T), I1=m.In(T), O=m.Out(T)) + m.ClockIO() sum_ = m.register(self.io.I0) + self.io.I1 self.io.O @= sum_
def reg_next_init(n, init): return m.register(n, init=init, reset_type=m.Reset)
def reg_next(n): return m.register(n)
class _Registered(m.Circuit): name = "Registered" io = m.IO(I=m.In(m.Bit), O=m.Out(m.Bit)) io.O @= m.register(~m.register(io.I, name="reg0"), name="reg1")