From 9505a87f444af09ebc021d3c7a8c2c2522d36c9f Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Wed, 22 May 2019 07:27:37 +0100 Subject: [PATCH] random regression test shows an inter-dependency fail --- src/experiment/score6600.py | 25 +++++++++++++++++++------ src/scoreboard/dependence_cell.py | 12 ++++++++++-- 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/src/experiment/score6600.py b/src/experiment/score6600.py index 9e17b3f2..455dfec5 100644 --- a/src/experiment/score6600.py +++ b/src/experiment/score6600.py @@ -374,12 +374,11 @@ def scoreboard_sim(dut, alusim): instrs = [] if False: - for i in range(2): + for i in range(50): src1 = randint(1, dut.n_regs-1) src2 = randint(1, dut.n_regs-1) while True: dest = randint(1, dut.n_regs-1) - break if dest not in [src1, src2]: break #src1 = 2 @@ -387,19 +386,33 @@ def scoreboard_sim(dut, alusim): #dest = 2 op = randint(0, 1) - op = i % 2 - op = 0 - instrs.append((src1, src2, dest, op)) + #op = i % 2 + #op = 0 + + instrs.append((src1, src2, dest, op)) if False: instrs.append((2, 3, 3, 0)) instrs.append((5, 3, 3, 1)) - if True: + if False: instrs.append((5, 6, 2, 1)) instrs.append((2, 2, 4, 0)) #instrs.append((2, 2, 3, 1)) + if False: + instrs.append((2, 1, 2, 0)) + + if False: + instrs.append((2, 6, 2, 1)) + instrs.append((2, 1, 2, 0)) + + if True: + instrs.append((1, 4, 7, 1)) + instrs.append((7, 1, 5, 0)) + instrs.append((4, 3, 1, 1)) + instrs.append((6, 5, 7, 1)) + for i, (src1, src2, dest, op) in enumerate(instrs): print ("instr %d: %d %d %d %d\n" % (i, op, src1, src2, dest)) diff --git a/src/scoreboard/dependence_cell.py b/src/scoreboard/dependence_cell.py index 649b44e2..a45c5839 100644 --- a/src/scoreboard/dependence_cell.py +++ b/src/scoreboard/dependence_cell.py @@ -122,8 +122,15 @@ class DependenceCell(Elaboratable): (src2_c, self.src2_i)]: m.d.comb += c.reg_i.eq(reg) + # wark-wark: yes, writing to the same reg you are reading is *NOT* + # a write-after-read hazard. + selfhazard = Signal(reset_less=False) + m.d.comb += selfhazard.eq((self.dest_i & self.src1_i) | + (self.dest_i & self.src2_i)) + # connect up hazard checks: read-after-write and write-after-read - m.d.comb += dest_c.hazard_i.eq(self.rd_pend_i) # read-after-write + with m.If(~selfhazard): + m.d.comb += dest_c.hazard_i.eq(self.rd_pend_i) # read-after-write m.d.comb += src1_c.hazard_i.eq(self.wr_pend_i) # write-after-read m.d.comb += src2_c.hazard_i.eq(self.wr_pend_i) # write-after-read @@ -137,7 +144,8 @@ class DependenceCell(Elaboratable): # to be accumulated to indicate if register is in use (globally) # after ORing, is fed back in to rd_pend_i / wr_pend_i m.d.comb += self.rd_rsel_o.eq(src1_c.q_o | src2_c.q_o) - m.d.comb += self.wr_rsel_o.eq(dest_c.q_o) + with m.If(~selfhazard): + m.d.comb += self.wr_rsel_o.eq(dest_c.q_o) return m -- 2.30.2