Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
14 years ago

need a help with strange error" left bound of the range must be a constant "

I have got this problem when I synthesize my design on Quartus II but when I use xilinx software its work perfectly

the error is that " left bound of the range must be a constant "

and it's indicated to this line

-----------------------------------------------

Reg_Q:process (CLK, r_by_2)

begin

if (CLK'event and CLK='1') then

if RESET='1' then

q<= (others => '0');

else

case CS is

-----------------------------------

when S2 =>

q<=p;

-----------------------------------

when S4 =>

if(r_by_2 = 1) then

q <= q (m_size-r_by_2-1 downto 0) & q(m_size-1);

else

---------->>>>> q(m_size-1 downto r_by_2) <= q (m_size - r_by_2 - 1 downto 0);

q(r_by_2-1 downto 0) <= q(m_size-1 downto m_size - r_by_2);

end if;

-----------------------------------

when others =>

null;

-----------------------------------

end case;

end if;

end if;

end process;

-----------------------------------------------

here is the signal definition

signal p, q, t : std_logic_vector (m_size-1 downto 0); --

Does anyone have idea how to make this synthesizable?

Im making a normal basis multiplier

thank you

11 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Looking a bit deeper, I realised that I gave you a solution for a 'right' rotate where your code shows a 'left' rotate. So I experimented a bit with my code, and at the same time getting to know some of ModelSim quirks (as sometimes QII synthesizes OK, but Modelsim stops on a negative value for a natural etc.)

    Here is my complete test code:

    library ieee;
        use ieee.std_logic_1164.all ;
        use ieee.numeric_std.all ;
        use ieee.math_real.all ;
    entity ahl2006 is
        generic (
            MSIZE               : natural   := 16 ;
            SHIFT_DIRECTION     : string    :=  "RIGHT"
            ) ;
        port (
            Clk     : in    std_logic ;
            Reset   : in    std_logic ;
            Ld      : in    std_logic ;
            Shift   : in    std_logic ;
            D       : in    std_logic_vector(MSIZE - 1 downto 0 ) ;
            Sel     : in    natural range 0 to MSIZE - 1 ;
            Q       : out   std_logic_vector(MSIZE - 1 downto 0 ) 
            ) ;
        end ahl2006 ;   
        
    architecture a of ahl2006 is
        constant MSIZE_IS_POWER_OF_2    : boolean   := (2 ** floor( log2( real( MSIZE )))  = real( MSIZE ) ) ;
        constant MWIDTH                 : natural   := integer( floor( log2( real( MSIZE )))) ;
        
        
        signal lq                       : std_logic_vector(MSIZE - 1 downto 0 ) ;
     
    begin
        
        process( Reset , Clk  )
            begin
                if (Reset = '1') then
                    lq <= (others => '0') ;
                    
                elsif rising_edge( Clk ) then
                    if (Ld = '1') then
                        lq <= D ;
                        
                    elsif (Shift = '1') then
                        if SHIFT_DIRECTION = "LEFT" then
                            for i in MSIZE - 1 downto 0 loop
                                if MSIZE_IS_POWER_OF_2 then
                                    lq(i) <= lq( (MSIZE + i - Sel) mod MSIZE ) ;
                                else
                                    if (i >= Sel) then
                                        lq(i) <= lq(i - Sel) ;
                                    else
                                        lq(i) <= lq( MSIZE + i - Sel) ;
                                    end if ;
                                end if ;
                            end loop ;
                        else
                            for i in 0 to MSIZE - 1 loop
                                if MSIZE_IS_POWER_OF_2 then
                                    lq(i) <= lq((i + Sel) mod MSIZE) ;
                                else
                                    if (i + Sel) < MSIZE then
                                        lq(i) <= lq(i + Sel) ;
                                    else
                                        lq(i) <= lq(i + Sel - MSIZE) ;
                                    end if ;
                                end if ;
                            end loop ;
                        end if ;
                    end if ;
                    
                end if ;
            end process ;
        
        Q <= lq ;
        
    end a ;
    

    Today I also ran an RTL-siulation for MSIZE = 16, for both LEFT and RIGHT rotates to verify proper operation.