Results 1 to 5 of 5

Thread: using lpm_counter to divide a clock by any No

  1. #1
    Join Date
    Nov 2016
    Posts
    39
    Rep Power
    1

    Default using lpm_counter to divide a clock by any No

    Greetings everyone, I want to divide a 50 MHz clock frequency by (2,3,4,5,6,7,8). I am using a Block Diagram Schematics. Can I do this by using a (Counter)?? I have tried using the (modulus) but I don't get any output in the Simulation. What can I do please?? I have been using VHDL for a long time, but now I want to accomplish the task using Block Diagram/Schematics because I don't want to go back to the coding.

    Your help means a lot to me, Thanks!

  2. #2
    Tricky is offline Moderator **Forum Master**
    Join Date
    Oct 2008
    Posts
    5,420
    Rep Power
    1

    Default Re: using lpm_counter to divide a clock by any No

    Why dont you want to go back to coding? Block diagrams have many disadvantages over code:

    1. You cannot simulate a block diagram (it has to be converted to HDL first)
    2. Block diagrams are not portable between vendors
    3. Block diagrams dont work very well with version control.

    Using a counter is possible to do anything - but I suggest not using the mod function - it implements a divider which may complete in a single clock and be very slow. And you should not generate a clock with logic anyway. It is much better practice to create a clock enable so that all logic uses the system clock, only enabled when required (every other clock, every third clock etc).

  3. #3
    Join Date
    Nov 2016
    Posts
    39
    Rep Power
    1

    Default Re: using lpm_counter to divide a clock by any No

    Thank you very much indeed. But how do I use the clock enable input???? I mean there is the output from the pll that is connected directly to the clock of the counter. What do I have to connect to clk_enable input???

    Regards.

  4. #4
    Tricky is offline Moderator **Forum Master**
    Join Date
    Oct 2008
    Posts
    5,420
    Rep Power
    1

    Default Re: using lpm_counter to divide a clock by any No

    you would have a counter free running, and then use the counter to generate a clock enable:

    for example - to divide a clock by 16 - eg in VHDL:

    Code:
    signal counter : unsigned(3 downto 0);
    signal clk_en : std_logic;
    
    process(clk)
    begin
      if rising_edge(clk) then
        counter <= counter + 1;
    
        if counter = 0 then
          clk_en <= '1';
        else 
          clk_en <= '0'
        end if;
    
        if clk_en = '1' then
          -- logic here is only switched on every 16 clocks
        end if;
      end if
    end process;

  5. #5
    Join Date
    Nov 2016
    Posts
    39
    Rep Power
    1

    Default Re: using lpm_counter to divide a clock by any No

    Thank you very much, that is really helpful.

Similar Threads

  1. how to make lpm_counter count just once
    By Naidy in forum Quartus II and EDA Tools Discussion
    Replies: 2
    Last Post: June 18th, 2015, 04:23 AM
  2. DE1 Clock divide by 2
    By ABlackBox in forum FPGA, Hardcopy, and CPLD Discussion
    Replies: 0
    Last Post: November 19th, 2013, 07:30 AM
  3. LPM_Counter odd behavior
    By Whitespace in forum General Altera Discussion
    Replies: 1
    Last Post: March 13th, 2013, 11:20 PM
  4. lpm_counter are synchronous?
    By Piyushm in forum General Altera Discussion
    Replies: 1
    Last Post: April 3rd, 2012, 05:30 AM
  5. divide the internal clock
    By nawer81 in forum Quartus II and EDA Tools Discussion
    Replies: 10
    Last Post: May 3rd, 2011, 10:25 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •