VHDL: Using hex values in constants

mike65535 picture mike65535 · Aug 4, 2016 · Viewed 33k times · Source

I am a VHDL noob, 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.

I'd appreciate any help. Thanks!

-Mike

Answer

Erasmus Cedernaes picture Erasmus Cedernaes · Jan 4, 2017

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

constant FOO_CONST : integer := 16#38#;