-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodify_slope.v
More file actions
executable file
·47 lines (44 loc) · 888 Bytes
/
modify_slope.v
File metadata and controls
executable file
·47 lines (44 loc) · 888 Bytes
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
module modify_slope( CLOCK_50, KEY, slope1, slope2, slope, reset );
input wire CLOCK_50, reset;
input wire [3:0] KEY;
output reg [3:0] slope1, slope2, slope;
reg old_key1;
reg old_key0;
always @( posedge CLOCK_50 ) begin
if( !reset ) begin
slope = 0;
slope2 = 0;
slope1 = 0;
end
else begin
if( old_key1 && !KEY[1] ) begin
if( slope2 < 9 ) begin
slope2 = slope2 + 1;
slope = slope + 1;
end
else begin
if( slope1 < 1 ) begin
slope2 = 0;
slope1 = slope1 + 1;
slope = slope + 1;
end
end
end
else if( old_key0 && !KEY[0] ) begin
if( slope2 > 0 ) begin
slope2 = slope2 - 1;
slope = slope - 1;
end
else begin
if( slope1 > 0 ) begin
slope2 = 9;
slope1 = slope1 - 1;
slope = slope - 1;
end
end
end
old_key1 = KEY[1];
old_key0 = KEY[0];
end
end
endmodule