4 Codes
4 Codes
4 Codes
Homework
2. How many 128x8 memory chips are needed to provide a memory capacity of
4096x16?
3. Which of the following multiplexers would have a 4-bit data selection input?
a. 4:1 mux b. 2:1 mux
2
1. How many address lines would a 64 x 8 RAM have?
Answer
A m x n RAM has n data output lines and k address input lines, where m=2k .
So, in case of a 64 x 8 RAM, m = 64
64 x 8
=> 2k = 64
=> 2k = 26 m n
=> k = 6
3
2. How many 128 x 8 memory chips are needed to provide a memory capacity
of 4096 x 16?
Answer
We have a 128 byte memory chip and we need to create 4096 x 2 or 8192
4
3. Which of the following multiplexers would have 4 input selection lines?
A 2n-by-1 mux has 2n input data lines and n input selection lines.
5
In this lecture, we will study
i. BCD
7
Binary Coded Decimal
PACKED BCD UNPACKED BCD
Decimal: 9 1
(Packed) BCD: 1001 0001
(Unpacked) BCD: 0000 1001 0000 0001
9
Advantages of BCD
Disadvantages of BCD
10
Gray Code
11
Gray Code
0=0000 8=1100
Also known as a reflected binary
1=0001 9=1101
code, the Gray Code is an
ordering of the binary numeral 2=0011 10 = 1 1 1 1
in digital communication.
12
Advantages of Gray Code
Disadvantages of Gray Code
With Gray code, the switching
activity is reduced (because The Gray code is not suitable
only one digit changes in for arithmetic operations.
consecutive code words). It also has limited practical
This results in low power use outside of a few
consumption, fast response, specific applications.
and reduced error in coding.
13
Gray to Binary Conversion
A B C D B4B3 B2B1
0=0 0 0 0 0=0 0 0 0
1=0 0 0 1 1=0 0 0 1
2=0 0 1 1 2=0 0 1 0
3=0 0 1 0 3=0 0 1 1
4=0 1 1 0 4=0 1 0 0
5=0 1 1 1 5=0 1 0 1
6=0 1 0 1 6=0 1 1 0
7=0 1 0 0 7=0 1 1 1
8=1 1 0 0 8=1 0 0 0
B4 = A (MSB remains the same) B3 = A + B 9=1 1 0 1 9=1 0 0 1
B2 = B3 + C B1 = B2 + D
14
Exercise
A B C D
1 1 1 0
+ + +
1 0 1 1
B4 B3 B2 B1
15
Binary to Gray Conversion
A B C D G4G3 G2G1
0=0 0 0 0 0=0 0 0 0
1=0 0 0 1 1=0 0 0 1
2=0 0 1 0 2=0 0 1 1
3=0 0 1 1 3=0 0 1 0
4=0 1 0 0 4=0 1 1 0
5=0 1 0 1 5=0 1 1 1
6=0 1 1 0 6=0 1 0 0
7=0 1 1 1 7=0 1 0 0
8=1 0 0 0 8=1 1 0 0
G4 = A (MSB remains the same) G3 = A + B 9=1 0 0 1 9=1 1 0 1
G2 = B + C G1 = C + D
16
Exercise
A B C D
1 + 0 + 1 + 1
1 1 1 0
G4 G3 G2 G1
17
2421
18
2421: A Weighted Code
19
2421: A Weighted Code
0=0000 5=1011
1=0001 6=1100
2=0010 7=1101
3=0011 8=1110
4=0100 9=1111
Note: The BCD code can be assigned the weights 8 4 2 1, which is why it is sometimes referred
to as the 8421 code.
20
Excess-3 Code
21
Excess-3 Code
22
ASCII Code
23
American Standard Code
for Information Interchange (ASCII)
Each character is
represented by a 7-bit
code and usually an
eighth bit is inserted
for parity.
24
Error Detection Codes
25
Error Detection Codes
An error detection code is a binary code that detects such errors during
transmission.
26
Parity Bit
At the receiving end, all the incoming bits are applied to a parity checker,
that checks the proper parity adopted (even or odd).
An error is detected if the checked parity does not match the adopted parity.
28
29
Homework 1
30
Homework 2
12349876
90009951
31
Homework 3
123900
000000
32
Homework 4
1. 876-234
2. 456-1235
33
9’s Complement
34
10’s Complement
35
Subtraction Using 9’s Complement
When the answer has NO CARRY, the FINAL RESULT of subtraction is obtained by
TAKING 9’S COMPLEMENT OF THE ANSWER along with a NEGATIVE SIGN.
Say, A = 123 and B = 718, and we have to find A-B using 9’s complement.
Step 1: Find 9’s complement of B
999
-718
=281
Step 2: Add 9‘s complement of 718 to 123.
123
+281
= 404 => NO CARRY => so, the result is – (9’s complement of 404),
which is -(595). 37
Subtraction Using 10’s Complement
38
Subtraction Using 10’s Complement
When the answer has NO CARRY, the FINAL RESULT of subtraction is obtained by
TAKING 10’S COMPLEMENT OF THE ANSWER along with a NEGATIVE SIGN.
Say, A = 1234 and B = 4567, and we have to find A-B using 10’s complement.
Step 1: Find 10’s complement of B
9999
-4567
= 5 4 3 2 + 1 = 5433
Step 2: Add 10‘s complement of 4567 to 1234.
1234
+5433
= 6667 => NO CARRY => so, the result is – (10’s complement of 6667),
which is -(3333). 39
In the next lecture, we will study…
i. Microoperations