Slow Synthesis

Discussion in 'VHDL' started by Jeremy Pyle, Jul 22, 2003.

  1. Jeremy Pyle

    Jeremy Pyle Guest

    Here is my code that divides a 32-bit number by a 32-bit number, where both
    operands are of type UNSIGNED(31 downto 0) and provides a 16-bit fractional
    number(the divisor is always greater than the dividend).

    process(CLK)
    variable count : integer range -1 to 15 := -1;
    variable tempVal : UNSIGNED(47 downto 0);
    begin
    if(RISING_EDGE(CLK) and go = '1') then
    if(count = -1) then
    tempVal(47 downto 32) := (others => '0');
    tempVal(31 downto 0) := dividend;
    quotient <= (others => '0');
    count := 15;
    end if;

    tempVal := SHL(tempVal, CONV_UNSIGNED(1,1));

    if(tempVal >= divisor) then
    quotient(count) <= '1';
    tempVal := tempVal - divisor;
    end if;
    count := count - 1;
    end if;
    end process;


    When I synthesize this, my maximum clock frequency is 53.110Mhz. Is there a
    reason why this code runs so slowly? Am I doing something that I shoudln't
    be doing? Now, I haven't tested this code yet, so if functionally it's
    wrong, just ignore that, but why is it so slow? Thanks for any help.
    Jeremy Pyle, Jul 22, 2003
    #1
    1. Advertising

  2. Hi Jeremy!

    > process(CLK)
    > variable count : integer range -1 to 15 := -1;
    > variable tempVal : UNSIGNED(47 downto 0);
    > begin
    > if(RISING_EDGE(CLK) and go = '1') then
    > if(count = -1) then
    > tempVal(47 downto 32) := (others => '0');
    > tempVal(31 downto 0) := dividend;
    > quotient <= (others => '0');
    > count := 15;
    > end if;
    >
    > tempVal := SHL(tempVal, CONV_UNSIGNED(1,1));
    >
    > if(tempVal >= divisor) then


    This will be synthesized as a (subtractor) adder. If you set higher
    clock-constraints or force the synthesis tool to use
    carry-look-ahead-adder or an other fast adder, it may be, that you get
    more speed - if ths adder is in the critical path.

    > quotient(count) <= '1';
    > tempVal := tempVal - divisor;


    ... an other adder...

    > end if;
    > count := count - 1;


    ....and the 3rd one.
    Note: I only want to give you the hint, that there are 3 adders inside
    your design. I have not thought about alternatives.

    > end if;
    > end process;



    > When I synthesize this, my maximum clock frequency is 53.110Mhz. Is there a
    > reason why this code runs so slowly?


    Well.. depending on your target process, this is not really slow.
    Try to find the critical path. Try to speed it up.


    Ralf
    Ralf Hildebrandt, Jul 22, 2003
    #2
    1. Advertising

  3. Jeremy Pyle

    Andrew Paule Guest

    Hi Jeremy -

    what architecture are you using for this design? Xilinx, Altera, Actel,
    Quicklogic, other? Compiler? What is your design goal?

    Andrew

    Jeremy Pyle wrote:

    >Here is my code that divides a 32-bit number by a 32-bit number, where both
    >operands are of type UNSIGNED(31 downto 0) and provides a 16-bit fractional
    >number(the divisor is always greater than the dividend).
    >
    > process(CLK)
    > variable count : integer range -1 to 15 := -1;
    > variable tempVal : UNSIGNED(47 downto 0);
    > begin
    > if(RISING_EDGE(CLK) and go = '1') then
    > if(count = -1) then
    > tempVal(47 downto 32) := (others => '0');
    > tempVal(31 downto 0) := dividend;
    > quotient <= (others => '0');
    > count := 15;
    > end if;
    >
    > tempVal := SHL(tempVal, CONV_UNSIGNED(1,1));
    >
    > if(tempVal >= divisor) then
    > quotient(count) <= '1';
    > tempVal := tempVal - divisor;
    > end if;
    > count := count - 1;
    > end if;
    > end process;
    >
    >
    >When I synthesize this, my maximum clock frequency is 53.110Mhz. Is there a
    >reason why this code runs so slowly? Am I doing something that I shoudln't
    >be doing? Now, I haven't tested this code yet, so if functionally it's
    >wrong, just ignore that, but why is it so slow? Thanks for any help.
    >
    >
    >
    >
    Andrew Paule, Jul 23, 2003
    #3
  4. Jeremy Pyle

    Jerold Green Guest

    Remember that a variable is assigned its value immediately. Its new value
    is available for subsequent assignments and tests in the same clock cycle.
    The speed relates to the amount of combinatorial logic between clock edges.
    If you look at tempVal, you have many levels of logic:
    1) mux between previous value and dividend
    2) left shift (no logic, just routing)
    3) comparison
    4) conditional subtraction

    comparison is a subtraction operation, which is a ripple operation over all
    48 bits (the comparison and subtraction are the same operation). So there
    is a LOT of logic to get the next value of tempVal.

    Keep in mind that this is not software. Re-using the same variable for
    multiple assignments is generally a bad idea.

    Also take a look at the quotient assignment. Making it a shift register and
    assigning to the low bit would speed that up. It's also at the end of the
    combinatorial chain
    if (...) then
    quotient <= quotient(14 downto 0) & '1';
    else
    quotient <= quotient(14 downto 0) & '0';
    end if;
    (my version of SHL)
    You didn't say what speed the part is.
    Does it have to take 16 clocks? You could try pipelining it, at least doing
    the initialization on a separate clock.

    Try not to assign count twice in the same clock cycle.

    "Jeremy Pyle" <> wrote in message
    news:ig1Ta.166053$...
    > Here is my code that divides a 32-bit number by a 32-bit number, where

    both
    > operands are of type UNSIGNED(31 downto 0) and provides a 16-bit

    fractional
    > number(the divisor is always greater than the dividend).
    >
    > process(CLK)
    > variable count : integer range -1 to 15 := -1;
    > variable tempVal : UNSIGNED(47 downto 0);
    > begin
    > if(RISING_EDGE(CLK) and go = '1') then
    > if(count = -1) then
    > tempVal(47 downto 32) := (others => '0');
    > tempVal(31 downto 0) := dividend;
    > quotient <= (others => '0');
    > count := 15;
    > end if;
    >
    > tempVal := SHL(tempVal, CONV_UNSIGNED(1,1));
    >
    > if(tempVal >= divisor) then
    > quotient(count) <= '1';
    > tempVal := tempVal - divisor;
    > end if;
    > count := count - 1;
    > end if;
    > end process;
    >
    >
    > When I synthesize this, my maximum clock frequency is 53.110Mhz. Is there

    a
    > reason why this code runs so slowly? Am I doing something that I

    shoudln't
    > be doing? Now, I haven't tested this code yet, so if functionally it's
    > wrong, just ignore that, but why is it so slow? Thanks for any help.
    >
    >
    Jerold Green, Jul 23, 2003
    #4
  5. Jeremy Pyle

    Jeremy Pyle Guest

    Yeah, I am using Xilinx ISE. Where can I find out about the critical path?

    Thanks,

    Jeremy

    "Dan RADUT" <> wrote in message
    news:...
    > "Jeremy Pyle" <> wrote in message

    news:<ig1Ta.166053$>...
    > > When I synthesize this, my maximum clock frequency is 53.110Mhz. Is

    there a
    > > reason why this code runs so slowly? Am I doing something that I

    shoudln't
    > > be doing? Now, I haven't tested this code yet, so if functionally it's
    > > wrong, just ignore that, but why is it so slow? Thanks for any help.

    >
    > What tools are you using? What is the frequency you would like your design

    to
    > work at?
    > To find out why the maximum clock frequency is limited to a certain value

    look
    > into the report files and see what is mentioned about the critical path

    and
    > the number of logic levels. Usually the maximum frequency is limited by

    the
    > number of logic levels and the corresponding net delays related to the

    nets
    > interconnecting these logic levels. The critical path lists all these

    delays.
    > To increase the maximum frequency you need to use certain options
    > provided by the tool, such as retiming, in order to reduce the number of

    logic
    > levels in between registers.
    >
    > Are you using Xilinx ISE? I could tell you more if the answer is positive.
    >
    > Regards,
    >
    > Dan R
    Jeremy Pyle, Jul 23, 2003
    #5
  6. Jeremy Pyle

    Jeremy Pyle Guest

    Sorry, I should have specified, I'm using a XiLinx chip, the XCV300. The
    compiler I'm using is XiLinx ISE from the Webpack.

    Jeremy


    "Andrew Paule" <> wrote in message
    news:NZlTa.83$...
    > Hi Jeremy -
    >
    > what architecture are you using for this design? Xilinx, Altera, Actel,
    > Quicklogic, other? Compiler? What is your design goal?
    >
    > Andrew
    >
    > Jeremy Pyle wrote:
    >
    > >Here is my code that divides a 32-bit number by a 32-bit number, where

    both
    > >operands are of type UNSIGNED(31 downto 0) and provides a 16-bit

    fractional
    > >number(the divisor is always greater than the dividend).
    > >
    > > process(CLK)
    > > variable count : integer range -1 to 15 := -1;
    > > variable tempVal : UNSIGNED(47 downto 0);
    > > begin
    > > if(RISING_EDGE(CLK) and go = '1') then
    > > if(count = -1) then
    > > tempVal(47 downto 32) := (others => '0');
    > > tempVal(31 downto 0) := dividend;
    > > quotient <= (others => '0');
    > > count := 15;
    > > end if;
    > >
    > > tempVal := SHL(tempVal, CONV_UNSIGNED(1,1));
    > >
    > > if(tempVal >= divisor) then
    > > quotient(count) <= '1';
    > > tempVal := tempVal - divisor;
    > > end if;
    > > count := count - 1;
    > > end if;
    > > end process;
    > >
    > >
    > >When I synthesize this, my maximum clock frequency is 53.110Mhz. Is

    there a
    > >reason why this code runs so slowly? Am I doing something that I

    shoudln't
    > >be doing? Now, I haven't tested this code yet, so if functionally it's
    > >wrong, just ignore that, but why is it so slow? Thanks for any help.
    > >
    > >
    > >
    > >

    >
    Jeremy Pyle, Jul 23, 2003
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. walala
    Replies:
    4
    Views:
    2,077
    Ralf Hildebrandt
    Sep 8, 2003
  2. walala
    Replies:
    4
    Views:
    1,178
    Technology Consultant
    Sep 9, 2003
  3. Replies:
    3
    Views:
    3,006
  4. HK
    Replies:
    3
    Views:
    432
  5. mike
    Replies:
    3
    Views:
    375
    Virgil Green
    Jul 11, 2005
Loading...

Share This Page