# these are all opcode fields involved in index-selection of CR,
# and need to do "standard" arithmetic. CR[BA+32] for example
# would, if using SelectableInt, only be 5-bit.
- if name in ['BF', 'BFA', 'BC', 'BA', 'BB', 'BT']:
+ if name in ['BF', 'BFA', 'BC', 'BA', 'BB', 'BT', 'BI']:
self.namespace[name] = val
else:
self.namespace[name] = SelectableInt(val, sig.width)
# fields for conditional branches (BO and BI are same for BC and BCREG)
b_fields = self.fields.FormB
- BO = b_fields.BO[0:-1]
- BI = b_fields.BI[0:-1][0:2] # CR0-7 selected already in PowerDecode2.
+ BO = b_fields.BO
+ BI = b_fields.BI[0:2] # CR0-7 selected already in PowerDecode2.
cr_bits = Array([cr[3-i] for i in range(4)]) # invert. Because POWER.
+ # copy of BO in a signal
+ bo = Signal(5, reset_less=True)
+ comb += bo.eq(BO[0:5])
+
# The bit of CR selected by BI
bi = Signal(2, reset_less=True)
cr_bit = Signal(reset_less=True)
# Whether the conditional branch should be taken
bc_taken = Signal(reset_less=True)
- with m.If(BO[2]):
- comb += bc_taken.eq((cr_bit == BO[3]) | BO[4])
+ with m.If(bo[2]):
+ comb += bc_taken.eq((cr_bit == bo[3]) | bo[4])
with m.Else():
# decrement the counter and place into output
ctr_n = Signal(64, reset_less=True)
comb += ctr_m.eq(ctr[:32])
with m.Else():
comb += ctr_m.eq(ctr)
- # check CTR zero/non-zero against BO[1]
- ctr_zero_bo1 = Signal(reset_less=True) # BO[1] == (ctr==0)
- comb += ctr_zero_bo1.eq(BO[1] ^ ctr_m.any())
- with m.If(BO[3:5] == 0b00):
+ # check CTR zero/non-zero against bo[1]
+ ctr_zero_bo1 = Signal(reset_less=True) # bo[1] == (ctr==0)
+ comb += ctr_zero_bo1.eq(bo[1] ^ ctr_n.any())
+ with m.If(bo[3:5] == 0b00):
comb += bc_taken.eq(ctr_zero_bo1 & ~cr_bit)
- with m.Elif(BO[3:5] == 0b01):
+ with m.Elif(bo[3:5] == 0b01):
comb += bc_taken.eq(ctr_zero_bo1 & cr_bit)
- with m.Elif(BO[4] == 1):
+ with m.Elif(bo[4] == 1):
comb += bc_taken.eq(ctr_zero_bo1)
### Main Switch Statement ###
initial_sprs=initial_sprs,
initial_cr=cr)
+ def case_bc_microwatt_1_regression(self):
+ """bc found to be testing ctr rather than (ctr-1)
+ 11fb4: 08 00 49 40 bc 2,4*cr2+gt,0x11fbc
+ cr_file.vhdl:83:13:@136835ns:(report note): Reading CR 33209703
+ """
+ lst = ["bc 2, 9, 8"]
+ initial_regs = [0] * 32
+ cr = 0x33209703
+ self.add_case(Program(lst, bigendian), initial_regs,
+ initial_cr=cr)
+
+ def case_bc_microwatt_2_regression(self):
+ """modified version, set CTR=1 so that it hits zero in BC
+ """
+ lst = ["bc 2, 9, 8"]
+ initial_regs = [0] * 32
+ cr = 0x33209703
+ ctr = 1
+ initial_sprs = {9: SelectableInt(ctr, 64),
+ }
+ self.add_case(Program(lst, bigendian), initial_regs,
+ initial_sprs=initial_sprs,
+ initial_cr=cr)
+
def case_ilang(self):
pspec = BranchPipeSpec(id_wid=2)
alu = BranchBasePipe(pspec)