VHDL unconstrained arrays

Status
Not open for further replies.

shaiko

Advanced Member level 5
Joined
Aug 20, 2011
Messages
2,644
Helped
303
Reputation
608
Reaction score
297
Trophy points
1,363
Activity points
18,302
In VHDL you can do the following assignment :

Code:
x <= ( others => '1' ) ;
However,
You cannot compare this way :
Code:
if x = ( others => '1' ) then
Is there a way to do it compactly without writing the whole long vector?
Code:
if x =  "1111111111111111111111111111111111111111" then
 

Good question, I will like to know that too!

But for me, since "1111111111111111111..." is a constant, will consider to declare CONSTANT in generic or library package named CONSTANT32bit1

then

Code:
if x = CONSTANT32bit1 then
..
..
end if;

if y = CONSTANT32bit1 then
..
..
end if;

---etc
 

either declare a handy constant:

constant ONES : std_logic_vector(x'range) := (others => '1');

if x = ONES then

or create the vector properly:

if x = (x'range => (others => '1') ) then

I think the first one is better.
 
Reactions: shaiko

    shaiko

    Points: 2
    Helpful Answer Positive Rating
IIRC, you can do "x = (x'range => '1')" or "signed(x) = -1"
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…