Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VHDL: Using hex values in constants

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

like image 977
mike65535 Avatar asked Aug 04 '16 21:08

mike65535


People also ask

How do you use hex numbers in VHDL?

In VHDL, hex is a much easier way to set bigger vectors instead of regular binary. This is because one symbol of hex is 4-bits of binary. For example: signal my_slv : std_logic_vector(15 downto 0);

How do you declare a constant in VHDL?

It is possible to create constants in VHDL using this syntax: constant <constant_name> : <type> := <value>; Constants can be declared along with signals in the declarative part of a VHDL file, or they can be declared along with variables in a process.


1 Answers

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

constant FOO_CONST : integer := 16#38#;
like image 81
Erasmus Cedernaes Avatar answered Sep 18 '22 17:09

Erasmus Cedernaes