How does VHDL handle bitwise operations

digital-logicvhdl

I'm having a problem in some VHDL code I'm writing. I want to drive a signal with two other signals AND'd together like this:

mysignal <= "010" and '1';

The result I expected was a bitwise AND, resulting in mysignal receiving the value of "010". Instead, I got a compiler error telling me "No feasible entries for infix operator "and"." When I try:

mysignal <= "010" and "111";

it compiles. Is it possible in VHDL to do a bitwise logical operation, without having to alter my signals and make them all the same width?

Best Answer

One way is to simplify generating signals of the right range. For example:

mysignal <= "010" and (mysignal'range => '1');

This creates a new value for the second operand, the correct size, with all bits set to '1',