Forum: FPGA, VHDL & Verilog Checking the validity of std_logic_vector value @testbench

von VHDL learner (Guest)

Rate this post
0 useful
not useful
Hi Experts,

what is the easiest way to check whether a std_logic_vector value has 
invalid/uninitialized bit(s) in it (such as 'X', 'U', 'Z'). VHDL-2008 
would be okay.


von Duke Scarring (Guest)

Rate this post
0 useful
not useful
I would write a function:
    function has_X( value : std_logic_vector) return boolean is
        for index in value'range loop
            if value( index) = 'X' then
                return true;
            end if;
        end loop;
        return false;
    end function has_X;


von Ottmar (Guest)

Rate this post
0 useful
not useful
This function is already defined in std_logic_1164.

    FUNCTION Is_X ( s : std_logic_vector  ) RETURN  BOOLEAN IS
        FOR i IN s'RANGE LOOP
            CASE s(i) IS
                WHEN 'U' | 'X' | 'Z' | 'W' | '-' => RETURN TRUE;
                WHEN OTHERS => NULL;
            END CASE;
        END LOOP;


Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [vhdl]VHDL code[/vhdl]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]

Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.