1

I would like to know your opinion on how to test and manage input signals of a component that are 'U', 'X', '-', ...

For example, if I want the output to be 'X' for all non-valid inputs, where at least one bit of the input isn't '0' or '1':

entity foo is
    port (
        signal inp : std_logic_vector(7 downto 0);
        signal outp: std_logic );
end entity foo;

architecture bar of foo is
begin
    process(inp)
        if (inp < "11001010") then
            outp <= '1';
        else
            outp <= '0';
        end if;
    end process;
end architecture bar;

This way, the test defaults to being false.

How would be a general way to test the inputs?

wattostudios
  • 8,666
  • 13
  • 43
  • 57
Mat
  • 13
  • 2
  • BTW, your `inp < "11001010"` suggests you are using the non-standard `std_logic_unsigned` or `std_logic_arith` packages from Synopsis that are erroneously stuffed into the ieee library. The correct alternative is `ieee.numeric_std`. – wjl Nov 12 '12 at 01:11

1 Answers1

3

Use Is_X from std_logic_1164; it will return true if your std_logic_vector contains any of 'U', 'X', 'Z', 'W', '-'.

Is_X will always return false during synthesis (you can e.g. use Is_X('W') to test whether you're in simulation or synthesis.)

vladr
  • 65,483
  • 18
  • 129
  • 130