Checking the validity of std_logic_vector value @testbench

Guest #4725065
Rate this post
useful
not useful
I would write a function:
1
    function has_X( value : std_logic_vector) return boolean is
2
    begin
3
        for index in value'range loop
4
            if value( index) = 'X' then
5
                return true;
6
            end if;
7
        end loop;
8
        return false;
9
    end function has_X;

Duke
Guest #4725659
Rate this post
useful
not useful
This function is already defined in std_logic_1164.

Excerpt:
1
    FUNCTION Is_X ( s : std_logic_vector  ) RETURN  BOOLEAN IS
2
    BEGIN
3
        FOR i IN s'RANGE LOOP
4
            CASE s(i) IS
5
                WHEN 'U' | 'X' | 'Z' | 'W' | '-' => RETURN TRUE;
6
                WHEN OTHERS => NULL;
7
            END CASE;
8
        END LOOP;
9
        RETURN FALSE;
10
    END;

Reply

Please log in before posting.

or

Log in with Google account

Registration is free and takes only a minute.

Register now