Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   VHDL (http://www.velocityreviews.com/forums/f18-vhdl.html)

 Jim Huang 04-21-2005 09:00 AM

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

 dutchgoldtony 04-21-2005 09:16 AM

Re: A question about syntax of VHDL

An assignment takes the form if A<= (others => '0');

 Jim Huang 04-21-2005 09:52 AM

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.

 charles.elias@wpafb.af.mil 04-21-2005 10:02 AM

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

 Mohammed A khader 04-21-2005 10:07 AM

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 04-21-2005 10:07 AM

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.

 info_ 04-24-2005 03:28 PM

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

 All times are GMT. The time now is 09:33 AM.