Search code examples
hexvhdlconstants

Using hex values in constants


I am trying to create a few constants and assign hex numbers to them; however, I keep getting errors.

I want the constant FOO_CONST to be equal to 0x38

Like this...

constant FOO_CONST : integer := x"38";

The error:

Type integer does not match with a string literal

I've tried a few variants with no success.


Solution

  • You can specify a base for integers by using the format base#value#:

    constant FOO_CONST : integer := 16#38#;