Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Question 2 (20 Points]- Verilog Operations Give the result of each Verilog expre

ID: 3724075 • Letter: Q

Question

Question 2 (20 Points]- Verilog Operations Give the result of each Verilog expression (in binary) for the following inputs: A=4 'b0 100, B-3;bol 1, C-2'b00, D-4'b1 101, 2-4,b1xxx. Operator Nane bit-select or part-select b) IB C ) logical and bit-wise NOT c) A && B uaary (sign) plus, mis+17,-7 concatenation: (3'BI01.3 B110) -6 B101110 replication: {3(3'B110))·9B1 10110110 multiply, divide, modubas;Land not he sparted Cor binary add, subtract bift left, shift right, Xc2 is maltiply by 4 comparisons. Reg and wire variables are taken as positive manbers logical equality, logikal loeguality case equality, case inequuanlity, pot sathesizablk bit-wise AND, AND together all the bits in a word bit-wise XOR, bit-wise XNOR bit-wise OR: AND tegether all the bits ia a word logical AND. Treat all variables as False (zero) or True (nouzero) logical OR Cio) is (TIE) -1. (1-3) is (TIT)-1 f) D

Explanation / Answer

Given inputs A=4'b0100, B=3'b011, C=2'b00, D=4'b1101, Z=4'b1xxx.

Verilog Expressions are described in terms of expressions instead of gates.

a) {2{B},C} = 8'b01101100 = 011_011_00

Concatenation Operator - A concatenation operator is used to combine two or more operands to form a large operand. To use this operator it is compulsory to define the size of every operand for the computation of the size of the result. All the operations are performed in curly braces { , }.

Replication Operator - Replication Operator are used to repeat an item to a desired number of times. The same number that has to be repeated is concatenated to the given number of times. A replication operator is represented as { { } }.

So, B= 3'b011, C= 2'b00

2{B} = 6'b011011

{2{B},C} = {6'b011011 , 2'b00}

{2{B},C} => 8'b01101100

b) ~|B = 0

Reduction Operators - Reduction operators are used to perform bitwise operation on the same operand bit by bit and return the single bit value. The operators start its operation from right and after evaluation of every bits to left it gives a single bit as the final result. Reduction operators are stated as follows:

&                     Reduction AND

~&                  Reduction NAND

|                      Reduction OR

~|                   Reduction NOR

^                      Reduction OR

^~ or ~^        Reduction NOR

So by reduction nor:

~|B = 0 xor 1 xor 1 => 0

c) A && B = 4'b0000 = 0000

Logical Operators - Logical operators always evaluates to a single bit 0(false) or 1(true). These operators can work on expressions, integers or group of bits and treat all values that are non-zero as “1”. Logical operators are:

&&      logical-and (binary operator)

||        logical-or (binary operator)

!           logical-not (unary operator)

So using logical &&,

A && B = 0100 && 011 => 0100 && 0011 => 0000

d) !B = 3'b100 = 100

Using the above explanation for c) using logical operators,

!B => ! 011 => 100

e) (A==B)? C : B => 3'b011 = 011

Conditional Operator - A conditional operator is used to make decision according to the given condition of the two operator out of which one is true and the other is false. It works in the same ways as a multiplexer do. Syntax: (condition)? (true statement) : (false statement)

So,

(A==B) => 0100 == 0011 , which is false

So, (A==B) ? C : B => 3'b011 = 011

f) D << 2 = 4'b0100 = 0100

Shift Operators - Shift operators are used to shift the number of bits of the first operand specified by the second operand. If any position is vacated by the shifting of operators then it is filled with the zeros. Shift operators are of following types:

>>                   right shift

<<                   left shift

>>>                 arithmetic right shift

<<<                 arithmetic left shift

So, using shift operator,

D << 2 = 1101 shifted left by 2 => 0100

g) D !== Z => 1

Equality - Equality operators are used in an expression to check whether the value of the operands in a given expression is equal or not. These operators compare two operands bit by bit. If the value equates on both the sides then the operator returns logical value 1(true) otherwise 0(false). Equality operators are stated as follows:

==                   Logical Equality

!=                    Logical Inequality

===                 Case Equality

!==                  Case Inequality

So by using case inquality ,

D !== Z => 1101 !== 1xxx (first bit 1 in D matches with first bit 1 in Z, but others are not a match) => 1

So since there is a single bit match the result is D !== Z => 1

Finally the answers are,

a) {2{B},C} = 8'b01101100 => 011_011_00

b) ~|B => 0

c) A && B = 4'b0000 => 0000

d) !B = 3'b100 => 100

e) (A==B)? C : B = 3'b011 => 011

f) D << 2 = 4'b0100 => 0100

g) D !== Z => 1

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote