-
Notifications
You must be signed in to change notification settings - Fork 0
/
rtc.v
66 lines (55 loc) · 1.2 KB
/
rtc.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
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 22:18:01 12/04/2021
// Design Name:
// Module Name: rtc
// Project Name:
// Target Devices:
// Tool versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module rtc(
output [4:0] hrs,
output [5:0] mins,
output [5:0] sec,
input clk60ns,clk1ns,reset
);
reg [4:0]hrs_reg;
reg [5:0]mins_reg,mins_reg1,sec_reg;
always @(posedge clk60ns)
begin
if(reset)
begin
hrs_reg = 5'b00000;
mins_reg = 6'b000000;
sec_reg = 6'b000000;
end
else
begin
mins_reg = (mins_reg == 6'b111011)?6'b000000:mins_reg + 6'b000001;
repeat(59) @(posedge clk1ns);
end
end
always @(mins_reg)
begin
hrs_reg = (hrs_reg == 5'b10111)?5'b000000:hrs_reg + 5'b00001;
repeat(59) @(posedge clk60ns);
end
always @(posedge clk1ns)
begin
sec_reg = (sec_reg == 6'b111011)?6'b000000:sec_reg + 6'b000001;
end
assign hrs = hrs_reg;
assign mins = mins_reg;
assign sec = sec_reg;
endmodule