-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathColor_Mapper.sv
49 lines (44 loc) · 2.09 KB
/
Color_Mapper.sv
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
//-------------------------------------------------------------------------
// Color_Mapper.sv --
// Stephen Kempf --
// 3-1-06 --
// --
// Modified by David Kesler 07-16-2008 --
// Translated by Joe Meng 07-07-2013 --
// Modified by Po-Han Huang 10-06-2017 --
// --
// Fall 2017 Distribution --
// --
// For use with ECE 385 Lab 8 --
// University of Illinois ECE Department --
//-------------------------------------------------------------------------
// color_mapper: Decide which color to be output to VGA for each pixel.
module color_mapper ( input is_ball, // Whether current pixel belongs to ball
// or background (computed in ball.sv)
input [9:0] DrawX, DrawY, // Current pixel coordinates
output logic [7:0] VGA_R, VGA_G, VGA_B // VGA RGB output
);
logic [7:0] Red, Green, Blue;
// Output colors to VGA
assign VGA_R = Red;
assign VGA_G = Green;
assign VGA_B = Blue;
// Assign color based on is_ball signal
always_comb
begin
if (is_ball == 1'b1)
begin
// White ball
Red = 8'hff;
Green = 8'hff;
Blue = 8'hff;
end
else
begin
// Background with nice color gradient
Red = 8'h3f;
Green = 8'h00;
Blue = 8'h7f - {1'b0, DrawX[9:3]};
end
end
endmodule