Bit slicing / indexing in vectors Given B[7..0] = 10100101 (bit 7 is MSB), what is the bit slice B[6..2]?

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:

  • B[7..0] = 10100101, where bit 7 is the most significant bit (leftmost).
  • We are asked for B[6..2], i.e., bits 6, 5, 4, 3, and 2 in that order.

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

More Questions from Digital Arithmetic Operations and Circuits

Discussion & Comments

No comments yet. Be the first to comment!
Join Discussion