1-element arrays are invalid in VHLD?

Discussion in 'VHDL' started by valentin tihomirov, Jun 18, 2005.

  1. This code is accepted

    type TLETTERS is array (0 to 1) of CHARACTER;
    constant LETTERS: TLETTERS := ('a', 'b');

    however the following is not

    type TLETTERS is array (0 to 0) of CHARACTER;
    constant LETTERS: TLETTERS := ('a');

    IMO, this is called inconsistency (bad design).

    BTW, is there a more compact (single line) way to declare a constant array
    avoiding the type declaration? I guess the long preparations creating
    templates (which are types in this case) are necessary for instantiating
    multiple objects using this template. But I have only one array, so what is
    the need to declare a special type for it? In C, we can instantiate an array
    of any elements avoiding developement of special array classes for each
    basic element. Am I missing something?
     
    valentin tihomirov, Jun 18, 2005
    #1
    1. Advertising

  2. valentin tihomirov wrote:
    > This code is accepted
    > type TLETTERS is array (0 to 1) of CHARACTER;
    > constant LETTERS: TLETTERS := ('a', 'b');
    > however the following is not
    > type TLETTERS is array (0 to 0) of CHARACTER;
    > constant LETTERS: TLETTERS := ('a');
    > IMO, this is called inconsistency (bad design).


    The type isn't the problem.
    The problem is ambiguity of ('a')

    If ('a') is an array then parenthesis
    are disallowed around character literals.
    You can't have it both ways.

    IMO this is an example of
    incompleteness for the sake of a
    logically consistent language.
    This is a limit on any formal system.

    For your example, this would also work:
    constant LETTER: TLETTERS := (0 =>'a');

    -- Mike Treseler
     
    Mike Treseler, Jun 18, 2005
    #2
    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. =?Utf-8?B?Um9iZXJ0?=
    Replies:
    3
    Views:
    6,943
    Steven Cheng[MSFT]
    Nov 15, 2005
  2. Patrick.O.Ige
    Replies:
    1
    Views:
    2,014
    Patrick.O.Ige
    Jul 2, 2006
  3. Java Guy
    Replies:
    1
    Views:
    709
    Manish Pandit
    Oct 15, 2006
  4. HANM
    Replies:
    2
    Views:
    763
    Joseph Kesselman
    Jan 29, 2008
  5. Philipp
    Replies:
    21
    Views:
    1,186
    Philipp
    Jan 20, 2009
Loading...

Share This Page