Forum Discussion

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

shifting in quartus ii

Hello,

I am using the following code in my design (c_repack_reg_size and c_k_eff are constant integers), trying to shift left by an unkonwn integer:

signal repack_reg : std_logic_vector (c_repack_reg_size - 1 downto 0);

signal repack_reg_ind : integer range (c_repack_reg_size - 1) downto 0;

repack_reg(c_repack_reg_size - 1 downto c_k_eff + repack_reg_ind + 1) <= repack_reg( c_repack_reg_size - 1 - c_k_eff downto repack_reg_ind + 1);

quartus gives me an error saying that the right bound of repack_reg must be constant.

what is the correct and most efficient way to perform the wanted shift?

Thanks,

Omer

2 Replies

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

    are you deliberatly trying to leave the LSBs of repack_reg alone? because thats what this code is trying to do. Usually you would assign the entire repack_reg.

    a variable shift is just a *2^n, which is fairly straight forward. try this:

    edit - forgot about sizing

    
    variable temp_var : unsigned(repack_reg'high*2 -1 downto 0);
    temp_var := unsigned(repack_reg) * (2**repack_reg_ind);
    repack_reg <= std_logic_vector( temp_var(repack_reg'range) );