In the VHDL code given below, what will be the values of y and z? [code] VARIABLE x : BIT_VECTOR(3 DOWNTO 0) := 1001; VARIABLE y : BIT_VECTOR(3

In the VHDL code given below, what will be the values of y and z?
Code:
VARIABLE x : BIT_VECTOR(3 DOWNTO 0) := 1001;
VARIABLE y : BIT_VECTOR(3 DOWNTO 0) := 0000;
VARIABLE z : BIT_VECTOR(3 DOWNTO 0) := 0000;
…
y := x ROR 2;
z := y ROL 2;
…
A. y = 0100 and z = 0000
B. y = 0000 and z = 0000
C. y = 0111 and z = 1110
D. y = 0110 and z = 0110
 
Answer: d
Explanation: ROR and ROL are Rotate Right and Rotate Left operators respectively. These operators’ wraps around the operand that means the bit shifted out will replace the vacant bit. Therefore, Rotating x two times towards right will give 0110 in y and when it is rotated left then it will be the same.
 

Tìm kiếm

Back
Top