m.d.comb += data_o.eq_without_core(self.saved_input_data)
m.d.comb += core_o.quotient_root.eq(self.div_state_next.o.quotient)
- m.d.comb += core_o.remainder.eq(self.div_state_next.o.remainder)
+ # fract width of `DivPipeCoreOutputData.remainder`
+ remainder_fract_width = 64 * 3
+ # fract width of `DivPipeCoreInputData.dividend`
+ dividend_fract_width = 64 * 2
+ rem_start = remainder_fract_width - dividend_fract_width
+ m.d.comb += core_o.remainder.eq(self.div_state_next.o.remainder
+ << rem_start)
m.d.comb += self.n.valid_o.eq(~self.empty & self.div_state_next.o.done)
m.d.comb += self.p.ready_o.eq(self.empty)
m.d.sync += self.saved_state.eq(self.div_state_next.o)
class DivTestCases(TestAccumulatorBase):
+ def case_divw_regression(self):
+ # simulator is wrong, FSM and power-instruction-analyzer are both correct
+ lst = [f"divw 0, 1, 2"]
+ initial_regs = [0] * 32
+ initial_regs[2] = 0x2
+ initial_regs[1] = 0x80000000
+ with Program(lst, bigendian) as prog:
+ self.add_case(prog, initial_regs)
+
+ # modulo
+ def case_modsd_regression2(self):
+ lst = [f"modsd 0, 1, 2"]
+ initial_regs = [0] * 32
+ initial_regs[2] = 0xff
+ initial_regs[1] = 0x7fffffffffffffff
+ with Program(lst, bigendian) as prog:
+ self.add_case(prog, initial_regs)
+
# modulo
def case_modsd_regression(self):
lst = [f"modsd 17, 27, 0"]