Know this topic? Give it a go. The lesson is here if you need it.
Binary represents values using bits, each either 0 or 1.
A group of four bits can describe a device's status code.
Read the positions from left to right with weights 8, 4, 2, and 1.
Question 1 of 1
In digital hardware, voltage ranges represent logic values. A bit describes one binary value; a bus groups several bits. An eight-bit parallel bus carries eight bits at once, not one bit per program instruction.
Width matters because each extra bit doubles the number of possible patterns.
N bits provide 2^N patterns.
When interpreted as unsigned, their range is 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.
For example, decimal 9 needs four bits: 1001.
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; A through F represent 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.
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. Hexadecimal notation does not change the circuit.
The following assignments drive the same eight-bit value on three outputs. They are concurrent: they describe outputs together, not three actions separated in time.
bin_o <= "10100101";
hex_o <= x"A5";
dec_o <= 8D"165";
A binary literal has one character per bit.
Each hex digit in x"A5" represents four bits.
The VHDL-2008 decimal form 8D"165" explicitly requests eight bits.
For twelve bits containing decimal 2026, use 12D"2026".
Match the literal width to the output width.
Here the expressions are constants, so the outputs remain constant. Later assignments can depend on changing inputs.
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.
Compare bin_o, hex_o, and dec_o in the waveform: they show the same value and remain flat.
The waveform viewer may display all three as hexadecimal. That is a display choice, not evidence that the binary or decimal source was ignored. The power-up defaults exercise asks you to encode different fixed values.