-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathColor_Mapper.sv.bak
63 lines (53 loc) · 2.52 KB
/
Color_Mapper.sv.bak
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
//-------------------------------------------------------------------------
// Color_Mapper.sv --
// Stephen Kempf --
// 3-1-06 --
// --
// Modified by David Kesler 07-16-2008 --
// Translated by Joe Meng 07-07-2013 --
// --
// Fall 2014 Distribution --
// --
// For use with ECE 385 Lab 7 --
// University of Illinois ECE Department --
//-------------------------------------------------------------------------
module color_mapper ( input [9:0] BallX, BallY, DrawX, DrawY, Ball_size,
output logic [7:0] Red, Green, Blue );
logic ball_on;
/* Old Ball: Generated square box by checking if the current pixel is within a square of length
2*Ball_Size, centered at (BallX, BallY). Note that this requires unsigned comparisons.
if ((DrawX >= BallX - Ball_size) &&
(DrawX <= BallX + Ball_size) &&
(DrawY >= BallY - Ball_size) &&
(DrawY <= BallY + Ball_size))
New Ball: Generates (pixelated) circle by using the standard circle formula. Note that while
this single line is quite powerful descriptively, it causes the synthesis tool to use up three
of the 12 available multipliers on the chip! Since the multiplicants are required to be signed,
we have to first cast them from logic to int (signed by default) before they are multiplied). */
int DistX, DistY, Size;
assign DistX = DrawX - BallX;
assign DistY = DrawY - BallY;
assign Size = Ball_size;
always_comb
begin:Ball_on_proc
if ( ( DistX*DistX + DistY*DistY) <= (Size * Size) )
ball_on = 1'b1;
else
ball_on = 1'b0;
end
always_comb
begin:RGB_Display
if ((ball_on == 1'b1))
begin
Red = 8'hff;
Green = 8'h55;
Blue = 8'h00;
end
else
begin
Red = 8'h00;
Green = 8'h00;
Blue = 8'h7f - DrawX[9:3];
end
end
endmodule