What will be the values of out1 and out2? [code] ARCHITECTURE bhv OF example IS CONSTANT out1 : BIT; CONSTANT out2 : BIT; BEGIN B1 : BLOCK CONST

Lượng Tiger

New member
What will be the values of out1 and out2?
Code:
ARCHITECTURE bhv OF example IS
CONSTANT out1 : BIT;
CONSTANT out2 : BIT;
BEGIN
B1 : BLOCK
CONSTANT S : BIT := 0;
BEGIN
B1-1 : BLOCK
SIGNAL S : BIT := 1;
BEGIN
out1 <= S;
END BLCOK B1-1;
out2 <= S;
END BLOCK B1;
END bhv;
A. out1 = 0 and out2 = 0
B. out1 = 0 and out2 = 1
C. out1 = 1 and out2 = 0
D. out1 = 1 and out2 = 1
 
Answer: c
Explanation: Objects declared in a block are visible to that block and the blocks nested within. But, when a child block declares an object with same name as the one in parent block then child’s declaration overrides the parent’s object. Therefore, S used in block B1-1 will be 1 and another will be 0.
 

Tìm kiếm

Back
Top