Assignments Week02
Assignments Week02
2. What does the statement the verilog statement “assign f = !(a & b) | !(a ^
b)” signify?
a. The value at LHS gets changed whenever there is a change in the
expression at RHS.
b. The LHS is a register type variable.
c. The variables at RHS must be wire type.
d. Specification of a combinational circuit design at behavioral level.
Answer: (c)
A net type variable is continuously driven by the output of a gate or
module. Thus option (a) is true. A net type variable may appear on the
RHS of an assign statement. Thus option (b) is also true. Since net type
variable is continuously driven, the value gets changed whenever the
output of the connected gate or module change. Thus option (c) is false.
4. For the following Verilog code segment, what will be the number of bits in
S as deduced during synthesis?
wire [31:0] X, Y;
integer S;
S = X + Y + 1;
a. 62
b. 32
c. 33
d. None of the above
Answer: (c)
Since X and Y are of 32 bits size, they represent an unsigned number as
large as 232 – 1. Adding such large numbers like X + Y + 1 = 232 – 1 + 232 –
1 + 1 = 233 – 1, i.e. S will be of size 33 bits. Thus option (c) is the right
answer.
Answer: 12
The assignment yields:
d1 = 3 4 5 6 (hexadecimal)
d2 = A B C D (hexadecimal)
data = 5 + C + B (hexadecimal)
= 0101 + 1100 + 1011 (binary)
= 1100(with a carry 1)
= 12
Answer: (c)
The bitwise NOR operation on A will result in 0, i.e B = 0 where A
=8’b00111001. Thus the concatenation of A[5:3] (=111) with 3 times
replication of B will result in 111000. Thus option (c) is true.
Answer: (c)
Logic gates are instantiated in structural specification. Thus option (a) is
false. The input ports of logic gates must be connected to wire type
variables whereas output ports can be connected to wire type or register
type variables. Thus option (b) is false. The delay in gate instantiation is
used only for simulation. Thus option (c) is true. Logic gates respond to all
possible logic values 0, 1, x, z. Thus option (d) is also false.
Answer: (a)
The bitwise operators & and | performs bitwise AND and OR operation
when operating on two operands whereas these operators acts as
reduction operator when operating on single operand. Thus option (a) is
true. The LHS of “assign” operator must be net type. Thus option (b) is
false. The shift right operator >> does not extend the sign bit whereas the
arithmetic right shift operator >>> extends the sign bit. Thus option (c) is
false. The == operator compare only logic values 1 and 0 whereas ===
operator tests for all possible logic values 0, 1, z, and x. Thus option (d) is
also false.