-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdrawBall.v
More file actions
54 lines (50 loc) · 1.21 KB
/
drawBall.v
File metadata and controls
54 lines (50 loc) · 1.21 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
module drawBall(clock, resetn, gameStart, enable, xBallCoordIn, yBallCoordIn, xBallOut, yBallOut, doneBallDraw);
input clock;
input resetn;
input gameStart;
input enable;
input [7:0] xBallCoordIn;
input [6:0] yBallCoordIn;
reg [2:0] counter;
output reg [7:0] xBallOut;
output reg [6:0] yBallOut;
output reg doneBallDraw;
always@(posedge clock) begin
if(resetn) begin
xBallOut <= 0;
yBallOut <= 0;
doneBallDraw <= 0;
counter <= 0;
end
else if(enable) begin
if(!doneBallDraw) begin
if(counter == 2'b00) begin //0
xBallOut <= xBallCoordIn;
yBallOut <= yBallCoordIn;
counter <= counter + 1'b1;
end
else if(counter == 2'b01) begin //1
xBallOut <= xBallCoordIn + 1'b1;
yBallOut <= yBallCoordIn;
counter <= counter + 1'b1;
end
else if(counter == 2'b10) begin //2
xBallOut <= xBallCoordIn;
yBallOut <= yBallCoordIn + 1'b1;
counter <= counter + 1'b1;
end
else if(counter == 2'b11) begin //3
xBallOut <= xBallCoordIn + 1'b1;
yBallOut <= yBallCoordIn + 1'b1;
counter <= counter + 1'b1;
end
else
doneBallDraw <= 1;
end
else begin
counter <= 0;
doneBallDraw <= 0;
end
end
end
endmodule