-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtimer.sv
More file actions
31 lines (28 loc) · 639 Bytes
/
Copy pathtimer.sv
File metadata and controls
31 lines (28 loc) · 639 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
module timer (
input logic clk,
input logic rst,
output logic timer_interrupt
);
parameter TIMER_LIMIT = 100;
reg [31:0] timer_counter;
always @(posedge clk or posedge rst)
begin
if (rst)
begin
timer_counter <= 0;
end
else
begin
timer_counter <= timer_counter + 1;
if (timer_counter == TIMER_LIMIT)
begin
timer_counter <= 0;
timer_interrupt <= 1;
end
else
begin
timer_interrupt <= 0;
end
end
end
endmodule