Difficulty: Easy
Correct Answer: 01001
Explanation:
Introduction / Context:
Bit slicing is used constantly in HDL design and low-level programming to extract fields from registers. This question tests careful indexing from a declared bit range.
Given Data / Assumptions:
Concept / Approach:
Write the bit positions explicitly and read off the requested slice without reordering. Ensure you do not reverse endianness or miscount indices.
Step-by-Step Solution:
Label bits: b7 b6 b5 b4 b3 b2 b1 b0 = 1 0 1 0 0 1 0 1.Extract b6..b2 → 0 1 0 0 1.Therefore, B[6..2] = 01001.
Verification / Alternative check:
Cross-check by masking and shifting: ((B >> 2) & 0b11111) yields 01001 for B = 0b10100101.
Why Other Options Are Wrong:
Each incorrect choice corresponds to a common indexing or reversal mistake (e.g., reading from the LSB end or omitting a bit).
Common Pitfalls:
Confusing bit numbering conventions (MSB..LSB vs. LSB..MSB) and accidentally reversing the slice.
Final Answer:
01001
Discussion & Comments