dlc pre requisite
TRANSCRIPT
-
7/30/2019 DLC Pre Requisite
1/21
UNIT - I
Numerical Presentation
In science, technology, business, and, in fact, most other fields of endeavor, we
are constantly dealing with quantities. Quantities are measured, monitored,recorded, manipulated arithmetically, observed, or in some other way utilized in
most physical systems. It is important when dealing with various quantities that
we be able to represent their values efficiently and accurately. There are basicallytwo ways of representing the numerical value of quantities: analogand digital.
Analog Representation
In analog representation a quantity is represented by a voltage, current, or meter
movement that is proportional to the value of that quantity. Analog quantities
such as those cited above have an important characteristic: they can vary over acontinuous range of values. Below is a diagram ofanalog voltage vs time:
Digital Representation
In digital representation the quantities are represented not by proportionalquantities but by symbols called digits. As an example, consider the digital watch,
which provides the time of day in the form of decimal digits which represent
hours and minutes (and sometimes seconds). As we know, the time of day
changes continuously, but the digital watch reading does not change continuously;rather, it changes in steps of one per minute (or per second). In other words, this
digital representation of the time of day changes in discrete steps, as compared
with the representation of time provided by an analog watch, where the dialreading changes continuously. Below is a diagram ofdigital voltage vs. time:
-
7/30/2019 DLC Pre Requisite
2/21
The major difference between analog and digital quantities, then, can be simply
stated as follows:
Analog = continuousDigital = discrete (step by step)
Advantages and Limitations of Digital Techniques
Advantages
1. Easier to design. Exact values of voltage or current are not important, only the
range (HIGH or LOW) in which they fall.2. Information storage is easy.
3. Accuracy and precision are greater.
4. Operation can be programmed. Analog systems can also be programmed, but thevariety and complexity of the available operations is severely limited.
5. Digital circuits are less affected by noise. As long as the noise is not large enough
to prevent us from distinguishing a HIGH from a LOW.
6. More digital circuitry can be fabricated on IC chips.
Limitations
There is really only one major drawback when using digital techniques:
The real world is mainly analog.
Most physical quantities are analog in nature, and it is these quantities that areoften the inputs and outputs that are being monitored, operated on, and controlled
by a system.
To take advantage of digital techniques when dealing with analog inputs and
outputs, three steps must be followed:
1. Convert the real-world analog inputs to digital form. (ADC)
2. Process (operate on) the digital information.3. Convert the digital outputs back to real-world analog form. (DAC)
-
7/30/2019 DLC Pre Requisite
3/21
The following diagram shows a temperature control system that requires
analog/digital conversions in order to allow the use of digital processing
techniques.
Number Systems
A number system specifies how values are represented. Human uses DECIMAL
Number System. There are ten digits in Decimal Number System:0,1,2,3,4,5,6,7,8,9
Digital Computers use Binary Numbers, which have only two digits: 0,1
There are other number systems, including: Octal and Hexadecimal
Number System Terminology
In Number System, a value of an n-digit number a n-1a n-2a1a 0 is:N = a n-1 x r
n-1 + a n-2 x rn-2 ++ a 1 x r
1 + a 0 x r0
where a n-1,a n-2,,a1,a 0 are coefficients
r is called the Base or RadixDecimal is Base-10 system, r = 10
Binary is Base-2 system, r = 2
Octal is Base-8 system, r = 8Hexadecimal is Base-16 system, r = 16
Decimal Number System
The decimal system is composed of 10 numerals or symbols. These 10 symbols
are 0, 1, 2, 3, 4, 5, 6, 7, 8, 9; using these symbols as digits of a number, we can
express any quantity. The decimal system, also called the base-10 system becauseit has 10 digits. Values are represented by the digits and their positions in the
number and the type of number system is called Positional Number System
-
7/30/2019 DLC Pre Requisite
4/21
103 102 101 100 10-1 10-2 10-3
=1000 =100 =10 =1 . =0.1 =0.01 =0.001
Most
Significant
Digit
Decimal
point
Least
Significant
Digit
8973 is Eight Thousand Nine Hundred and Seventy Three:
8 = 8000 = 8 x 103 (Thousands Place)
9 = 900 = 9 x 102 (Hundreds Place)7 = 70 = 7 x 101 (Tens Place)
3 = 3 = 3 x 100 (Units Place)
Binary Number System
An n-bit binary number a n-1a n-2a1a 0 has a value:
N = a n-1 x 2n-1 + a n-2 x 2
n-2 ++ a 1 x 21 + a 0 x 2
0
This base-2 system can be used to represent any quantity that can be represented
in decimal or other number system.
23 22 21 20 2-1 2-2 2-3
=8 =4 =2 =1 . =1/2 =1/4 =1/8
Most
Significant Bit
Binary
point
Least
Significant Bite.g. A 4-bit binary number 10112 is:
N = 1 x 23 + 0 x 22 + 1 x 21 + 1 x 20
= 8 + 0 + 2 + 1 = 1110e.g. A 6-bit binary number 1100102 is:
N = 1x25 + 1x24 + 0x23 + 0x22 + 1x21 + 0x20
= 32 + 16 + 0 + 0 + 2 = 5010
The Binary counting sequence is shown in the table:
-
7/30/2019 DLC Pre Requisite
5/21
Representing Binary Quantities
In digital systems the information that is being processed is usually presented in
binary form. Binary quantities can be represented by any device that has only twooperating states or possible conditions. Eg. a switch has only open or closed. We
arbitrarily (as we define them) let an open switch represent binary 0 and a closed
switch represent binary 1. Thus we can represent any binary number by usingseries of switches.
Typical Voltage Assignment
Binary 1: Any voltage between 2V to 5VBinary 0: Any voltage between 0V to 0.8V
Not used: Voltage between 0.8V to 2V, this may cause error in a digital circuit.
-
7/30/2019 DLC Pre Requisite
6/21
We can see another significant difference between digital and analog systems. In
digital systems, the exact value of a voltage is notimportant; eg, a voltage of 3.6V
means the same as a voltage of 4.3V. In analog systems, the exact value of avoltage is important.
Binary to Decimal Number Conversion
Binary numbers can be converted to Decimal numbers by using:N = a n-1 x 2
n-1 + a n-2 x 2n-2 ++ a 1 x 2
1 + a 0 x 20
1 1 0 1 1 2(binary)
24+23+0+21+20= 16+8+0+2+1
= 2710 (decimal)
and
1 0 1 1 0 1 0 1 2(binary)
27+0+25+24+0+22+0+20= 128+0+32+16+0+4+0+1
= 18110 (decimal)
Decimal to Binary Number Conversion
Decimal numbers can be converted to binary numbers by dividing the decimal
number by 2 successively.
This method uses repeated division by 2. Ex. Convert 2510 to binary
25/ 2 = 12+ remainder of1 1 (Least Significant Bit)
12/ 2 = 6 + remainder of 0 0
6 / 2 = 3 + remainder of 0 0
3 / 2 = 1 + remainder of 1 1
1 / 2 = 0 + remainder of1 1 (Most Significant Bit)
Result 2510 = 1 1 0 0 12
The Flow chart for repeated-division method is as follow:
-
7/30/2019 DLC Pre Requisite
7/21
e.g. 16810 = 101010002
Octal Number System
Octal Numbers are base 8Octal has 8 digits: 0, 1, 2, 3, 4, 5, 6, 7
An n-bit octal number a n-1a n-2a1a 0 has a decimal value:
a n-1 x 8n-1 + a n-2 x 8
n-2 ++ a 1 x 81 + a 0 x 8
0
-
7/30/2019 DLC Pre Requisite
8/21
The conversion of octal to decimal can be done with the above equatione.g. 2638 = 2x8
2 + 6x81 + 3x80
= 128 + 48 + 3 = 17910
e.g 24.68 = 2 x (81) + 4 x (80) + 6 x (8-1) = 20.7510
Decimal to Octal Number Conversion
Can be done by successive division of 8
This method uses repeated division by 8.
e.g. Convert 17710 to octal and binary:
177/8 = 22+ remainder of1 1 (Least Significant Bit)
22/ 8 = 2 + remainder of 6 6
2 / 8 = 0 + remainder of2 2 (Most Significant Bit)
Result 17710 = 2618
Convert to Binary = 0101100012
e.g. 93810 = 16528
Hexadecimal Number System
83 82 81 80 8-1 8-2 8-3
=512 =64 =8 =1 . =1/8 =1/64 =1/512
Most
Significant
Digit
Octalpoint
Least
Significant
Digit
-
7/30/2019 DLC Pre Requisite
9/21
Hexadecimal Numbers are base 16
There are 16 digits: 0 to 9, A, B, C, D, E, F
163 162 161 160 16-1 16-2 16-3
=4096 =256 =16 =1 . =1/16 =1/256 =1/4096
Most
Significant
Digit
Hexadec.
point
Least
Significant
Digit
An n-bit hexadecimal number a decimal value:a n-1 x 16
n-1 + a n-2 x 16n-2 ++ a 1 x 16
1 + a 0 x 160
The conversion of hexadecimal to decimal can be done with the above equation
e.g. B5E16 = 11x162
+ 5x161
+ 14x160
= 2816 + 80 + 14 = 291010
Decimal to Hexadecimal Conversion
This method uses repeated division by 16.
e.g. Convert 37810 to hexadecimal and binary:
378/16 = 23+ remainder of10 A (Least Significant Bit)
23/ 16 = 1 + remainder of 7 7
1 / 16 = 0 + remainder of1 1 (Most Significant Bit)
Result 37810 = 17A16
Convert to Binary = 0001 0111 10102
e.g. 279310 = AE916
-
7/30/2019 DLC Pre Requisite
10/21
Conversion between Binary and Octal
Conversion between Binary and Octal is convenientEach Octal digit equals to 3 bits
e.g. 3 6 2 8 - 011 110 010 25 4 1 8 - 101 100 001 2
e.g. 010 101 110 2 - 2 5 6 8111 010 001 2 - 7 2 1 8
Conversion between Binary and Hex
Conversion between Binary and Hexadecimal is also convenient
Each Hexadecimal digit equals to 4 bits
E 2 8 0 16 - 1110 0010 1000 0000 2
F B 1 16 - 1111 1011 0001 2
Conversion among number systems
7318 = 111 011 0012
-
7/30/2019 DLC Pre Requisite
11/21
= 0001 1101 10012= 1 D 9 16= 1x162 + 13x161 + 9x160
= 256 + 208 + 9
= 47310
7318 = 7x82
+ 3x81
+ 1x80
= 448 + 24 + 1
= 47310
Signed Binary Numbers
In ordinary arithmetic, a minus sign - is used to represent negative
numbers,e.g.-38In digital electronic circuits, everything is represented with bits (0, 1).There are
several ways to represent the signed binary numbers with just bits, e.g.:
Signed Magnitude Representation
1s Complement Representation 2s Complement Representation
Signed Magnitude Number System
The most significant bit (MSB) is a sign bitIf the MSB is 0, the number is positive
If the MSB is 1, the number is negative
e.g. 01101 = +1311101 = -13
e.g. 00000 = +0
10000 = -0Disadvantage (a):2 patterns represent 0
(b): Handle sign bit separately
1s Complement Number System
Positive numbers and the corresponding negative numbers complement each other
Complement is inversion (Logic NOT)e.g. 01101 = +13
10010 = -1
e.g. 00000 = +0
11111 = -0Disadvantage (a):2 patterns represent 0
(b): Handle sign bit separately25
2s Complement Number Conversion
To find the 2s complement number for a negative decimal, we can find thebinary of
-
7/30/2019 DLC Pre Requisite
12/21
the positive decimal and then take its 2scomplement.Twos complement is
obtained by adding one to the ones complement
e.g. -9109 = 01001
Invert bits: 10110
Plus 1: 10111 = -910Check: -16 + 0 + 4 + 2 + 1 = -9
Value Range
For 4-bit binary, the range is:
Value Range
For n-bit binary, the range is:
CODES
-
7/30/2019 DLC Pre Requisite
13/21
Group of bits assigned to represent, identify or relate to multivalued items of
information. By assigning each item of information a unique combination of bits the
information is transferred from one form to another. The group of bits may be numbers,alphabets, control functions and special characters.
An n-bit binary code is a group of n bits that assume up to 2 n combinations of 1s
and 0s with each combination representing one element of the set being enclosed.
Types
Weighted codes
Non weighted codes
Self complementing codes
Reflective codesAlphanumeric codes
Error detecting and correcting codes
1.Weighted Codes
Each bit has a positional value of 8,4,2 or 1 in binary codes. Examples are8421, 2421, 3321, 4221, 5211, 5311, 5421, 6311,7421, 7421,
8421
All the above codes are used to represent a given decimal digit into four bitbinary word.
S.No. DecimalNumber
8421 2421 3321 4221 5311 5421 6311 7421 7421
8421
1. 0 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
2. 1 0001 0001 0001 0001 0001 0001 0001 0001 0111 01113. 2 0010 0010 0010 0010 0011 0010 0011 0010 0110 0110
4. 3 0011 0011 0011 0011 0100 0011 0100 0011 0101 0101
5. 4 0100 0100 0101 1000 0101 0100 0101 0100 0100 0100
6. 5 0101 1011 0110 0111 1000 0101 0111 0101 1010 1011
7. 6 0110 1100 0111 1100 1001 0110 1000 0110 1001 1010
8. 7 0111 1101 1101 1101 1010 0111 1001 0111 1000 1001
9. 8 1000 1110 1110 1110 1100 1011 1011 1001 1111 1000
10. 9 1001 1111 1111 1111 1101 1100 1100 1010 1110 1111
2. Non-weighted Codes:
Each bit has no positional value1. Excess-3 code2.Gray code
3.Five bit BCD
3. Self complementing codes (or) Reflective codes
Code for one digit will be the complement of other
-
7/30/2019 DLC Pre Requisite
14/21
1.2421
2.5211
3. Excess-3
4. Sequential Codes
Succeeding number is one more than the previous one
1. 84212. Excess-3
5. Alphanumeric codes
1. ASCII2. EBCDIC
3. Hollerith
6. Error detecting and correcting codes
For reliable transmission and storage of digital data, error detection and correction
is required. Below are a few examples of codes which permit error detection and
error correction after detection
Error Detecting Codes
When data is transmitted from one point to another, like in wireless transmission,
or it is just stored, like in hard disks and memories, there are chances that data
may get corrupted. To detect these data errors, we use special codes, which areerror detection codes.
Parity
In parity codes, every data byte, or nibble (according to how user wants to use it)
is checked if they have even number of ones or even number of zeros. Based on
this information an additional bit is appended to the original data. Thus if weconsider 8-bit data, adding the parity bit will make it 9 bit long.
At the receiver side, once again parity is calculated and matched with the received
parity (bit 9), and if they match, data is ok, otherwise data is corrupt.
There are two types of parity:
Even parity: Checks if there is an even number of ones; if so, parity bit is
zero. When the number of ones is odd then parity bit is set to 1.
Odd Parity: Checks if there is an odd number of ones; if so, parity bit is
zero. When number of ones is even then parity bit is set to 1.
Error-Correcting Codes
Error-correcting codes not only detect errors, but also correct them. This is used
normally in Satellite communication, where turn-around delay is very high as is
the probability of data getting corrupt.
-
7/30/2019 DLC Pre Requisite
15/21
ECC (Error correcting codes) are used also in memories, networking, Hard disk,
CDROM, DVD etc. Normally in networking chips (ASIC), we have 2 Error
detection bits and 1 Error correction bit.
Hamming Code
Hamming code adds a minimum number of bits to the data transmitted in a noisy
channel, to be able to correct every possible one-bit error. It can detect (not
correct) two-bits errors and cannot distinguish between 1-bit and 2-bitsinconsistencies. It can't - in general - detect 3(or more)-bits errors.
The idea is that the failed bit position in an n-bit string (which we'll call X) can be
represented in binary with log2(n) bits, hence we'll try to get it adding just log 2(n)
bits.
First, we set m = n + log2(n) to the encoded string length and we number each bit
position starting from 1 through m. Then we place these additional bits at power-of-two positions, that is 1, 2, 4, 8..., while remaining ones (3, 5, 6, 7...) hold the
bit string in the original order.
Now we set each added bit to the parity of a group of bits. We group bits this
way: we form a group for every parity bit, where the following relation holds:
position(bit) AND position(parity) = position(parity)
(Note that: AND is the bit-wise boolean AND; parity bits are included in the
groups; each bit can belong to one or more groups.)
So bit 1 groups bits 1, 3, 5, 7... while bit 2 groups bits 2, 3, 6, 7, 10... , bit 4
groups bits 4, 5, 6, 7, 12, 13... and so on.
Thus, by definition, X (the failed bit position defined above) is the sum of the
incorrect parity bits positions (0 for no errors).
To understand why it is so, let's call Xn the nth bit of X in binary representation.
Now consider that each parity bit is tied to a bit of X: parity1 -> X 1, parity2 -> X2,
parity4 -> X3, parity8 -> X4 and so on - for programmers: they are the respective
AND masks. By construction, the failed bit makes fail only the parity bits which
correspond to the 1s in X, so each bit of X is 1 if the corresponding parity iswrong and 0 if it is correct.
Note that the longer the string, the higher the throughput n/m and the lower the
probability that no more than one bit fails. So the string to be sent should bebroken into blocks whose length depends on the transmission channel quality (the
cleaner the channel, the bigger the block). Also, unless it's guaranteed that at most
-
7/30/2019 DLC Pre Requisite
16/21
one bit per block fails, a checksum or some other form of data integrity check
should be added.
Alphanumeric Codes
The binary codes that can be used to represent all the letters of the alphabet,numbers and mathematical symbols, punctuation marks, are known as
alphanumeric codes or character codes. These codes enable us to interface the
input-output devices like the keyboard, printers, video displays with the computer.
ASCII Code
ASCII stands for American Standard Code for Information Interchange. It has
become a world standard alphanumeric code for microcomputers and computers.
It is a 7-bit code representing 27 = 128 different characters. These characters
represent 26 upper case letters (A to Z), 26 lowercase letters (a to z), 10 numbers
(0 to 9), 33 special characters and symbols and 33 control characters.
The 7-bit code is divided into two portions, The leftmost 3 bits portion is called
zone bits and the 4-bit portion on the right is called numeric bits.
An 8-bit version of ASCII code is known as USACC-II 8 or ASCII-8. The 8-bitversion can represent a maximum of 256 characters.
EBCDIC Code
EBCDIC stands for Extended Binary Coded Decimal Interchange. It is mainly
used with large computer systems like mainframes. EBCDIC is an 8-bit code andthus accomodates up to 256 characters. An EBCDIC code is divided into two
portions: 4 zone bits (on the left) and 4 numeric bits (on the right).
Hollerith code
Hollerith developed a way of feeding information into digital computers using
punched cards. The code used in this system to represent alphanumericinformation is known as Hollerith code. Punch card has 80 columns and 12 rows.
Each column represents an alphanumeric character with holes in appropriate
rows. A hole is sensed as 1 and absence of hole is sensed as 0 by the circuit in
card reader. The 12 rows are marked starting from top as12,11,0,1,2,3,4,5,6,7,8,9,. Each row is 1-bit information. So, Hollerith code is
a12-bit code. The first 3 rows are zone punch rows and the remaining 9 arenumeric punch rows. The numbers are represented in the column by single punch
whereas alphabets are represented using 2 punches.
Binary Coded Decimal (BCD)
-
7/30/2019 DLC Pre Requisite
17/21
Binary numbers are used by computers and human beings are familiar with
decimals.
To facilitate the easy conversion between binary and decimal, BCD is used.In BCD number system, each decimal digit is represented by 4 bits
Group of 4 binary bits is a nibble. A nibble representing a number greaterthan 9 is invalid BCD
Decimal to BCD Conversion
Binary 1010 to 1111 are not used in BCD
Example 1. Decimal 56 in BCD is 0101 0110
in binary is 00111000
BCD addition Add the given BCD numbers using binary addition
If the sum nibble (group of 4 bits) is equal to or less than 9 (without
carry) then it is valid BCD.
If the sum nibble (group of 4 bits) is greater than 9 (or) if a carry is
generated then it is invalid BCD.
To make the invalid BCD valid add 01102 to the nibble and if a carry is
generated add it to the next higher order BCD digit.
Examples
1. Add 4 and 5
4-> 0100
5-> 0101
---------1001 -> 9 -> valid BCD
---------
2. Add 4 and 8
-
7/30/2019 DLC Pre Requisite
18/21
4-> 0100
8-> 1000
---------1100
---------
1100 is invalid BCD since it is greater than 1001 so add 0110 to 1100and
the result is 1 0010 which is equal to 12.
3. Add 8 and 9
8-> 1000
9-> 1001---------
10001
---------
In the addition carry is generated so the result is invalid BCD. To make it
valid add 0110 to 10001 and the result is 1 0111 which is equal to 17.
Excess-3 (XS3) code
1. Non weighted BCD code
2. Add three to each nibble of BCD code to get the XS3 code.
3. This code helps in performing subtraction operations in the earlier
computers.4. The table below shows the BCD and XS-3 codes for decimal digits 0 to
9
Decimal BCD Excess-3
0 0000 00111 0001 0100
2 0010 0101
3 0011 0110
4 0100 01115 0101 1000
6 0110 1001
7 0111 10108 1000 1011
9 1001 1100
Decimal to XS-3 conversion
(Ex).Convert 436 into XS-3 code
BCD equivalent of 436 is 0100 0011 0110
-
7/30/2019 DLC Pre Requisite
19/21
Add 3 (i.e) 0011 to each group of 4 bits
0100 0011 0110
0011 0011 0011----------------------
0111 0110 1001
----------------------7 6 9 - Xs-3 in decimal
Gray code
It is a minimum change code where only one bit in the code group changes
while going from one step to the next. Binary numbers have more than 1 bits
changing when increasing or decreasing continuouslye.g. 0011 to 0100 (3 to4): 3 bits change.In digital electronic circuits, sometimes it is desired to have
only 1 bit changed In this case, Gray Code can be used In Gray Code, the
adjacent numbers have only 1 bit different
It is also called as unit distance code.
In this code no weight can be attached with each bit position therefore it is
unsuitable for arithmetic operations.
Gray codes are useful in input and output devices and in analog and digital
converters.
Gray to Binary conversion
MSB of the gray code is same as binary number. So write the MSB as it is.
Add the MSB of the output with bit immediately on right in input and record
the sum. If a carry is generated it is ignored.
Continue adding the bits in the output to immediate input bit in right till the
LSB is reached.
The binary equivalent has same number of bits as the gray code.
This can be achieved by using X-OR gate.
ExampleConvert 1011 to binary
-
7/30/2019 DLC Pre Requisite
20/21
Binary to Gray conversion
MSB of the binary is same as MSB of gray code.
Add the MSB of binary with immediate bit to right in binary and that is
the next gray bit. If a carry is generated it is ignored.
Repeat the procedure till the LSB is reached.
Example:
Convert 1011 to gray code
-
7/30/2019 DLC Pre Requisite
21/21