Sie sind auf Seite 1von 108

Digital Logic Design (3+1)

Course Objectives
To familiarize the students with basic concepts and procedures used in the design of
digital circuits.
Text Book
Digital Design (Fourth Edition), by M. Morris Mano and Michael D. Ciletti
Reference
Digital Design (Fifth Edition), by M. Morris Mano and Michael D. Ciletti
Digital Fundamentals (Tenth Edition), by Floyd
Logic and Computer Design Fundamentals (Fourth Edition), by M. Morris Mano and
Charles R. Kime
Fundamentals of Logic Design (Fifth Edition), by Charles H. Roth, Jr
Digital Systems: Principles and Applications(Tenth Edition), by Tocci Widmer
Contemporary Logic Design (Second Edition), Randy H. Katz
Verilog HDL: A Guide to Digital Design and Synthesis(Second Edition), by Samir Palnitkar
Course contents
Chapters 1-6 of Text Book
Chapter 1
Binary Systems
Digital Systems
Binary Numbers
Number Base Conversion
Octal and Hexadecimal Number
Complements
Signed Binary Numbers
Binary Codes
Binary Storage and Registers
Binary Logic and Logic Gates
Timing Diagrams
Analog and Digital Systems
Real world is analog but digital circuits are found in an astonishingly
wide range of electronic systems.
Analog systems process information that varies continuously .
Examples of analog represented variables are:
a mercury thermometer
needle speedometer of cars
sine wave voltages indicated on a galvanometer
audio amplifier
simple light dimmer switch
Digital systems process discrete information. Discrete means distinct
or separated as opposed to continuous or connected. The examples
are:
telephone switching exchanges
Speedometer of cars with numerical readout
electronic calculators
ten position switch
digital computers
Analog and Digital Systems

Which of the systems are analog?

an audio public address system

a CD player
Digital Systems
Digital Systems have such a prominent role in everyday life that we refer to
the present technological period as the digital age.
Digital systems manipulate discrete elements of information and have wide
applications.
Digital systems are used in communication, business transactions,
traffic control, space guidance, medical treatment, weather monitoring,
the Internet, and many other commercial, industrial, and scientific
enterprises.
We have digital telephones, digital television, digital versatile discs,
digital cameras, and digital computers.
The discrete elements of information are represented in a digital system by
physical quantities called signals i.e voltage and current.
The signals in present-day electronic digital systems use just two discrete
values and are therefore said to be binary. A binary digit, called a bit, has
two values: 0 and 1.
Why binary?
reliability: a transistor circuit is either ON or OFF (two stable states)
Digital Computer

The digital computer is one of the most well known


digital systems.
The digital computer consists of the following
components:
Memory unit
Central processing unit
Input and output units
The digital computer can perform both arithmetic and
logical operations.
A digital computer

Inputs: Keyboard, mouse, modem, Outputs: CRT, LCD, modem,


speakers
microphone

- stored program
- control unit
- arithmetic computations and logical operations
Digital Systems
Digital Systems represent systems that understand,
represent and manipulate discrete elements.
A discrete element is any set that has a finite number of elements, for
example 10 decimal digits, 26 letters of the alphabet, etc.
Discrete elements are represented by signals, such as
electrical signals (voltages and currents)
The signals in most electronic digital systems use two
discrete values, termed binary.
Digital Systems takes a set of discrete information
inputs and discrete internal information (system state)
and generates a set of discrete information outputs.
Digital Systems

Discrete Discrete
Inputs Information
Processing
System Discrete
Outputs

System State
Signals
A collection of information variables mapped to some
physical quantity.
For digital systems, the quantities take on discrete
values. Two level, or binary values are the most
prevalent values in digital systems.
The binary values are represented abstractly by digits
0 and 1.
other physical signals represented by 1 and 0?
CPU Voltage
Disk Magnetic Field Direction
CD Surface Pits/Light
Dynamic RAM Electrical Charge
Why Digital Components?
Why do we choose to use digital components?
The main reason for using digital components is that they can
easily be programmed, allowing a single hardware unit to be
used for many different purposes.
Advances in circuit technology decrease the price of
technology dramatically.
Digital integrated circuits can perform at speeds of hundreds
of millions of operations per second.
Error-checking and correction can be used to ensure the
reliability of the machine.
Binary Digits
A binary digit, called a bit, is Decimal Binary Code
represented by one of two values: 0 0 0000
or 1. 1 0001
Discrete elements can be represented by 2 0010
groups of bits called binary codes. For
example the decimal digits 0 to 9 are 3 0011
represented as follows: 4 0100
5 0101
6 0110
7 0111
8 1000
9 1001
Different Bases
In order to represent numbers of different bases, we
surround a number in parenthesis and then place a
subscript with the base of the number.
A decimal number (9233)10
A binary number (11011)2
A base 5 number (3024)5
Decimal number digits are 0 through 9
Binary number digits are 0 through 1
Base (radix) r number digits are 0 through r - 1
Commonly Used Bases
Name Radix Digits (0 through r-1)
Binary 2 0,1
Octal 8 0,1,2,3,4,5,6,7
Decimal 10 0,1,2,3,4,5,6,7,8,9
Hexadecimal 16 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F
Decimal Numbers
A decimal number such as 5723 represents a quantity
equal to:
5 thousands
7 hundreds
2 tens
3 ones
Or, it can be written as:
5 X 103 + 7 X102 + 2 * 101 + 3 * 100
The 5, 7, 2, and 3 represent coefficients.
The decimal number system is said to be of base or
radix 10 because it uses the 10 digits (0..9) and the
coefficients are multiplied by powers of 10.
Binary Numbers
The binary system contains only two values in the
allowed coefficients (0 and 1).
The binary system uses powers of 2 as the
multipliers for the coefficients.
For example, we can represent the binary number
10111.01 as:
1 X 24 + 0 X 23 + 1 X 22 + 1 X 21 + 1 X 20 + 0 X 2-1 + 1 X 2-2 = 23.25
Understanding Binary Numbers
Binary numbers are made of binary digits (bits):
0 and 1
How many items does an binary number represent?
(1011)2 = 1x23 + 0x22 + 1x21 + 1x20 = (11)10
What about fractions?
(110.10)2 = 1x22 + 1x21 + 0x20 + 1x2-1 + 0x2-2
Groups of eight bits are called a byte
(11001001) 2
Groups of four bits are called a nibble.
(1101) 2
Understanding Binary Numbers (Contd..)
MSB most significant bit MSB LSB
1011001010011100
LSB least significant bit 15 0
Bit numbering

Each digit (bit) is either 1 or 0 1 1 1 1 1 1 1 1


Each bit represents a power of 2 27 26 25 24 23 22 21 20
Why Use Binary Numbers?
Easy to represent 0 and 1 using
electrical values.
Possible to tolerate noise.
Easy to transmit data
Easy to build binary circuits.

AND Gate

1
0
0
Powers of Two
Important powers of 2

210 is referred to as Kilo, called "K"

220 is referred to as Mega, called "M"

230 is referred to as Giga, called "G"


Octal Numbers

The octal number system is a base-8 system that


contains the coefficient values of 0 to 7.
The octal system uses powers of 8 as the multipliers
for the coefficients.
For example, we can represent the octal number
72032 as:
7 X 84 + 2 X 83 + 0 X 82 + 3 X 81 + 2 X 80 = (29722)10
Hexadecimal Numbers

The hexadecimal number system is a base-16 system


that contains the coefficient values of 0 to 9 and A to
F. The letters A through F represent the coefficient
values of 10, 11, 12, 13, 14, and 15, respectively.
The hexadecimal system uses powers of 16 as the
multipliers for the coefficients.
For example, we can represent the hexadecimal
number C34D as:
12 X 163 + 3 X 162 + 4 X 161 + 13 X 160 = (49997)10
Number Examples
Conversion between bases

To convert from one base to other:


Convert the integer portion
Convert the fraction portion
Join the two with radix point Octal (base 8)

Binary (base 2) Decimal (base 10)

Hexadecimal
(base16)
r-Decimal Conversion

Conversion of a number in base r to decimal is done


by expanding the number in a power series and
adding all the terms.
For example, (C34D)16 is converted to decimal:
12 X 163 + 3 X 162 + 4 X 161 + 13 X 160 = (49997)10
(11010.11)2 is converted to decimal:
1 X 24 + 1 X 23 + 0 X 22 + 1 X 21 + 0 X 20 + 1 X 2-1 + 1 X 2-2 = 26.75

In general (Number)r = i n 1
i 0
ai r
i
j 1
a
j m j
r j

(Integer Portion) + (Fraction Portion)
Decimal-r Conversion
If a decimal number has a radix point, it is necessary
to separate the number into an integer part and a
fraction part.
The conversion of a decimal integer into a number in
base-r is done by dividing the number and all
successive quotients by r and accumulating the
remainders in reverse order of computation.
For example, to convert decimal 13 to binary:
Integer Remainder Coefficient
Quotient
13/2 = 6 + a0 = 1
6/2 = 3 + 0 a1 = 0
3/2 = 1 + a2 = 1
1/2 = 0 + a3 = 1

Answer (13)10 = (a3 a2 a1 a0)2 = (1101)2


Example

Convert (37)10 to binary

(37)10 = 100101
Decimal-r Conversion (converting fraction)

To convert the fraction portion repeatedly multiply the


fraction by the radix and save the integer digits that
result. The process continued until the fraction
becomes 0 or the number of digits have sufficient
accuracy. The new radix fraction digits are the integer
digits in computed order.
For example convert fraction (0.6875)10 to base 2
0.6875 * 2 = 1.3750 integer = 1
0.3750 * 2 = 0.7500 integer = 0
0.7500 * 2 = 1.5000 integer = 1
0.5000 * 2 = 1.0000 integer = 1

Answer = (0.1011)2
Example

When converting fractions, we must use multiplication


rather than division. The new radix fraction digits are
the integer digits in computed order.
Example:

Convert 0.8125 decimal to


binary.
To convert the decimal 0.8125
to binary, we multiply by the
radix 2.
(0.1101)2
Decimal to Octal Conversion

In converting decimal to octal we must divide by 8.


Converting Fractions (Decimal to Octal)

Decimal to Octal fraction conversion takes the same


approach but it multiplies by the base 8.
Converting Decimal to Hexadecimal

The conversion of a decimal integer into hexadecimal


is done by dividing the number and all successive
quotients by 16 and accumulating the remainders in
reverse order of computation.

(422)10 = (1A6)16
Binary, Octal and Hexadecimal
Conversions between binary, octal and hexadecimal
have an easier conversion method.
Each octal digit represents 3 binary digits.
Each hexadecimal digit represents 4 binary digits.
Binary to Octal and back

Binary to Octal:
Group the binary digits into three bit groups starting at the radix
point and going both ways, padding with zeros as needed (at the
ends).
Convert each group of three bits to an equivalent octal digit.
Octal to Binary:
It is done by reversing the preceding procedure
Restate the octal as three binary digits
Start at the radix point and go both ways, padding with zeros as
needed.
Examples

Convert (10110001101011.11110000011)2 to Octal


= 010 110 001 101 011 . 111 100 000 110
= 2 6 1 5 3 . 7 4 0 6
= (26153.7406)8
Convert (673.124)8 to binary
= 110 111 011 . 001 010 100
= (110111011.001010100)2
Convert (11010100011011) 2
to Octal
Binary to Hexadecimal and back

Binary to Hexadecimal:
Group the binary digits into four bit groups starting at the radix point
and going both ways, padding with zeros as needed (at the ends)
Convert each group of four bits to an equivalent hexadecimal digit
Hexadecimal to Binary:
It is done by reversing the preceding procedure
Restate the hexadecimal as four binary digits
Start at the radix point and go both ways, padding with zeros as
needed
Examples

Convert (10110001101011.11110010)2 to hexadecimal


= 0010 1100 0110 1011 . 1111 0010
= 2 C 6 B . F 2
= (2C6B.F2)16
Convert (306.D)16 to binary
= 0011 0000 0110. 1101
= (001100000110.1101)2
Convert (11010100011011) 2
to hexadecimal
Base-r Arithmetic

Arithmetic operations with numbers in base r follow


the same rules as for decimal numbers.
When a base other than 10 is used, one must
remember to use only the r-allowable digits.
The following are some examples:
Arithmetic Rules

The sum of two digits are calculated as expected but


the digits of the sum can only be from the r-allowable
coefficients.
Any carry in a sum is passed to the next significant
digits to be summed.
In subtraction the rules are the same but a borrow
adds r (where r is the base) to the minuend digit.
Binary Addition
Given two binary digits (X,Y), a carry in (Z) we get
the following sum (S) and carry (C):
Carry in (Z) of 0: Z 0 0 0 0
X 0 0 1 1
+Y +0 +1 +0 +1
CS 00 01 01 10

Carry in (Z) of 1: Z 1 1 1 1
X 0 0 1 1
+Y +0 +1 +0 +1
CS 01 10 10 11
Binary Addition Examples
carry: 1

0 0 0 0 0 1 0 0 (4)

+ 0 0 0 0 0 1 1 1 (7)

0 0 0 0 1 0 1 1 (11)
bit position: 7 6 5 4 3 2 1 0

1 1 1 1 1
1 carries
1
1 1 1 0 1
+ 1 0 1 1 1
---------------------
1 0 1 0 1 0 0
Binary Subtraction

Subtraction Table
0-0=0
0 - 1 = 1 and borrow 1
1-0=1
1-1=0
The borrow process works:
Decimal subtraction:
1 x 10n = 10 x 10n-1
Binary subtraction:
1 x 2n = 2 x 2n-1
Binary Subtraction Example

1 10 borrows
0 10 10 0 0 10

1 0 0 1 1 0 1
- 1 0 1 1 1
------------------------
1 1 0 1 1 0
Binary Multiplication and Division

Multiplication table 1
0 1 1 1
0x0=0 X 1 0 1 0
-----------------------
0x1=0 0 0 0 0 0
1x0=0 1 0 1 1 1
1x1=1 0 0 0 0 0
1 0 1 1 1
-----------------------
1 1 1 0 0 1 1 0

Binary division is similar to decimal division


Complements

Complements are used to simplify subtraction


operations. We do subtraction by adding.
A B = A+ (-B)
There are two types:
The radix complement, called the rs complement.
The diminished radix complement, called the (r-1)s complement.
Diminished Radix Complement (DRC)

Given a number N in base r having n digits, the (r-1)s


complement of N is defined as:
(rn 1) N
Decimal numbers are in base-10.
(r-1) = (10-1) = 9.
The 9s complement would be defined as:
(10n 1) N
So, to determine the 9s complement of 52:
(102 1) 52 = 47
Another example is to determine the 9s complement
of 3124:
(104 1) 3124 = 6875
Finding Diminished Radix Complement (DRC)

The DRC or (r-1)s complement of decimal number is


obtained by subtracting each digit from 9
The (r-1)s complement of octal or hexadecimal
number is obtained by subtracting each digit from 7 or
F, respectively
The DRC (1s complement) of a binary number is
obtained by subtracting each digit from 1. It can also
be formed by changing 1s to 0s and 0s to 1s
DRC for Binary Numbers

For binary numbers r = 2 and (r-1) = 1. So, the 1s


complement would be defined as:
(2n 1) N
To determine the 1s complement of 1000101:
(27 1) 1000101 = 0111010
To determine the 1s complement of 11110111101:
(211 1) - 11110111101 = 00001000010

Note that 1s complement can be done by switching


all 0s to 1s and 1s to 0s.
Radix Complement
The rs complement of an n-digit number N in base-r is
defined as:
rn N - for N 0
0 - for N = 0
We may obtain rs complement by adding 1 to (r-1)s
complement. Since rn N = [(rn 1) N]+1
10s complement of 3229 is:
104 3229 = 6771
2s complement of 101101 is:
26 101101 = 010011

Note that to determine 2s complement, leave the least


significant 0s and the first 1 unchanged and then
switch the remaining 1s to 0 and 0s to 1s.
2s Complement

Another method to find 2s complement is


Complement (reverse) each bit
Add 1
Example:

Note that 00000001 + 11111111 = 00000000


Notes on Complements

A couple of notes on complements to keep in mind:


If you are trying to determine the complement of a value that
contains a radix point:
Remove the radix point.
Determine the complement.
Replace the radix point in the same relative position.
The complement of a complement will restore the original number.
Subtraction with Complements

In digital computers the use of borrows to complete


subtraction is inefficient. Complements are used to
overcome this inefficiency.
The subtraction of two n-digit unsigned numbers M
N in base r can be done as follows:
Add the minuend, M, to the rs complement of the subtrahend, N:
M + (rn N) = M N + rn
If M N, the sum will produce an end carry, rn, which can be
discarded; what is left is the result of M N.
If M N, the sum does not produce an end carry and is equal to rn
(N M), which is the rs complement of (N M). To obtain the
answer in a familiar form, take the rs complement of the sum and
place a negative sign in front.
10s Complement Subtraction

Using 10s complement, subtract 62513 2140

Note that the extra 9 in the 10s complement of N is to fill the


space holder 0.
10 Complement Subtraction

Using 10s complement, subtract 2140 - 62513


2s Complement Subtraction

Using 2s complement, subtract 1001001 - 1000110


2s Complement Subtraction

Using 2s complement, subtract 1000110 - 1001001


Using 1s Complement

You can also use the 1s complement for performing


subtraction.
You can add the minuend M to the (r-1)s complement
of subtrahend N. Then inspect the result
If an end carry occurs add 1
If there is no end carry take (r-1)s complement of the result obtained
and place a negative sign
Note: Remember that 1s complement is 1 less than 2s complement.
This means we must compensate by adding 1 when an end carry
occurs. Removing an end-carry and adding one is called an end-
around carry.
1s Complement Subtraction

Using 1s complement, subtract 1001001 - 1000110


1s Complement Subtraction

Using 1s complement, subtract 1000110 - 1001001


Signed Binary Numbers

In ordinary arithmetic a negative number is indicated


by minus sign and positive number by plus sign. This
is not possible in computers, because of hardware
limitation computers must represent everything with
binary digits. There are two methods to do this:
The signed magnitude convention uses the left-most bit to represent
the sign (0 for positive and 1 for negative).
The signed complement system negates a number by taking its
complement.
It could be either, 1s complement representation
or 2s complement representation.
Signed Magnitude Convention sign bit

1 1 1 1 0 1 1 0
Negative

0 0 0 0 1 0 1 0 Positive

The signed magnitude convention uses the left-most bit to


represent the sign (0 for positive and 1 for negative).
The user determines whether the number is signed or unsigned
If the binary number is signed then the leftmost bit represents the sign
and the rest of the bits represents the number
If the binary number is unsigned then the leftmost bit is the most
significant bit of the number
For example:
01001 can be considered as 9 (unsigned binary) or a +9 because the
left most bit is zero.
On the other hand, the string of bits 11001 represents binary
equivalent of 25 when considered as an unsigned number or as 9
when considered as signed number
Signed Complement System

The signed Complement System negative number is


indicated by its complement (Complement of positive
number)
Positive numbers always start with 0 (plus), its complement
(representing negative number) will always start with 1
Signed complement system can use either 1s complement or 2s
complement.
For example:
+9 is represented only as 00001001 but 9 can be represented
as:
11110110 Signed 1s complement representation
11110111 Signed 2s complement representation
Number Representations

The following is the representation for +11:


00001011
The following are different methods for representing
-11:
Signed magnitude: 10001011
Signed-1s-complement: 11110100
Signed-2s-complement: 11110101
Signed Binary Numbers
Arithmetic Addition (Signed-Magnitude
System)

The addition of two signed binary numbers in the


signed-magnitude system follows the rules of
ordinary arithmetic
If the signs are the same we add the two magnitudes
and give the sum the common sign
If the signs are different we subtract the smaller
magnitude from the larger and give the result the sign
of the larger magnitude
Arithmetic Addition (Signed 2s Complement
system)

This system doesnt require the comparison of the


signs and the magnitudes (as in signed-magnitude
system), but only addition.
The addition of two signed binary numbers with
negative numbers represented in signed-2s
complement form is obtained from addition of the two
numbers, including their sign bits.
A carry out of the sign-bit position is discarded.
If the sum is negative, it will be in 2s complement
form.
Arithmetic Subtraction

Subtraction can be performed by simply converting


the equation into an addition formula.
Take the 2s complement of the subtrahend (including the sign bit)
and add it to the minuend (including the sign bit)
A carry out of the sign bit position is discarded
Note: Subtraction operation can be changed to an addition operation
if the sign of the subtrahend is changed. This is easily done by
taking its 2s complement
Example Arithmetic (Signed 2s
Complement)
Example

Consider the subtraction (6) (13) = +7


In binary with eight bits the same is written as
(11111010 11110011)
This subtraction is changed to addition by taking 2s
complement of the subtrahend ( 13) to give (+ 13)
In binary this is 11111010 + 00001101 = 100000111
Removing the end carry, we obtain the correct
answer: 00000111(+7)
Binary Codes
Digital systems use discrete elements of information represented
with binary codes (i.e., a pattern of 0s and 1s). The codes
should be in binary because computers have circuits that
represents and manipulate 0s and 1s.
An n-bit binary code is a group of n bits that can represent up to
2n distinct combinations of 1s and 0s.
Each distinct combination represents a single symbol in the
computer.
The bit combination of an n-bit code is determined fro the count in
binary from 0 to 2n-1. Each element must be assigned a unique binary
bit combination, and no two elements can have the same value.
Although the minimum number of bits required to code 2n distinct
quantities is n, there is no maximum number of bits that can be used for
a binary code.
Codes can be categorized as numeric and alphanumeric used for
numbers and transmission of textual data.
BCD Code (8 4 2 1)
The most common representation for binary digits is the binary coded
decimal (BCD) form which is a binary assignment of the decimal
numbers.
This code is the simplest, most intuitive binary code for decimal digits
and uses the same weights as a binary number, but only encodes the
first ten values from 0 to 9 (6 out of 16 possible combinations remains
unassigned ).
A number with k distinct decimal digits will require 4k bits in BCD.
Each digit of a decimal value is converted to its respective binary
representation.
BCD number needs more bits than its equivalent binary value?
Each decimal digit in BCD code can be represented as shown below
Binary Coded Decimal Code (BCD)
BCD Addition
BCD only represents each of the decimal digitals 0 through 9 as a
single 4-bit binary value. BCD is a numeral code used in arithmetic
operations in digital machines. Addition is the most important
operation because the other three operations (subtraction,
multiplication, and division can be accomplished by the use of
addition. Following rules apply:
Add the two BCD numbers, using the rules of binary addition.
If a 4-bit sum is equal to or less than 9, it is a valid BCD number.
If a 4-bit sum is greater than 9, or if a carry out of the 4-bit group is
generated, it is an invalid result. Add 6(0110) to the 4-bit sum in order to
skip the invalid states and return the code to 8421. If a carry results when
6 is added, simply add the carry to the next significant 4-bit group.
Some BCD addition examples are:
Multi-Digit BCD Addition
BCD Arithmetic
BCD arithmetic involving negative numbers uses
the 10s complement for representing the negative
numbers including the sign digit.
0 (0000) represents a positive sign and 9 (1001) represents a
negative sign
As an example, imagine we want to add
(+257) + (-160) = +97 Are these signed?

Note: To obtain 10s complement of a BCD number, we first


take the 9s complement (by subtraction of each digit from 9)
and then add one to least significant digit
Perform subtraction (-257) - (+160) both signed and
unsigned?
Other Decimal Codes
There are various other decimal codes that can be
used:
BCD (8 4 2 1)
2421
Excess-3 code. (adds binary 0011 to the BCD code)
8 4 -2 -1
Gray Code
ASCII Character Code
Error-Detecting Code
Each bit has a "weight" associated with it and you can
compute the decimal value by adding the weights
where a 1 exists in the code-word.
Which of the above codes are self-complementing?
Four Different Binary Codes
Gray Code
The Gray (reflected) code is named after Frank Gray who
patented it for shaft encoders in 1953. It is un-weighted and non-
arithmetic code; that is, there are no specific weights assigned to
the bit positions
Some of the uses of Gray code are:-
Conversion of physical variables like position or voltage that have a
continuous range of values to a digital representation.
A different use of Gray codes appears in low-power CMOS
logic circuits that count up or down.
Gray code is cyclic code i.e any n-bit code can be generated form
n-1 bit code by taking reflection along the mirror and padding the
two halves with 0s and 1s respectively.
The advantage of Gray code over straight binary number
sequence is that only one bit in the code group changes when
going from one number to the next (unit distance code).
Gray Code
This property is important in many applications, such as optical shaft
angle encoders, where error susceptibility increases with the number
of bit changes between adjacent numbers in a sequence.
Optical shaft encoder is a disc attached to rotating shaft to measure its
rotational position. The disc contains areas that are clear for binary 1
and opaque for binary 0. An illumination source is placed on one side
of the disc, and optical sensors, one for each of the bits to be encoded
are placed on the other side of the disc. When a clear region lies
between the source and a sensor, the sensor responds to the light with
a binary 1 output. When opaque region lies between the source and the
sensor, the sensor responds to the dark with a binary 0.
The optical shaft encoder using 3-Bit Gray code for positions 0
through 7 is shown.
Gray Code
Gray Code
Gray Code Vs Binary Code

Compare the number of


bits changing when
going from one number
to the next for a three-bit
Binary and Gray Code:
In Gray code it is
always 1 bit (unit-
distance code).
Can you guess the
applications where this
important property cab
be used in digital
applications?
Gray Code vs Binary Code Cont
Binary to Gray code Conversion: The following rules apply:
The most significant bit (left-most) in the Gray code is the same as the
corresponding MSB in the binary number.
Going from left to right, add each adjacent pair of binary code bits to get
the next Gray code bit and discard carries. Which addition?
For example, the conversion of binary number 10110 to Gray code is as
follows

The Gray code is 11101.


Gray to Binary code Conversion: The following rules apply:
The most significant bit (left-most) in the Binary code is the same as the
corresponding MSB in the Gray code.
Add each Binary code bit generated to the Gray code bit in the next
adjacent position and discard carries.
For example, the conversion of binary number 10110 to Gray code is as
follows

The binary number is 10010.


ASCII Character Code
The American Standard Code for Information Interchange (ASCII)
uses seven bits to code 128 characters.
The ASCII code contains 94 graphic characters that are printable
and 34 nonprinting characters used for various control functions.
The graphic characters consist of the 26 uppercase letters (A
through Z0, the 26 lowercase letters (a through z), the 10
numerals (0 through 9), and 32 special characters, such as %, *,
and $.
The 34 control characters are designated in the ASCII table with
abbreviated names. They are listed again in the table with their
function names. The control characters are used for routing data
and arranging the printed text into a prescribed format.
The following ASCII chart allows you to specify the characters in
decimal representation by concatenating the column headings to the
row headings. For example, the character 5 is represented in binary
as 0110101
ASCII Table
ASCII Table (Contd )
Error-Detecting Code
Error-Detecting uses an eighth bit (added to 7-bit ASCII
character) to indicate parity.
A parity bit is an extra bit that is set to 0 or 1 as needed to make the
total number of 1s either even or odd.
In an odd-parity code, the parity bit is specified so that the total
number of ones is odd.
In an even-parity code, the parity bit is specified so that the total
number of ones is even.
It detects one, three or any odd combination of errors but even
combination of errors is undetected.

P Information Bits
1 1 0 0 0 0 1 1 0 1 0 0 0 0 1 1

Added even parity bit Added odd parity bit
Parity Code Example
Concatenate a parity bit to the ASCII code for the
characters 0, X, and = to produce both odd-parity and
even-parity codes.

Character ASCII Odd-Parity Even-Parity


ASCII ASCII

0 0110000 10110000 00110000

X 1011000 01011000 11011000

= 0111100 10111100 00111100


Binary Storage

Binary storage represents the storage mechanisms for


binary data stored in a computer.
A binary cell is a device that possesses two stable states and it can
store a single state value (0 or 1). It stores single bit of data.
examples: flip-flop circuits, ferrite cores, capacitor
A register is a group of binary cells. n cells allows the register to
store n bits and thus 2n possible states.
The type of information (BCD, ASCII, etc.) stored in a register
has to be agreed upon by the users of the register.

0 0 1 0 1 0 1 1

Binary Cell
Register Transfer

A register transfer operation involves the transfer of


binary information from one set of binary registers
into other set of binary registers.
The capture and storage of information requires:
An input register to store the key inputs from the keyboard
A processor register to store the data when processed by the CPU
A memory register in the memory unit to store the values
Register Transfer

Data input at keyboard


Shifted into place
Stored in memory

NOTE: Data input in ASCII


Binary Information Processing

The actual processing of binary information in a


computer is completed by digital logic circuits which
have been implemented to serve a specific purpose
(i.e. addition).
The registers are accessed (read and write) when they are needed to
complete an operation. For example we need two register sets to
store two values to be added and a register set to store the result of
the sum.
Furthermore, we need three registers in both the memory unit
and in the processor.
Example Binary Information Processing

We need processing
We need storage
We need communication
Binary Logic

Binary logic consists of binary variables and logical


operations.
The variables are designated by letters of the alphabet (A, B, C, x, y,
z, etc.).
There are three basic logical operations:
AND
OR
NOT
Logical Operations

AND is represented by a dot or the absence of an operator.


xy = z or xy = z
Read as x and y is equal to z
Means that z=1 if and only if x=1 and y=1
OR is represented by a plus sign.
x+y = z
Read as x or y is equal to z
Means that z=1 if x=1 or y=1 or both x=1 and y=1
NOT is represented by a prime or an over bar.
x=z or x = z
Read as not x is equal to z
Means that if x=1 then z=0 or if x=0 then z=1
Truth Tables

Since each binary variable consists of value of 0 or 1,


each combination of values for the variables involved
in a binary operation has a specific result value.
A truth table is a method of visualizing all possible
combinations of the input values and the respective
output values that occur due to the operation on the
specified combination.
AND Truth Table

AND
A B A.B
0 0 0
0 1 0
1 0 0
1 1 1
OR Truth Table

OR
A B A+B
0 0 0
0 1 1
1 0 1
1 1 1
NOT Truth Table

NOT
A A
0 1
1 0
Binary Signal

Two separated voltage


levels represents a
binary variable equal to
logic 1 or logic 0
Logic 0 is equal to 0 volt
and logic 1 equal to 4 volt
(with acceptable range as
shown in figure)
Logic Gates

Logic gates are electronic circuits that operate on one or


more input signals to produce an output signal.
The state (high-low, on-off) of electricity on a line represents each of the two
states for binary representation (1 or 0).

Logic Gate Notation


AND Logic Function

Using door Using Switches


Both doors are opened Switches are input and
to pass the light LED is output
Both switches closed (ON)
to give output
OR Logic Function

Using door Using Switches


Any one or both doors are Switches are input and LED
opened to pass the light is output
Any one switch or both
closed to give output
Timing Diagram
Multi-Input Circuits
End of Chapter1
End of Chapter 1

Das könnte Ihnen auch gefallen