Forum: FPGA, VHDL & Verilog Verilog clock divider 50 MHz to 1 MHz

von Daniel (Guest)

Rate this post
0 useful
not useful
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

von Valko (Guest)

Rate this post
0 useful
not useful
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.


Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [vhdl]VHDL code[/vhdl]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]

Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.