Detecting of 'U' in a std_logic_vector

Discussion in 'VHDL' started by Thomas Reinemann, Oct 28, 2004.

  1. Hello,

    I have to convert a std_logic_vector in an integer. This is generally no
    matter. But I want to threat vectors in a special way which have 'U's or
    'X'. How can I detect whether a vector only contains '0's and '1's.

    Bye Tom
    Thomas Reinemann, Oct 28, 2004
    #1
    1. Advertising

  2. Thomas Reinemann a écrit:
    > Hello,
    >
    > I have to convert a std_logic_vector in an integer. This is generally no
    > matter. But I want to threat vectors in a special way which have 'U's or
    > 'X'. How can I detect whether a vector only contains '0's and '1's.


    Hi
    Xor all the bits together (parity check), then pass the result through
    the to_x01 function, which will return 'X' for 'U' or 'X' input. Result
    should be 0 or 1 if your vector contains only 0s and 1s, or X if not.

    Something like
    if to_x01(xor_reduce(your_vector)) = 'X' then
    ...

    (xor_reduce function code has been posted here a few weeks ago)

    --
    ____ _ __ ___
    | _ \_)/ _|/ _ \ Adresse de retour invalide: retirez le -
    | | | | | (_| |_| | Invalid return address: remove the -
    |_| |_|_|\__|\___/
    Nicolas Matringe, Oct 28, 2004
    #2
    1. Advertising

  3. On Thu, 28 Oct 2004 15:19:36 +0200, Nicolas Matringe
    <> wrote:

    >Thomas Reinemann a écrit:
    >> Hello,
    >>
    >> I have to convert a std_logic_vector in an integer. This is generally no
    >> matter. But I want to threat vectors in a special way which have 'U's or
    >> 'X'. How can I detect whether a vector only contains '0's and '1's.

    >
    >Hi
    >Xor all the bits together (parity check), then pass the result through
    >the to_x01 function, which will return 'X' for 'U' or 'X' input. Result
    >should be 0 or 1 if your vector contains only 0s and 1s, or X if not.
    >
    >Something like
    > if to_x01(xor_reduce(your_vector)) = 'X' then
    > ...
    >
    >(xor_reduce function code has been posted here a few weeks ago)


    std_logic_1164 contains these functions:

    FUNCTION Is_X ( s : std_ulogic_vector ) RETURN BOOLEAN;
    FUNCTION Is_X ( s : std_logic_vector ) RETURN BOOLEAN;
    FUNCTION Is_X ( s : std_ulogic ) RETURN BOOLEAN;


    if is_x(your_vector) then

    .... is much cleaner


    Regards,
    Allan
    Allan Herriman, Oct 28, 2004
    #3
  4. Allan Herriman a écrit:

    > std_logic_1164 contains these functions:
    >
    > FUNCTION Is_X ( s : std_ulogic_vector ) RETURN BOOLEAN;
    > FUNCTION Is_X ( s : std_logic_vector ) RETURN BOOLEAN;
    > FUNCTION Is_X ( s : std_ulogic ) RETURN BOOLEAN;
    >
    >
    > if is_x(your_vector) then
    >
    > ... is much cleaner


    Didn't know that. It sure is much cleaner.

    --
    ____ _ __ ___
    | _ \_)/ _|/ _ \ Adresse de retour invalide: retirez le -
    | | | | | (_| |_| | Invalid return address: remove the -
    |_| |_|_|\__|\___/
    Nicolas Matringe, Nov 3, 2004
    #4
  5. On Wed, 03 Nov 2004 08:55:36 +0100, Nicolas Matringe
    <> wrote:

    >Allan Herriman a écrit:
    >
    >> std_logic_1164 contains these functions:
    >>
    >> FUNCTION Is_X ( s : std_ulogic_vector ) RETURN BOOLEAN;
    >> FUNCTION Is_X ( s : std_logic_vector ) RETURN BOOLEAN;
    >> FUNCTION Is_X ( s : std_ulogic ) RETURN BOOLEAN;
    >>
    >>
    >> if is_x(your_vector) then
    >>
    >> ... is much cleaner

    >
    >Didn't know that. It sure is much cleaner.


    Faster as well.

    Regards,
    Allan
    Allan Herriman, Nov 3, 2004
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jeremy Pyle
    Replies:
    3
    Views:
    52,579
    Mike Treseler
    Jun 28, 2003
  2. Mike
    Replies:
    3
    Views:
    3,040
    Mike Treseler
    Jul 9, 2003
  3. Willem Oosthuizen

    Array of std_logic_vector

    Willem Oosthuizen, Jul 9, 2003, in forum: VHDL
    Replies:
    3
    Views:
    35,410
    mathukutty
    Feb 26, 2010
  4. Thomas Rouam
    Replies:
    6
    Views:
    1,113
  5. Tobias Baumann
    Replies:
    14
    Views:
    1,291
    Tobias Baumann
    Feb 21, 2012
Loading...

Share This Page