Forum Discussion

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

question about unsigned constant

Hi everyone,

I meet a problem when I am trying to define a one bit unsigned constant.

I think declaration should be constant var1: unsigned :='1'; But everytime I try this, it always be an error. Does anybody know how

to fix it? Thanks.

3 Replies

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

    --- Quote Start ---

    think declaration should be constant var1: unsigned :='1';

    --- Quote End ---

    The definition involves two faults.

    - it's missing a size constraint

    - it uses incorrect bit-vector constant syntax

    constant CONST1: unsigned(0 downto 0) :="1";
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- Quote Start ---

    The definition involves two faults.

    - it's missing a size constraint

    --- Quote End ---

    When declaring a constant, sizing is implicit in the constant value, so explicit sizing is not required.

    constant A : unsigned := "0";

    is perfectly legal.