Checking the validity of std_logic_vector value @testbench

Guest #4725065
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
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

A question of your own? This thread is over 10 years old. Ask it in a thread of its own – more people read along there, and it gets answered more often and sooner.

Start a new thread

A fix, an addition or feedback on this thread? Then reply here.

Formatting
  • [c]C-Code[/c]
  • [vhdl]VHDL-Code[/vhdl]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.