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

Reply

VHDL - A question about syntax of VHDL

 
Thread Tools Search this Thread
Old 04-21-2005, 10:00 AM   #1
Default A question about syntax of VHDL


Can I write the if condition like this? Assume

signal A std_logic_vector(29 downto 0);

if A = (others => '0´) then
.................
end if;

if this syntax is invalid, how should I write it? any simple way.
I do not want to put 30 zeros here.

Can I write the condition as
A = "00" & 0x0000000

Thanks
Jim



Jim Huang
  Reply With Quote
Old 04-21-2005, 10:16 AM   #2
dutchgoldtony
 
Posts: n/a
Default Re: A question about syntax of VHDL
An assignment takes the form if A<= (others => '0');



dutchgoldtony
  Reply With Quote
Old 04-21-2005, 10:52 AM   #3
Jim Huang
 
Posts: n/a
Default Re: A question about syntax of VHDL
Hi

Thanks, but I think you misunderstood me. I asked if I can compare the
signal A with (other => '0') in the IF clause.



Jim Huang
  Reply With Quote
Old 04-21-2005, 11:02 AM   #4
charles.elias@wpafb.af.mil
 
Posts: n/a
Default Re: A question about syntax of VHDL
This form will work:

if Sig = (Sig'range => '0') then

This is from comp.lang.vhdl "Frequently Asked Questions" Part 1. This
very useful document can be found at http://vhdl.org/comp.lang.vhdl/.

Best regards,

Charles



charles.elias@wpafb.af.mil
  Reply With Quote
Old 04-21-2005, 11:07 AM   #5
Mohammed A khader
 
Posts: n/a
Default Re: A question about syntax of VHDL
HI Jim,

> if A = (others => '0´) then


will give you error as

others must be use with constrained array. (others => '0') is not
enough to know the length of the array.
>Can I write the condition as
> A = "00" & 0x0000000


Yes you can write the numbers in hex or oct

if ( A = X"0000") then -- will work fine but make sure that type A
is a vector of bit or std_logic.

-- Mohammed A Khader.



Mohammed A khader
  Reply With Quote
Old 04-21-2005, 11:07 AM   #6
Mohammed A khader
 
Posts: n/a
Default Re: A question about syntax of VHDL
HI Jim,

> if A = (others => '0´) then


will give you error as

others must be use with constrained array. (others => '0') is not
enough to know the length of the array.
>Can I write the condition as
> A = "00" & 0x0000000


Yes you can write the numbers in hex or oct

if ( A = X"0000") then -- will work fine but make sure that type A
is a vector of bit or std_logic.

-- Mohammed A Khader.



Mohammed A khader
  Reply With Quote
Old 04-24-2005, 04:28 PM   #7
info_
 
Posts: n/a
Default Re: A question about syntax of VHDL
Jim Huang wrote:
> Can I write the if condition like this? Assume
>
> signal A std_logic_vector(29 downto 0);
>
> if A = (others => '0´) then
> .................
> end if;
>
> if this syntax is invalid, how should I write it?


One clean solution is to use subtypes and qualified expression :

subtype SLV30 is std_logic_vector(29 downto 0);

signal A : SLV30;

if A = SLV30'(others=>'0') then -- will work

As you noticed , hexadecimal notation isn't for fun except
on exact multiple of four bits...

Other solution :

if (unsigned(A)=0 then

etc...

Bert Cuzeau




info_
  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
VHDL sll shift question ohaqqi Hardware 4 09-29-2009 11:27 AM
How to execute an external software from VHDL? And how to interface VHDL with JAVA? becool_nikks Software 0 03-06-2009 07:08 PM
Need help on Modelsim VHDL syntax? ASAP:) kaji General Help Related Topics 0 03-14-2007 10:43 PM
Need help on a Modelsim VHDL Syntax? ASAP:) kaji Software 0 03-14-2007 10:43 PM
Need Help on a Modelsim VHDL Syntax....ASAP:) kaji Hardware 0 03-14-2007 10:41 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