summaryrefslogtreecommitdiff
path: root/rtl/gfx/gfx_perspective_flow.sv
blob: ecacc6500635ee895ad748be901c0060490a3c22 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
`include "gfx/gfx_defs.sv"

module gfx_perspective_flow
(
	input  logic clk,
	             rst_n,

	input  logic vertex_start,
	output logic stall,
	             in_start,
	             out_start,

	input  logic in_valid,
	             out_ready,

	output logic in_ready,
	             out_valid
	             stall
);

	localparam STAGES = `FP_INV_STAGES + `FP_MUL_STAGES;

	logic[STAGES - 1:0] start_pipes;

	assign in_start = start_pipes[`FP_INV_STAGES - 1];
	assign out_start = start_pipes[STAGES - 1];

	pipeline_flow #(.STAGES(STAGES)) flow
	(
		.*
	);

	always_ff @(posedge clk or negedge rst_n)
		if (!rst_n)
			start_pipes[0] <= 0;
		else if (!stall)
			start_pipes[0] <= in_valid && vertex_start;

	genvar i;
	generate
		for (i = 1; i < STAGES; ++i) begin: pipeline
			always_ff @(posedge clk or negedge rst_n)
				if (!rst_n)
					start_pipes[i] <= 0;
				else if (!stall)
					start_pipes[i] <= start_pipes[i - 1];
		end
	endgenerate

endmodule