-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGPU_Core.sv
More file actions
155 lines (150 loc) · 3.32 KB
/
Copy pathGPU_Core.sv
File metadata and controls
155 lines (150 loc) · 3.32 KB
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
module GPU_Core(
input logic Clock,
input logic Reset,
input logic [95:0] Instruction,
output logic ReadInstruction,
input logic InstructionValid,
output logic [43:0] PixelInstruction,
output logic WriteInstruction,
input logic Ready
);
logic [9:0] Current_x,Start_x,End_x;
logic [8:0] Current_y,Start_y,End_y;
logic [7:0] Current_Red,Current_Green,Current_Blue;
logic[3:0] CurrentState;
logic[95:0] CurrentInstruction;
enum logic[3:0]{
Idle=4'b0000,
Decode=4'b0001,
Line0=4'b0010,
Line1=4'b0011,
Pixel0=4'b0100,
Pixel1=4'b0101,
Rectangle0=4'b0110,
Rectangle1=4'b0111
}States;
enum logic[3:0]{
Pixel=4'b0001,
Line=4'b0010,
Rectangle=4'b0011,
Circle=4'b0100,
Arc=4'b0101
}OpCodes;
always_ff @(posedge Clock)
begin
case(CurrentState)
Idle:
begin
if(InstructionValid)
begin
CurrentInstruction<=Instruction;
CurrentState<=Decode;
end
end
Decode:
begin
Current_Red<=CurrentInstruction[47:40];
Current_Green<=CurrentInstruction[39:32];
Current_Blue<=CurrentInstruction[31:24];
case(CurrentInstruction[95:92])
Pixel:
begin
Start_x<=CurrentInstruction[91:82];
Current_x<=CurrentInstruction[91:82];
End_x<=CurrentInstruction[72:63];
Start_y<=CurrentInstruction[81:73];
Current_y<=CurrentInstruction[81:73];
End_y<=CurrentInstruction[62:54];
CurrentState<=Pixel0;
end
Line:
begin
Start_x<=CurrentInstruction[91:82];
Current_x<=CurrentInstruction[91:82];
End_x<=CurrentInstruction[72:63];
Start_y<=CurrentInstruction[81:73];
Current_y<=CurrentInstruction[81:73];
End_y<=CurrentInstruction[62:54];
CurrentState<=Line0;
end
Rectangle:
begin
Start_x<=CurrentInstruction[91:82];
Current_x<=CurrentInstruction[91:82];
End_x<=CurrentInstruction[72:63];
Start_y<=CurrentInstruction[81:73];
Current_y<=CurrentInstruction[81:73];
End_y<=CurrentInstruction[62:54];
CurrentState<=Rectangle0;
end
default:
begin
CurrentState<=Idle;
end
endcase
end
Pixel0:
begin
PixelInstruction<={Current_y,Current_x,Current_Red,Current_Green,Current_Blue};
WriteInstruction<=1;
CurrentState<=Pixel1;
end
Pixel1:
begin
if(Ready)
begin
CurrentInstruction<=Idle;
WriteInstruction<=0;
end
end
Line0:
begin
PixelInstruction<={Current_y,Current_x,Current_Red,Current_Green,Current_Blue};
WriteInstruction<=1;
CurrentState<=Line1;
end
Line1:
begin
if(Ready)
begin
WriteInstruction<=0;
if(Current_x==End_x)
begin
CurrentInstruction<=Idle;
end else begin
Current_x<=Current_x+1;
CurrentState<=Line0;
end
end
end
Rectangle0:
begin
PixelInstruction<={Current_y,Current_x,Current_Red,Current_Green,Current_Blue};
WriteInstruction<=1;
CurrentState<=Rectangle1;
end
Rectangle1:
begin
if(Ready)
begin
WriteInstruction<=0;
if(Current_x==End_x)
begin
if(Current_y==End_y)
begin
CurrentInstruction<=Idle;
end
else
begin
Current_x<=Start_x;
Current_y<=Current_y+1;
end
end else begin
Current_x<=Current_x+1;
CurrentState<=Rectangle0;
end
end
end
endcase
end
endmodule