diff options
Diffstat (limited to 'rtl/gfx')
| -rw-r--r-- | rtl/gfx/mat_mat_mul.sv | 12 | ||||
| -rw-r--r-- | rtl/gfx/transpose.sv | 17 |
2 files changed, 26 insertions, 3 deletions
diff --git a/rtl/gfx/mat_mat_mul.sv b/rtl/gfx/mat_mat_mul.sv index cf4bd35..7c21249 100644 --- a/rtl/gfx/mat_mat_mul.sv +++ b/rtl/gfx/mat_mat_mul.sv @@ -15,7 +15,7 @@ module mat_mat_mul out_valid ); - mat4 a_hold, b_hold, q_hold, mul_b; + mat4 a_hold, b_hold, b_transpose, q_hold, mul_b; vec4 mul_q; logic mul_in_ready, mul_in_valid, mul_out_ready, mul_out_valid; index4 in_index, out_index; @@ -26,6 +26,12 @@ module mat_mat_mul assign mul_in_valid = in_valid || in_index != `INDEX4_MIN; assign mul_out_ready = out_ready || out_index != `INDEX4_MAX; + transpose transpose + ( + .in(b), + .out(b_transpose) + ); + mat_vec_mul mul ( .a(in_index == `INDEX4_MIN ? a : a_hold), @@ -40,7 +46,7 @@ module mat_mat_mul always_comb begin mul_b = b_hold; - mul_b[0] = b[0]; + mul_b[0] = b_transpose[0]; q = q_hold; q[`VECS_PER_MAT - 1] = mul_q; @@ -61,7 +67,7 @@ module mat_mat_mul always_ff @(posedge clk) begin if (in_ready) begin a_hold <= a; - b_hold <= b; + b_hold <= b_transpose; end if (mul_out_ready && mul_out_valid) diff --git a/rtl/gfx/transpose.sv b/rtl/gfx/transpose.sv new file mode 100644 index 0000000..1df68d5 --- /dev/null +++ b/rtl/gfx/transpose.sv @@ -0,0 +1,17 @@ +`include "gfx/gfx_defs.sv" + +module transpose +( + input mat4 in, + output mat4 out +); + + integer i, j; + + // Esto no tiene costo en hardware, es un renombramiento de seƱales + always_comb + for (i = 0; i < `VECS_PER_MAT; ++i) + for (j = 0; j < `FLOATS_PER_VEC; ++j) + out[i][j] = in[j][i]; + +endmodule |
