Trying to divide 100Mhz clock to 25Mhz for VGA

Guest #3598397
I came up with this but I am not sure if this will give me 25Mhz and I 
can't think of a way to test it. Can someone tell me if this is right?
1
 signal clock_25MHz : std_logic;
2
  signal counter : integer;
3
  
4
  process(clk,counter,clock_25Mhz)
5
    constant max_count : integer := 3; --divide 100 by 4 (0-3)
6
  begin
7
    if (rising_edge(clk)) then
8
      counter <= counter + 1;
9
        if (counter = max_count) then
10
          clock_25Mhz <= not clock_25Mhz;
11
          counter <= 0;
12
        end if;
13
    end if;
14
  end process;
Guest #3598459
Altera Quartus will promote clock_25 automatically to the clock network
if clock_25 is used as clock for other parts. No need for BUFG.

But clock_25 should not be a part of the sensitiv list of the process.
Guest #3599187
this is the most xxxx way to generate a clock I have ever seen.

... wrote:
> But clock_25 should not be a part of the sensitiv list of the process.
why not?
Guest #3599279
I don't know, if on Altera Quartus this will feed a clock network as 
...Guest states or if it will be just a toggling flip-flop.

But I'm quite sure that clk_25 will run at 12.5MHz, not at 25MHz ;-)
Guest #3599326
> But I'm quite sure that clk_25 will run at 12.5MHz, not at 25MHz

The TO can use a PLL to get a 200 MHz clock.

Or he divides by two only...
Moderator (Company: Titel) #3599337
... wrote:
> Or he divides by two only...
Or he uses a binary counter and takes the third bit of it:
1
   signal cnt : unsigned( 2 downto 0) := "000";
2
 :
3
   clkcnt <= clkcnt+1 when rising_edge(clk); -- take advantage of the automatic rollover of an unsigned vector
4
   clock_25 <= clkcnt(2);

Achim S. wrote:
> I don't know, if on Altera Quartus this will feed a clock network as
> ...Guest states
And up to now its not known if it is a FPGA at all and if it is one if 
it is from Altera...

Reply

A question of your own? This thread is over 12 years old. Ask it in a thread of its own – more people read along there, and it gets answered more often and sooner.

Start a new thread

A fix, an addition or feedback on this thread? Then reply here.

Formatting
  • [c]C-Code[/c]
  • [vhdl]VHDL-Code[/vhdl]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.