Basic question #3

M

m

....don't know why I am numbering my questions, but I'm on a roll, so
I'll keep it that way.

Just ran into this:

signal A: std_logic_vector(5 downto 0);
....
later on in a conditional statement it is used this way:
.........A(5 downto 7).......

What does that mean? There isn't a seventh element to this vector.
Also, wouldn't "downto" require the second index to be less than or
equal to the first?

Similarly, elsewhere in the code I found:

.....ext("0", (3 - 2))...

Of course "(3-2)" is actually an expression that results in these
numbers. I'm simplifying here.
Now, from what I gather, if the SIZE portion of "ext" is < 0 it is
interpreted as 0. Presumably, then, this would simply return "0".

I think I got the second one right. The first one I can't figure
out. The three books on my desk don't seem to help either.

Thanks,

-Martin
 
T

Thomas Stanka

...don't know why I am numbering my questions, but I'm on a roll, so
I'll keep it that way.

Just ran into this:

signal A: std_logic_vector(5 downto 0);
...
later on in a conditional statement it is used this way:
........A(5 downto 7).......
What does that mean? There isn't a seventh element to this vector.
Also, wouldn't "downto" require the second index to be less than or
equal to the first?

I guess this is a typo. (5 downto 7) is not allowed, but it might be
interpreted as (5 downto 5) by some (wrong) programs.

bye Thomas
 
T

Tricky

I guess this is a typo. (5 downto 7) is not allowed, but it might be
interpreted as (5 downto 5) by some (wrong) programs.

bye Thomas

(5 downto 7) IS allowed, it just returns a null array. It will compile
ok, not sure what exactly it would do in simulation though. A
synthesiser will probably either throw it away or just complain and
stop.

These null arrays are declared in numeric_std:
-- null range array constants

constant NAU: UNSIGNED(0 downto 1) := (others => '0');
constant NAS: SIGNED(0 downto 1) := (others => '0');
 
J

jens

(5 downto 7) IS allowed, it just returns a null array. It will compile
ok, not sure what exactly it would do in simulation though. A
synthesiser will probably either throw it away or just complain and
stop.

These null arrays are declared in numeric_std:
  -- null range array constants

  constant NAU: UNSIGNED(0 downto 1) := (others => '0');
  constant NAS: SIGNED(0 downto 1) := (others => '0');

When I recently tried a null array (of natural) as an input to a
generic, ISE 10.1 turned it into either (0 downto 0) or (1 downto 0),
which in turn generated some hardware where the intention was to
generate nothing, so null arrays don't seem to work with Brand X. The
workaround ended up being passing in a specific one element array (0
=> natural'high) and detecting the natural'high in the entity, in
which case no hardware was generated. Thank you, natural'high!
 
T

Thomas Stanka

(5 downto 7) IS allowed, it just returns a null array. It will compile
ok, not sure what exactly it would do in simulation though. A
synthesiser will probably either throw it away or just complain and
stop.

Seems I need to take a look in the lrm instead of arguing with
practical gained knowledge *g*.

regards Thomas
 
T

Tricky

When I recently tried a null array (of natural) as an input to a
generic, ISE 10.1 turned it into either (0 downto 0) or (1 downto 0),
which in turn generated some hardware where the intention was to
generate nothing, so null arrays don't seem to work with Brand X.  The
workaround ended up being passing in a specific one element array (0
=> natural'high) and detecting the natural'high in the entity, in
which case no hardware was generated.  Thank you, natural'high!

having just experiemented, Quartus appears to recognise null ranged
vectors and gives a warning before throwing them away.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,233
Latest member
AlyssaCrai

Latest Threads

Top