FARAH F MIRZA
Newbie level 5
this is the code for frequency divider but i am not getting the output wave for divided clock.....
also is there any rule or formula for dividing the frequency from 50mhz to some other value? like how many bits of counter to use ???
also is there any rule or formula for dividing the frequency from 50mhz to some other value? like how many bits of counter to use ???
Code:
module clockdivider(clkdivout,reset,clk);
input reset,clk;
output clkdivout;
reg clkdivout;
wire reset,clk;
parameter period=10;
parameter halfperiod=period/2;
reg [3:0]countvalue;
always @(posedge clk)
begin
if(reset)
begin
countvalue = 0;
clkdivout <= 0;
end
else
begin
if(countvalue == period-1)
begin
countvalue = 0;
clkdivout <= 0;
end
else
countvalue = countvalue+1;
if(countvalue == halfperiod)
clkdivout <= 1;
end
end
endmodule
Last edited by a moderator: