Basic question #3

Discussion in 'VHDL' started by m, Sep 30, 2008.

  1. m

    m Guest

    ....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
     
    m, Sep 30, 2008
    #1
    1. Advertising

  2. On 30 Sep., 08:08, m <> wrote:
    > ...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
     
    Thomas Stanka, Sep 30, 2008
    #2
    1. Advertising

  3. m

    Tricky Guest

    On 30 Sep, 08:06, Thomas Stanka <>
    wrote:
    > On 30 Sep., 08:08, m <> wrote:
    >
    > > ...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


    (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');
     
    Tricky, Sep 30, 2008
    #3
  4. m

    jens Guest

    > (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!
     
    jens, Sep 30, 2008
    #4
  5. On 30 Sep., 10:17, Tricky <> wrote:
    > On 30 Sep, 08:06, Thomas Stanka <>
    > wrote:
    >
    >
    >
    > > On 30 Sep., 08:08, m <> wrote:

    >
    > > > ...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

    >
    > (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
     
    Thomas Stanka, Oct 1, 2008
    #5
  6. m

    Tricky Guest

    On 30 Sep, 18:01, jens <> wrote:
    > > (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!


    having just experiemented, Quartus appears to recognise null ranged
    vectors and gives a warning before throwing them away.
     
    Tricky, Oct 1, 2008
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Stefan Duenser

    Basic shifting question

    Stefan Duenser, Dec 7, 2004, in forum: VHDL
    Replies:
    4
    Views:
    448
    Stefan Duenser
    Dec 8, 2004
  2. Replies:
    1
    Views:
    589
    Eric Smith
    Jul 8, 2005
  3. Engineer
    Replies:
    6
    Views:
    643
    Jeremy Bowers
    May 1, 2005
  4. Replies:
    0
    Views:
    452
  5. Ark Khasin

    A basic question question about volatile use

    Ark Khasin, Jul 31, 2008, in forum: C Programming
    Replies:
    12
    Views:
    363
    Ark Khasin
    Jul 31, 2008
Loading...

Share This Page