with m.Else():
# Yes, the CTR only counts 32 bits
ctr = Signal(64, reset_less=True)
- comb += ctr.eq(self.i.spr - 1)
+ comb += ctr.eq(self.i.ctr - 1)
comb += self.o.spr.data.eq(ctr)
comb += self.o.spr.ok.eq(1)
ctr_eq_zero = Signal(reset_less=True)
class BranchInputData(IntegerData):
def __init__(self, pspec):
super().__init__(pspec)
- # We need both lr and spr for bclr and bcctrl. Bclr can read
- # from both ctr and lr, and bcctrl can write to both ctr and
- # lr.
- self.lr = Signal(64, reset_less=True) # Link Register
- self.spr = Signal(64, reset_less=True) # CTR
- self.cr = Signal(32, reset_less=True) # Condition Register(s) CR0-7
- self.cia = Signal(64, reset_less=True) # Current Instruction Address
- self.tar = Signal(64, reset_less=True) # Target Address Register
+ # For OP_BCREG, this will either be CTR, LR, or TAR
+ self.spr = Signal(64, reset_less=True)
+ self.ctr = Signal(64, reset_less=True) # CTR
+ self.cr = Signal(32, reset_less=True) # Condition Register(s) CR0-7
+ self.cia = Signal(64, reset_less=True) # Current Instruction Address
def __iter__(self):
yield from super().__iter__()
- yield self.lr
+ yield self.ctr
yield self.spr
yield self.cr
yield self.cia
- yield self.tar
def eq(self, i):
lst = super().eq(i)
- return lst + [self.lr.eq(i.lr), self.spr.eq(i.spr), self.tar.eq(i.tar),
+ return lst + [self.ctr.eq(i.ctr), self.spr.eq(i.spr),
self.cr.eq(i.cr), self.cia.eq(i.cia)]
yield instruction.eq(ins) # raw binary instr.
yield branch.p.data_i.cia.eq(simulator.pc.CIA.value)
yield branch.p.data_i.cr.eq(simulator.cr.get_range().value)
- yield branch.p.data_i.spr.eq(simulator.spr['CTR'].value)
- yield branch.p.data_i.lr.eq(simulator.spr['LR'].value)
+ yield branch.p.data_i.ctr.eq(simulator.spr['CTR'].value)
print(f"cr0: {simulator.crl[0].get_range()}")
yield Settle()
fn_unit = yield pdecode2.e.fn_unit