-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathseven_seg.v
48 lines (43 loc) · 937 Bytes
/
seven_seg.v
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
// Controls a 7 segment display
module seven_seg(
input clk,
input reset,
input count,
output reg [6:0]display,
output reg overflow
);
reg [3:0]counter;
always @(posedge clk) begin
if (reset) begin
counter <= 1'b0;
overflow <= 1'b0;
end else begin
if(count) begin
if (counter == 4'd9) begin
counter <= 1'b0;
overflow <= 1'b1;
end else begin
counter <= counter + 1'b1;
overflow <= 1'b0;
end
end else begin
overflow <= 1'b0;
end
end
end
always @(*) begin
case(counter)
4'd0 : display = 7'b1000000;
4'd1 : display = 7'b1111001;
4'd2 : display = 7'b0100100;
4'd3 : display = 7'b0110000;
4'd4 : display = 7'b0011001;
4'd5 : display = 7'b0010010;
4'd6 : display = 7'b0000010;
4'd7 : display = 7'b1111000;
4'd8 : display = 7'b0000000;
4'd9 : display = 7'b0010000;
default : display = 7'b0000000;
endcase
end
endmodule