summaryrefslogtreecommitdiff
path: root/rtl/gfx/fold_flow.sv
diff options
context:
space:
mode:
authorAlejandro Soto <alejandro@34project.org>2023-10-22 00:16:40 -0600
committerAlejandro Soto <alejandro@34project.org>2023-10-22 00:16:50 -0600
commitc1c1f1e823099c82d02e94827a64d7a0b223048e (patch)
treecc6466fad9a943bbde314feb151bbacadf5b338a /rtl/gfx/fold_flow.sv
parenta14fc04f3b9f5bcef941ea79c794532d7ca0e7fc (diff)
rtl/gfx: reimplement multiplier as a much smaller mat-vec pipeline
Diffstat (limited to '')
-rw-r--r--rtl/gfx/fold_flow.sv55
1 files changed, 55 insertions, 0 deletions
diff --git a/rtl/gfx/fold_flow.sv b/rtl/gfx/fold_flow.sv
new file mode 100644
index 0000000..718786e
--- /dev/null
+++ b/rtl/gfx/fold_flow.sv
@@ -0,0 +1,55 @@
+`include "gfx/gfx_defs.sv"
+
+module fold_flow
+(
+ input logic clk,
+ rst_n,
+
+ input logic in_valid,
+ out_ready,
+
+ output logic in_ready,
+ out_valid,
+ stall,
+ feedback,
+ feedback_last
+);
+
+ index4 rounds[`FP_ADD_STAGES], last_round;
+
+ assign stall = out_valid && !out_ready;
+ assign in_ready = !stall && !feedback;
+ assign out_valid = last_round == `INDEX4_MAX;
+
+ assign feedback = last_round[1] ^ last_round[0];
+ assign feedback_last = last_round[1];
+
+ assign last_round = rounds[`FP_ADD_STAGES - 1];
+
+ always_ff @(posedge clk or negedge rst_n)
+ if (!rst_n)
+ rounds[0] <= `INDEX4_MIN;
+ else if (!stall)
+ unique case (last_round)
+ 2'b01:
+ rounds[0] <= 2'b10;
+
+ 2'b10:
+ rounds[0] <= 2'b11;
+
+ 2'b00, 2'b11:
+ rounds[0] <= {1'b0, in_valid};
+ endcase
+
+ genvar i;
+ generate
+ for (i = 1; i < `FP_ADD_STAGES; ++i) begin: pipeline
+ always_ff @(posedge clk or negedge rst_n)
+ if (!rst_n)
+ rounds[i] <= `INDEX4_MIN;
+ else if (in_ready)
+ rounds[i] <= rounds[i - 1];
+ end
+ endgenerate
+
+endmodule