summaryrefslogtreecommitdiff
path: root/rtl/gfx/gfx_persp_vertex.sv
diff options
context:
space:
mode:
authorAlejandro Soto <alejandro@34project.org>2023-11-22 01:38:58 -0600
committerAlejandro Soto <alejandro@34project.org>2023-11-22 02:31:52 -0600
commit11231e7173d16415d45f809dc570cba0a2aae0cd (patch)
tree9a2a3e984b7b8e6c2ccc6da1b54d847a020c45ac /rtl/gfx/gfx_persp_vertex.sv
parent1e064f29139a45061a8082914e9ee75c15e803a4 (diff)
rtl/gfx: implement perspective correction
Diffstat (limited to 'rtl/gfx/gfx_persp_vertex.sv')
-rw-r--r--rtl/gfx/gfx_persp_vertex.sv52
1 files changed, 52 insertions, 0 deletions
diff --git a/rtl/gfx/gfx_persp_vertex.sv b/rtl/gfx/gfx_persp_vertex.sv
new file mode 100644
index 0000000..f7434f0
--- /dev/null
+++ b/rtl/gfx/gfx_persp_vertex.sv
@@ -0,0 +1,52 @@
+`include "gfx/gfx_defs.sv"
+
+module gfx_persp_vertex
+(
+ input logic clk,
+
+ input raster_xyzw in_vertex,
+ input logic stall,
+
+ output raster_xyzw out_vertex
+);
+
+ raster_xyzw skid_vertex;
+
+ gfx_fixed_div x_div
+ (
+ .z(in_vertex.xy.x),
+ .d(in_vertex.zw.w),
+ .q(skid_vertex.xy.x),
+ .*
+ );
+
+ gfx_fixed_div y_div
+ (
+ .z(in_vertex.xy.y),
+ .d(in_vertex.zw.w),
+ .q(skid_vertex.xy.y),
+ .*
+ );
+
+ gfx_pipes #(.WIDTH($bits(fixed)), .DEPTH(`FIXED_DIV_STAGES)) z_pipes
+ (
+ .in(in_vertex.zw.z),
+ .out(skid_vertex.zw.z),
+ .*
+ );
+
+ gfx_pipes #(.WIDTH($bits(fixed)), .DEPTH(`FIXED_DIV_STAGES)) w_pipes
+ (
+ .in(in_vertex.zw.w),
+ .out(skid_vertex.zw.w),
+ .*
+ );
+
+ gfx_skid_buf #(.WIDTH($bits(out_vertex))) vertex_skid
+ (
+ .in(skid_vertex),
+ .out(out_vertex),
+ .*
+ );
+
+endmodule