Chapter 1 & 2
Chapter 1 & 2
Chapter One
Introduction to Digital Logic and
Digital Systems
• Computer organization and architecture
• Basic components of Digital computer
• Logic Gates
• Combinational Circuits
• Flip-Flops
• Sequential Circuits
• Common Digital Components
3/22/2023 1
1.1 Computer Architecture and Organization
What is Computer Architecture?
• It is concerned with the structure and behavior of various
functional modules (HW and SW) of a digital computer as well as
how these modules interact to meet the requirement of the user
• Deals with interface between hardware and software
• It helps us to understand the functionalities of a system. (deals
with high-level design issues)
• Is those attributes visible to the programmer
Describes WHAT the computer does (logical view)
• Examples:
3/22/2023 4
1.2 Basic Components of Computer
• The digital computer is a digital system that performs
various computational tasks.
• Computer is made up of the following HW components:
– A Central Processing Unit
• Arithmetic & Logic Unit
• Control Unit
• Registers
– Memory
• any physical device capable of storing information
temporarily or permanently
– Primary Memory (Usually called RAM)
– Secondary Memory or Mass Storage (Disk drives)
– Input and Output Devices
• allow the computer system to interact with the outside world by
moving data into and out of the system.
3/22/2023 5
Organization of the computer
3/22/2023
Logic Gates
• The 7 basic logic gates includes: AND, OR,
NOT, NAND, NOR, XOR, and XNOR.
1. The AND gate
3/22/2023
Logic Gates
2. The OR gate
3/22/2023
Logic Gates
3. The NOT gate (or inverter)
3/22/2023
Logic Gates
4. The NAND gate
– Is the complement of AND gate
3/22/2023
Logic Gates
5. The NOR gate
– Is the complement of OR gate
3/22/2023
Logic Gates
6. The Exclusive OR gate
C=A’B+AB’
3/22/2023
Logic Gates
7. The Exclusive NOR gate
3/22/2023
1.4 Combinational Circuits
• A combinational circuit is a connected arrangement of logic
gates with a set of inputs and outputs.
• The output is dependent upon combination of input
variable.
• The state of the output at any instant is entirely
determined by the states of the inputs at that time.
• Gates are basic combinational circuits themselves, and gates
used to construct more complex combinational functions.
• Combinational circuits are employed in digital computers:
– For generating binary control decisions and
– For providing digital components required for data
processing
3/22/2023
1.4 Combinational Circuits
Combinational logic
where the outputs are determined solely(only)
by the current states of the inputs
Examples
• Adders (Half adder and Full adder)
• Decoders /Encoders
• Multiplexers/ Demultiplexers
• Comparator
Used to implement comparison operators (= , > , < , , )
3/22/2023
Half-Adder
• The most basic digital arithmetic circuit.
• Performs the addition of two binary digits.
• The input variables of a half-adder are called the augends
• The output variables of a half-adder are called the sum (S) and
the carry (C).
half adder
S = x’y+xy’=x ⊕ y
C=xy
3/22/2023
Full-Adder
• A full-adder performs the addition of three binary digits.
• Two half-adders can be combined to form a full-adder.
• Full adder has three inputs and two outputs
• The full adder circuit contains two half adders and an OR gate.
• We have to use k-map to draw logic circuit.
3/22/2023
Decoder
A decoder is a combinational circuit that converts binary
information from the n coded inputs to a maximum of 2n unique
outputs.
Consists of: n Inputs and 2n Outputs (numbered from 0 - 2n - 1)
2 to 4 decoder
3/22/2023
Decoder
• The truth table of 3-to-8 Decoder is shown below:
3/22/2023
Decoder
Logic Diagram for 3-to-8 Decoder
3/22/2023
Multiplexer (MUX)/selector
• It is a combinational circuit that receives input from
one of 2n input data lines and directs it to a single
output line.
• The selection of a particular input data line for a
particular output is determined by a set of selection
inputs.
• A 2n-to-1 multiplexer has 2n input data lines and n
input selection lines.
3/22/2023
3/22/2023
Multiplexers
• Multiplexer 4-data input MUX
– 2n data inputs
– n selection
inputs
– a single output
• Selection input
determines the
input that
should be
connected to
the output
3/22/2023
Multiplexers
• Like encoders, Multiplexers can have an enable
input to control the operation of the unit.
Function Table
4-to-1
multiplexer
3/22/2023
1.5 Flip-Flops
• Are the single bit storage devices
• Flip flops are the smallest temporary storage units
/memory/of a computer
• It is a binary cell capable of storing just one bit of
information (it contains 0 or 1)
• It is a bistable device (i.e. it has two stable states: its
output remains either high (1) or low (0))
• The high state ,i.e, 1 is called Set and the low state, i.e,
0 is called the Reset or clear state
3/22/2023
1.5 Flip-Flops
All flip flops have 2 outputs,
one for the normal value (Q) and other giving a value
opposite to the value stored in the flip flop (Q’)
Flip flops are of many types depending on the
number of inputs they have and how these inputs
affect the outputs.
The most common types of flip flops are:
• SR Flip- Flop
• D Flip- Flop
• JK Flip- Flop
• T Flip- Flop
3/22/2023
1.5 Flip-Flops
• SR (set-reset) Flip- Flop
– Can be constructed using two NOR gates
– There are two inputs (S & R) and two outputs (Q &
Q’)
S R Q
R Q 0 0 hold
0 1 0
1 0 1
S Q' 1 1 disallow
3/22/2023
1.5 Flip-Flops
• SR Flip Flops S R Q0 Q Q’
0 0 0 0 1
Q = Q0
0 0 1 1 0
0 1 0 0 1
R 1
Q=0
10 0 1 1 0 1
Q 1 0 0 1 0
Q=1
1 0 1 1 0
1 1 0 0 0 Q = Q’
1 1 1 0 0 Q = Q’
S Q
1 0
3/22/2023
1.5 Flip-Flops
• SR Flip- Flop
3/22/2023
1.5 Flip-Flops
• Disadvantages of SR flip flop
1. It needs two data inputs a high S to store a 1 bit
and a high R to store 0 bit
• Generation of two signals to drive a flip flop is difficult in
many applications
2. The SR flip flop puts a forbidden(invalid)
condition that both S and R can not be high at the
same time
3/22/2023
1.5 Flip-Flops
D Flip Flop
• The D (Data) flip flop is a slight modification of SR flip flop
• SR flip flop is converted to D flip flop by inserting an
inverter b/n S and R and assigning the symbol D to the
signal input
3/22/2023
1.5 Flip-Flops
JK Flip Flop
• Is a refinement of the SR flip flop in that the
indeterminate condition of the SR type is define
in the JK type
• Inputs J and K behave like inputs S and R to set
and clear the flip flop, respectively
• When inputs J and K are both equal to 1, a clock
transition switches the outputs of the flip flop to
their complement state.
3/22/2023
1.5 Flip-Flops
JK Flip Flop
• Instead of the indeterminate condition, the JK
flip flop has a complement condition
3/22/2023
1.5 Flip-Flops
T Flip Flop
• T(Toggle) flip flop is obtained from a JK flip flop when
inputs J and K are connected to provide a signal input
designated by T. (both J and K inputs are always equal)
• When T=0 (J=K=0) a clock transition does not change the
state of the flip flop
• When T=1 (J=K=1) a clock transition complements the
state of the flip flop
3/22/2023
1.6 Sequential Circuits
• Is an interconnection of flip flops and gates
/combinational circuits/
• the current output of a sequential circuit depends on the
current input and the current state of that circuit.
• Remembering the past is the key feature of
sequential circuits.
3/22/2023
1.6 Sequential Circuits
The two major uses of Sequential circuits in digital
systems are:
As memories to store information while processing
As control circuits to generate control signals which
are essential to select and enable a sequence of data
transfer or data processing steps in the execution of
multistep tasks
Examples
Registers
Counter
3/22/2023
Registers
• An n-bit register has a group of n flip-flops and is capable
of storing any binary information of n bits.
• In addition to flip-flops, registers can have combinational
gates that perform certain data-processing tasks.
– The gates control how and when new information is
transferred into the registers.
• The transfer of new information into a register is referred
to as a loading the register.
• If the loading occurs simultaneously at a common clock
pulse transition, we say that the load is done in parallel.
3/22/2023
Registers
• The load input in a register determines the action to be
taken with each clock pulse.
• When the load input is 1, the data from the input lines is
transferred into the register's flip-flops.
• When the load input is 0, the data inputs are inhibited and
the flip-flop maintains its present state.
• 4 bit register
3/22/2023
1.7. Integrated Circuits (IC)
• Digital circuits are constructed with integrated circuits
• The various gates are interconnected inside the chip to form
the required IC
• An IC is a piece (also called a chip) of silicon on which
multiple gates or transistors have been embedded
• These silicon pieces are mounted on a plastic or ceramic
package with pins along the edges that can be soldered onto
circuit boards or inserted into appropriate sockets
3/22/2023
Chapter Two:
Data Representation
• Data representation refers to the form in which data is
stored, processed, and transmitted
• In computers instructions and data are stored in binary
number system consists of 0 and 1.
• The computer is required to store the following types of
data:
1. Numbers used in arithmetic computations
2. Alphabets used in symbolic instructions
3. Special Characters and symbols
Computers internally store all data in binary form, i.e,
as strings of 0’s and 1’s.
3/22/2023
Data Representation
• Since binary numbers are awful to see and work
with, octal and hexadecimal numbers are most
widely used to compress long string of binary data.
i.e,
– It is difficult for a human to work with long strings
of 0’s and 1’s
– Octal and Hexadecimal are ways to group bits
together
3/22/2023
Data Representation
• BIT for Binary Digit -- each 0 or 1 in the binary system
– Single bit is not overly useful
• Bits commonly stored and manipulated in groups
• BYTE – a group of bits (8 bits = 1 byte)
– Each byte represents one character of data
• Numbers, letters, special characters (%, $, # etc.)
• Letter, numbers and symbols are the form we use to
represent information.
• WORD – the number of bits that can be processed at one time by
the central processing unit of the computer. (4 bytes = 1 word (in
many systems)
– Early computers – Apple II – 8 bit Words,
– Modern machines – can process up to 64 bits/word
3/22/2023
Common Number Systems:
The base of number system represents the number of
digits that are used in the system.
The digits always begin with 0 and continue through one
less than the base
System Base Symbols
Decimal 10 0, 1, … 9
Binary 2 0, 1
Octal 8 0, 1, … 7
Hexa- 16 0, 1, … 9,
decimal A, B, … F
3/22/2023
Decimal Binary Octal Hexa
0 0 0 0
1 1 1 1
2 10 2 2
3 11 3 3
4 100 4 4
5 101 5 5
6 110 6 6
7 111 7 7
8 1000 10 8
9 1001 11 9
10 1010 12 A
11 1011 13 B
12 1100 14 C
13 1101 15 D
14 1110 16 E
15 1111 17 F
16 10000 20 10
3/22/2023
Conversion Among Bases
• The possibilities:
Decimal Octal
Binary Hexadecimal
3/22/2023
Base Conversion
Converting a decimal number into binary
(decimal binary)
Divide the decimal number by 2 and take its remainder
The process is repeated until it produces the result of 0
The binary number is obtained by taking the remainder
from the bottom to the top
3/22/2023
Example: Decimal Binary
= 1101012 (6 bits)
= 001101012 (8 bits)
(note: bit = binary digit)
3/22/2023
0.8110 binary???
0.1100112
0.8110 => 0.81 x 2 = 1.62
0.62 x 2 = 1.24
0.24 x 2 = 0.48
0.48 x 2 = 0.96
0.96 x 2 = 1.92
0.92 x 2 = 1.84
= 0.1100112 (approximately)
3/22/2023
Converting a binary number into decimal
• Multiply each bit in the binary number with the weight (or
position)
• Add up all the results of the multiplication performed
• The desired decimal number is the total of the multiplication
results performed
Example: Binary Decimal
a)1110012 (6 bits)
(1x25) + (1x24) + (1x23) + (0x22) + (0x21) + (1x20)
= 32 + 16 + 8 + 0 + 0 + 1=5710
b)000110102 (8 bits)
= 24 + 23 +21
= 16 + 8 + 2=2610
3/22/2023
Binary to octal
– 3 digits in binary is equivalent to 1
digit in octal
Binary Octal
000 0 In a computer
001 1 system, the
conversion from
010 2
binary to octal or
011 3 otherwise is based
100 4 on the conversion
table above.
101 5
110 6
111 7
3/22/2023
Example: Binary Octal
0 5 7 3 6 4
= 578 = 3648
3/22/2023
Binary − Hexadecimal Conversion
Hex Binary
• Each group of 4 bits represents 0
1
0000
0001
a hexadecimal digit 2 0010
3 0011
4 0100
5 0101
Assume Zeros 6 0110
Example: 7 0111
8 1000
( 1 0 1 1 0 . 0 1 )2 9 1001
A 1010
B 1011
C 1100
D 1101
(1 6 . 4 )16 E 1110
F 1111
68 58 18 28 38
110 101 001 010 011
0000 0000 0011 01012 0000 0000 0101 00112
0 0 3 5 0 0 5 3
= 3516 = 5316
octal binary hexadecimal
3/22/2023
Example: Hexadecimal Binary
1 2 B16 A B D E16
0001 0010 10112 (12 bits) 1010 1011 1101 11102
= 0001001010112 = 10101011110111102
3/22/2023
Signed Integer Representation
3/22/2023
1. Sign-Magnitude
3/22/2023
Examples:
a) +7 = 0 0 0 0 0 1 1 1
(–7 = 100001112)
b) –10 = 1 0 0 0 1 0 1 0
(+10 = 000010102)
3/22/2023
ii) 6 bits binary number
3/22/2023
2. Ones Complement
• In the ones complement representation, positive
numbers are same as that of sign-and-magnitude
Example: +5 = 00000101 (8 bit)
as in sign-magnitude representation
• Sign-magnitude and ones complement use the same
representation above for +5 with 8 bits and all positive
numbers.
• For negative numbers, their representation are obtained
by changing bit 0 → 1 and 1 → 0 from their positive
numbers
3/22/2023
Example:
3/22/2023
Exercise:
Solution: Solution:
So,
(-10)10 = 1101012
3/22/2023
3. Twos complement
• Similar to ones complement, its positive number is same as
sign-magnitude
• Representation of its negative number is obtained by adding 1
to the ones complement of the number.
Example: Convert –5 into twos complement representation
and give the answer in 8 bits.
Solution:
First, obtain +5 representation in 8 bits
000001012
Obtain ones complement for –5 111110102
Add 1 to the ones complement number:
111110102 + 12 = 111110112
–5 in twos complement is 111110112
3/22/2023
Exercise:
(-10) 10 = 1101012 + 12
= 1101102
So, twos compliment
for –10 is 1101102
3/22/2023
10/26/2019 63
Exercise:
Obtain representation for the following
numbers
-13
3/22/2023
Solution:
Obtain representation for the following
numbers
3/22/2023
Floating point representation
3/22/2023
Floating point representation
• Computers use a form of scientific notation for floating-
point representation
• Numbers written in scientific notation have three
components:
3/22/2023
Floating point representation
• Floating numbers “normalized” to utilize
maximum precision possible
– number arranged so that first bit of mantissa
always a non-zero digit.
– For binary, this means the first digit must be a 1
• A fixed place is chosen for the binary point of
the mantissa, say immediately after the first
digit.
3/22/2023
Floating point representation
example
3/22/2023
Floating point representation
Biased Exponent Notation
• The value actually stored for the exponent made always
positive which simplifies implementation of floating
point operations.
• the bias is a fixed positive constant big enough to make
all “biased exponents” positive.
• Two reasons quoted for using baised notation:
– easier to design hardwrae for floating point arthmetic
– Easier to sort numbers as can sort simply on bit patterns.
3/22/2023
Floating point representation
• The IEEE has established a standard for floating-point numbers
• IEEE (Institute of Electrical and Electronics Engineers) Standard
Floating-Point Format (IEEE 754)
Short (32-bit) format
Short exponent range is –127 to 128
but the two extreme values
8 bits, 23 bits for fractional part are reserved for special operands
bias = 127, (plus hidden 1 in integer part)
–126 to 127
(similarly for the long format)
3/22/2023
Floating point representation
3/22/2023
Floating point representation
3/22/2023
Floating point representation
Exercises:
1. Express the decimal number -3.75 as a floating point
number using IEEE single precision (32 bit format).
2. Represent 10101010.010101 in the floating point
representation,
Assume we use the following figure to represent floating
point number in a 32 bit system: (Exponent Bias=2n-1-1 for
an n bit exponent)
3/22/2023
Floating point representation
3/22/2023