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

Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.

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.