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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
|
`include "gfx/gfx_defs.sv"
module gfx_setup
(
input logic clk,
input raster_xy vertex_a,
vertex_b,
vertex_c,
input logic stall,
output raster_xy pos_ref,
output coarse_dim span_x,
span_y,
output raster_offsets_tri offsets,
output fixed_tri edge_refs,
coarse_x_offsets,
coarse_y_offsets,
coarse_test_offsets
);
// FIXME FIXME FIXME: Top-left rule
fixed_tri edge_base, edge_inc_x, edge_inc_y, out_edge_refs, x_offsets, y_offsets, test_offsets;
raster_xy bounds_ref, hold_vertex_a, hold_vertex_b, hold_vertex_c, ps[3], qs[3], out_pos_ref;
coarse_dim bounds_span_x, bounds_span_y, out_span_x, out_span_y;
raster_offsets_tri out_offsets;
struct packed
{
raster_xy pos_ref;
coarse_dim span_x,
span_y;
raster_offsets_tri offsets;
fixed_tri edge_refs,
coarse_x_offsets,
coarse_y_offsets,
coarse_test_offsets;
} out, skid_out;
gfx_skid_buf #(.WIDTH($bits(out))) skid
(
.in(out),
.out(skid_out),
.*
);
assign out.span_x = out_span_x;
assign out.span_y = out_span_y;
assign out.pos_ref = out_pos_ref;
assign out.offsets = out_offsets;
assign out.edge_refs = out_edge_refs;
assign out.coarse_x_offsets = x_offsets;
assign out.coarse_y_offsets = y_offsets;
assign out.coarse_test_offsets = test_offsets;
assign span_x = skid_out.span_x;
assign span_y = skid_out.span_y;
assign pos_ref = skid_out.pos_ref;
assign offsets = skid_out.offsets;
assign edge_refs = skid_out.edge_refs;
assign coarse_x_offsets = skid_out.coarse_x_offsets;
assign coarse_y_offsets = skid_out.coarse_y_offsets;
assign coarse_test_offsets = skid_out.coarse_test_offsets;
assign ps[0] = hold_vertex_a;
assign qs[0] = hold_vertex_b;
assign ps[1] = hold_vertex_b;
assign qs[1] = hold_vertex_c;
assign ps[2] = hold_vertex_c;
assign qs[2] = hold_vertex_a;
gfx_pipes #(.WIDTH($bits(vertex_a)), .DEPTH(`GFX_SETUP_BOUNDS_STAGES)) vertex_a_pipes
(
.in(vertex_a),
.out(hold_vertex_a),
.*
);
gfx_pipes #(.WIDTH($bits(vertex_b)), .DEPTH(`GFX_SETUP_BOUNDS_STAGES)) vertex_b_pipes
(
.in(vertex_b),
.out(hold_vertex_b),
.*
);
gfx_pipes #(.WIDTH($bits(vertex_c)), .DEPTH(`GFX_SETUP_BOUNDS_STAGES)) vertex_c_pipes
(
.in(vertex_c),
.out(hold_vertex_c),
.*
);
gfx_setup_bounds bounds
(
.span_x(bounds_span_x),
.span_y(bounds_span_y),
.reference(bounds_ref),
.*
);
localparam POST_BOUNDS_DEPTH = `GFX_SETUP_EDGE_STAGES + `GFX_SETUP_OFFSETS_STAGES;
gfx_pipes #(.WIDTH($bits(pos_ref)), .DEPTH(POST_BOUNDS_DEPTH)) ref_pipes
(
.in(bounds_ref),
.out(out_pos_ref),
.*
);
gfx_pipes #(.WIDTH($bits(span_x)), .DEPTH(POST_BOUNDS_DEPTH)) span_x_pipes
(
.in(bounds_span_x),
.out(out_span_x),
.*
);
gfx_pipes #(.WIDTH($bits(span_y)), .DEPTH(POST_BOUNDS_DEPTH)) span_y_pipes
(
.in(bounds_span_y),
.out(out_span_y),
.*
);
always_comb
for (integer i = 0; i < 3; ++i)
// Imaginárselo
unique case ({x_offsets[i][$bits(fixed) - 1], y_offsets[i][$bits(fixed) - 1]})
2'b00:
test_offsets[i] = out_offsets[i][`GFX_RASTER_OFFSETS - 1];
2'b01:
test_offsets[i] = out_offsets[i][`GFX_RASTER_SIZE - 1];
2'b10:
test_offsets[i] = out_offsets[i][`GFX_RASTER_OFFSETS - `GFX_RASTER_SIZE - 1];
2'b11:
test_offsets[i] = out_offsets[i][0];
endcase
genvar i;
generate
for (i = 0; i < 3; ++i) begin: edges
gfx_setup_edge edge_fn
(
.p(ps[i]),
.q(qs[i]),
.base(edge_base[i]),
.inc_x(edge_inc_x[i]),
.inc_y(edge_inc_y[i]),
.origin(bounds_ref),
.*
);
gfx_pipes #(.WIDTH($bits(fixed)), .DEPTH(`GFX_SETUP_OFFSETS_STAGES)) base_pipes
(
.in(edge_base[i]),
.out(out_edge_refs[i]),
.*
);
gfx_pipes #(.WIDTH($bits(fixed)), .DEPTH(`GFX_SETUP_OFFSETS_STAGES)) coarse_x_pipes
(
.in(edge_inc_x[i] << `GFX_RASTER_BITS),
.out(x_offsets[i]),
.*
);
gfx_pipes #(.WIDTH($bits(fixed)), .DEPTH(`GFX_SETUP_OFFSETS_STAGES)) coarse_y_pipes
(
.in(edge_inc_y[i] << `GFX_RASTER_BITS),
.out(y_offsets[i]),
.*
);
gfx_setup_offsets edge_offsets
(
.inc_x(edge_inc_x[i]),
.inc_y(edge_inc_y[i]),
.offsets(out_offsets[i]),
.*
);
end
endgenerate
endmodule
|