# https://bugs.libre-soc.org/show_bug.cgi?id=313#c2
b_fields = self.fields.FormB
BO = b_fields.BO[0:-1]
- BI = b_fields.BI[0:-1]
+ BI = b_fields.BI[0:-1][0:2]
+
+ cr_bits = Array([cr[3-i] for i in range(4)])
# The bit of CR selected by BI
cr_bit = Signal(reset_less=True)
- comb += cr_bit.eq((cr & (1<<(31-BI))) != 0)
+ comb += cr_bit.eq(cr_bits[BI])
# Whether the conditional branch should be taken
bc_taken = Signal(reset_less=True)
class BranchInputData(IntegerData):
regspec = [('SPR', 'spr1', '0:63'),
('SPR', 'spr2', '0:63'),
- ('CR', 'cr', '32'),
+ ('CR', 'cr', '4'),
('PC', 'cia', '0:63')]
def __init__(self, pspec):
super().__init__(pspec)
self.spr1 = Signal(64, reset_less=True) # see table above, SPR1
self.spr2 = Signal(64, reset_less=True) # see table above, SPR2
- self.cr = Signal(32, reset_less=True) # Condition Register(s) CR0-7
+ self.cr = Signal(4, reset_less=True) # Condition Register(s) CR0-7
self.cia = Signal(64, reset_less=True) # Current Instruction Address
# convenience variables. not all of these are used at once
yield pdecode2.dec.bigendian.eq(0) # little / big?
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)
# note, here, the op will need further decoding in order
# to set the correct SPRs on SPR1/2/3. op_bc* require
# spr2 to be set to CTR, op_bctar require spr1 to be
yield branch.p.data_i.spr2.eq(simulator.spr['CTR'].value)
print(f"cr0: {simulator.crl[0].get_range()}")
yield Settle()
+
+ cr_en = yield pdecode2.e.read_cr1.ok
+ if cr_en:
+ cr_sel = yield pdecode2.e.read_cr1.data
+ cr = simulator.crl[cr_sel].get_range().value
+ yield branch.p.data_i.cr.eq(cr)
+ full_cr = simulator.cr.get_range().value
+ print(f"full cr: {full_cr:x}, sel: {cr_sel}, cr: {cr:x}")
fn_unit = yield pdecode2.e.fn_unit
self.assertEqual(fn_unit, Function.BRANCH.value, code)
yield