-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclearscreen.v
More file actions
75 lines (65 loc) · 1.17 KB
/
Copy pathclearscreen.v
File metadata and controls
75 lines (65 loc) · 1.17 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
module clearscreen(CLOCK_50, rst, x_out , y_out);
input CLOCK_50;
input rst;
wire [2:0] color = 3'b000;
output [7:0] x_out;
output [6:0] y_out;
wire change;
fsm_clear f1(.clk(CLOCK_50), .rst(rst), .change(change), .colour(color));
datapath_clear d1(.clk(CLOCK_50), .rst(rst), .x(x_out), .y(y_out), .change(change));
endmodule
module fsm_clear(clk, rst, change, colour);
output [2:0] colour;
input change;
input rst;
input clk;
reg [2:0] p_state;
reg [2:0] n_state;
assign colour=000;
always@(*)
begin
if(change)
case(p_state)
0:n_state = 1;
1:n_state = 2;
2:n_state = 3;
3:n_state = 4;
4:n_state = 5;
5:n_state = 6;
6:n_state = 7;
7:n_state = 0;
endcase
else
n_state = p_state;
end
always@(posedge clk or posedge rst)
begin
if(rst) begin
p_state <= 0;
end
else begin
p_state <= n_state;
end
end
endmodule
module datapath_clear(clk, rst, x, y, change);
input clk, rst;
output reg [7:0]x;
output reg [6:0]y;
output change;
assign change = (x == 159);
always@(posedge clk or posedge rst)
begin
if(rst) begin
y <= 0;
x <= 0;
end
else begin
x <= x + 1;
if(change)
y <= y + 1;
else
y <= y;
end
end
endmodule