Forum Discussion
Altera_Forum
Honored Contributor
15 years agointerval timer
Hi I'm new in using the altera environment and my question would be how to build a timer of 1 second with interval timer. The interval timer that would use it to activate an interrupt every secon...
Altera_Forum
Honored Contributor
15 years agoSince I'm in a good mood here is most of the logic minus the slave port decoding of the interrupt clearing (note: I just typed this really fast so there could be errors):
input clear_interrupt;
output wire interrupt;
reg counter;
reg interrupt_reg;
wire set_interrupt_high;
always @ (posedge clk or posedge reset)
begin
if (reset)
begin
counter <= 0;
end
else
begin
if (set_interrupt_high == 1)
counter <= 0;
else
counter <= counter + 1'b1;
end
end
always @ (posedge clk or posedge reset)
begin
if (reset)
begin
interrupt_reg <= 0;
end
else
begin
if (set_interrupt_high == 1)
interrupt_reg <= 1;
else if (clear_interrupt == 1)
interrupt_reg <= 0;
end
end
assign set_interrupt_high = (counter == 49999999);
assign interrupt = interrupt_reg;