From 7438c3f8514e758b15ea89cf6665580e7c183455 Mon Sep 17 00:00:00 2001 From: "Jose T. de Sousa" Date: Sun, 14 Jan 2024 19:49:54 +0000 Subject: [PATCH] more fixes to pack and unpack and bfifo --- .../{bfifo => iob_bfifo}/hardware/src/iob_bfifo.v | 2 +- .../modules/fifo/{bfifo => iob_bfifo}/iob_bfifo.py | 0 .../modules/iob_pack/hardware/src/iob_pack.v | 13 +++++++++---- .../modules/iob_unpack/hardware/src/iob_unpack.v | 12 ++++++++---- 4 files changed, 18 insertions(+), 9 deletions(-) rename submodules/LIB/hardware/modules/fifo/{bfifo => iob_bfifo}/hardware/src/iob_bfifo.v (99%) rename submodules/LIB/hardware/modules/fifo/{bfifo => iob_bfifo}/iob_bfifo.py (100%) diff --git a/submodules/LIB/hardware/modules/fifo/bfifo/hardware/src/iob_bfifo.v b/submodules/LIB/hardware/modules/fifo/iob_bfifo/hardware/src/iob_bfifo.v similarity index 99% rename from submodules/LIB/hardware/modules/fifo/bfifo/hardware/src/iob_bfifo.v rename to submodules/LIB/hardware/modules/fifo/iob_bfifo/hardware/src/iob_bfifo.v index b1cb83032..da09be0e5 100644 --- a/submodules/LIB/hardware/modules/fifo/bfifo/hardware/src/iob_bfifo.v +++ b/submodules/LIB/hardware/modules/fifo/iob_bfifo/hardware/src/iob_bfifo.v @@ -51,7 +51,7 @@ module iob_bfifo #( end end - //CONTROL LOGIC + //control logic integer i; always @* begin diff --git a/submodules/LIB/hardware/modules/fifo/bfifo/iob_bfifo.py b/submodules/LIB/hardware/modules/fifo/iob_bfifo/iob_bfifo.py similarity index 100% rename from submodules/LIB/hardware/modules/fifo/bfifo/iob_bfifo.py rename to submodules/LIB/hardware/modules/fifo/iob_bfifo/iob_bfifo.py diff --git a/submodules/LIB/hardware/modules/iob_pack/hardware/src/iob_pack.v b/submodules/LIB/hardware/modules/iob_pack/hardware/src/iob_pack.v index 4a19d400a..0f0ac68dc 100644 --- a/submodules/LIB/hardware/modules/iob_pack/hardware/src/iob_pack.v +++ b/submodules/LIB/hardware/modules/iob_pack/hardware/src/iob_pack.v @@ -23,7 +23,7 @@ module iob_pack #( ); //bfifo size - localparam BFIFO_REG_W = `IOB_MAX(UNPACKED_DATA_W, PACKED_DATA_W); + localparam BFIFO_REG_W = 2*`IOB_MAX(UNPACKED_DATA_W, PACKED_DATA_W); //packed data width as a bit vector localparam [$clog2(PACKED_DATA_W):0] PACKED_DATA_W_INT = {1'b1, {$clog2(PACKED_DATA_W){1'b0}}}; @@ -66,14 +66,19 @@ module iob_pack #( data_read_nxt = data_read; //prioritize push over pop - if (data_read && push_level >= len_i && rready_i) begin + if (data_read && push_level >= len_i) begin //push and read from external input fifo push = 1'b1; - read = 1'b1; //read next unpacked word from external input fifo + if (rready_i) begin + read = 1'b1; + end else begin + data_read_nxt = 1'b0; + end + read = 1'b1; end else if (wrap_i && push_level > 0 && push_level < len_i) begin //wrap up word by pushing zeros push_len = push_level; push_data = {UNPACKED_DATA_W{1'b0}}; push = 1'b1; - end else if (pop_level >= len_i && wready_i) begin //pop and write to external output fifo + end else if (pop_level >= PACKED_DATA_W_INT && wready_i) begin //pop and write to external output fifo pop = 1'b1; write = 1'b1; end else if (!data_read && rready_i) begin //read new data from external input fifo diff --git a/submodules/LIB/hardware/modules/iob_unpack/hardware/src/iob_unpack.v b/submodules/LIB/hardware/modules/iob_unpack/hardware/src/iob_unpack.v index 6b7756734..e4ccc8430 100644 --- a/submodules/LIB/hardware/modules/iob_unpack/hardware/src/iob_unpack.v +++ b/submodules/LIB/hardware/modules/iob_unpack/hardware/src/iob_unpack.v @@ -23,7 +23,7 @@ module iob_unpack #( ); //bfifo size - localparam BFIFO_REG_W = `IOB_MAX(PACKED_DATA_W, UNPACKED_DATA_W); + localparam BFIFO_REG_W = 2*`IOB_MAX(PACKED_DATA_W, UNPACKED_DATA_W); //packed data width as a bit vector localparam [$clog2(PACKED_DATA_W):0] PACKED_DATA_W_INT = {1'b1, {$clog2(PACKED_DATA_W){1'b0}}}; @@ -73,9 +73,13 @@ module iob_unpack #( pop_len = pop_level; pop = 1'b1; //no write - end else if (data_read && push_level >= PACKED_DATA_W_INT && rready_i) begin //push and read from external input fifo - push = 1'b1; - read = 1'b1; + end else if (data_read && push_level >= PACKED_DATA_W_INT) begin //push and read from external input fifo + push = 1'b1; + if (rready_i) begin + read = 1'b1; + end else begin + data_read_nxt = 1'b0; + end end else if (!data_read && rready_i) begin //read new data from external input fifo read = 1'b1; data_read_nxt = 1'b1;