Anda di halaman 1dari 32

Course Learning Outcomes

1. Perform Logic Minimization for single/multiple output function(s).


2. Generate multiple digital solutions to a verbally described problem.
3. Perform timing analysis of the digital circuits/systems.
4. Assess the performance of a given digital circuit with Mealy and
Moore configurations.
5. Perform static timing analysis of the digital circuits/systems.
6. Evaluate the performance of a given Digital circuit/system with
respect to
Speed,
Power consumption,
Number of ICs,
Cost
Reference Books

Fundamentals of Digital Circuits by Anand Kumar


Engineering Approach to Digital Design by Fletcher
W.I
Digital Design Principles and Practices by Wakerly JF
Digital Design by M Morris Mano
Points to be Noted
Marks Distribution:
MST : 25 EST : 35 Sessional : 40

Sessional: (a) Lab : 20 Lab Quiz + Viva/ Lab Perf


10 + 10
(b) Tutorial : 10
(c) Quiz (General) : 10

Dates for Quiz:


Lab Quiz : 11 Oct/1700 Hrs
Quiz (General) : 15 Nov/1700 Hrs
Codes
Coding/Encoding is the process of assigning a group of binary digits
(referred as Bits) to relate to some piece of information. By assigning each
item of information a unique combination of bits (1's & 0's), some given
information is transformed in to another form.
Hence, a CODE is a symbolic representation of an information transform.
The bit combinations are referred as WORDS or CODE WORDS.
Some general definitions assigned to bit combinations are:-
Bit a binary bit (1 or 0)
Byte a group of 8 bits
Nibble a group of 4 bits
Word a group of bytes; usually a word has 2 bytes or four nibbles
In addition to providing security, Standardization is the main reason for
evolving a coding scheme. Some typical examples of Codes are:-
(a) Binary Codes (b) Binary Coded Decimal Codes
(c) Reflected Codes (d) Unit Distance Codes
(e) Alphanumeric Codes (f) Error Detecting Codes
Binary Codes
Binary coding scheme utilizes two symbols of code generation '1' & '0'.
If 'n' elements of information in some form are to be coded with two valued
bits How many bits would be required to represent each element of
information uniquely to avoid ambiguity.
Best approach establish how many unique code words can be derived
from a combination of 'n' bits.
From above, it can be derived that if X elements of information is to be
coded in binary form then
X 2n where n is number of code bits
n log2 X or n 3.32 log10 X
Example: No. of binary bits required to represent 26 alphabetic characters
plus 10 decimal digits.
Number of unique codes to be generated x = 26 + 10 = 36
No of bits required in the code word n 3.32 log10 X
n 3.32 log1036 n 5.16
Since there cannot be a fractional bit, we take the next higher number. Thus,
6 bits are required for above representation.
Binary Codes For Decimal Numbers
Binary Codes broadly fall under two categories: Numeric and Alphanumeric.

Numeric Codes: are used to represent numbers.

Alphanumeric Codes: are used to represent letters for alphabets and


numbers.

BCD Numbers: Binary Numbers are prevalent in digital systems, but for
representation of decimal numbers, specially where man-machine interfaces
exist, Binary Coded Decimal codes are used for ease of communication.

BCD encoding for decimal digits is done one at a time in groups of 4


binary digits. Thus, BCD codes are at least 4 bits long with at least 6
unassigned code words. BCD codes may be weighted or Non-weighted.

Weighted codes obey position weighting system i.e. position of each binary
digit also represents the positional value (weight). For each group of four
binary digits, sum of weights of these positions where binary digit is '1',
represents the value of the decimal number.
Binary Codes For Decimal Numbers
Weighted codes may be
Positively weighted: There are total 17 positively weighted codes,
with 1st weight being 1, 2nd weight can be 1 or 2. Sum of all weights
should be 9. Examples: 8421, 2421, 5211, 3321,4311
Negatively weighted. In Negatively weighted codes, some weights
are -ve. Examples: 642-3, 631-1, 8 4-2-1, 74-2-1
Non-weighted codes do not have positional weighting system. Excess-3
(XS-3) code and Gray Code are non-weighted codes..
BCD Codes

Note: 8421 binary code is referred as Natural Binary Coded Decimal code (NBCD).
Since there are many possible weights that can be assigned to derive BCD code,
there are following two properties that give some figure of merit to a code over
another Code: Self-Complementing Property and Reflective Property
Binary Code Types
Sequential Codes:
In this type of coding, each code word is one binary number greater than
the preceding code word.
These codes facilitate mathematical operations on data.
XS-3 and 8421 are sequential codes. 5421, 2421 and 642-3 are not
sequential codes.
Cyclic Codes:
In these codes, each successive code word differs from the preceding
one in only one bit position.
These codes are also called Unit Distance Codes. Cyclic codes help in
detecting transitional errors.
Gray code is a cyclic code.
Binary Code Types

Reflective Codes:
A reflected code is characterized by the fact
that it is imaged about the center entries with
one bit changed.
The 9's complement of a reflected BCD code
is formed by simply changing only one of its
bits. Ex: 9's Complement of 2 is 7
Code of 2 0 0 1 0
only 1 bit change

Code of 7: 1 0 1 0
Gray code is reflective code.
Binary Code Types (Gray Code)
Unit Distance Codes:
Codes in which each successive code word differ
from the preceding code in only one bit position.
Unit distance codes minimize transitional errors
(flashing). It is used for translating an analog
quantity such as shaft position in to a digital value.
Gray code is an example of Unit Distance code. It is
a non-weighted code and is not suitable for
arithmetic operations. It is not a BCD code also.
Gray code is also a Reflective Code.
An N-bit Gray code can be obtained by reflecting N-1
bit code about an axis at the end of the code and
putting the
MSB of 0 above the axis and
MSB of 1 below the axis.
Binary Code Types
Self Complementing Codes: A code is self
complementing if the code word of the 9's
complement of N, i.e. 9-N can be obtained from
the code word of N by interchanging all the 0s and
1s. Hence, code for 9 is the complement code of
0, 8 is the complement of 1, 7 is the complement
of 2 and so on.
The 2421, 5211, 642-3, 84-2-1 and XS-3 are self
complementing codes. 8421 & 5421 are not self-
complementing codes.
For a code to be self complementing, the sum
of all its weights must be 9.
Only 4 positively-weighted self complementing
codes are 2421, 5211, 3321 & 4311.
There are 13 negatively-weighted self
complementing codes.
Adjacent table gives an example of negatively
weighted (631-1), positively weighted (2421) and
non-weighted (Excess-3) codes that are self-
complementing.
Excess-3 (XS-3) Code
Excess-3:
XS-3code is obtained by adding 3 to the
normal binary code of a decimal
number.
In a normal XS-3 Code, the bit pattern
for 0 (0000) and 9 (1001) are not unit
distance apart.
Excess-3 Gray
XS-3 Gray code removes the above
anomaly and provides unit distance
between bit patterns for 0 and 9.
Each decimal digit is encoded with the
Gray Code pattern of the digit that is
greater by 3 (refer slide-10 on Gray
Code to see the code of 3, which is
treated as XS-3 Gray code of decimal
0 and so on).
Code Chart
Alphanumeric Codes
A binary digit or bit can represent only two symbols as it has only two states
'0' or '1'. Additional symbols are required to represent 26 alphabets with
capital and small letters, numbers from 0 to 9, punctuation marks etc.
Alphanumeric codes represent numbers, alphabetic, numeric and other
characters such as special symbols and various instructions necessary for
conveying information.
Following are the three alphanumeric codes very commonly used for data
representation.
American Standard Code for Information Interchange (ASCII).
Extended Binary Coded Decimal Interchange Code (EBCDIC).
Five bit Baudot Code.
ASCII code is a 7-bit code and EBCDIC is an 8-bit code.
ASCII code is more commonly used worldwide while EBCDIC is used
primarily in large IBM computers.
Error Detecting Codes
Environmental interference and physical defects in the communication
medium can cause random bit errors during data transmission. The 1s may
change to 0s and 0s may change to 1s. Therefore, data errors need to be
detected and corrected to ensure integrity of data.
Error coding is a method of detecting and correcting these errors to ensure
information is transferred intact from its source to its destination.
Error coding uses mathematical formulas to encode data bits at the source
into longer bit words for transmission.
The "code word" is decoded at the destination to retrieve the information. The
extra bits in the code word provide redundancy for the destination to decode
and determine errors introduced in the communication medium and in some
cases correct them to avoid re-sending data.
Different error coding schemes are chosen depending on the types of errors
expected, expected error rate in the communication medium, and whether or
not data re-transmission is possible. Popular error detecting techniques are:
Simple Parity check
Two-dimensional Parity check
Checksum
Cyclic redundancy check
Error Detecting Codes
Parity: Simplest and least expensive technique is addition of an extra bit
called parity bit to the data word being transmitted. Parity is of two types
Even Parity and Odd Parity.
For Even Parity, the parity bit is set to 0 or 1 at the transmitter such that
number of 1 bits is even.
For Odd Parity, the parity bit is set to 0 or 1 at the transmitter such that
number of 1 bits is odd.

On receipt of data, a parity checking circuit generates an error signal if the


total number of 1s is even in an odd-parity system or odd in an even-parity
system. This helps in checking 1-bit error in the data.
Error Detecting Codes

Adjacent table shows the Odd and Even


parities for 8421 weighted BCD codes.
Simple Parity Code cannot correct errors,
and can detect only an odd number of bits
in error.
Error Detecting Codes
Two Dimensional Parity Check: Data to
be transmitted is set in a tabular form.
Parity (even or odd) is generated for each
row and column and transmitted along with
the data to the receiver. It increases the
likelihood of detecting burst error.
Example: When several binary words are
transmitted in succession, the resulting
collection of bits is regarded as Block of
data arranged in rows and columns.
Parity bits are generated for each row and
column. In the adjacent table, odd parity is Parity Row Parity Column
generated.
The above table has six-8bit words
This scheme helps in correcting single forming a 6X8 message block for
error in a data word and to detect any two transmission.
errors in a word. Block Parity technique is Parity bits generated in row &
column make the block to be 7X9.
also called Word Parity. At the receiving end, row and
column parities are checked.
Error Detecting Codes
The adjacent table has six-8bit words forming 6X8 block
for transmission. Parity bits generated in row & column
makes the block to be 7X9.
Refer TableB for Error Detection: At the receiving end,
row and column parities are checked for odd parity.
Single bit errors for odd parity can be detected and
corrected by complementing the error bit.
Refer Table C for Detecting two errors using odd
parity for block code, but not corrected.

Parity Error
in 3rd Row

Parity Error in 5th Column Parity Errors in 2nd & 4th Column
Error Detecting Codes
Checksum:
In this error detection scheme, the data is divided into k segments each of

m bits.
At the senders end the segments are added using 1s complement

arithmetic to get the sum. The sum is complemented to get the checksum,
which is sent along with the data segments.
At the receivers end, all received segments are added using 1s

complement arithmetic to get the sum. The sum is complemented. If the


result is zero, the received data is accepted; otherwise discarded.
Cyclic Redundancy Check:
CRC is based on binary division and simple to implement.

At the transmitter end, a sequence of redundant bits, called cyclic

redundancy check bits, are appended to the end of data unit so that the
resulting data unit becomes exactly divisible by a predetermined binary
number.
At the Receiver end, the incoming data unit is divided by the same number,

if there is no remainder, the data unit is assumed to be correct. A


remainder indicates corruption of data.
Error Correcting Codes
Error Correction is handled in two ways:
Backward Error Correction: when an error is discovered; the receiver
requests the sender to re-transmit the entire data unit.
Forward Error Correction: Receiver uses an error-correcting
schemes to automatically corrects certain errors.
Error-correcting codes are more sophisticated than error detecting codes
and require more redundant bits.
In theory, it is possible to correct any number of errors automatically.
However, number of bits required to correct multiple-bit or burst error is so
high that in most of the cases it is inefficient to do so. For this reason, most
error correction is limited to one, two or at the most three-bit errors.
Error Detection & Correcting Code:
Hamming Code
Hamming codes are a family of linear error-correcting codes invented by
Richard Hamming in 1950.
Hamming codes can detect up to two-bit errors or correct one-bit errors
without detection of uncorrected errors.
Hamming(7,4) is a 7-bit Hamming Code. It is a combination of parity bits
and data bits used for detecting and correcting single bit errors.
Determining number of Parity bits required for generating hamming code
for D number of data bits?
Assume 'P' is number of parity bits required for D data bits then
No. of parity bits must satisfy this expression 2P D + P + 1
For Data Bits = 4 Case-1: Assume P=1 21 4 + 1 + 1 Not correct

Case-1: Assume P=2 22 4 + 2 + 1 Not correct


Case-1: Assume P=3 23 4 + 3 + 1 Correct
Hence, 4 data bits require 3 parity bits. Parity bits are placed at locations that are
powers of binary No. 2 i.e. 20, 21 & 22 (from left side of the message).
Error Detection & Correcting Code:
Hamming Code
Locating Parity Bits: Parity bits, interspersed in the code word along
with data bits, are located at positions 20, 21 and 22 from left of the
message block and are as shown below:
P1 P2 D3 P4 D5 D6 D7 Where D bits are data bits and P
Setting Values of Parity bits: Parity bits calculated in following
manner:-
P1 : set to 0 or 1 to create even parity for bits 1, 3, 5 & 7 (P1 D3 D5 D7)
P2 : set to 0 or 1 to create even parity for bits 2, 3, 6 & 7 (P2 D3 D6 D7)
P4 : set to 0 or 1 to create even parity for bits 4, 5, 6 & 7 (P4 D5 D6 D7)
Error Detection at Receiver: Received hamming code
(P1P2D3P4D5D6D7) is decoded to detect and correct any error. Bits 1,3,5,7,
bits 2,3,6,7 and bits 4,5,6,7 are all checked for even parity.
If there is an error, location of error bit can be found by forming a 3-bit
binary number c3c2c1 where c3= XORing of bits 4, 5, 6 & 7
c2= XORing of bits 2, 3, 6 & 7
c1= XORing of bits 1, 3, 5 & 7
Error Detection & Correcting Code
Hamming Code
Example: Received 7-bit Hamming Code 1 1 1 1 0 0 1
P1 P2 D3 P4 D5 D6 D7
Step-1: Analyze bits 1, 3, 5, 7 (1 1 0 1) of which bit-1 is parity bit P1.
Error is present as number of 1's is odd.
Derive c1 by XORing (1 1 0 1) = 1
Step-2: Analyze bits 2, 3, 6, 7 (1 1 0 1) of which bit-1 is parity bit P2.
Error is present as number of 1's is odd.
Derive c2 by XORing (1 1 0 1) = 1
Step-3: Analyze bits 4, 5, 6, 7 (1 0 0 1) of which bit-1 is parity bit P4.
Error is not present as number of 1's is even.
Derive c3 by XORing (1 0 0 1) = 0
Step-4: Locating Bit Error Position:
Error word is c3c2c1 = 011
Decimal equivalent is 3. Thus bit 3 (from left) is in error.
Step-5: Locating Error Bit & Correcting: By taking complement of bit 3,
we get the corrected code, which is
1 1 0 1 0 0 1
P1 P2 D3 P4 D5 D6 D7
Error Detection & Correcting Code
Hamming Code
Example:
Encode data bits 1101 in to the 7-bit even parity Hamming code.
7-bit Hamming Code Pattern is ? ? 1 ? 1 0 1
P1 P2 D3 P4 D5 D6 D7

Bits 1,3,5,7 (i.e. P1,1,1,1) for Parity to be even P1 = 1


Bits 2,3,6,7 (i.e. P2,1,0,1) for Parity to be even P2 = 0
Bits 4,5,6,7 (i.e. P4,1,0,1) for Parity to be even P4 = 0

Final Code:
7-bit Hamming Code Pattern is 1 0 1 0 1 0 1
P1 P2 D3 P4 D5 D6 D7
Error Detection & Correcting Code
Hamming Code
Example: A 7-bit hamming code sequence 1001001 0111001 1110110
0011011 is received through a noisy channel. Decode the message
assuming a single bit error.
Since the received sequence is coded using 7-bit hamming Code, the
received bit stream of 28 bits is divided in 4 groups as shown below:-
1001001 0111001 1110110 0011011
Analyze 1st Group 1001001 (Even Parity Considered)
Bits 1,3,5,7 (1001) no error c1 = 0
Bits 2,3,5,7 (0001) error c2 = 1
Bits 4,5,6,7 (1001) no error c3 = 0
Error word is c3c2c1 = 010 = decimal 2
Corrected bit pattern is obtained by complementing 2nd bit 1101001
Analyze 2nd Group 0111001 (Even Parity Considered)
Bits 1,3,5,7 (0101) no error c1 = 0
Bits 2,3,5,7 (1101) error c2 = 1
Bits 4,5,6,7 (1001) no error c3 = 0
Error word is c3c2c1 = 010 = decimal 2
Corrected bit pattern is obtained by complementing 2nd bit 0011001
Analyze 3rd Group 1110110 (Even Parity Considered)
Bits 1,3,5,7 (1110) error c1 = 1
Bits 2,3,5,7 (1110) error c2 = 1
Bits 4,5,6,7 (0110) no error c3 = 0
Error word is c3c2c1 = 011 = decimal 3
Corrected bit pattern is obtained by complementing 3rd bit 1100110
Analyze 4th Group 0011011 (Even Parity Considered)
Bits 1,3,5,7 (0101) no error c1 = 0
Bits 2,3,5,7 (0111) error c2 = 1
Bits 4,5,6,7 (1011) error c3 = 1
Error word is c3c2c1 = 110 = decimal 6
Corrected bit pattern is obtained by complementing 6th bit 0011001

Hence the corrected message bit pattern is


1101001 0011001 1100110 0011001
15-Bit Hamming Code
Bit Positions 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

Bit Designation P1 P2 P4 P8

Data Bits D3 D5 D6 D7 D9 D1 D D1 D1 D1 D
11 15
0 2 3 4

Parity Bits are P1, P2, P4, P8


P1 will be set for bits located at bit positions 1, 3, 5, 7, 9, 11, 13, 15
P2 will be set for bits located at bit positions 2, 3, 6, 7, 10, 11, 14, 15
P4 will be set for bits located at bit positions 4, 5, 6, 7,12, 13,14,15
P8 will be set for bits located at bit positions 8, 9, 10, 11, 12, 13, 14, 15
No. of Data Bits : 11
Verifying Number of Parity bits p =4
24 11 + 4 + 1 16 = 16
This type of code is referred as Hamming Code (15, 11)
Example Hamming Code
Example:Formulate a single error correcting code for 11-bit group 01101110101
Bit Positions 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

Bit Designation P1 P2 P4 P8
Data Bits D3 D5 D6 D7 D9 D1 D D1 D1 D1 D
11 15
0 2 3 4

Parity Bits 1 0 0 1
Data Bits 0 1 1 0 1 1 1 0 1 0 1

P1 will be set for bits located at bit positions 1, 3, 5, 7, 9, 11, 13, 15 = P0101111 = 1
P2 will be set for bits located at bit positions 2, 3, 6, 7, 10, 11,14,15 = P0101101 = 0
P4 will be set for bits located at bit positions 4, 5, 6, 7,12, 13,14,15 = P1100101 = 0
P8 will be set for bits located at bit positions 8, 9,10,11,12,13,14,15 =P1110101 = 1
Example Hamming Code
Example:Test the Hamming code sequence 101001011101011 for any error.
Bit Sequence 1 0 1 0 0 1 0 1 1 1 0 1 0 1 1

Bit Designation P1 P2 P4 P8
Data Bits D3 D5 D6 D7 D9 D1 D D1 D1 D1 D
11 15
0 2 3 4

Check Bits at Positions:


1, 3, 5, 7, 9, 11, 13, 15 = 11001001 = 0 c1
2, 3, 6, 7, 10, 11,14,15 = 01101011 = 1 c2
4, 5, 6, 7,12, 13,14,15 = 00101011 = 0 c3
8, 9,10,11,12,13,14,15 = 11101011 = 0 c4
Error location is indicated by c4c3c2c1 0010 (2)10
Complement the bit No. 2 to get correct bit sequence: 111001011101011
End

Anda mungkin juga menyukai