Refer to the VHDL code given below, what should be the output of the identifier ‘y’ and ‘z’? [code] VARIABLE x : BIT_VECTOR(3 DOWNTO 0)

Refer to the VHDL code given below, what should be the output of the identifier ‘y’ and ‘z’?
Code:
VARIABLE x : BIT_VECTOR(3 DOWNTO 0) := 1010;
VARIABLE y : BIT_VECTOR(3 DOWNTO 0) := 0000;
VARIABLE z : BIT_VECTOR(3 DOWNTO 0) := 0000;
…
y := x SRL 2;
z := x SLL 2;
…
A. y = 0100 and z = 0100
B. y = 0010 and z = 0100
C. y = 0100 and z = 1000
D. y = 0010 and z = 1000
 
Answer: d
Explanation: SRL operator will shift the operand towards right and SLL will shift the same towards left. All the left bits will be filled with zero in SRL operation and in SLL right bits will be filled with zero. Therefore, y must be x shifted towards right with 2 positions.
 

Tìm kiếm

Back
Top