Know this already? Skip to the exercise: Power-Up Defaults in Binary and Hex
Binary represents values using bits, each either 0 or 1. Four of them are enough to describe a device's status code, read from left to right with weights 8, 4, 2, and 1.
Quick check
Question 1 of 1
In digital hardware, voltage ranges represent logic values. A bit describes one binary value and a bus groups several of them. An eight-bit parallel bus carries all eight at once rather than one bit per program instruction.
Width matters because each extra bit doubles the number of possible patterns. N bits provide 2^N patterns, which as unsigned values cover zero through 2^N - 1.
| Width | Number of patterns | Unsigned range |
|---|---|---|
| 1 bit | 2 | 0 through 1 |
| 4 bits | 16 | 0 through 15 |
| 8 bits | 256 | 0 through 255 |
| 16 bits | 65,536 | 0 through 65,535 |
The circuit's bus width does not grow when the value becomes larger. Decimal 9 needs four bits, 1001, and on an eight-bit bus the same value is 00001001.
You will declare these widths in Entities and Modules.
One hexadecimal digit represents four bits. Digits zero through nine keep their familiar values, and A through F stand for ten through fifteen.
| Hex | Binary | Hex | Binary |
|---|---|---|---|
| 0 | 0000 | 8 | 1000 |
| 1 | 0001 | 9 | 1001 |
| 2 | 0010 | A | 1010 |
| 3 | 0011 | B | 1011 |
| 4 | 0100 | C | 1100 |
| 5 | 0101 | D | 1101 |
| 6 | 0110 | E | 1110 |
| 7 | 0111 | F | 1111 |
Group binary digits in fours, starting from the right, so 10100101 becomes 1010 0101, or hexadecimal A5. Its decimal value is 128 + 32 + 4 + 1 = 165.
You can also convert an eight-bit decimal value directly: 60 = 3 × 16 + 12. The quotient is 3 and the remainder is C, giving hexadecimal 3C.
These are different spellings of the same bit pattern, and hexadecimal notation does not change the circuit.
The following assignments drive the same eight-bit value on three outputs. They are concurrent, which means they describe the three outputs together rather than as three actions separated in time.
bin_o <= "10100101";
hex_o <= x"A5";
dec_o <= 8D"165";
A binary literal has one character per bit, and each hex digit in x"A5" represents four bits. The VHDL-2008 decimal form 8D"165" explicitly requests eight bits, so twelve bits containing decimal 2026 would be 12D"2026". Match the literal width to the output width.
Here the expressions are constants, so the outputs remain constant, but later assignments can depend on changing inputs.
Quick check
Question 1 of 1
Open One Value, Three Ways in the example panel on the right. Its literal_bases source contains the three assignments above, and in the waveform bin_o, hex_o, and dec_o show the same value and remain flat.
The waveform viewer may display all three as hexadecimal. That is a display choice in the viewer, and it does not mean the binary or decimal source was ignored. The power-up defaults exercise asks you to encode different fixed values.