-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathgl_fetch.v
169 lines (159 loc) · 5.77 KB
/
gl_fetch.v
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
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 11:40:45 11/03/2010
// Design Name:
// Module Name: gl_fetch
// Project Name:
// Target Devices:
// Tool versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
`include "gl_defines.v"
module gl_fetch(inst_out, inst_in, inst_addr,
decode_bram_addr,
clk, stall, reset, fifo_full);
parameter
text_start = 0,
width = 32,
reset_value = 0;
output reg [(width-1):0] inst_out; // instruction output
output reg [(width-1):0] inst_addr; // instruction address (bram read)
output reg [(width-1):0] decode_bram_addr; //
input [(width-1):0] inst_in; //
input clk; //
input stall; // stall
input fifo_full; // vertex and color fifo full
input reset;
reg tmp_stall; // temporary stall
wire [31:0] jmp_addr;
assign jmp_addr = {9'h0 , inst_in[30:8]};
initial begin
inst_addr <= text_start;
inst_out <= 32'b0;
decode_bram_addr <= 32'b0;
tmp_stall <= 0;
end
always @ (posedge clk) begin
if (reset) // Reset
begin
inst_addr <= text_start;
inst_out <= reset_value;
tmp_stall <= 0;
end
else if (tmp_stall)
begin
tmp_stall <= 0;
end
else if (stall || fifo_full) // Stall
begin
inst_addr <= inst_addr;
inst_out <= inst_out;
end
else // Normal Operation
begin
case (inst_in[7:0])
//`OP_VERTEX:
8'b00000011:
begin
inst_addr <= inst_addr + 4;
inst_out <= inst_in;
decode_bram_addr <= inst_addr + 1;
tmp_stall <= 1;
end
//`OP_COLOR:
8'b00000100:
begin
inst_addr <= inst_addr + 4;
decode_bram_addr <= inst_addr + 1;
inst_out <= inst_in;
tmp_stall <= 1;
end
//`OP_MULTMATRIX:
8'b00010001:
begin
inst_addr <= inst_addr + 17;
inst_out <= inst_in;
decode_bram_addr <= inst_addr + 1;
tmp_stall <= 1;
end
//`OP_LOADMATRIX:
8'b00010011:
begin
inst_addr <= inst_addr + 17;
inst_out <= inst_in;
decode_bram_addr <= inst_addr + 1;
tmp_stall <= 1;
end
//`OP_ROTATE:
8'b00010110:
begin
inst_addr <= inst_addr + 17;
inst_out <= 32'h80001016; // Rotate
decode_bram_addr <= inst_addr + 1;
tmp_stall <= 1;
end
//`OP_SCALE:
8'b00010111:
begin
inst_addr <= inst_addr + 17;
inst_out <= 32'h80001016; // Rotate
decode_bram_addr <= inst_addr + 1;
tmp_stall <= 1;
end
//`OP_TRANSLATE:
8'b00011000:
begin
inst_addr <= inst_addr + 17;
inst_out <= 32'h80001016; // Rotate
decode_bram_addr <= inst_addr + 1;
tmp_stall <= 1;
end
//`OP_VIEWPORT:
8'b00011001:
begin
inst_addr <= inst_addr + 5;
decode_bram_addr <= inst_addr + 1;
inst_out <= inst_in;
tmp_stall <= 1;
end
//`OP_FRUSTUM:
8'b00011010:
begin
inst_addr <= inst_addr + 17;
inst_out <= 32'h80001011; // MULTMATRIX
decode_bram_addr <= inst_addr + 1;
tmp_stall <= 1;
end
//`OP_ORTHO:
8'b00011011:
begin
inst_addr <= inst_addr + 17;
inst_out <= 32'h80001011; // MULTMATRIX
decode_bram_addr <= inst_addr + 1;
tmp_stall <= 1;
end
//`OP_JMP:
8'b00000110:
begin
inst_addr <= jmp_addr;
inst_out <= inst_in;
end
default:
begin
inst_addr <= inst_addr + 1;
inst_out <= inst_in;
end
endcase
end
end
endmodule