Go Back   Velocity Reviews > Newsgroups > VHDL
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

VHDL - Detecting of 'U' in a std_logic_vector

 
Thread Tools Search this Thread
Old 10-28-2004, 01:29 PM   #1
Default Detecting of 'U' in a std_logic_vector


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
  Reply With Quote
Old 10-28-2004, 02:19 PM   #2
Nicolas Matringe
 
Posts: n/a
Default Re: Detecting of 'U' in a std_logic_vector
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
  Reply With Quote
Old 10-28-2004, 02:37 PM   #3
Allan Herriman
 
Posts: n/a
Default Re: Detecting of 'U' in a std_logic_vector
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
  Reply With Quote
Old 11-03-2004, 07:55 AM   #4
Nicolas Matringe
 
Posts: n/a
Default Re: Detecting of 'U' in a std_logic_vector
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
  Reply With Quote
Old 11-03-2004, 08:24 AM   #5
Allan Herriman
 
Posts: n/a
Default Re: Detecting of 'U' in a std_logic_vector
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
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Detecting other users mikmik1981 Hardware 0 06-01-2009 12:12 AM
Detecting Intruders on Your System Is Fun and Easy konanimo@gmail.com DVD Video 0 12-11-2007 01:52 PM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46