diff options
| author | Alejandro Soto <alejandro@34project.org> | 2023-10-21 03:21:18 -0600 |
|---|---|---|
| committer | Alejandro Soto <alejandro@34project.org> | 2023-10-21 03:21:18 -0600 |
| commit | d84718bf7955a6bba03aa44938f0f140c1a6390d (patch) | |
| tree | 58aca8052f775ae5697688c759ef24977db4f6a2 /rtl/gfx/horizontal_fold.sv | |
| parent | 1b5eeb9a949272232ff543f684c7be62d31d0d40 (diff) | |
rtl/gfx: implement non-synthesizable matrix multiplier
Diffstat (limited to 'rtl/gfx/horizontal_fold.sv')
| -rw-r--r-- | rtl/gfx/horizontal_fold.sv | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/rtl/gfx/horizontal_fold.sv b/rtl/gfx/horizontal_fold.sv new file mode 100644 index 0000000..127150e --- /dev/null +++ b/rtl/gfx/horizontal_fold.sv @@ -0,0 +1,51 @@ +`include "gfx/gfx_defs.sv" + +// Asume que N es una potencia de 2 +module horizontal_fold +#(parameter N=1) +( + input logic clk, + rst_n, + + input logic start, + input fp vec[N - 1:0], + + output logic done, + output fp q +); + + fp q_left, q_right; + logic halves_done; + + generate + if (N > 1) begin + horizontal_fold #(.N(N / 2)) left + ( + .q(q_left), + .vec(vec[N - 1:N / 2]), + .done(halves_done), + .* + ); + + horizontal_fold #(.N(N / 2)) right + ( + .q(q_right), + .vec(vec[N / 2 - 1:0]), + .done(), + .* + ); + + fp_add fold + ( + .a(q_left), + .b(q_right), + .start(halves_done), + .* + ); + end else begin + assign q = vec[0]; + assign done = start; + end + endgenerate + +endmodule |
