# VHDL SLA operator

Maybe it is really easy question but I spent two hours looking for solution and information in the internet and still I can't push it to work.

I need to do arithmetic left shift operation. I used standard SLA operator.

ModelSim during compilation shows an error:

Blockquote ** Error: (vcom-1581) No feasible entries for infix operator 'sla'. ** Error: Bad right hand side (infix expression) in variable assignment.

My code

constant Vlsb : std_logic_vector(47 downto 0) := x"00002710CB29";
i_data      : in std_logic_vector(15 downto 0);


.

process(i_clk) is
variable data : std_logic_vector(47 downto 0);
begin
if(i_rst_asyn = '0') then
data := (others => '0');
else
if(rising_edge(i_clk)) then
if(i_rst_syn = '1') then
data := (others => '0');
else
data(15 downto 0) := i_data;
data := data sla 31; -- ERROR LINE
data := std_logic_vector(signed(data) / signed(Vlsb));
end if;
end if;
end if;
o_data <= data;
end process;


Could sombody tell me what I am doing wrong, please.

Add- I am using std_logic_1164 and numeric_std library in this module.

• There is a good answer on this topic here stackoverflow.com/a/9035788/4090959. Note that the 'Update' is important. – scary_jeff Jul 18 '17 at 9:35
• Simply declare your variable of a type for which there is a declaration of sla; alternatively, nothing stops you writing your own sla for the type you have chosen. – Brian Drummond Jul 18 '17 at 14:46

To use the operators sla or sll , etc ... you need to use the bit_vector type and not the std_logic_vector one.

That's why I don't advise anyone to use these kind of shift operators but rather instantiate a for loop like the following:

FOR i IN 0 TO N - 1 LOOP
data := data(14 DOWNTO 0) & data(0);
END LOOP;

• What exactly does the loop do in this example? – Brian Drummond Jul 18 '17 at 11:55
• It shifts data from N bits to the left in one clock cycle (and pad with '1'). That's what @e2p is looking for I guess – A. Kieffer Jul 18 '17 at 12:22
• You mean it's a way of obfuscating data := data(15-n downto 0) & (n-1 downto 0 => '1');? Also, where does padding with '1' come from? – Brian Drummond Jul 18 '17 at 12:54
• why '1'? , arithmetic left shifting put '0' on empty position – e2p Jul 18 '17 at 14:12
• Regarding the padding, I think you are confusing sla with sign extension in sra on negative numbers. – Brian Drummond Jul 18 '17 at 14:44