Solution and feedback of Assignment No: 1

Assignment No.1 / Course Name CS302 / Marks:20 / Due Date: 19/04/2012
Q1 (a) Binary to Gray
1 1 0 0 0 1 1 0
Step 1: Write left most bit as it is
1
Step 2: Add the left most binary digit to adjacent one and write the resulting bit down
1 + 0 0 0 1 1 0
1  0
Step 3: Add next adjacent pair
1 1 + 0 0 0 1 1 0
1 0 1
Step 4: Again add next adjacent pair and repeat until the last pair
1 1 0 + 0 0 1 1 0
1 0 1 0
Step 5: Repeat step 4
1 1 0 0 + 0 1 1 0
1 0 1 0 0
Step 6: Repeat step 4
1 1 0 0 0 + 1 1 0

1 0 1 0 0 1
Step 7: Repeat step 4
1 1 0 0 0 1 + 1 0
1 0 1 0 0 1 0
Step 8: Repeat step 4
1 1 0 0 0 1 1 + 0
1 0 1 0 0 1 0 1
So the Gray code for the binary 11000110 is 10100101
(b) Gray to Binary
Step 1: Write left most bit as it is
1 0 1 0 1 1 1 1
Gray Code 1
Step 2: Add this gray bit to next binary bit and write the result below as arrows indicate.
1 0 1 0 1 1 1 1
1  1
Step 3: Repeat step 2 until the last bit
1 0 1 0 1 1 1 1
1 1 0
1 0 1 0 1 1 1 1
1 1 0 0
1 0 1 0 1 1 1 1
1 1 0 0 1
1 0 1 0 1 1 1 1
1 1 0 0 1 0
1 0 1 0 1 1 1 1
1 1 0 0 1 0 1
1 0 1 0 1 1 1 1
1 1 0 0 1 0 1 0
So Binary code for the gray 10101111 is 11001010
Q2 Fill the empty columns in the table by performing each operation against each row.
A / B / C / D / AND / OR / NAND / NOR
0 / 0 / 0 / 0 / 0 / 0 / 1 / 1
0 / 0 / 0 / 1 / 0 / 1 / 1 / 0
0 / 0 / 1 / 0 / 0 / 1 / 1 / 0
0 / 0 / 1 / 1 / 0 / 1 / 1 / 0
0 / 1 / 0 / 0 / 0 / 1 / 1 / 0
0 / 1 / 0 / 1 / 0 / 1 / 1 / 0
0 / 1 / 1 / 0 / 0 / 1 / 1 / 0
0 / 1 / 1 / 1 / 0 / 1 / 1 / 0
1 / 0 / 0 / 0 / 0 / 1 / 1 / 0
1 / 0 / 0 / 1 / 0 / 1 / 1 / 0
1 / 0 / 1 / 0 / 0 / 1 / 1 / 0
1 / 0 / 1 / 1 / 0 / 1 / 1 / 0
1 / 1 / 0 / 0 / 0 / 1 / 1 / 0
1 / 1 / 0 / 1 / 0 / 1 / 1 / 0
1 / 1 / 1 / 0 / 0 / 1 / 1 / 0
1 / 1 / 1 / 1 / 1 / 1 / 0 / 0
Common Mistakes & Explanation: / Mistake 1: Conversion between binary and gray can be solved wrongly by the students.
Explanation: Differentiation between both methods are given above in the solution, learn carefully how a binary number can be converted into gray number and vice versa.
Mistake 2: Students may confused about 4 inputs for each gate in Q2
Explanation: Each AND, OR, NAND and NOR operation would be performed by considering four inputs gates and applying the thumb rule given in truth table for each gate. For example Out put of the AND gate would be zero if any one of the input bits is 0, and out put of the OR gate would be 1 if any one of the input bits is 1 same is the case with NAND and NOR