# VHDL initialize vector using readable integers not long binary string

So I am only starting out my VHDL journey. One thing I am finding a bit of a nuisance is the following format:

signal sig_A : unsigned (3 downto 0) := "0101";


being that "0101" is just a string which somewhere down the line gets converted to bits. Is there a way I can initialize this to where its a bit easier to read, especially when I get to bigger numbers. For example

signal sig_A : unsigned (9 downto 0) := "753";


which for the life of my I cant think of the binary or hex equivalent unless I whip out a calculator.

I just do not know the language well enough yet to figure this out. It seems like a trivial thing but I have tried a lot of variations with no success. I was thinking like a prefix dec"753" or "D753" I really have no clue but it surely has to be implemented in the language somehow I cannot imagine people really typing out 32 bits or trying to compute hex constantly.

Before anyone mentions it, I am not expecting it to throw 7 and a 5 and a 3 in there literally. Just as I dont expect it to throw an "F" in there when typiing hex. I am expecting it to decipher the number to its binary equivalent based on a string just how it deciphers the "010101" string.

• You can use the B#Number where B is a base between 2-16. See this answer stackoverflow.com/questions/3248181/… – ks0ze Mar 1 at 2:51
• @ks0ze that was helpful thanks!!!!! – Edwin Fairchild Mar 1 at 16:25
• signal sig_A : unsigned (9 downto 0) := 10d"753"; interprets the bitstring literal 753 as decimal, which is converted to 10 binary digits. – Paebbels Mar 2 at 16:50

You can use to_unsigned() to convert an integer into an array of bits suitable for an unsigned vector.

library ieee;
use ieee.numeric_std.all;

--snip

signal my_vector : unsigned(7 downto 0);

--snip

my_vector <= to_unsigned(124, my_vector'length);

• that works. Also I have been playing with it for a few minutes and I have a signal named zero and I can do myvector <= zero + 753 that seems to get the job done too. – Edwin Fairchild Feb 28 at 16:10
• There's also IEEE Std 1076-2008 15.8 Bit string literals paragraph 9: "The length of a bit string literal is the length of its string literal value. If a bit string literal includes the integer immediately preceding the base specifier, the length of the bit string literal is the value of the integer. Otherwise, the length is the number of characters in the expanded bit value." – user8352 Feb 28 at 20:30