error: * can not have such operands in this context

OP (Company: enis) #3575007
Rate this post
• ▲ useful
▼ not useful
Hi,

I am trying to multipy an std_logic_vector with a negatif number :

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.numeric_std.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;

entity mul_main is
    Port ( a :in  STD_LOGIC_VECTOR( 0 to 7);
        clk: in  STD_LOGIC;
           c :out STD_LOGIC_VECTOR(0 to 15)
        );
end mul_main;

architecture Behavioral of mul_main is

begin
p: process(clk)
begin
if (clk' event and clk='1') then
c <= (-2)* a;
end if;
end process;

end Behavioral;

But, I'm getting this error: * can not have such operands in this 
context

In fact, I want to multiply an std_logic_vector with a positif or 
negatif constant , unfortunately, I'm getting the same problem.
Can you help me please.

Thanks in advance
Moderator (Company: Titel) #3575243
Rate this post
• ▲ useful
▼ not useful
Mariem Makni wrote:
> But, I'm getting this error: * can not have such operands in this
> context
Due to the very strict type checking you cannot multiply an integer and 
a std_logic_vector in VHDL (unless you don't overload the * operator).

> In fact, I want to multiply an std_logic_vector with a positif or
> negatif constant
How can you use the unsigned lib and try to perform a signed 
multiplication?

Use the
> use IEEE.numeric_std.all;
Or the
> use ieee.std_logic_arith.all;
> use ieee.std_logic_unsigned.all;
But never ever all of them together!
I advise you to use the signed and unsigned vectors and the conversions 
from the numeric_std.
Try this with Google translator:

http://www.lothar-miller.de/s9y/categories/16-Numeric_Std

Reply

Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.

Formatting
  • [c]C-Code[/c]
  • [vhdl]VHDL-Code[/vhdl]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.