**Vector Part-Select with Variable Offset** What is the value of out ? re…
**Vector Part-Select with Variable Offset** What is the value of out ? reg [7:0] bus; reg [3:0] out; integer i; initial begin bus = 8'b1101_0010; i = 3; out = bus[i +: 4]; end
- 4'b1010
- 4'b0100
- 4'b1101
- 4'b1001
Correct answer
A. 4'b1010
Explanation
The indexed part-select operator [i +: width] starts at bit index i and slices width bits upwards. For i = 3 and width 4 , it selects bits bus[6:3] . Bits [6:3] of 8'b1101_0010 are 1010 .