Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > VHDL > Detecting of 'U' in a std_logic_vector

Reply
Thread Tools

Detecting of 'U' in a std_logic_vector

 
 
Thomas Reinemann
Guest
Posts: n/a
 
      10-28-2004
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
 
Reply With Quote
 
 
 
 
Nicolas Matringe
Guest
Posts: n/a
 
      10-28-2004
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 -
|_| |_|_|\__|\___/

 
Reply With Quote
 
 
 
 
Allan Herriman
Guest
Posts: n/a
 
      10-28-2004
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
 
Reply With Quote
 
Nicolas Matringe
Guest
Posts: n/a
 
      11-03-2004
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 -
|_| |_|_|\__|\___/

 
Reply With Quote
 
Allan Herriman
Guest
Posts: n/a
 
      11-03-2004
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Detecting bit transistion in std_logic_vector Tobias Baumann VHDL 14 02-21-2012 09:53 AM
Array of std_logic_vector Willem Oosthuizen VHDL 3 02-26-2010 12:27 AM
inout std_logic_vector to array of std_logic_vector of generic length conversion... Thomas Rouam VHDL 6 11-09-2007 11:49 AM
std_logic_vector port doesn't work after synthesis. Mike VHDL 3 07-09-2003 09:10 PM
STD_LOGIC_VECTOR vs. UNSIGNED vs. SIGNED Jeremy Pyle VHDL 3 06-28-2003 10:47 PM



Advertisments