Altera_Forum
Honored Contributor
16 years agoConvert a 50MHz clock into 1Hz Clock
Hi,
I am working on a project that requires a counter. The ALTERA board that I am using has a 50 MHz clock on PIN N2. I wrote the following code for the counter:
module counter(clock, reset, count);
input clock, reset;
output count;
reg next_count,count;
always@*
begin
if(count<15)
next_count=count+4'd1;
else
next_count=count;
end
always@(posedge clock)
begin
if(reset)
count<=4'd0;
else
count<=next_count;
end
endmodule
I need to map the input clock to a 1 Hz clock so that the counter counts every second. But the board only has a 50 MHz clock. How can I use this 50 MHz as an input to the counter so that the counter counts every second? Please help .. Thanks!!!!