![]() |
|
|
|||||||
![]() |
VHDL - A question about syntax of VHDL |
|
|
Thread Tools | Search this Thread |
|
|
#1 |
|
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 |
|
|
|
|
#2 |
|
Posts: n/a
|
An assignment takes the form if A<= (others => '0');
dutchgoldtony |
|
|
|
#3 |
|
Posts: n/a
|
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 |
|
|
|
#4 |
|
Posts: n/a
|
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 |
|
|
|
#5 |
|
Posts: n/a
|
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 |
|
|
|
#6 |
|
Posts: n/a
|
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 |
|
|
|
#7 |
|
Posts: n/a
|
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_ |
|
![]() |
| Thread Tools | Search this Thread |
|
|
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 |