1
\$\begingroup\$

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.

\$\endgroup\$
2
  • \$\begingroup\$ There is a good answer on this topic here stackoverflow.com/a/9035788/4090959. Note that the 'Update' is important. \$\endgroup\$
    – scary_jeff
    Commented Jul 18, 2017 at 9:35
  • \$\begingroup\$ 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. \$\endgroup\$
    – user16324
    Commented Jul 18, 2017 at 14:46

1 Answer 1

-2
\$\begingroup\$

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;
\$\endgroup\$
7
  • \$\begingroup\$ What exactly does the loop do in this example? \$\endgroup\$
    – user16324
    Commented Jul 18, 2017 at 11:55
  • \$\begingroup\$ 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 \$\endgroup\$
    – A. Kieffer
    Commented Jul 18, 2017 at 12:22
  • 2
    \$\begingroup\$ 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? \$\endgroup\$
    – user16324
    Commented Jul 18, 2017 at 12:54
  • \$\begingroup\$ why '1'? , arithmetic left shifting put '0' on empty position \$\endgroup\$
    – e2p
    Commented Jul 18, 2017 at 14:12
  • 1
    \$\begingroup\$ Regarding the padding, I think you are confusing sla with sign extension in sra on negative numbers. \$\endgroup\$
    – user16324
    Commented Jul 18, 2017 at 14:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.