Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VHDL initialize vector (the length is not a multiple of 4) in hex

For example, I have a vector which length is 10. How can I initialize it in hex. (The synthesize tool complains size mismatch as it thinks the hex value is a multiple of 4)

signal v : std_logic_vector (9 downto 0)    := x"11A";

Many thanks! Nigong

like image 691
nigong Avatar asked Apr 25 '13 21:04

nigong


Video Answer


2 Answers

x"11A" is a "hexadecimal bit string literal". Prior to VHDL-2008, these had to be a multiple of 4 bits, hence the problem you're seeing. VHDL-2008 removed this restriction, so you can now write 10x"11A". I don't know how much tool support there is for 2008, though.

like image 144
EML Avatar answered Oct 03 '22 11:10

EML


a possible workaround is to write multiples of 4 bits as hex value and add the rest in binary, e.g.:

signal v: std_logic_vector(9 downto 0) := "01" & X"1A";
like image 23
baldyHDL Avatar answered Oct 03 '22 10:10

baldyHDL