From d40a9977b51aca8d69740ab49d2f46fced434443 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Thu, 23 May 2019 21:57:56 +0100 Subject: [PATCH] shadow seems to do the job of guaranteeing write-after-write --- src/experiment/score6600.py | 20 ++++++++++---------- src/scoreboard/shadow.py | 2 +- src/scoreboard/shadow_fn.py | 9 ++++++--- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/experiment/score6600.py b/src/experiment/score6600.py index a4f34564..d67325cb 100644 --- a/src/experiment/score6600.py +++ b/src/experiment/score6600.py @@ -244,9 +244,7 @@ class Scoreboard(Elaboratable): # on which unit(s) have writes pending and the current instruction # also needing to write m.submodules.wawgrid = wawgrid = WaWGrid(n_int_fus, n_int_fus) - busy_prev = Signal(n_int_fus) - busy_curr = Signal(n_int_fus) - busy_prevbit = Signal(n_int_fus) + fn_issue_prev = Signal(n_int_fus) #--------- # ok start wiring things together... @@ -329,18 +327,20 @@ class Scoreboard(Elaboratable): m.d.comb += shadows.s_good_i[0:n_int_fus].eq(go_wr_o[0:n_int_fus]) # work out the current-activated busy unit (by recording the old one) - m.d.sync += busy_prev.eq(cu.busy_o) - m.d.comb += busy_curr.eq(~busy_prev & cu.busy_o) + with m.If(fn_issue_o): # only update prev bit if instruction issued + m.d.sync += fn_issue_prev.eq(fn_issue_o) # now the "2D-bit-array-linked-list" can be created, with the # relationships of the previous and current instruction. - # *previous* instruction (busy_prev) shadows *current* instruction - #m.d.comb += wawgrid.shadow_i.eq(cu.busy_o & ~fn_issue_o) + # *previous* instruction shadows *current* instruction + #m.d.comb += wawgrid.shadow_i.eq(fn_issue_prev & cu.busy_o & ~fn_issue_o) #m.d.comb += wawgrid.fu_i.eq(fn_issue_o) # and now we can connect the wawgrid to the shadow matrix. whewww for i in range(n_int_fus): - m.d.comb += shadows.shadow_i[i].eq(wawgrid.waw_o[i]) + m.d.comb += shadows.shadow_i[i].eq(\ + ~fn_issue_o & fn_issue_prev & cu.busy_o) + #m.d.comb += shadows.shadow_i[i].eq(wawgrid.waw_o[i]) #--------- # Connect Register File(s) @@ -446,9 +446,9 @@ def print_reg(dut, rnums): def scoreboard_sim(dut, alusim): - yield dut.int_store_i.eq(0) + yield dut.int_store_i.eq(1) - for i in range(10): + for i in range(20): # set random values in the registers for i in range(1, dut.n_regs): diff --git a/src/scoreboard/shadow.py b/src/scoreboard/shadow.py index fd5cb864..8b6a1143 100644 --- a/src/scoreboard/shadow.py +++ b/src/scoreboard/shadow.py @@ -59,7 +59,7 @@ class Shadow(Elaboratable): good_l.append(l.s_good_i) sho_l.append(l.shadow_o) rec_l.append(l.recover_o) - m.d.comb += Cat(*i_l).eq(self.issue_i) + m.d.comb += Cat(*i_l).eq(Repl(self.issue_i, self.shadow_wid)) m.d.comb += Cat(*fail_l).eq(self.s_fail_i) m.d.comb += Cat(*good_l).eq(self.s_good_i) m.d.comb += Cat(*shi_l).eq(self.shadow_i) diff --git a/src/scoreboard/shadow_fn.py b/src/scoreboard/shadow_fn.py index d40d6148..4b266bcd 100644 --- a/src/scoreboard/shadow_fn.py +++ b/src/scoreboard/shadow_fn.py @@ -23,10 +23,13 @@ class ShadowFn(Elaboratable): m = Module() m.submodules.sl = sl = SRLatch(sync=False) - m.d.comb += sl.s.eq(self.shadow_i & self.issue_i) + cq = Signal() # resets to 0 + m.d.sync += cq.eq(sl.q) + + m.d.comb += sl.s.eq(self.shadow_i & self.issue_i & ~self.s_good_i) m.d.comb += sl.r.eq(self.s_good_i) - m.d.comb += self.recover_o.eq(sl.q & self.s_fail_i) - m.d.comb += self.shadow_o.eq(sl.q) + m.d.comb += self.recover_o.eq((cq | sl.q) & self.s_fail_i) + m.d.comb += self.shadow_o.eq((cq | sl.q)) return m -- 2.30.2