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.

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

1 Answer 1


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;


signal my_vector : unsigned(7 downto 0);


my_vector <= to_unsigned(124, my_vector'length);
  • \$\begingroup\$ 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. \$\endgroup\$ Commented Feb 28, 2019 at 16:10
  • \$\begingroup\$ 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." \$\endgroup\$
    – user8352
    Commented Feb 28, 2019 at 20:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.