-
Notifications
You must be signed in to change notification settings - Fork 1
/
bcd_counter.v
68 lines (61 loc) · 998 Bytes
/
bcd_counter.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
module bcd_counter(
input clk,
input reset,
output reg [3:0] cnt,
output reg carry
);
//reg [3:0] cnt_mem;
//assign cnt = cnt_mem;
always @(posedge clk, posedge reset)
begin
if (reset == 1)
cnt = 0;
else
begin
if (cnt == 9)
begin
cnt <= 0;
carry <= 1;
end // if
else
begin
cnt <= cnt + 1;
carry <= 0;
end // else
end
end // always
endmodule
//module BCDcount (Clock, Clear, E, BCD1, BCD0);
//module bcd_counter(
// input clk,
// input reset,
// output reg [3:0] cnt,
// output reg carry
//);
//
//// input Clock, Clear, E;
//// output reg [3:0] BCD1, BCD0;
//
// always @(posedge clk)
// begin
//
// if (reset)
// begin
// cnt <= 0;
//// BCD0 <= 0;
// end
//
// else if (1)
// if (cnt == 4'b1001)
// begin
// cnt <= 0;
// carry <= 1;
// end
// else
// begin
// cnt <= cnt + 1;
// carry <= 0;
// end
//end
//
//endmodule