forked from felixnavid/FPGA-Breakout
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbricks.v
More file actions
144 lines (140 loc) · 5.37 KB
/
bricks.v
File metadata and controls
144 lines (140 loc) · 5.37 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
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 11:31:43 08/13/2014
// Design Name:
// Module Name: bricks
// Project Name:
// Target Devices:
// Tool versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module bricks(
input[9:0] xIndex,
input[9:0] yIndex,
input displayEnable,
input [29:0] bricksDisplay,
output reg[7:0] color,
output reg shouldDisplay
);
// red 6:0
// orange 12:7
// yellow 18:13
// green 24:19
// blue 30:25
parameter startXCoord = 20;
parameter startYCoord = 20;
parameter endXCoord = 620;
parameter brickYSize = 20;
parameter brickXSize = 100;
parameter redColor = 8'b11000000;
parameter orangeColor = 8'b11001100;
parameter yellowColor = 8'b11011000;
parameter greenColor = 8'b00011000;
parameter blueColor = 8'b00000011;
parameter blackColor = 8'b00000000;
always @(*) begin
if((displayEnable)&&(xIndex>=startXCoord)&&(xIndex<startXCoord+brickXSize*6)) begin
if((yIndex>=startYCoord)&&(yIndex<=startYCoord+brickYSize)) begin
if(xIndex<startXCoord+brickXSize) begin
color = bricksDisplay[0] ? redColor : blackColor;
end else if(xIndex<startXCoord+2*brickXSize) begin
color = bricksDisplay[1] ? redColor : blackColor;
end else if(xIndex<startXCoord+3*brickXSize) begin
color = bricksDisplay[2] ? redColor : blackColor;
end else if(xIndex<startXCoord+4*brickXSize) begin
color = bricksDisplay[3] ? redColor : blackColor;
end else if(xIndex<startXCoord+5*brickXSize) begin
color = bricksDisplay[4] ? redColor : blackColor;
end else if(xIndex<startXCoord+6*brickXSize) begin
color = bricksDisplay[5] ? redColor : blackColor;
end else begin
color = 8'b00000000;
end
shouldDisplay = 1;
end else if((yIndex>=startYCoord+brickYSize)&&(yIndex<startYCoord+brickYSize*2)) begin
if(xIndex<startXCoord+brickXSize) begin
color = bricksDisplay[6] ? orangeColor : blackColor;
end else if(xIndex<startXCoord+2*brickXSize) begin
color = bricksDisplay[7] ? orangeColor : blackColor;
end else if(xIndex<startXCoord+3*brickXSize) begin
color = bricksDisplay[8] ? orangeColor : blackColor;
end else if(xIndex<startXCoord+4*brickXSize) begin
color = bricksDisplay[9] ? orangeColor : blackColor;
end else if(xIndex<startXCoord+5*brickXSize) begin
color = bricksDisplay[10] ? orangeColor : blackColor;
end else if(xIndex<startXCoord+6*brickXSize) begin
color = bricksDisplay[11] ? orangeColor : blackColor;
end else begin
color = 8'b00000000;
end
shouldDisplay = 1;
end else if((yIndex>=startYCoord+brickYSize*2)&&(yIndex<startYCoord+brickYSize*3)) begin
if(xIndex<startXCoord+brickXSize) begin
color = bricksDisplay[12] ? yellowColor : blackColor;
end else if(xIndex<startXCoord+2*brickXSize) begin
color = bricksDisplay[13] ? yellowColor : blackColor;
end else if(xIndex<startXCoord+3*brickXSize) begin
color = bricksDisplay[14] ? yellowColor : blackColor;
end else if(xIndex<startXCoord+4*brickXSize) begin
color = bricksDisplay[15] ? yellowColor : blackColor;
end else if(xIndex<startXCoord+5*brickXSize) begin
color = bricksDisplay[16] ? yellowColor : blackColor;
end else if(xIndex<startXCoord+6*brickXSize) begin
color = bricksDisplay[17] ? yellowColor : blackColor;
end else begin
color = 8'b00000000;
end
shouldDisplay = 1;
end else if((yIndex>=startYCoord+brickYSize*3)&&(yIndex<startYCoord+brickYSize*4)) begin
if(xIndex<startXCoord+brickXSize) begin
color = bricksDisplay[18] ? greenColor : blackColor;
end else if(xIndex<startXCoord+2*brickXSize) begin
color = bricksDisplay[19] ? greenColor : blackColor;
end else if(xIndex<startXCoord+3*brickXSize) begin
color = bricksDisplay[20] ? greenColor : blackColor;
end else if(xIndex<startXCoord+4*brickXSize) begin
color = bricksDisplay[21] ? greenColor : blackColor;
end else if(xIndex<startXCoord+5*brickXSize) begin
color = bricksDisplay[22] ? greenColor : blackColor;
end else if(xIndex<startXCoord+6*brickXSize) begin
color = bricksDisplay[23] ? greenColor : blackColor;
end else begin
color = 8'b00000000;
end
shouldDisplay = 1;
end else if((yIndex>=startYCoord+brickYSize*4)&&(yIndex<startYCoord+brickYSize*5)) begin
if(xIndex<startXCoord+brickXSize) begin
color = bricksDisplay[24] ? blueColor : blackColor;
end else if(xIndex<startXCoord+2*brickXSize) begin
color = bricksDisplay[25] ? blueColor : blackColor;
end else if(xIndex<startXCoord+3*brickXSize) begin
color = bricksDisplay[26] ? blueColor : blackColor;
end else if(xIndex<startXCoord+4*brickXSize) begin
color = bricksDisplay[27] ? blueColor : blackColor;
end else if(xIndex<startXCoord+5*brickXSize) begin
color = bricksDisplay[28] ? blueColor : blackColor;
end else if(xIndex<startXCoord+6*brickXSize) begin
color = bricksDisplay[29] ? blueColor : blackColor;
end else begin
color = 8'b00000000;
end
shouldDisplay = 1;
end else begin
color = 8'b00000000;
shouldDisplay = 0;
end
end else begin
shouldDisplay = 0;
end
end
endmodule