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
|
`include "gfx/gfx_defs.sv"
module gfx_sp_writeback
(
input logic clk,
rst_n,
input wb_op stream_wb,
input logic stream_wb_valid,
output logic stream_wb_ready,
input wb_op combiner_wb,
input logic combiner_wb_valid,
output logic combiner_wb_ready,
input wb_op shuffler_wb,
input logic shuffler_wb_valid,
output logic shuffler_wb_ready,
output logic wr,
output vreg_num wr_reg,
output mat4 wr_data
);
wb_op wb_in, wb_out;
assign wr_reg = wb_out.dst;
assign wr_data = wb_out.data;
gfx_pipeline_flow #(.STAGES(`GFX_SP_WB_STAGES)) flow
(
.stall(),
.in_ready(),
.in_valid(stream_wb_valid || combiner_wb_valid || shuffler_wb_valid),
.out_ready(1),
.out_valid(wr),
.*
);
gfx_pipes #(.WIDTH($bits(wb_out)), .DEPTH(`GFX_SP_WB_STAGES)) pipes
(
.in(wb_in),
.out(wb_out),
.stall(0),
.*
);
always_comb begin
stream_wb_ready = 0;
combiner_wb_ready = 0;
shuffler_wb_ready = 0;
if (stream_wb_valid) begin
wb_in = stream_wb;
stream_wb_ready = 1;
end else if (shuffler_wb_valid) begin
wb_in = shuffler_wb;
shuffler_wb_ready = 1;
end else begin
wb_in = combiner_wb;
combiner_wb_ready = 1;
end
end
endmodule
|