Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
14 years ago

VHDL question

Hi all!

According to std.standard:

TYPE string IS ARRAY ( positive RANGE <> OF character);

"hello" is a valid string litteral

"" is a valid string litteral too, it is the empty string.

Let

TYPE foo IS ARRAY ( positive RANGE <> OF integer);

(0, 1, 1, 2, 3, 5) is a valid foo litteral

What is the litteral for an empty foo?

Thx

Julien

5 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    The only way I know is to create a null array constant, and use that in place of a literal:

    constant NULL_FOO : foo(1 downto 2) := (others => 0);
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    I dont think there is. Could you explain why you want to do it?

    another less "clean" way - declare a pointer to foo.

    type foo_ptr_t is access foo;

    variable foo_ptr : foo_ptr_t;

    and then you can actually compare it to null:

    if foo_ptr = null then

    ...etc

    But that is getting rather extreme.