From 2c41fcd7fb4ba4885cd6967df0ca847712583dae Mon Sep 17 00:00:00 2001 From: jon <> Date: Mon, 12 Apr 2021 12:48:49 +0100 Subject: [PATCH] Fix bug and improve expression by using Int. --- src_Core/RISCY_OOO/procs/lib/Map.bsv | 8 ++++---- src_Core/RISCY_OOO/procs/lib/SplitLSQ.bsv | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src_Core/RISCY_OOO/procs/lib/Map.bsv b/src_Core/RISCY_OOO/procs/lib/Map.bsv index 9bf3600..64ac758 100644 --- a/src_Core/RISCY_OOO/procs/lib/Map.bsv +++ b/src_Core/RISCY_OOO/procs/lib/Map.bsv @@ -61,7 +61,7 @@ interface Map#(type ky, type ix, type vl, numeric type as); method Bool clearDone; endinterface -module mkMapLossy(Map#(ky,ix,vl,as)) provisos ( +module mkMapLossy#(vl default_value)(Map#(ky,ix,vl,as)) provisos ( Bits#(ky,ky_sz), Bits#(vl,vl_sz), Eq#(ky), Arith#(ky), Bounded#(ix), Literal#(ix), Bits#(ix, ix_sz), Bitwise#(ix), Eq#(ix), Arith#(ix)); @@ -83,18 +83,18 @@ Bitwise#(ix), Eq#(ix), Arith#(ix)); action Bool found = False; Bit#(TLog#(as)) way = wayNext; - MapKeyValue#(ky,vl) old = unpack(0); + vl old_value = default_value; if (a > 1) begin for (Integer i = 0; i < a; i = i + 1) begin MapKeyValue#(ky,vl) entry = mem[i].sub(ki.index); if (entry.key == ki.key) begin found = True; way = fromInteger(i); - old = entry; + old_value = entry.value; end end end - if (found || insert) mem[way].upd(ki.index, MapKeyValue{key: ki.key, value: up(old.value, value)}); + if (found || insert) mem[way].upd(ki.index, MapKeyValue{key: ki.key, value: up(old_value, value)}); wayNext <= (wayNext == fromInteger(a-1)) ? 0: wayNext + 1; didUpdate.send; endaction diff --git a/src_Core/RISCY_OOO/procs/lib/SplitLSQ.bsv b/src_Core/RISCY_OOO/procs/lib/SplitLSQ.bsv index 9dc8173..29a6566 100644 --- a/src_Core/RISCY_OOO/procs/lib/SplitLSQ.bsv +++ b/src_Core/RISCY_OOO/procs/lib/SplitLSQ.bsv @@ -957,7 +957,7 @@ module mkSplitLSQ(SplitLSQ); RWire#(void) wrongSpec_wakeBySB_conflict <- mkRWire; // make wrongSpec more urgent than firstSt (resolve bsc error) Wire#(Bool) wrongSpec_urgent_firstSt <- mkDWire(True); - Map#(Bit#(10),Bit#(6),UInt#(2),2) ldKillMap <- mkMapLossy; + Map#(Bit#(10),Bit#(6),Int#(3),2) ldKillMap <- mkMapLossy(minBound); Reg#(Bit#(16)) rand_count <- mkReg(0); rule inc_rand_count; rand_count <= rand_count + 1; @@ -2132,12 +2132,12 @@ module mkSplitLSQ(SplitLSQ); Bool rand_inv = (rand_count & (512-1)) == 0; Bool waited = ld_waitForOlderSt[deqP]; // Don't negative train if we waited for older stores. // Update predictor. - UInt#(3) inc = 1; // Subtract one by default. + Int#(3) inc = -1; // Subtract one by default. if (waited) inc = 0; // Don't train if we waited for stores. else if (killedLd) inc = 2; // Double train if we flushed the pipe. ldKillMap.updateWithFunc(unpack(ld_pc_hash[deqP]), // Key inc, // value; don't train if we waited. - killedLd ? boundedPlus:boundedMinus, // function to combine this value with existing + boundedPlus, // function to combine this value with existing killedLd || rand_inv // insert if doesn't exist );