Verilog clock divider 50 MHz to 1 MHz

Guest #3921565
Hi, I'm trying to figure out how this clock diver works but I don't 
understand, why it's necessary to multiple clk_out by two. I'd be 
grateful for an explanation, thx.


// counter size calculation according to input and output frequencies
// parameter sys_clk = 50000000;  // 50 MHz system clock
// parameter clk_out = 1000000;  // 1 MHz clock output
// parameter max = sys_clk / (2*clk_out); // max-counter size


// always@(posedge Clk_in) begin
//   if (counter == max-1)
//     begin
//     counter <= 0;
//     Clk_out <= ~Clk_out;
//     end
//   else
//     begin
//     counter <= counter + 1'd1;
//     end
//   end
// endmodule
Guest #3921615
CLK_OUT is a toggle flip flop and has 50% duty cycle. So you want to 
have half the time LOW and half the time HIGH. "cnt" measures only half 
of the period.

Reply

Only registered users may reply in this topic.

or

Log in with Google account

Registration is free and takes only a minute.

Register now