Changing the clock frequency


mchowder

Recommended Posts

No, the CMT can't do that.  If some part of the logic needs to advance at a slow rate, the common way to do that is to use a clock-enable signal, i.e. clock the logic with the system clock (say 32 MHz) and then generate a clock-enable signal using a counter (in your case a 23-bit counter) that resets at the period you want (in your case at 6399999).  The clock-enable signal is true when the counter is at the max value (in your case 6399999) and is used to qualify the clocking of the slow circuit.

Hope this helps

Link to comment
Share on other sites

  • 2 weeks later...

Just a quick comment that to generate a slower clock, a preferred method is to use a synchronous counter. This type of counter has all counter flops clocked by the same high speed input clock and fits well with the way that FPGAs handle clocks. It is also the way that this type of circuit would be designed in an ASIC.

Here is some code I wrote recently (as an example). It divides 315MHz from a PLL to 3.57MHz. A divide by 88 is required.
 

reg [6:0] pll315_counter;

reg clk357;

// create 3.57MHz NTSC clock by dividing 315MHz by 88
always @ (posedge w_clk315) begin
  clk357 <= (pll315_counter<7'd44);
  if (pll315_counter==7'd87) begin
    pll315_counter <= 7'b0;
  end else begin
    pll315_counter <= pll315_counter + 7'b1;
  end
end

You would need to change the counter length, termination count and half count to suit your frequencies. I should have really used constants (such as tick defines) rather than hard code numbers, but hey this is my personal hobby project 😃

 

Link to comment
Share on other sites

  • 8 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.