1 / 36 · अवधारणा
Binary and hexadecimal
Represent the same value in binary and hexadecimal.
पाठ पढ़ना मुफ़्त है। प्रगति सेव करने के लिए नामांकन करें।
अनुवाद अभी उपलब्ध नहीं है। मूल पाठ दिखाया गया है। (English)
Learning goals
- Calculate a binary value from its place weights.
- Map groups of four bits to hexadecimal digits.
Each bit position has a weight.
The unsigned value of b[3:0] is 8×b[3] + 4×b[2] + 2×b[1] + b[0]. Thus 1010 is 10 and 0010 is 2. Leading zeros preserve the value but affect the declared width.
An N-bit unsigned value ranges from 0 to 2^N−1. The value 16 needs five bits. A four-bit destination can discard the high bit, so choose the required range first.
Hexadecimal is a compact notation for bits.
Group bits in fours from the right. 1010 is A and 1111 is F, so 1010_1111 is AF in hexadecimal. The notation changes; the stored bits do not.
In SystemVerilog, 8'hAF and 8'b1010_1111 have the same value and width. The number before the apostrophe specifies the bit width, not the base.
| Binary | Hex | Decimal |
|---|---|---|
| 0000 | 0 | 0 |
| 0111 | 7 | 7 |
| 1000 | 8 | 8 |
| 1111 | F | 15 |
खुद आज़माएँ
Convert 0011_1100 to hexadecimal and decimal.
व्याख्या पढ़ें
0011 is 3 and 1100 is C, giving 0x3C. The weighted sum is 32+16+8+4=60.