diff options
| author | Alejandro Soto <alejandro@34project.org> | 2023-11-20 18:41:09 -0600 |
|---|---|---|
| committer | Alejandro Soto <alejandro@34project.org> | 2023-11-20 21:29:11 -0600 |
| commit | 314a2a21260a8b61a5679dfc1f7df9b18c785535 (patch) | |
| tree | c2d1a51b4856d0db94912e2bbf891e7bfb20b4ea /rtl/gfx | |
| parent | ec2f4c0e20aaa130359630299362d03ce41d585c (diff) | |
rtl/gfx: implement shuffle, swizzle
Diffstat (limited to 'rtl/gfx')
| -rw-r--r-- | rtl/gfx/gfx_defs.sv | 5 | ||||
| -rw-r--r-- | rtl/gfx/gfx_shuffle.sv | 20 | ||||
| -rw-r--r-- | rtl/gfx/gfx_swizzle.sv | 19 |
3 files changed, 43 insertions, 1 deletions
diff --git a/rtl/gfx/gfx_defs.sv b/rtl/gfx/gfx_defs.sv index fa297e6..01fe2e3 100644 --- a/rtl/gfx/gfx_defs.sv +++ b/rtl/gfx/gfx_defs.sv @@ -212,6 +212,9 @@ typedef struct packed `define GFX_BATCH_FIFO_DEPTH 4 `define GFX_SP_LANES `VECS_PER_MAT -typedef logic[`GFX_SP_LANES - 1:0] lane_mask; +typedef logic[`GFX_SP_LANES - 1:0] lane_mask; +typedef logic[`FLOATS_PER_VEC - 1:0] vec_mask; + +typedef logic[`FLOATS_PER_VEC - 1:0][$clog2(`FLOATS_PER_VEC) - 1:0] swizzle_lanes; `endif diff --git a/rtl/gfx/gfx_shuffle.sv b/rtl/gfx/gfx_shuffle.sv new file mode 100644 index 0000000..c52ef25 --- /dev/null +++ b/rtl/gfx/gfx_shuffle.sv @@ -0,0 +1,20 @@ +`include "gfx/gfx_defs.sv" + +module gfx_shuffle +( + input logic clk, + + input vec4 a, + b, + input vec_mask select, + input logic stall, + + output vec4 out +); + + always_ff @(posedge clk) + if (!stall) + for (integer i = 0; i < `FLOATS_PER_VEC; ++i) + out[i] <= select[i] ? b[i] : a[i]; + +endmodule diff --git a/rtl/gfx/gfx_swizzle.sv b/rtl/gfx/gfx_swizzle.sv new file mode 100644 index 0000000..1a57c11 --- /dev/null +++ b/rtl/gfx/gfx_swizzle.sv @@ -0,0 +1,19 @@ +`include "gfx/gfx_defs.sv" + +module gfx_swizzle +( + input logic clk, + + input vec4 in, + input swizzle_lanes select, + input logic stall, + + output vec4 out +); + + always_ff @(posedge clk) + if (!stall) + for (integer i = 0; i < `FLOATS_PER_VEC; ++i) + out[i] <= in[select[i]]; + +endmodule |
