Search code examples
vhdl

what is the equivalent of logical and (&&) in vhdl?


what is the equivalent for && in vhdl in an if statement?

otherwise: if (i/=0 && i/=15)  generate
...
end generate;

I need to meet two prerequisites.


Solution

  • The question of what is the equivalent of logical and (&&) in VHDL doesn't really make sense, because of VHDL's strong typing. The short answer to your question is that you need:

    otherwise: if (i/=0) and (i/=15)  generate
    ...
    end generate;
    

    but the and in that example is no different to the and operator in this example:

    signal F, A, B: boolean;
    ...
    F <= A and B;
    

    because the /= operator returns the type boolean. Therefore, in both examples, I am just anding two booleans together. The return type in both examples will also be of type boolean. The type that the if statement expects is boolean, which is why the first example works.