Forum Discussion

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

Error using shift and power operator

Hi;

I am getting error using sla and ** operators.

My code is as under :

Rx_Buff_i : in STD_LOGIC_VECTOR (7 downto 0);

.

.

.

signal Chksum : std_logic_vector(7 downto 0) :=

(others => '0');

signal Shft_buff : std_logic_vector(1607 downto

0) :=(others => '0');

.

.

.

.

Shft_buff<= Shft_buff sla 8;

Chksum <= Chksum ** Rx_Buff_i;

I am including the following libraries:

use IEEE.STD_LOGIC_1164.ALL;

use IEEE.STD_LOGIC_unsigned.ALL;

use IEEE.std_logic_arith.all;

use IEEE.numeric_std.ALL;

The following errors I am getting

1)found '0' definitions of operator "sla", cannot

determine exact overloaded matching definition

for "sla"

2) found '0' definitions of operator "**", cannot

determine exact overloaded matching definition

for "**"

plz help

1 Reply

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

    --- Quote Start ---

    Hi;

    I am getting error using sla and ** operators.

    I am including the following libraries:

    use IEEE.STD_LOGIC_1164.ALL;

    use IEEE.STD_LOGIC_unsigned.ALL;

    use IEEE.std_logic_arith.all;

    use IEEE.numeric_std.ALL;

    --- Quote End ---

    Please, don't use numeric_std and std_logic_arith/unsigned at the same time! That makes for a lot of type confusion. Use numeric_std only.

    --- Quote Start ---

    Shft_buff<= Shft_buff sla 8;

    Chksum <= Chksum ** Rx_Buff_i;

    The following errors I am getting

    1)found '0' definitions of operator "sla", cannot

    determine exact overloaded matching definition

    for "sla"

    --- Quote End ---

    Regarding the sla operator, it is not defined for std_logic_vector. It is defined (in numeric_std) for unsigned and signed, but they're problematic and nobody uses them (and they may not synthesize). Instead, just use the usual shift left:

    ShiftLeft : process (clk) is
    begin
        if rising_edge(clk) then
            foo <= foo(foo'left - 1 downto 0) & '0';
        end if;
    end process ShiftLeft;

    --- Quote Start ---

    2) found '0' definitions of operator "**", cannot

    determine exact overloaded matching definition

    for "**"

    plz help

    --- Quote End ---

    The exponent has to be:

    a) a constant (compile-time) integer. It cannot be a variable and it certainly cannot be a std_logic_vector.

    b) a power-of-two, which means it is implemented as a shift left.

    So just use the shift left.