From 5733ed9ac0fa84e021a4604815bf55d6b25d9332 Mon Sep 17 00:00:00 2001 From: Karlis Susters Date: Wed, 12 Apr 2023 21:58:35 +0300 Subject: [PATCH] Implemented overflow bypass fifo, required for double target table --- src_Core/RISCY_OOO/procs/lib/Fifos.bsv | 50 +++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/src_Core/RISCY_OOO/procs/lib/Fifos.bsv b/src_Core/RISCY_OOO/procs/lib/Fifos.bsv index 9ad7714..813592f 100644 --- a/src_Core/RISCY_OOO/procs/lib/Fifos.bsv +++ b/src_Core/RISCY_OOO/procs/lib/Fifos.bsv @@ -740,4 +740,52 @@ module mkOverflowPipelineFifo( Fifo#(n, t) ) provisos (Bits#(t,tSz)); empty[2] <= True; full[2] <= False; endmethod -endmodule \ No newline at end of file +endmodule + +module mkOverflowBypassFifo( Fifo#(n, t) ) provisos (Bits#(t,tSz)); + // n is size of fifo + // t is data type of fifo + Vector#(n, Ehr#(2,t)) data <- replicateM(mkEhr(?)); + Ehr#(2, Bit#(TLog#(n))) enqP <- mkEhr(0); + Ehr#(3, Bit#(TLog#(n))) deqP <- mkEhr(0); + Ehr#(3, Bool) empty <- mkEhr(True); + Ehr#(3, Bool) full <- mkEhr(False); + Bit#(TLog#(n)) max_index = fromInteger(valueOf(n)-1); + + method Bool notFull = !full[0]; + + method Action enq(t x); + data[enqP[0]][0] <= x; + empty[0] <= False; + let next_enqP = (enqP[0] == max_index) ? 0 : enqP[0] + 1; + if (full[0]) begin + deqP[0] <= next_enqP; + end + enqP[0] <= next_enqP; + if( next_enqP == deqP[0] ) begin + full[0] <= True; + end + endmethod + + method Bool notEmpty = !empty[1]; + + method Action deq if( !empty[1] ); + full[1] <= False; + let next_deqP = (deqP[1] == max_index) ? 0 : deqP[1] + 1; + deqP[1] <= next_deqP; + if( next_deqP == enqP[1] ) begin + empty[1] <= True; + end + endmethod + + method t first if( !empty[1] ); + return data[deqP[1]][1]; + endmethod + + method Action clear; + enqP[1] <= 0; + deqP[2] <= 0; + empty[2] <= True; + full[2] <= False; + endmethod +endmodule