self.cycle = Signal(range(5))
self.regs = Array(Signal(32, name=f"r{i}") for i in range(8))
self.cycle = Signal(range(5))
self.regs = Array(Signal(32, name=f"r{i}") for i in range(8))
m.d.comb += self.rw.eq(Rw.READ)
with m.If(self.cycle == 3):
m.d.sync += self.regs[self.reg_b].eq(self.d_in)
m.d.comb += self.rw.eq(Rw.READ)
with m.If(self.cycle == 3):
m.d.sync += self.regs[self.reg_b].eq(self.d_in)
m.d.comb += self.rw.eq(Rw.WRITE)
m.d.comb += self.d_out.eq(self.b)
with m.If(self.cycle == 3):
m.d.comb += self.rw.eq(Rw.WRITE)
m.d.comb += self.d_out.eq(self.b)
with m.If(self.cycle == 3):
with m.Case(Op.BEQ):
with m.If(self.cycle == 2):
dest = self.pc + 1 + self.offset
dest = Mux(self.a == self.b, dest, self.pc + 1)
with m.Case(Op.BEQ):
with m.If(self.cycle == 2):
dest = self.pc + 1 + self.offset
dest = Mux(self.a == self.b, dest, self.pc + 1)
with m.Case(Op.JALR):
with m.If(self.cycle == 2):
same_reg = self.reg_a == self.reg_b
dest = Mux(same_reg, self.pc + 1, self.a)
m.d.sync += self.regs[self.reg_b].eq(self.pc + 1)
with m.Case(Op.JALR):
with m.If(self.cycle == 2):
same_reg = self.reg_a == self.reg_b
dest = Mux(same_reg, self.pc + 1, self.a)
m.d.sync += self.regs[self.reg_b].eq(self.pc + 1)