-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcloud.sv
67 lines (58 loc) · 2.19 KB
/
cloud.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
module cloud(
input Reset, frame_clk,
output[9:0] cloudX1, cloudY1,cloudX2, cloudY2, cloudW, cloudH
);
logic [9:0] cloud_X_Pos1, cloud_X_Pos2, cloud_X_Motion1, cloud_X_Motion2, cloud_Y_Pos1, cloud_Y_Pos2, cloud_Y_Motion, cloud_Width, cloud_Height;
parameter [9:0] cloud_Y_Center=20; // Center position on the Y axis
parameter [9:0] cloud_X_Center=20; // Center position on the Y axis
parameter [9:0] cloud_X_Min=0; // Leftmost point on the X axis
parameter [9:0] cloud_X_Max=639; // Rightmost point on the X axis
parameter [9:0] cloud_Y_Min=0; // Topmost point on the Y axis
parameter [9:0] cloud_Y_Max=479; // Bottommost point on the Y axis
parameter [9:0] cloud_X_Step=1; // Step size on the X axis
parameter [9:0] cloud_Y_Step=0; // Step size on the Y axis
assign cloud_Width = 80; // assigns the value 4 as a 10-digit binary number, ie "0000000100"
assign cloud_Height = 40;
always_ff @ (posedge Reset or posedge frame_clk )
begin: Move_cloud
if (Reset) // Asynchronous Reset
begin
cloud_Y_Motion <= 10'd0; //cloud_Y_Step;
cloud_X_Motion1 <= 10'd0; //cloud_X_Step;
cloud_Y_Pos1 <= cloud_Y_Center;
cloud_X_Pos1 <= cloud_X_Center;
cloud_Y_Pos2 <= cloud_Y_Center;
cloud_X_Pos2 <= cloud_X_Center+200;
end
else
begin
if (cloud_X_Pos1 >=700 )
begin
cloud_X_Motion1 <= cloud_X_Step;
cloud_X_Pos1 <= 0;
end
else if(cloud_X_Pos2 <= 0)
begin
cloud_X_Motion1 <= 0;
cloud_X_Motion2 <= -cloud_X_Step;
cloud_X_Pos2 <= 700;
end
else
begin
cloud_X_Motion1 <= cloud_X_Step;
cloud_X_Motion2 <= -cloud_X_Step;
cloud_Y_Motion <= 0;
end
cloud_Y_Pos1 <= (cloud_Y_Pos1 + cloud_Y_Motion); // Update cloud position
cloud_X_Pos1 <= (cloud_X_Pos1 + cloud_X_Motion1);
cloud_Y_Pos2 <= (cloud_Y_Pos2 + cloud_Y_Motion); // Update cloud position
cloud_X_Pos2 <= (cloud_X_Pos2 + cloud_X_Motion2);
end
end
assign cloudX1 = cloud_X_Pos1;
assign cloudY1 = cloud_Y_Pos1;
assign cloudX2 = cloud_X_Pos2;
assign cloudY2 = cloud_Y_Pos2;
assign cloudW = cloud_Width;
assign cloudH = cloud_Height;
endmodule