summaryrefslogtreecommitdiff
path: root/rtl
diff options
context:
space:
mode:
authorAlejandro Soto <alejandro@34project.org>2023-11-05 22:54:19 -0600
committerAlejandro Soto <alejandro@34project.org>2023-11-10 01:43:02 -0600
commitd5783a6ebde5d38fe72dd19293d9144827c35c56 (patch)
treee1f26ec2c89db0c5a206b97dbbf3a693c2876d6e /rtl
parent5c982f38139cd1b0c5b590f67e99b1bcc1a32c9b (diff)
rtl/gfx: add gfx_pipes
Diffstat (limited to '')
-rw-r--r--rtl/gfx/gfx_fixed_fma_dot.sv33
-rw-r--r--rtl/gfx/gfx_pipes.sv25
2 files changed, 42 insertions, 16 deletions
diff --git a/rtl/gfx/gfx_fixed_fma_dot.sv b/rtl/gfx/gfx_fixed_fma_dot.sv
index 2831d08..c19b49e 100644
--- a/rtl/gfx/gfx_fixed_fma_dot.sv
+++ b/rtl/gfx/gfx_fixed_fma_dot.sv
@@ -14,7 +14,7 @@ module gfx_fixed_fma_dot
output fixed q
);
- fixed q0, a1_hold[`FIXED_FMA_STAGES], b1_hold[`FIXED_FMA_STAGES];
+ fixed q0, a1_hold, b1_hold;
gfx_fixed_fma fma0
(
@@ -24,25 +24,26 @@ module gfx_fixed_fma_dot
.*
);
- gfx_fixed_fma fma1
+ gfx_pipes #(.WIDTH($bits(fixed)), .DEPTH(`FIXED_FMA_STAGES)) a_pipes
(
- .a(a1_hold[`FIXED_FMA_STAGES - 1]),
- .b(b1_hold[`FIXED_FMA_STAGES - 1]),
- .c(q0),
+ .in(a1),
+ .out(a1_hold),
.*
);
- integer i;
-
- always_ff @(posedge clk)
- if (!stall) begin
- a1_hold[0] <= a1;
- b1_hold[0] <= b1;
+ gfx_pipes #(.WIDTH($bits(fixed)), .DEPTH(`FIXED_FMA_STAGES)) b_pipes
+ (
+ .in(b1),
+ .out(b1_hold),
+ .*
+ );
- for (i = 1; i < `FIXED_FMA_STAGES; ++i) begin
- a1_hold[i] <= a1_hold[i - 1];
- b1_hold[i] <= b1_hold[i - 1];
- end
- end
+ gfx_fixed_fma fma1
+ (
+ .a(a1_hold),
+ .b(b1_hold),
+ .c(q0),
+ .*
+ );
endmodule
diff --git a/rtl/gfx/gfx_pipes.sv b/rtl/gfx/gfx_pipes.sv
new file mode 100644
index 0000000..55ebd19
--- /dev/null
+++ b/rtl/gfx/gfx_pipes.sv
@@ -0,0 +1,25 @@
+module gfx_pipes
+#(parameter WIDTH=0, DEPTH=0)
+(
+ input logic clk,
+
+ input logic[WIDTH - 1:0] in,
+ input logic stall,
+
+ output logic[WIDTH - 1:0] out
+);
+
+ logic[WIDTH - 1:0] pipes[DEPTH];
+
+ assign out = pipes[DEPTH - 1];
+
+ integer i;
+ always_ff @(posedge clk)
+ if (!stall) begin
+ pipes[0] <= in;
+
+ for (i = 1; i < DEPTH; ++i)
+ pipes[i] <= pipes[i - 1];
+ end
+
+endmodule