Unit Notes
Unit Notes
COURSE OUTCOMES:
At the end of this course, the students will be able to:
CO1 : Design various combinational digital circuits using logic gates
CO2 : Design sequential circuits and analyze the design procedures
CO3 : State the fundamentals of computer systems and analyze the execution of an
instruction
CO4 : Analyze different types of control design and identify hazards
CO5 : Identify the characteristics of various memory systems and I/O communication
TOTAL: 75 PERIODS
TEXT BOOKS:
1. M. Morris Mano, Michael D. Ciletti, “Digital Design : With an Introduction to the
Verilog HDL, VHDL, and System Verilog”, Sixth Edition, Pearson Education,
2018.
2. David A. Patterson, John L. Hennessy, “Computer Organization and Design, The
Hardware/Software Interface”, Sixth Edition, Morgan Kaufmann/Elsevier, 2020.
REFERENCES:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, Naraig Manjikian, “Computer
Organization andEmbedded Systems”, Sixth Edition, Tata McGraw-Hill, 2012.
2. William Stallings, “Computer Organization and Architecture – Designing for
Performance”, TenthEdition, Pearson Education, 2016.
3. M. Morris Mano, “Digital Logic and Computer Design”, Pearson Education, 2016.
CONTENTS
UNIT-I
COMBINATIONAL LOGIC
1.1 Introduction 1.1
1.2 Analogue Versus Digital 1.2
1.3 Combinational Circuits 1.4
1.4 Implementing Combinational Logic 1.4
1.5 Simplification Techniques 1.5
1.6 Sum-of-Products 1.6
1.7 Products -Of-Sum 1.7
1.8 Karnaugh Map 1.9
1.9 Don’t Care Combinations 1.19
1.10 Analysis and Design Procedures 1.21
1.11 Binary Adder 1.22
1.11.1 Half Adder 1.23
1.11.2 Full-Adder 1.24
1.11.3 Parallel Binary Adder 1.26
1.11.4 Half Subtractor 1.28
1.11.5 Full- Subtractor 1.30
1.12 BCD Adder 1.32
1.13 Magnitude Comparator 1.35
1.13.1 Single-Bit Magnitude Comparator 1.36
1.13.2 4-Bit Magnitude Comparator 1.36
1.14 Multiplexers (Data Selectors) 1.39
1.14.1 Basic Four-Input Multiplexer 1.40
1.14.2 Implementation of Boolean Expression Using Multiplexers 1.43
1.14.3 Applications of Multiplexers 1.44
1.15 Demultiplexers (Data Distributors) 1.45
1.15.1 1 To 4 Demultiplexer 1.45
1.16 Decoders 1.46
1.16.1 Basic Binary Decoder 1.47
1.16.2 3-To-8 Decoder 1.47
1.16.3 BCD-To-Seven-Segment Decoder/Driver 1.50
1.16.3.1 Design of BCD-To-Seven –Segment Decoder 1.50
1.16.3.2 Applications of Decoders 1.55
1.17 Encoders 1.56
1.17.1 Octal-To-Binary Encoder 1.56
1.17.2 Decimal-To-BCD Encoder 1.57
UNIT-II
SYNCHRONOUS SEQUENTIAL LOGIC
2.1 Introduction 2.1
2.2 Latches and Flip-Flops 2.4
2.2.1 S-R Latch 2.5
2.2.2 Flip-Flops 2.7
2.2.2.1 sr Flip-Flop - (Set / Reset) 2.8
2.2.2.2 D Flip-Flop - (Delay) 2.13
2.2.2.3 J-K Flip-Flop 2.15
2.2.2.4 Master-Slave J-K Flip-Flop 2.18
2.2.2.5 T Flip- Flop 2.19
2.3 Triggering of Flip – Flops 2.22
2.3.1 Level Triggering in Flip - Flops 2.22
2.3.2 Edge Triggering in Flip – Flops 2.23
2.4 Realisation of One Flip-Flop Using Other Flip- Flops 2.23
2.4.1 Realization of Delay Flip-Flop Using S-R Flip – Flop 2.24
2.5 Counters 2.26
2.5.1 Synchronous Counters 2.26
2.5.1.1 Binary 4-Bit Synchronous Up Counter 2.27
2.5.1.2 Binary 4-Bit Synchronous Down Counter 2.28
2.5.1.3 Ripple (Asynchronous) Counter 2.29
2.5.1.4 Binary Ripple Counter 2.31
2.5.1.5 Up/Down Counters 2.32
2.5.1.6 Modulus of a Counter 2.34
2.6 Designing Counters with Arbitrary Sequences 2.35
2.6.1 Excitation Table of a Flip-Flop 2.36
2.6.2 State Transition Diagram 2.36
2.6.3 Design Procedure 2.37
2.7 Shift Register 2.41
2.7.1 Serial-In Serial-Out Shift Register 2.41
2.7.2 Serial-In Parallel-Out Shift Register 2.42
2.7.3 Parallel-In Serial-Out Shift Register 2.43
2.7.4 Parallel-In Parallel-Out Shift Register 2.43
2.8 Shift Register Counters 2.44
2.8.1 Ring Counter 2.44
2.8.2 Shift Counter 2.45
2.9 Asynchronous Sequential Circuits 2.47
2.9.1 Clocked Sequential Circuits 2.48
2.9.1.1 Moore Model 2.48
2.9.1.2 Mealy Model 2.49
UNIT- III
COMPUTER FUNDAMENTALS
3.1 Functional Units of a Digital Computer: Von Neumann Architecture 3.2
3.2 Operation and Operands of Computer Hardware Instruction 3.5
3.2.1 Basic Operational Concepts 3.5
3.2.2 Basic Operands Concepts 3.7
3.3 Instruction Set Architecture (Isa): Memory Location, Address and 3.9
Operation
3.3.1 Memory Locations and Addresses 3.10
3.4 Instruction and Instruction Sequencing 3.13
3.5 Addressing Modes 3.16
3.6 Encoding of Machine Instruction 3.25
3.7 Interaction Between Assembly and High Level Language 3.29
UNIT-IV
PROCESSOR
4.1 Instruction Execution 4.1
4.1.1 Mipsarchitecture 4.2
4.2 Building a Data Path 4.6
4.3 Designing a Control Unit 4.11
4.3.1 Hardwired Control 4.11
4.3.2 Micro-Programmed Control 4.13
4.4 Pipelining 4.13
4.5 Data Hazards 4.21
4.6 Control Hazards 4.25
UNIT - V
MEMORY AND I/O
5.1 Memory Concepts and Hierarchy 5.1
5.1.2 Memory Hierarchy 5.3
5.2 Memory Management 5.7
5.3 Cache Memories 5.10
5.4 Mapping and Replacement Techniques 5.16
5.5 Virtual Memory 5.20
5.6 DMA 5.23
5.7 I/O 5.25
5.8 Accessing I/O 5.26
5.9 Parallel and Serial Interface 5.27
5.9.1 Serial Interface 5.28
5.9.2 Parallel Interface 5.30
5.9.3 Difference Between Serial and Parallel Communication 5.31
5.9.4 Advantages of Serial Communication Over Parallel 5.33
Communication
5.10 Interrupt I/O 5.33
5.10.1 Interrupt Hardware 5.34
5.10.2 Handling Multiple Devices 5.34
5.10.3 Vectored Interrupts 5.35
5.10.4 Interrupt Nesting 5.35
5.10.5 Exceptions 5.35
5.11 Interconnection Standards: USB, SATA 5.36
5.11.1 USB 5.36
5.11.2 SATA 5.39
1
COMBINATIONAL LOGIC
1.1 INTRODUCTION
❖ Digital electronics is the branch of electronics that deals with the study of digital
signals, and the components that use or create them.
❖ Digital electronics or the digital circuit comprises various components that
perform specific functions.
❖ These components are divided into two categories:
Active components
Passive components
❖ The active components are the transistors and diodes while the passive
components are the capacitors, resistors, inductors, etc.
➢ Logic Gates
❖ Logic gates are the basic components of the digital circuit with one output and
more than one input.
❖ AND, OR and NOT gates are the basic gates while NAND and NOR the universal
gates.
❖ EX-OR and EX-NOR are the special gates.
➢ Advantages of Digital System vs Analog System
❖ The transmission of data in digital systems takes place without degradation due to
noise when compared to an analog system.
1.2 Combinational Logic
❖ The digital system comes with noise-immunity, which makes the storage of data
easier.
❖ Whereas the analog system undergoes wear and tear, which degrades the
information in storage.
❖ The digital system comes with an interface with computers which makes it easy
to control the data.
❖ The system can be kept bug free by updating the software. This feature is not
available in the analog system.
➢ Disadvantages of Digital System
Though the digital system has noise-immunity and better storage it does have
disadvantages too:
❖ The energy consumed by the digital system is more compared to the analog
system. This energy is consumed in calculations and signal processing which
results in the generation of heat.
❖ These systems are expensive.
❖ The digital systems are fragile, that is if one of the digital data is misinterpreted,
the final data will change completely.
❖ Taking care of analog issues in digital systems could be demanding as analog
components are used in designing the digital system.
➢ Applications of Digital Circuits
Digital electronics or digital circuits are an integral part of electronic devices and
here are the uses of digital circuits:
❖ The display of digital watches is designed based on digital circuits.
❖ Rocket science and quantum computing use digital electronics.
❖ The automatic doors work on the principle of digital electronics.
❖ Everyday encounters with traffic lights are based on digital circuits.
❖ For example, the temperature of an oven settable anywhere from 0 to 100 °C may
be measured to be 65 °C or 64.96 °C or 64.958 °C or even 64.9579 °C and so on,
depending upon the accuracy of the measuring instrument.
❖ Similarly, voltage across a certain component in an electronic circuit may be
measured as 6.5 V or 6.49 V or 6.487 V or 6.4869 V.
❖ The underlying concept in this mode of representation is that variation in the
numerical value of the quantity is continuous and could have any of the infinite
theoretically possible values between the two extremes.
❖ The other possible way, referred to as digital, represents the numerical value of
the quantity in steps of discrete values. The numerical values are mostly
represented using binary numbers.
❖ For example, the temperature of the oven may be represented in steps of 1 °C as
64 °C, 65 °C, 66°C and so on. To summarize, while an analogue representation
gives a continuous output, a digital representation produces a discrete output.
❖ Analogue systems contain devices that process or work on various physical
quantities represented in analogue form.
❖ Digital systems contain devices that process the physical quantities represented in
digital form.
❖ Digital techniques and systems have the advantages of being relatively much
easier to design and having higher accuracy, programmability, and noise
immunity, easier storage of data and ease of fabrication in integrated circuit form,
leading to availability of more complex functions in a smaller size.
❖ There all world, however, is analogue. Most physical quantities – position,
velocity, acceleration, force, pressure, temperature and flow rate, for example –
are analogue in nature.
❖ That is why analogue variables representing these quantities need to be digitized
or discretized at the input if we want to benefit from the features and facilities that
come with the use of digital techniques.
❖ In a typical system dealing with analogue inputs and outputs, analogue variables
are digitized at the input with the help of an analogue-to-digital converter block
and reconverted back to analogue form at the output using a digital-to-analogue
converter block.
1.4 Combinational Logic
1.6 SUM-OF-PRODUCTS
❖ A sum-of-products expression contains the sum of different terms, with each term
being either a single literal or a product of more than one literal.
❖ It can be obtained from the truth table directly by considering those input
combinations that produce a logic ‘1‘at the output.
❖ Each such input combination produces a term. Different terms are given by the
product of the corresponding literals.
❖ The sum of all terms gives the expression. For example, the truth table in Table
can be represented by the Boolean expression
𝑌 = 𝐴̅. ̅
𝐵 . 𝐶̅ + 𝐴̅. 𝐵. 𝐶 + 𝐴. 𝐵. ̅𝐶 + 𝐴. ̅
𝐵. 𝐶
❖ A Product term containing all the K variables of the function in either
complemented or uncomplemented form is called a Minterm in other words a
sum-of-products expression is also known as a minterm expression. The Minterms
of a 3-variable function can be represented by m0, m1, m2, m3, m4, m5, m6 and m7
❖ Table truth table of Boolean expression of equation
A B C Y Minterm
0 0 0 1 𝐴̅𝐵̅ 𝐶̅
0 0 1 0 𝐴̅𝐵̅ 𝐶
Digital Principles and System Design 1.7
0 1 0 0 𝐴̅𝐵 𝐶̅
0 1 1 1 𝐴̅𝐵𝐶
1 0 0 0 𝐴𝐵̅ 𝐶̅
1 0 1 1 𝐴𝐵̅ 𝐶
1 1 0 1 𝐴𝐵𝐶̅
1 1 1 0 𝐴𝐵𝐶
❖ The product of all terms gives the expression. For example, the truth table in Table
can be represented by the Boolean expression
𝑌 = ( ̅𝐴 + ̅
𝐵 + 𝐶̅ )(𝐴̅ + 𝐵 + 𝐶)(𝐴 + 𝐵 + ̅𝐶 ) (𝐴 + ̅
𝐵 + 𝐶)
❖ A sum term containing all the K variables of the function in either complemented
or uncomplemented form is called a Maxterm in other words a product of sum
expression is also known as a maxterm expression. The Maxterms of a 3-variable
function can be represented by M0, M1, M 2, M 3, M 4, M 5, M 6 and M 7
❖ Table truth table of Boolean expression of equation
A B C Y Maxterm
0 0 0 1 𝐴+𝐵+𝐶
0 0 1 0 𝐴 + 𝐵 + 𝐶̅
0 1 0 0 𝐴 + 𝐵̅ + 𝐶
0 1 1 1 𝐴 + 𝐵̅ + 𝐶̅
1 0 0 0 𝐴̅ + 𝐵 + 𝐶
1 0 1 1 𝐴̅ + 𝐵 + 𝐶̅
1 1 0 1 𝐴̅ + 𝐵̅ + 𝐶
1 1 1 0 𝐴̅ + 𝐵̅ + 𝐶̅
A B F 0 1
A
0 0 a B
0 1 b 0 a b
1 0 C 1 c d
1 1 d
Fig 1.2 K-Map
❖ In an n-variable K-map, there are 2n cells. Each cell corresponds to one
combination of n variables.
❖ The variables have been marked as A, B, C, D and the binary numbers formed by
them are taken as AB, ABC and ABCD for 2, 3 and 4 variables respectively.
1.10 Combinational Logic
A 0 1 AB 00 01 11 10
B C
0 0 2 0 0 2 6 4
1 1 3 1 1 3 7 5
AB 00 01 11 10
CD
00 0 4 12 8
01 1 5 13 9
11 3 7 15 11
10 2 6 14 10
(c) 4 – variables
Fig 1.3 Karnaugh maps
❖ The 3 and 4 variable K-maps shows that the column and row headings, used in
representing the cells, are cyclic or unit distance code which results in adjacent
cells, differing in just one variable.
❖ The left and right most cells of the 3 variable K-map are adjacent, for example the
cells 0 and 4 are adjacent, and the cells 1 and 5 are adjacent.
Example 1.3:
Consider the following map. The function plotted is: Z = f (A,B) = A + AB
Solution:
Digital Principles and System Design 1.11
Example 1.4:
Consider the expression Z = f(A,B) = + A + B plotted on the K- map
Solution:
❖ The Karnaugh map uses the following rules for the simplification of
expressions by grouping together adjacent cells containing ones
❖ Groups may not include any cell containing a zero
A A
0 1 0 1
B B
0 0
0
1 1 1 1 1
❖ Groups may wrap around the table. The leftmost cell in a row may be grouped with
the rightmost cell and the top cell in a column may be grouped with the bottom
cell.
❖ There should be as few groups as possible, as long as this does not contradict any
of the previous rules.
Digital Principles and System Design 1.13
= ABCD+A𝐵̅ 𝐶̅ 𝐷
̅ +A𝐵̅C (D=𝐷
̅ ) + AB(C+𝐶̅ ) (D+𝐷
̅)
= ABCD+ A𝐵̅ 𝐶̅ 𝐷
̅ +A𝐵̅ 𝐶𝐷+A𝐵̅ 𝐶𝐷
̅ + (ABC+AB𝐶̅ ) (D+𝐷
̅)
= ABCD+ A𝐵̅ 𝐶̅ 𝐷
̅ +A𝐵̅ 𝐶𝐷+A𝐵̅ 𝐶𝐷
̅ +ABCD+ABC𝐷
̅ +AB𝐶̅ D+AB𝐶̅ 𝐷
̅
= ABCD+ A𝐵̅ 𝐶̅ 𝐷
̅ +A𝐵̅ 𝐶𝐷+A𝐵̅ 𝐶𝐷
̅ + ABC𝐷
̅ + AB𝐶̅ D+AB𝐶̅ 𝐷
̅
= ∑ (8,10,11,12,13,14,15)
𝑚
AB 00 01 11 10
CD
00 0 0 1 1
01 0 0 1 0
11 0 0 1 1
10 0 0 1 1
Fig. 1.4
In the K-map in Fig.1.4, there are three quads; the minimized terms for them are
AB, AC and 𝐴𝐷 ̅ and the simplified expression is;
̅
Y= AB+AC+A𝐷
Example 1.6: Simplify the expression Y=∑𝒎(𝟑, 𝟒, 𝟓, 𝟕, 𝟗, 𝟏𝟑, 𝟏𝟒, 𝟏𝟓), using the K-map
method.
Solution:
The K-map foe above function is shown in Fig. 1.5.
AB 00 01 11 10
CD
00 0 1 0 0
01 0 1 1 1
11 1 1 1 0
10 0 0 1 0
Fig. 1.5
In the above K-map, the cells5, 7, 13 and 15 can be grouped to form a quad as
indicated by the dotted lines, In order to group the remaining 1s, four pairs have to be
formed as shown in Fig.1.5.
Digital Principles and System Design 1.15
However, all the four 1s covered by the quad are also covered by the pairs. So,
the quad in the above K-map is redundant. Therefore, the simplified expression will be,
Y= 𝐴̅CD+ABC+A𝐶̅ D+𝐴̅𝐵 𝐶̅
Example 1.7 Simply the expression Y=∑𝑚(7,9,10,11,12,13,14,15), using the K – map
method.
Solution:
The K – map for the above function is shown in Fig.1.6.
AB 00 01 11 10
CD
00 1
0 0 0
01 1
0 0 1
11
0 1 1 1
10
0 0 1 1
Fig. 1.6
In the given K-map, there are three quads and one pair, the corresponding
simplified terms are AB, AD, AC and BCD. Now, the simplified expression is
Y=AB+AD+AC+BCD
Since the quads and pair formed in the above K –map overlap, the expression can
be further simplified using the Boolean algebra as follows:
Y = AB+AD+AC+BCD
= A (B+D+C) + BCD
Example 1.8 Simplify the expression Y=𝑚1 + 𝑚5 + 𝑚10 + 𝑚11 + 𝑚12 + 𝑚13 + 𝑚15
using the K-map method.
Solution:
The K- map for the above expression is shown in fig.1.7.
1.16 Combinational Logic
AB 00 01 11 10
CD
00 0 0 1 0
01 1 1 1 0
11 0 0 1 1
10 0 0 0 1
Fig.1.7
As shown in fig.1.7, the K- map contains four pairs but no quads or octets; the
corresponding simplified expression is given by
Y = 𝐴̅𝐶̅ 𝐷 + 𝐴𝐵𝐶̅ + 𝐴𝐵𝐷 + 𝐴𝐵̅ 𝐶 (1)
It is important to note that the simplified expression obtained from the K-map is
not unique. This can be explained by grouping the pairs in a different manner as shown
in fig.1.8.
From the K-map shown in fig.1.8, the simplified expression can be written as,
Y = 𝐴̅𝐶̅ 𝐷 + 𝐴𝐵𝐶̅ + 𝐴𝐶𝐷 + 𝐴𝐵̅ 𝐶 (2)
In equation (1) and (2), the third term is different due to the different groupings done
in fig.1.8.
Though the simplified expression for any given function is not unique, both the
above expression are logically equivalent.
Two expressions are said to be logically equivalent if and only if both the
expression have the same value for every combination of input variables.
AB 00 01 11 10
CD
00 0 0 1 0
01 1 1 1 0
11 0 0 1 1
10 0 0 0 1
Fig.1.8
Digital Principles and System Design 1.17
AB 00 01 11 10
CD
00 0 0 0 0
01 0 0 0 0
11 1 1
1 1
10 1 0 0 1
Fig. 1.9
In the above K-map, one octet and one quad are produced by combining 0 cells.
The simplified sum term corresponding to the octet is C where as for the quad is
(𝐵̅+D).
Hence, the simplified POS expression for the given function is
Y= C (𝐵̅+D)
1.18 Combinational Logic
Example 1.10 Obtain (a) minimal sum of product and (b) minimal product of sum
expressions for the function given below:
F (A, B, C, D) = ∑𝒎(𝟎, 𝟏, 𝟐, 𝟓, 𝟖, 𝟗, 𝟏𝟎)
Solution:
Cells with 1 are grouped to obtain the minimal sum of products; cells with 0 are
grouped to obtain minimal product of sum as shown in fig. 1.10.
AB 00 01 11
CD
00 1 0 0 1
01 1 1 0 1
11 0 0 0 0
10 1 0 0 1
̅+𝑩
Fig. 1.10 (a) Y = (𝑨 ̅ )(𝑪
̅+𝑫
̅ )(𝑩
̅+𝑫
̅)
AB 00 01 11 10
CD
00 1 0 0 1
01 1 1 0 1
11 0 0 0 0
10 1 0 0 1
̅𝑫
Fig. 1.10 (b) Y = 𝑩 ̅ +𝑨
̅𝑪̅ 𝑫 + 𝑨𝑩
̅𝑪̅
Digital Principles and System Design 1.19
a) To obtain minimal product of sum: Three quads can be formed as shown in Fig.
1.10 (a) with the corresponding sum terms (𝐴̅ + ̅𝐵)
̅̅̅, (𝐶̅ + 𝐷
̅ )𝑎𝑛𝑑 (𝐵̅ + 𝐷). Thus
the minimal product of sum expression for the given function is:
Y = (𝐴̅ + 𝐵̅ )(𝐶̅ + 𝐷
̅ )(𝐵̅ + 𝐷
̅)
b) To obtain minimal sum of products. A quad with four corner 1s and two pairs can
be formed as shown in Fig.1.10.(b) Hence, the minimal SOP expression is:
Y = 𝐵̅ 𝐷
̅ + 𝐴̅𝐶̅ 𝐷 + 𝐴𝐵̅ 𝐶̅
The d in cell 5 is left free since it does not combining the 1s and d s, two equals
can be obtained.
The d in cell 5 is left free since it does not contribute in increasing the size of any
group. Now, the simplified expression in SOP form is
Y = 𝐴̅𝐵̅ +CD
AB 00 01 11 10
CD
00 d 0 0 0
1
01 d 0 0
11 1 1 1 1
10 d 0 0 0
Fig .1.11
Example 1.12 Obtain the minimal SOP expression for the function
Y=∑𝒎(𝟏, 𝟓, 𝟕, 𝟏𝟑, 𝟏𝟒, 𝟏𝟓, 𝟏𝟕, 𝟏𝟖, 𝟐𝟏, 𝟐𝟐, 𝟐𝟓, 𝟐𝟗) + ∑𝒅(𝟔, 𝟗, 𝟏𝟗, 𝟐𝟑, 𝟑𝟎)
Solution
The K-map for the given function is shown in Fig.1.12.
ABC
000 001 011 010 110 111 101 100
DE
00 0 0 0 0 0 0 0 0
01 1 1 1 d 1 1 1 1
11 0 1 1 0 0 0 d d
10 0 d 1 0 0 d 1 1
Fig .1.12
Digital Principles and System Design 1.21
By combining the 1s and d s, one octet and two quads can be obtained as shown
in Fig.1.12. The simplified expression is
̅ 𝐸 + 𝐴̅CD+A𝐵̅ 𝐷
Y=𝐷
1 0 0 0
1 0 1 1
1 1 0 1
1 1 1 1
Now we obtain the simplified Boolean expression for output variable Y using K-
map simplification.
BC
00 01 11 10
A
0 0 0 1 0
0
1 1 1 1
Y = AC + BC + AB
B
Y
C
A
B
A Sum
Inputs Half Adder Output
B Carry s
Inputs Outputs
A B Carry Sum
0 0 0 0
0 1 0 1
1 0 0 1
1 1 1 0
1.24 Combinational Logic
1 0 1 1 1 0
Sum
B
Carry
1.11.2 Full-Adder:
o A full-adder is a combinational circuit that forms the arithmetic sum of three input
bits.
o It consists of three inputs and two outputs.
o Two of the input variables, denoted by A and B, represent the two significant bits
to be added.
Digital Principles and System Design 1.25
o The third input represents the carry from the previous lower significant position.
o The Block diagram and truth table for full-adder is
Block Diagram:
A Sum
Inputs Outputs
B Full Adder
Carry
Cin
Kmap Simplification:
For sum
AB
00 01 11 10
cin
0 1 1
1 1 1
For carry
AB
00 01 11 10
cin
0 1
1 1 1 1
o The addition operation is illustrated in the following example: the 4-bit words to
be added be represented by A3A2A1A0 = 1111 and B3B2B1B0 = 0011.
Significant place 4 3 2 1
Input carry 1 1 1 0
Augend word A: 1 1 1 1
Addend word B: 0 0 1 1
1 0 0 1 0 Sum
Output carry
A3 B3 A2 B2 A1 B1 A0 B0
C4 C3 C3 C2 C2 C1 C1 C0
Cout Gnd
S3 S2 S1 S0
Fig: 1.8 4- bit binary parallel adder
o In a 4-bit parallel binary adder circuit, the input to each full-adder will be A1, B1
and C1, and the outputs will be Si and Ci+1, where i’ varies from 0 to 3.
o Also, the carry output of the lower order stage is connected to the input of the
carry output of the next higher order stage.
o Hence, this type of adder is called ripple carry adder.
o In the least significant stage, A0, B0 and C0 (which is 0) are added resulting in Sum
S0 and carry C1.
o This carry C1 becomes the carry input to the second stage.
o Similarly, in the second stage, A1, B1 and C1 are added resulting in S1 and C2; in
the third stage, A3, B3 and C3 are added resulting in S3 and C4 which is the output
carry.
o Thus, the circuit resulting a sum (S3, S2, S1, S0) and a carry output (Cout).
1.28 Combinational Logic
o Through the parallel binary adder is said to generate output immediately after the
inputs are applied, its speed of operation is limited by the carry propagation delay
through all stages.
o In each full-adder, the carry input has to be generated from the previous full-adder
which has an inherent propagation delay.
o The propagation delay (tp) of a full-adder is the time difference between the
instant at which the inputs (Ai, Bi and Ci ) are applied and the instant at which its
outputs (Si and Ci+1 ) are generated.
o Suppose, in a 4-bit binary adder, the output in LSB stage is generated only after
tp seconds.
o For a 4-bit binary adder, where each full adder has a propagation delay of 50ns,
the output in the fourth stage will be generated only after 4tp=4×50ns=200ns.
o The magnitude of such delay is prohibitive for high-speed computers.
o One of the methods of speeding up this process is look-ahead carry addition which
elimination the ripple-carry delay.
o This method is based on the carry generate and the carry propagate functions of
the full-adder.
1.11.4 Half Subtractor:
o The half-subtractor is a combinational circuit which is used to perform subtraction
of two bits.
o It has two inputs, X (minuend) and Y (Subtrahend) two outputs D (difference) and
Bout (borrow out).
o The truth table shown below gives the relation between input and output variables
for half-subtractor operation.
Block Diagram:
X
D
Inputs Half Outputs
Subtractor
Y Bout
Truth Table:
Inputs Outputs
Minuend X Subtrahend Y Difference D Borrow Bout
0 0 0 0
0 1 1 1
1 0 1 0
1 1 0 0
Kmap Simplification:
For Difference,
X
Y 0 1
0 1
1 1
̅ 𝒀 + 𝑿𝒀
𝑫=𝑿 ̅ =𝑿⊕ 𝒀
For Borrow,
X
Y 0 1
0
1 1
̅𝒀
𝑩𝒐𝒖𝒕 = 𝑿
Logic Diagram:
X D
Full
Inputs Y Outputs
Subtractor
Bin Bout
0 0 0 0 0
0 0 1 1 1
0 1 0 1 1
0 1 1 0 1
1 0 0 1 0
1 0 1 0 0
1 1 0 0 0
1 1 1 1 1
Digital Principles and System Design 1.31
Kmap Simplification:
For Difference,
XY
Bin 00 01 11 10
0 1 1
1 1 1
̅𝒀
𝑫=𝑿 ̅ 𝑩𝒊𝒏 + 𝑿
̅ 𝒀𝑩𝒊𝒏
̅̅̅̅̅ + 𝑿𝒀
̅ 𝑩𝒊𝒏
̅̅̅̅̅ + 𝑿𝒀𝑩𝒊𝒏
For Borrow,
XY
Bin 00 01 11 10
0 1
1 1 1 1
̅𝒀 + 𝑿
𝑩𝒐𝒖𝒕 = 𝑿 ̅ 𝑩𝒊𝒏 + 𝒀𝑩𝒊𝒏
Logic Diagram:
0 0 0 0 0 0 0 0 0 No
Correction
1 0 0 0 1 0 0 0 1
required
2 0 0 1 0 0 0 1 0
3 0 0 1 1 0 0 1 1
4 0 1 0 0 0 1 0 0
5 0 1 0 1 0 1 0 1
6 0 1 1 0 0 1 1 0
7 0 1 1 1 0 1 1 1
8 1 0 0 0 1 0 0 0
9 1 0 0 1 1 0 0 1
10 1 0 1 0 1 0 0 0 0 Correction
required
11 1 0 1 1 1 0 0 0 1
12 1 1 0 0 1 0 0 1 0
Digital Principles and System Design 1.33
13 1 1 0 1 1 0 0 1 1
14 1 1 1 0 1 0 1 0 0
15 1 1 1 1 1 0 1 0 1
16 1 0 0 0 0 1 0 1 1 0
17 1 0 0 0 1 1 0 1 1 1
18 1 0 0 1 0 1 1 0 0 0
19 1 0 0 1 1 1 1 0 0 1
Z3Z2
Z1Z0 00 01 11 10
00 12
01 13
11 15 11
10 14 10
❖ The Boolean expression that can apply the necessary correction is written as
C = K + Z3Z2 + Z3Z1
❖ A correction needs to be applied whenever K = 1.
❖ This takes care of the last four entries.
❖ Also, a correction needs to be applied whenever both Z3 and Z2 are ‘1‘.
❖ This takes care of the next four entries from the bottom, corresponding to a
decimal sum
❖ From the above tabular form 12, 13, 14 and 15. For the remaining two entries
corresponding to a decimal sum equal to 10 and11, a correction is applied for both
Z3 and Z1, being ‘1‘.
❖ While hardware-implementing, 0110 can be added to the binary sum output with
the help of a second four-bit binary adder.
❖ The correction logic as dictated by the Boolean expression should ensure that
(0110) gets added only when the above expression is satisfied.
1.34 Combinational Logic
❖ Otherwise, the sum output of the first binary adder should be passed on as such to
the final output, which can be accomplished by adding (0000) in the second adder.
❖ Figure shows the logic arrangement of a BCD adder capable of adding two BCD
digits with the help of two four-bit binary adders and some additional
combinational logic.
adjacent BCD adder. This BCD adder produces the sum output (S7 S6 S5 S4),
which is the BCD code for the second digit of the sum, and a carry output.
❖ This output carry serves as an input carry for the BCD adder representing the most
significant digits.
❖ The sum outputs (S11 S10 S9 S8) represent the BCD code for the MSD of the
sum.
A0˃B0
A0 Single - bit
magnitude A0=B0
B0 comparator
A0˂B0
A0 𝐴̅0
𝐵̅0 B0
Fig. 1.15
1.36 Combinational Logic
magnitude of two numbers and the next pair of bits (𝐴2 and 𝐵2) must be
examined
(b) If 𝐴3 = 𝐵3 and 𝐴2 >𝐵2, then A > B; if 𝐴3 = 𝐵3 and 𝐴2 <𝐵2, then A < B.
However, if 𝐴3 = 𝐵3 and 𝐴2 =𝐵2, no conclusion can be drawn regarding the
relative magnitudes of the two numbers and the next pair of bits (𝐴1 and𝐵1)
must be examined.
(c) If 𝐴3 = 𝐵3, 𝐴2 = 𝐵2 and 𝐴1 > 𝐵1; then A > B; if 𝐴3 = 𝐵3 , 𝐴2 = 𝐵2 and 𝐴1 <
𝐵1 , then A < B. However, if 𝐴3 = 𝐵3 , 𝐴2 = 𝐵2 and 𝐴1 =𝐵1, no conclusion can
be yet be drawn regarding the relative magnitudes of the two numbers and the
LSBs (𝐴0 and𝐵0) must be examined.
(d) If 𝐴3 = 𝐵3, 𝐴2 = 𝐵2, 𝐴1 = 𝐵1 and 𝐴0 > 𝐵0, then A > B; if 𝐴3 = 𝐵3, 𝐴2 = 𝐵2, 𝐴1
= 𝐵1
And 𝐴0 <𝐵0, then A < B. However, if 𝐴3 =𝐵3 , 𝐴2 =𝐵2, 𝐴1 = 𝐵1 and 𝐴0 =𝐵0,
then A = B.
If the most significant bits are equal (i.e. 𝐴3 = 𝐵3 =0 OR 𝐴3 = 𝐵3 =1), then
𝐸3 = ̅̅̅ 𝐵3+ 𝐴3 𝐵3 = ̅̅̅̅̅̅̅̅̅̅̅
𝐴3 ̅̅̅ 𝐴3 ⊕ 𝐵3
If the next two most significant bits are equal, then
𝐸2 = ̅̅̅
𝐴2 ̅̅̅ ̅̅̅̅̅̅̅̅̅̅̅
𝐵2+ 𝐴2 𝐵2 = 𝐴 2 ⊕ 𝐵2
Multiplexer
n input 1 Output
Signals Signals
m select
Signals
Logic Symbol
D0
Data D1 4 – to – 1 Y Data
Inputs D2 MUX Output
D3
S1 S0
and the AND gate outputs are connected with the inputs of OR gate to generate
the output Y.
o The first half of the min terms are associated with 𝐴̅ and the second half with
A.
❖ Now, using the procedure and the table, the given function can be implemented
using an 8-to-1 multiplexer as shown in Fig.1.21.
1 D0
D1
0 D2
D3 8 × 1 MUX
Y=F
D4
D5
D6
A D7
S2 S1 S0
B
C
D
Demultiple
xer n output
1 Input signal signals
DMUX
❖ From the above truth table , the expression for outputs can be written as
𝑌0 = 𝑆̅1 𝑆̅0 𝐷
𝑌1 = 𝑆̅1 𝑆0 𝐷
𝑌2 = 𝑆1 𝑆̅0 𝐷
𝑌3 = 𝑆1 𝑆0 𝐷
1.46 Combinational Logic
❖ Now, using the above expression a 1-to-4 demultiplexer can be implemented using
four 3- input AND gates and two NOT gates
1.16 DECODERS
❖ A decoder is similar to de-multiplexer but without any data input.
❖ Most digital systems require the decoding of data. Decoding is necessary in
application such as data de-multiplexing, digital display, digital-to-analog
converters and memory addressing.
Digital Principles and System Design 1.47
❖ A decoder is a logic circuit that converts an n-bit binary input code(data) into 2nd
output lines, such that each output line will be activated for one of the possible
combinations of inputs.
❖ In a decoder, the number of output is greater than the number of inputs.
❖ Here, it is important to note that if the number of inputs and outputs are equal in a
digital system then it can be called converters, e.g. BCD to Excess-3 code, Binary
to Gray and Gray to Binary code converters.
Input Outputs
A B C D0 D1 D2 D3 D4 D5 D6 D7
0 0 0 1 0 0 0 0 0 0 0
0 0 1 0 1 0 0 0 0 0 0
0 1 0 0 0 1 0 0 0 0 0
0 1 1 0 0 0 1 0 0 0 0
1 0 0 0 0 0 0 1 0 0 0
1 0 1 0 0 0 0 0 1 0 0
1 1 0 0 0 0 0 0 0 1 0
1 1 1 0 0 0 0 0 0 0 1
❖ Using the above expressions, the circuit of a 3-to-8 decoder can be implemented
using three NOT gates and eight 3-input AND gates as shown in Fig.1.24.
❖ The three inputs, A, B and C are decoded into eight outputs, each output
representing one of the minterms of the 3-input variables.
❖ The three inverters provide the complement of the inputs and each one of the eight
AND gates generate one of the minterms.
❖ The decoder can be used for decoding any 3-bit code to provide eight outputs,
corresponding to eight different combinations of the input code.
❖ This is also called a 1-of-8 decoder, since only one of eight output lines is HIGH
for a particular input combination.
❖ For example, when ABC=010, only the AND gate-2 has HIGH at all its inputs,
and therefore D2 = HIGH.
❖ Similarly, if ABC=110, the AND gate 6 has all its inputs in HIGH state and
thereby D6 =HIGH.
❖ It is also called a binary-to-octal decoder since the inputs represent three-bit binary
numbers and the outputs represent the eight digits in the octal number system.
Digital Principles and System Design 1.49
A BCD to a
b
B 7- Segment c
d
C decoder e
f
D
g
❖ Since the BCD inputs are valid combinations, the other input combination of four
variables corresponding to 10, 11, 12, 13, 14 and 15 can be termed as don’t care
combinations to aid the simplification of logic expressions.
❖ Now, the logic expressions, corresponding to seven-segment can be written from
the truth table shown in Table as follows:
̅ = 𝐴 + 𝐶 + ̅̅̅̅̅̅̅̅̅
From the above K-map, 𝑎 = 𝐴 + 𝐶 + 𝐵𝐷 + 𝐵̅ 𝐷 𝐵⊕𝐷
̅ = 𝐵̅ + ̅̅̅̅̅̅̅̅̅
𝑏 = 𝐵̅ + 𝐶𝐷 + 𝐶̅ 𝐷 𝐶 ⊕𝐷
Digital Principles and System Design 1.53
𝑐 = 𝐵 + 𝐶̅ + 𝐷
𝑑 = 𝐴 + 𝐵̅ 𝐷
̅ + 𝐶𝐷
̅ + 𝐵̅ 𝐶 + 𝐵𝐶̅ 𝐷
̅ + 𝐵̅ (𝐶 + 𝐷
= 𝐴 + 𝐶𝐷 ̅ ) + 𝐵𝐶̅ 𝐷
̅ + 𝐵 ⊕ (𝐶 + 𝐷
= 𝐴 + 𝐶𝐷 ̅)
1.54 Combinational Logic
𝑒 = 𝐵̅ 𝐷
̅ + 𝐶𝐷
̅=𝐷
̅ (𝐵̅ + 𝐶)
𝑓 = 𝐴 + 𝐶̅ 𝐷
̅ + 𝐵𝐶̅ + 𝐵𝐷
̅ = 𝐴 + 𝐶̅ 𝐷
̅ + 𝐵(𝐶̅ + 𝐷
̅)
̅ + 𝐵𝐶̅ + 𝐵̅ 𝐶 = 𝐴 + 𝐶𝐷
𝑔 = 𝐴 + 𝐶𝐷 ̅ + (𝐵 ⊕ 𝐶)
Digital Principles and System Design 1.55
1.17 ENCODERS
❖ An encoder is a digital circuit that performs the inverse operation of a decoder.
❖ Here the opposite of the decoding is called encoding.
❖ An encoder is a combinational logic circuit that converts an active input signal
into a coded output signal.
❖ It has n input only one of which is active at any time and m output lines.
❖ It encodes one of the active input to a binary output with m bits.
❖ In an encoder, the number of outputs is less than the number of inputs.
❖ The blocks diagram of an encoder is shown in Fig.1.28.
m outputs
Encoder
n inputs
❖ The above truth table shows that Y0 (LSB of output code) must be 1 whenever the
input D1 OR D3 OR D5 OR D7 is HIGH. Thus,
𝑌0 = 𝐷1+ 𝐷3 + 𝐷5 + 𝐷7
Similarly, 𝑌1 = 𝐷2 + 𝐷3 + 𝐷6 + 𝐷7
𝑌2 = 𝐷4 + 𝐷5 + 𝐷6 + 𝐷7
❖ Using the above expressions, the octal-to-binary encoder can be implemented
using three 4-input OR gates as shown in Fig. 1.29.
❖ The circuit is designed in such a way that, when D0 is HIGH, the binary code 000
is generated; when D1 is HIGH.
❖ The binary code 001 is generated, and soon.
❖ From the above truth table, it is clear that the output A is HIGH whenever the
input 8 OR 9 is HIGH.
Therefore, A=8+9
❖ The output B is HIGH whenever the input 4 Or 5 OR 6 OR 7 is HIGH.
Therefore, B=4+5+6+7
❖ Similarly, C=2+3+6+7 and D=1+3+5+7+9
❖ Now, the above expression for BCD outputs can be implemented as shown in
Fig.1.30 using four OR gates.
2.1 INTRODUCTION
❖ The analysis and design of combinational digital circuits. It constitutes only a part
of digital systems. The other major aspect of digital system is analysis and design
of sequential circuits
❖ There are many applications in which digital outputs are required to be generated
in accordance with the sequence in which the input signals are received.
❖ This requirement cannot be satisfied using a combinational logic system. These
applications require outputs to be generated that are not only dependent on the
present input conditions but they also depend upon the past history of these inputs.
❖ The past history is provided by feedback from the output back to the input. Fig.2.1
shows the block diagram of sequential circuit.
❖ As shown in the Fig.2.1 memory elements are connected to the combinational
circuit as a feedback path.
❖ The information stored in the memory elements at any given time defines
the present state of the sequential circuit.
❖ The present state and the external inputs determine the outputs and the next state
of the sequential circuit.
❖ Thus we can specify the sequential circuit by a lime sequence of external
inputs, internal states (Present states and next states) and outputs.
2.2 Synchronous Sequential Logic
10 These circuits do not have any These circuits have memory element.
memory element.
11 It is easy to use and handle. It is not easy to use and handle.
❖ The sequential circuits can be classified depending on the timing of their signals:
o Synchronous sequential circuits and Asynchronous sequential circuits.
o In synchronous sequential circuits, signals can affect the memory elements
only at discrete.
o Instants of time. In asynchronous sequential circuits change in input
signals can affect memory element at any instant of time.
o The memory elements used in both circuits are flip-flops which are capable
of storing 1-bit binary information.
Sl. Key Synchronous Sequential Asynchronous Sequential
No. Circuits Circuits
1 Definition Synchronous sequential On other hand Asynchronous
circuits are digital sequential sequential circuits are digital
circuits in which the feedback sequential circuits in which
to the input for next output the feedback to the input for
generation is governed by next output generation is not
clock signals. governed by clock signals.
2 Memory Unit In Synchronous sequential On other hand unclocked flip
circuits, the memory unit flop or time delay is used as
which is being get used for memory element in case of
governance is clocked flip Asynchronous sequential
flop. circuits.
3 State The states of Synchronous On other hand there are
sequential circuits are always chances for the Asynchronous
predictable and thus reliable. circuits to enter into a wrong
state because of the time
difference between the
2.4 Synchronous Sequential Logic
CASE 2: S = 0 and R = 1
❖ In this case, R input of the NOR gate I is at logic 1, hence its output, Q is at logic
0.Both inputs to or gate 2 are now at logic.0. So that its output, Q is at logic 1.
CASE 3: S = 0 and R = 0
❖ Assume, Q = 1 and Q = 0
❖ Let us assume that initially Q = 1 and Q = 0. With Q = 0, neither inputs to NOR
gate I are at logic 0.
❖ So its output, Q is at logic 1, With Q = 1, one did not input of NOR gate 2 is at
logic 1, hence its output, Q is at logic 0.
❖ This shows that when S and R both are low (at logic 0) the output state does not
change.
❖ Assume, Q = 0 and = 1
❖ Let us make opposite assumption that Q= 0 and Q =1. With Q = 1, one input of
NOR gate 1 is at logic I hence its output Q is at logic 0. With Q = 0, both inputs
to NOR gate 2 are at logic 0.
❖ So its output Q is at logic 1.
❖ In this case also there is no change in the output state
CASE 4: S = 1 and R = 1
❖ When R and S both are at logic 1, they force the outputs of both NOR gates to the
low state
Digital Principles and System Design 2.7
2.2.2 Flip-Flops
❖ Flip-flops are the first stage in sequential logic design which incorporates memory
(storage of previous states).
❖ Flip-flops that we will look at include the following:
2.8 Synchronous Sequential Logic
S Q
R 𝑄ത
Case 1
❖ For S=0, R=0 and CLK=0, the flip-flop simply remains in its present state.
❖ That is, Q remains unchanged. Even for S=0, R=0 and CLK=1, the flip-flop
remains in its present state. This condition will not affect the outputs of flip-flop.
❖ The first four rows of the truth table clearly indicate that the state of the flip-flop
remains unchanged, i.e., 𝑄𝑛 + 1 = 𝑄𝑛.
Digital Principles and System Design 2.11
Case 2
❖ For S=0, R=1 and CLK=0, the flip-flop remains in its present state.
❖ When CLK=1,the NAND gate 1 output will go to 1 and the NAND gate 2 output
will go to 0.
❖ Now, a 0 at NAND gate-4 inputs forces 𝑄ത = 1
❖ Which in turn results in NAND gate-3 output Q=0.
❖ Thus, for S=0, R=1 and CLK=1, the flip-flop RESETS to the 0 state.
Case 3
❖ For S=1, R=0 and CLK=0, the flip-flop remains in its present state.
❖ But for S=1, R=0 and CLK=1 the set state of the flip-flop is reached.
❖ This causes the NAND gate-1 output to go to 0 and the NAND gate-2 output to 1.
❖ Now a 0 at NAND gate-3 input forces Q to 1 which in turn forces NAND gate-4
output 𝑄ത to 0.
Case 4
❖ An inderminate condition occurs when all the inputs, namely CLK, S and R, are
equal to 1.
❖ This condition results in 0’s in the output of gate-1 and 2 and 1’s in both outputs
Q and 𝑄ത .
❖ When the CLK input goes back to 0 (while S and R remains at 1), it is not possible
to determine the next state, as it depends on wheather the output of gate-1 or gate-
2 goes to 1 first.
State diagram and Characteristics equations:
Set
Reset
0 1 Set
Reset
0 0 0 0
0 0 1 0
0 1 0 1
0 1 1 d
1 0 0 1
1 0 1 0
1 1 0 1
1 1 1 d
❖ Using the above present state- next state table of S-R flip-flop, a k map for the
next state transition (Qn+1)
SR 00 01 11 10
Qn
0 0 0 d 1
1 1 0 d 1
̅
𝐷 0 1 D
̅
𝐷
❖ From the above state diagram the present and next state table and application or
excitation table for D flip-flop can be written as
Present State Delay input Next state
Qn D Qn+1
0 0 0
0 1 1
1 0 0
1 1 1
❖ Using the above present state- next state table of D flip-flop, a k map for the next
state transition (Qn+1)
D 0 1
Qn
0 0 1
1 0 1
From the above k-map, Qn+1 = D
Digital Principles and System Design 2.15
❖ The design of the JK flip – flop is such that the three inputs to one NAND gate
are J,
❖ Clock signal along with a feedback signal from Q’ and the three inputs to the other
NAND are K, clock signal along with a feedback signal from Q.
❖ This arrangement eliminates the indeterminate state in SR flip – flop.
Case 2
❖ When J is LOW and K is HIGH, then flip flop will be in Reset state i.e. Q = 0, Q’
= 1.
❖ When we apply a clock pulse to the J K flip flop and the inputs are J is low and K
is high the output of the NAND gate connected to J input becomes 1.
❖ Then Q becomes 0. This will reset the flip flop again to its previous state.
❖ So the Flip flop will be in RESET state.
Case 3
❖ When J is HIGH and K is LOW, then flip – flop will be in Set state i.e. Q = 1, Q’
=0
❖ When we apply a clock pulse to the J K flip flop and the inputs are J is high and
K is low the output of the NAND gate connected to K input becomes 1.
❖ Then Q’ becomes 0. This will set the flip flop with the high clock input. So the
Flip flop will be in SET state.
Case 4
❖ When both the inputs J and K are HIGH, then flip – flop is in Toggle state.
❖ This means that the output will complement of the previous state.
Race around condition of JK Flip Flop
❖ For high inputs of J K flip flop, only the lower NAND gates are triggered by the
outputs that are compliment to each other i.e Q and Q’.
❖ So while high inputs are connected to flip – flop, at any instant, one gate is enabled
and other gate will be disabled.
❖ If the upper gate is in disabled state, it will drive the flip flop to SET state, later
when the lower gate is enabled, it will drive the flip flop to RESET state which
causes the toggling of output.
❖ This will cause the Race around condition in J K flip – flop.
Steps to avoid racing condition
❖ We can avoid the Race around condition by setting up the clock-on time less than
the propagation delay of the flip flop. It can be achieved by edge triggering.
❖ By making the flip flop to toggle over one clock period. This concept is introduced
in Master Slave J K flip flop.
2.18 Synchronous Sequential Logic
❖ The new state of the slave then becomes the state of the entire master slave flip-
flop.
❖ The operation of master-slave J-K flip- flop for different J-K input combinations
can be explained as follows.
❖ When the T input is in the 0 state (i.e. J=K=0) prior to a clock pulse, the Q output
will not change with clocking.
❖ When the T inputs is at a 1 (i.e. J=K=1) level prior to clocking, the output will be
in the 𝑄ത state after clocking.
❖ In other words, if the T input is a logical 1 and the device is clocked, the output
will change state regardless of what output was prior to clocking.
❖ This is called toggling hence the name T flip-flop.
❖ The truth table shown that when T=0, then𝑄𝑛+1 = 𝑄𝑛 , i.e., the next state is the
same as the present state and no change occurs.
❖ When T=1, then 𝑄𝑛+1 = 𝑄ത𝑛 , i.e. the state of the flip-flop is complemented.
State Diagram and Characteristic Equation of T Flip-flop
❖ The state transition diagram for the Trigger flip-flop is shown in fig. 2.14
❖ It is clear that when T=1, the flip-flop changes or toggles its state irrespective of
its previous state; when T=1 and 𝑄𝑛 =0, the next state will be 1; when T=1 and
Digital Principles and System Design 2.21
𝑇ത 0 1 T
𝑇ത
0 0 0
0 1 1
1 0 1
1 1 0
Qn Qn+1 Excitation
Inputs T
0 0 0
0 1 1
1 0 1
1 1 0
❖ The K-map for the next state (𝑄𝑛+1) of trigger flip-flop can be drawn as shown
below and the simplified expression for 𝑄𝑛+1 can be found as follows.
❖ The characteristic equation for trigger flip-flop is 𝑄𝑛+1 = 𝑇𝑄ത𝑛 + 𝑇ത𝑄𝑛
❖ So, in a trigger flip-flop, the next state will be the complement of the previous
state when T=1.
2.22 Synchronous Sequential Logic
T 0 1
Qn
0 0 1
1 1 0
0 0 0
0 1 1
1 0 0
1 1 1
Digital Principles and System Design 2.25
Step 3 Using the application table of S-R flip-flop is given in Table, the next state
codes i.e. S & R values can be augmented in the above PS-Ns table as shown in Table.
Step 4 In this step, one can design the next state decoder, i.e. the simplified expressions
for S and R, from the excitation map as shown in figure.
D 0 1
D 0 1
Qn
Qn
0 0 1
0 d 0
1 0 1
1 1 0
S=D ̅
𝑅=𝐷
Step 5 From the above step, S=D and R=𝐷 ̅ .Now the circuit for delay flip-flop using S-
R flip-flop can be drawn as shown in figure. 2.17, with a single NOT gate in the next state
decoder logic. Note that the designed circuit confirms with the earlier connection of the
delay flip-flop using S-R flip-flop.
Qn D Qn+1 Excitation
Inputs
S R
0 0 0 0 d
0 1 1 1 0
1 0 0 0 1
1 1 1 d 0
2.5 COUNTERS
❖ A counter is a register capable of counting the number of clock pulses arriving at
its clock input.
❖ Specified sequence of states appears as the counter output.
❖ This is the main difference between a register and a counter.
❖ A specified sequence of states is different for different types of counters.
❖ There are two types of counters, synchronous and asynchronous.
❖ In synchronous counter, the common clock input is connected to all of the flip-
flops and thus they are clocked simultaneously.
❖ In asynchronous counter, commonly called, ripple counters, the first flip- flop is
clocked by the external clock pulse and then each successive flip-flop is clocked
by the 0 or Q output of the previous flip-flop.
❖ Therefore in an asynchronous counter, the flip-flops are not clocked
simultaneously.
❖ The delay involved in this case is equal to the propagation delay of one flip-flop
only, irrespective of the number of flip-flops used to construct the counter.
❖ In other words, the delay is independent of the size of the counter.
❖ Figure 2.21 shows the generalized block schematic arrangement of an n-bit binary
ripple counter.
❖ As a natural consequence of this, not all flip-flops change state at the same time.
❖ The second flip-flop can change state only after the output of the first flip-flop has
changed its state.
❖ That is, the second flip-flop would change state a certain time delay after the
occurrence of the input clock pulse owing to the fact that it gets its own clock
input from the output of the first flip-flop and not from the input clock.
❖ This time delay here equals the sum of propagation delays of two flip-flops, the
first and the second flip-flops.
❖ In general, the nth flip-flop will change state only after a delay equal ton times the
propagation delay of one flip-flop.
❖ The term ‘ripple counter’ comes from the mode in which the clock information
ripples through the counter.
❖ It is also called an ‘asynchronous counter’ as different flip-flops comprising the
counter do not change state in synchronization with the input clock.
❖ In a counter like this, after the occurrence of each clock input pulse, the counter
has to wait for a time period equal to the sum of propagation delays of all flip-
flops before the next clock pulse can be applied.
❖ The propagation delay of each flip-flop, of course, will depend upon the logic
family to which it belongs.
Digital Principles and System Design 2.31
❖ On HIGH-to-LOW transition of the first clock pulse, Q0 goes from ‘0’ to ‘1’ owing
to the toggling action.
❖ As the flip-flops use dare negative edge-triggered ones, the ‘0’ to ‘1’ transition of
Q0 does not trigger flip-flop FF1. FF1, along with FF2 and FF3, remains in its ‘0’
state.
❖ So, on the occurrence of the first negative-going clock transition, Q0= 1, Q1= 0,
Q2= 0 and Q3= 0.
❖ On the HIGH-to-LOW transition of the second clock pulse, Q0 toggles again.
❖ That is, it goes from ‘1’ to ‘0’.
❖ This ‘1’ to ‘0’ transition at the Q0 output triggers FF1, the output Q1 of which
goes from ‘0’ to ‘1’.
❖ The Q2 and Q3 outputs remain unaffected.
❖ Therefore, immediately after the occurrence of these condition HIGH-to-LOW
transition of the clock signal, Q0= 0, Q1= 1, Q2= 0 and Q3= 0.
❖ On similar lines, we can explain the logic status of Q0, Q1, Q2 and Q3 outputs
immediately after subsequent clock transitions.
❖ Thus, we see that the counter goes through 16 distinct states from 0000 to 1111
and then, on the occurrence of the desired transition of the sixteenth clock pulse,
it resets to the original state of 0000from where it had started.
❖ Some counter ICs have separate clock inputs for UP and DOWN counts, while
others have a single clock input and an UP/DOWN control pin.
❖ The logic status of this control pin decides the counting mode.
❖ As an example, ICs 74190 and 74191 are four-bit UP/DOWN counters in the TTL
family with a single clock input and an UP/DOWN control pin.
❖ While IC 74190 is a BCD decade counter, IC74191 is a binary counter.
❖ Also, ICs 74192 and 74193 are four-bit UP/DOWN counters in the TTL family,
with separate clock input terminals for UP and DOWN counts.
❖ While IC 74192 is a BCD decade counter, IC 74193 is a binary counter.
❖ Figure 2.23 shows a three-bit binary UP/DOWN counter. This is only one possible
logic arrangement.
❖ As we can see, the counter counts upwards when UP control is logic ‘1’ and
DOWN control is logic ‘0’.
2.34 Synchronous Sequential Logic
❖ In this case the clock input of each flip-flop other than the LSB flip-flop is fed
from the normal output of the immediately preceding flip-flop.
❖ The counter counts downwards when the UP control input is logic ‘0’ and DOWN
control is logic ‘1’.
❖ In this case, the clock input of each flip-flop other than the LSB flip-flop is fed
from the complemented output of the immediately preceding flip-flop.
❖ Figure 2.24 shows another possible configuration for a three-bit binary ripple
UP/DOWN counter.
❖ It has a common control input. When this input is in logic ‘1’ state the counter
counts downwards, and when it is in logic ‘0’ state it counts upwards.
❖ As an example, Fig. 2.25 shows the state transition diagram of an MOD-8 binary
counter.
f b
e
c
d
Figure 2.26 shows the state transition diagram
2.38 Synchronous Sequential Logic
❖ The state table given in above Table has no redundant state because no two states
are equivalent.
❖ Hence, there is no modification required in the given state table.
STEP 3 State assignment
❖ Let us assign two state variables to states a, b, c, d, e, and f as follows:
a=000, b=001, c=010, d=011, e=100 and f=101. Then, the PS-NS table
gets modified as shown in Table.
q2q1 00 01 11 10 q2q1 00 01 11 10
q0 q0
0 0 0 d d 0 d d d 0
1 0 1 d d 1 d d d 1
For J2 For K2
J2 = q1q0 K2 = q0
2.40 Synchronous Sequential Logic
q2q1 00 01 11 10 q2q1 00 01 11 10
q0 q0
0 0 d d 0 0 d 0 d d
1 1 d d 0 1 d 1 d d
For J1 For K1
J1 = 𝑞ത 2q0 K1 = q0
SR 00 01 11 10 SR 00 01 11 10
Qn Qn
0 1 1 d 1 0 d d d d
1 d d d d 1 1 1 d 1
For J0 For K0
J0 = 1 K1 = 1
at either of the inputs inhibits entry of new data and also resets the first flip-flop
to the logic LOW level at the next clock pulse.
❖ Logic HIGH at either of the inputs enables the other input, which then determines
the state of the first flip-flop.
❖ Data at the serial inputs may be changed while the clock input is HIGH or LOW,
and the register responds to LOW-to-HIGH transition of the clock.
❖ Similarly, with the second and third clock pulses, the counter output will become
0010 and 0001.
❖ With the fourth clock pulse, the counter output will again become 1000.
❖ The count cycle repeats in the subsequent clock pulses.
❖ Circulating registers of this type find wide application in the control section of
microprocessor-based systems where one event should follow the other.
❖ The timing waveforms for the circulating register of Figure 2.30, as shown in Fig.
2.31, further illustrate their utility as a control element in a digital system to
generate control pulses that must occur one after the other sequentially.
❖ If R-S flip-flops are used, the Q output goes to the R input and the Q output is
connected to the S input.
❖ Figure 2.32 shows the logic diagram of a basic four-bit shift counter.
❖ When the output of the sequential circuit depends only on the present state of the
flip-flop the sequential circuit is referred to as Moore model. Let us see one
example of Moore model.
2.9.1.2 Mealy model
❖ When the output of the sequential circuit depends on both the present state of the
flip-flops and on the inputs, the sequential circuit is referred to as mealy model.
❖ Figure 2.35.shows the sample mealy model.
INTRODUCTION
Computer Organization: It refers to the operational units and their interconnections that
realize the architectural specifications. It describes the function of and design of the
various units of digital computer that store and process information. The attributes in
computer organization refers to:
• Control signals
• Computer/peripheral interface
• Memory technology
Computer hardware: Consists of electronic circuits, displays, magnetic and optical
storage media, electromechanical equipment and communication facilities.
Computer Architecture: It is concerned with the structure and behavior of the
computer. It includes the information formats, the instruction set and techniques for
addressing memory. The attributes in computer architecture refers to the:
• Instruction set
• Data representation
• I/O mechanisms
• Addressing techniques
The basic distinction between architecture and organization is: the attributes of the
former are visible to programmers whereas the attributes of the later describes how
features are implemented in the system.
3.2 Computer Fundamentals
Output Unit
The output unit is the counterpart of the input unit. Its function is to send
processed results to the outside world. A familiar example of such a device is a printer.
Most printers employ either photocopying techniques, as in laser printers, or ink jet
streams. Such printers may generate output at speeds of 20 or more pages per minute.
However, printers are mechanical devices, and as such are quite slow compared
to the electronic speed of a processor. Some units, such as graphic displays, provide
both an output function, showing text and graphics, and an input function, through
touch screen capability.
Control Unit
The operations of Input unit, output unit, ALU are co-ordinate by the control
unit. The control unit is the Nerve centre that sends control signals to other units and
senses their states. The control section directs the flow of traffic (operations) and data. It
also maintains order within the computer. The control section selects one program
statement at a time from the program storage area, interprets the statement, and sends
the appropriate electronic impulses to the arithmetic-logic and storage sections so they
can carry out the instructions. The control section does not perform actual processing
operations on the data.
The control section instructs the input device on when to start and stop
transferring data to the input storage area. It also tells the output device when to start
and stop receiving data from the output storage area. Data transfers between the
processor and the memory are controlled by the control unit through timing signals.
Information stored in the memory is fetched, under program control into an arithmetic
and logic unit, where it is processed.
The operation of a computer can be summarized as follows:
➢ The computer accepts information in the form of programs and data through an
input unit and stores it in the memory.
➢ Information stored in the memory is fetched under program control into an
arithmetic and logic unit, where it is processed.
➢ Processed information leaves the computer through an output unit.
➢ All activities in the computer are directed by the control unit
Digital Principles and System Design 3.5
Figure 3.2: Connection between the processor and the main Memory.
It contains the memory address of the next instruction to be fetched and
executed. During the execution of an instruction, the contents of the PC are updated to
correspond to the address ofthe next instruction to be executed.
In addition to the IR and PC, Figure 3.2 shows general-purpose registers R0
through Rn−1, often called processor registers. They serve a variety of functions,
including holding operands that have been loaded from the memory for processing.
The processor-memory interface is a circuit which manages the transfer of data
between the main memory and the processor. If a word is to be read from the memory,
the interface sends the address of that word to the memory along with a Read control
signal. The interface waits for the word to be retrieved, then transfers it to the
appropriate processor register.
Digital Principles and System Design 3.7
Example
Given the following C statement:
f = (g + h) - (i + j);
Assume the compiler associates the variables f, g, h, i, and j to the registers $s0,
$s1, $s2, $s3, and $s4, respectively
What is the compiled MIPS assembly language code?
Answer
add $t0, $s1, $s2 # Register $t0 contains g+h
add $t1, $s3, $s4 # Register $t1 contains i+j
sub $s0, $t0, $t1 # f gets $t0-$t1, or (g+h) - (i+j)
What if we have a program that manipulates a large array of numbers - they
cannot all be stored in the registers of the MIPS processor.
➢ In this case, the elements of the array would be stored in the memory of the
MIPS computer.
➢ The memory is a large storage space that can store millions of data elements.
➢ When we need to perform an operation on certain elements of this array, we
transfer these elements from the memory to the registers -MIPS cannot perform
operations directly on data elements stored in memory (certain computers can).
➢ These instructions are called data transfer instructions.
To command the computer, you need to speak its language and the instructions
are the words of a computer’s language and the instruction set is basically its
vocabulary. ISA is the portion of the machine which is visible to either the assembly
language programmer or a compiler writer or an application programmer.
A complete instruction set, including operand addressing methods, is often
referred to as the instruction set architecture (ISA) of a processor.
3.3.1 Memory Locations and Addresses
The memory consists of many millions of storage cells, each of which can store
a bit of information having the value 0 or 1. Because a single bit represents a very small
amount of information, bits are seldom handled individually.
Each group of n bits is referred to as a word of information, and n is called the
word length. The memory of a computer can be schematically represented as a
collection of words, as shown in Figure 3.3.
A unit of 8 bits is called a byte. Machine instructions may require one or more
words for their representation.
To start a Read operation, the processor sends the address of the desired location
to the memory and requests that its contents be read. The memory reads the data stored
at that address and sendsthem to the processor.
The Write operation transfers an item of information from the processor to a
specific memory location, overwriting the former contents of that location.
To initiate a Write operation, the processor sends the address of the desired
location to the memory, together with the data to be written into that location.
The contents of LOC are unchanged by the execution of this instruction, but the
old contents of register R2 are overwritten.
The second example of adding two numbers contained in processor registers R2
and R3 and placing their sum in R4 can be specified by the assembly-language
statement
Add R4, R2, R3
In this case, registers R2 and R3 hold the source operands, while R4 is the
destination.
RISC and CISC Instruction Sets
The restriction that each instruction must fit into a single word reduces the
complexity and the number of different types of instructions that may be included in the
instruction set of a computer. Such computers are called Reduced Instruction Set
Computers (RISC).
Although the use of complex instructions was not originally identified by any
particular label, computers based on this idea have been subsequently called Complex
Instruction Set Computers (CISC).
Instruction Execution and Straight-Line Sequencing
In the preceding subsection, we used the task C =A+ B, implemented as C←[A]
+ [B], as an example. Figure 3.6 shows a possible program segment for this task as it
appears in the memory of a computer.
We assume that the word length is 32 bits and the memory is byte-addressable.
The four instructions of the program are in successive word locations, starting at location
i. Since each instruction is 4 bytes long, the second, third, and fourth instructions are at
addresses i+4, i+8, and i+12.
Let us consider how this program is executed. The processor contains a register
called the program counter (PC), which holds the address of the next instruction to be
executed.
To begin executing a program, the address of its first instruction (i in our
example) must be placed into the PC. Then, the process or control circuits use the
information in the PC to fetch and execute instructions, one at a time, in the order of
increasing addresses. This is called straight-line sequencing.
During the execution of each instruction, the PC is incremented by 4 to point to
the next instruction. Thus, after the Store instruction at location i + 12 is executed, the
Digital Principles and System Design 3.15
PC contains the value i + 16, which is the address of the first instruction of the next
program segment.
At the end of the nth pass through the loop, the Subtract instruction produces a
value of zero in R2, and, hence, branching does not occur. Instead, the Store instruction
is fetched and executed. It moves the final result from R3 into memory location SUM.
• Example : Move P, Ro
Add Q, Ro
Where P and Q are the address of operand, Ro is any register. Sometimes
Accumulator (AC) is the default register. Then the instruction will look like:
Add A
3. Indirect or Pseudodirect Addressing:
• Indirect addressing mode, the address field of the instruction refers to the
address of a word in memory, which in turn contains the full length address of
the operand.
• The address field of instruction gives the memory address where on, the
operandis stored in memory.
• Control fetches the instruction from memory and then uses its address part to
accessmemory again to read Effective Address.
• The advantage of this mode is that for the word length of N, an address
space of2N can be addressed.
• The disadvantage is that instruction execution requires two memory references
tofetch the operand.
• Multilevel or cascaded indirect addressing can also be used.
Example: Effective Address (EA) = (A).
• The operand will be present in the memory location A.
4. Register Addressing:
• Register addressing mode is similar to direct addressing. The only difference
is that the address field of the instruction refers to a register rather than a
memory location.
• 3 or 4 bits are used as address field in the instruction to refer 8 to 16 generate
purposeregisters (GPR).
• The operands are in registers that reside within the CPU.
• The instruction specifies a register in CPU, which contain the operand.
• There is no need to compute the actual address as the operand is in a
register andto get operand there is no memory access involved.
• The advantages of register addressing are small address field is needed in the
instructionand faster instruction fetch.
• The disadvantages includes very limited address space and usage of multiple
registershelps in performance but it complicates the instructions.
• Example: MOV AX, BX
• Control fetches instruction from memory and then uses its address to access
Register and looks in Register(R) for effective address of operand in
memory.
• The address space is limited to the width of the registers available to store
theeffective address.
• Example:MOV AL, [BX]
Code example in Register:
MOV BX, 1000H
MOV 1000H, operand
• The instruction MOV AL, [BX]) specifies a register[BX] which contain the
address of operand (1000H) rather than address itself.
This is similar to indexed addressing mode except that the register is now called as
Base Register instead of Index Register.
Example: EA=A+Base
7. Stack Addressing:
• Stack is a linear array of locations referred to as last-in first out queue.
• The stack is a reserved block of location, appended or deleted only at the
top ofthe stack.
• Stack pointer is a register which stores the address of top of stack location.
• This mode of addressing is also known as implicit addressing.
• Example: Add
• This instruction pops two items from the stack and adds.
Additional Modes:
There are two additional modes. They are:
• Auto-increment mode
• Auto-decrement mode
These are similar to Register indirect Addressing Mode except that the register is
incremented or decremented after (or before) its value is used to access memory. These
modes are required because when the address stored in register refers to a table of data
in memory, then it is necessary to increment or decrement the register after every access
to table so that next value is accessed from memory.
Auto-increment mode:
• Auto-increment Addressing Mode are similar to Register Indirect Addressing
Mode except that the register is incremented after its value is loaded (or
accessed) at another location like accumulator(AC).
• The Effective Address of the operand is the contents of a register in the
instruction.
• After accessing the operand, the contents of this register is automatically
incrementedto point to the next item in the list.
• Example: (R) +.
• The contents in register R will be accessed and them it will be incremented to
point the next item in the list.
• The effective address is (R )=400 and operand in AC is 7. After loading R1 is
incremented by 1, it becomes 401.
3.24 Computer Fundamentals
• Requires 16 bits to denote the OP code and the two registers, and some bits to
express that the source operand uses the Index addressing mode and that the
index value is 24.
The shift instruction
LShiftR #2, R0
And the move instruction
Move #$3A, R1
• Have to indicate the immediate values 2 and #$3A, respectively, in addition to
the 18bits used to specify the OP code, the addressing modes, and the register.
This limits the size of the immediate operand to what is expressible in 14 bits.
• Consider next the branch instruction
Branch >0 LOOP
• Again, 8 bits are used for the OP code, leaving 24 bits to specify the branch
offset. Since the offset is a 2’s-complement number, the branch target address
must be within 223 bytes of the location of the branch instruction. To branch to
an instruction outside this range, a different addressing mode has to be used,
such as Absolute or Register Indirect. Branch instructions that use these modes
are usually called Jump instructions.
• In all these examples, the instructions can be encoded in a 32-bit word. Depicts a
possible format. There is an 8-bit Op-code field and two 7-bit fields for
specifying the source and destination operands. The 7-bit field identifies the
addressing mode and the register involved (if any). The “Other info” field allows
us to specify the additional information that may be needed, such as an index
value or an immediate operand.
RISC AND CISC STYLES
RISC and CISC are two different styles of instruction sets. We introduced
RISC first because it is simpler and easier to understand. Having looked at some basic
features of both styles, we should summarize their main characteristics.
CISC :
• The CISC approach attempts to minimize the number of instructions per
program, sacrificing the number of cycles per instruction.
Digital Principles and System Design 3.27
• Computers based on the CISC architecture are designed to decrease the memory
cost.
• Because, the large programs need more storage, thus increasing the memory cost
and large memory becomes more expensive.
• To solve these problems, the number of instructions per program can be reduced
by embedding the number of operations in a single instruction, thereby making
the instructions more complex.
RISC :
• RISC (Reduced Instruction Set Computer) is used in portable devices due to its
powerefficiency.
For Example, Apple iPod and Nintendo DS. RISC is a type of
microprocessorarchitecture that uses highly-optimized set of instructions.
• RISC does the opposite, reducing the cycles per instruction at the cost of the
number of instructions per program Pipelining is one of the unique feature of
RISC.
• It is performed by overlapping the execution of several instructions in a pipeline
fashion.It has a high performance advantage over CISC.
3.28 Computer Fundamentals
was the COBOL language. C#, Python, etc., are a few examples of high-level
languages.
Difference Between Assembly Language and High-Level Language
Here is a list of the differences present between Assembly Language and High-
Level Language.
Parameters Assembly Language High-Level Language
Conversion The assembly language A high-level language
requires an assembler for the requires an interpreter/
process of conversion. compiler for the process of
conversion.
Process of Conversion We perform the conversion We perform the
of an assembly language into conversion of a high-level
a machine language. language into an assembly
language and then into a
machine-level language
for the computer.
Machine Dependency The assembly language is a A high-level language is a
machine-dependent type of machine-independent type
language. of language.
Codes It makes use of the It makes use of the
mnemonic codes for English statements for
operation. operation.
Operation of Lower It provides support for It does not provide any
Level various low-level operations. support for low-level
languages.
Access to Hardware Accessing the hardware Accessing the hardware
Component component is very easy in component is very
this case. difficult in this case.
Compactness in Code The code is more compact in No code compactness is
this case. present in this case.
Type of Processor The program that we write This language is
for one processor in an processor-independent. It
Digital Principles and System Design 3.31
• After the instruction has been executed on the operands, results may be stored
back in memory.
• The memory unit see sortly a stream of memory addresses; it does not know
how they are generated (by the instruction counter, indexing, indirection, literal
addresses, and so on) or what they are for (instructions or data).
• Accordingly, we can ignore a program generates a memory address. We are
interested only in the sequence of memory addresses generated by the running
program.
• The following is a summary of the six steps used to execute a single instruction.
Step 1: Fetch instruction.
Step 2: Decode instruction and Fetch Operands.
Step 3: Perform ALU operation.
Step 4: Access memory.
Step 5: Write back result to register file.
Step 6: Update the PC.
• The objectives of this module are to discuss how an instruction gets executed in
a processor and the datapath implementation, using the MIPS architecture as a
case study.
4.1.1 MIPSARCHITECTURE
MIPS (Million Instructions per Second) is a simple, streamlined, highly scalable
RISC architecture with adopted by the industries.
The features that makes its widely useable are:
• Simple load and store with large number of register
• The number and the character of the instructions
• Better pipelining efficiency with visible pipeline delay slots
• Efficiency with compilers
These features make the MIPS architecture to deliver the highest performance
with high levels of power efficiency. It is important to learn the architecture of MIPS to
understand the detailed working of the processors.
Digital Principles and System Design 4.3
Implementation of MIPS
MIPS have 32 General purpose registers (GPR) or integer registers (64 bit)
holding integer data. Floating point registers (FPR) are also available in MIPS capable
of holding both single precision (32 bit) and double precision data (64 bit). The
following are the data types available for MIPS:
Size Name Registers
Fig 4.2: Implementation of MIPS architecture with multiplexers and control lines
With these resources the MIPS performs the following operations:
• Memory referencing : load word(lw) and store word(sw)
• Arithmetic-logical instructions: add, sub, and, or, and slt
• Branch instructions: equal(beq) and jump (j)The common steps in load and store
instructions are:
4.4 Processor
i. Set the program counter (PC) to the address of the code and fetch the
instruction from that memory.
ii. Read one or two registers, using fields of the instruction to select the
registers to read. For the load word instruction, read only one register and
for store word the processor has to operate on two registers.
The ALU operations are done and the result of the operation is stored in the
destination register using store operation. When a branching operation is involved, then
next address to be fetched must be changes based on the branch target.
Sequence of operations
• Program Counter(PC):This register contains the address (location) of the
instruction
currently getting executed. The PC is incremented to read the next instruction to
beexecuted.
• The operands in the instruction are fetched from the registers.
• The ALU or branching operations are done. The results of the ALU operations
arestored in registers. If the result is given in load and store forms, then the
results are written to the memory address and from there they are transferred to
the registers.
• In case of branch instructions, the result of the branch operation is used to
determine the next instruction to be executed.
• The multiplexer (MUX1), selects one input control from multiple inputs. This
act s as a data selector.
• This helps to control several units depending on the type of instruction.
• The top multiplexor controls the target value of the PC. To execute next
instruction the PC is set as PC+4. To execute a branch instruction set the PC to
the branch target address.
• The multiplexor is controlled by the AND gate that operates on the zero output
of the ALU and a control signal that indicates that the instruction is a branch.
• The multiplexor (MUX2) returns the output to the register file for loading the
resultant data of ALU operation into the registers.
• MUX3 determines whether the second ALU input is from the registers or from
the offset field of the instruction.
Digital Principles and System Design 4.5
• The control lines determine the operation performed at the ALU. The control
lines decide whether to read or write the data.
MIPS instruction format
There are only three instruction formats in MIPS. The instructions belong to any
one of the following type:
➢ Arithmetic/logical/shift/comparison
➢ Controlinstructions(branchandjump)
➢ Load/store
➢ Other(exception, register movement to/from GP registers, etc.)
The data and memory are well separated in MIPS implementation because:
• The instruction formats for the operations arenot unique; hence the memory
access will also be different.
• Maintaining separate memory area is less expensive.
• The operations of the processor are performed in single cycle. A single memory
(forboth data and memory access) will not allow for two different accesses
within onecycle.
LOGICDESIGNCONVENTIONS
The information in a computer system is encoded in binary form (0 or 1). The
highvoltage is encoded as 1 and low voltage as 0. The data is transmitted inside the
processorsthrough control wires / lines. These lines are capable of carrying only one bit
at a time. Sotransfer of multiple data can be done through deploying multiple control
lines or buses. The data should be synchronized with time by transferring it according to
the clock pulses. All the internal operations inside the processor are implemented
through logic elements. The logic elements are broadly classified into: Combinatorial
and Sequential elements.
DIFFERENCES BETWEEN COMBINATORIAL AND SEQUENTIAL
ELEMENTS
Combinatorial Elements Sequential Elements
The output of the combinatorial circuit Theoutputdependsonthepreviousstageoutput
depends only on the current input. s.
It has faster operation speed and easy It has comparatively low operation speed
4.6 Processor
• Instruction Memory: It is a state element that provides read access because the
data path do not perform write operation. This combinatorial memory always
holds contents of location specified by the address.
• Program Counter (PC): This is a 32 bit state register containing the address of
the current instruction that is being executed. It is updated after every clock
cycle and do not require an explicit write signal.
• Adder: This is a combinatorial circuit that updates the value of PC after every
clock cycle to get that address of the next instruction to be executed.
Instruction Fetch:
The fundamental operation in Instruction Fetch is to send the address in the PC to
the instruction memory and obtain the specified instruction, and the increment the PC.
Branch Instructions:
Branch Target is the address specified in a branch, which is used to update the
PC if the branch is taken. In the MIPS architecture the branch target is computed as
the sum of the offset field of the instruction and the address of the Instruction
following the branch.
The beq instruction (branch instruction) has three operands, two registers that
are compared for equality, anda16-bitoffsettocomputethebranchtargetaddress.
Beq t1, t2, offset
• Thus, the branch data path must do two operations: compute the branch target
address and compare the register contents.
• Branch Taken is where the branch condition is satisfied and the program
counter (PC) loads the branch target. All unconditional branches are taken
branches.
• Branch not Taken is where the branch condition is false and the program
counter (PC) loads the address of the instruction that sequentially follows the
branch.
• The branch target is calculated by taking the address of the net instruction after
thebranch instruction, since the PC value will be updated as PC+4 even before
the branchdecisionistaken
• The offset field is shifted left 2 bits to increase the effective range of the offset
field by a factor of four.
• The unit labelled Shift left 2 adds two zero’s to the low-order end of the sign-
extended off set field. This operation truncated the sign values.
• The control logic decides whether the incremented PC or branch target should
replace the PC, based on the Zero output of the ALU.
• The jump instruction operates by replacing the lower 28 bits of the PC with the
lower 26 bits of the instruction shifted left by 2 bits. This shift is done by
concatenating 00 to the jump offset.
• Delayed branch is where the instruction immediately following the branch is
always executed, independent of whether the branch condition is true or false.
• MIPS architecture implements delayed branch (i.e.) the instruction immediately
following the branch is always executed, independent of whether the branch
condition is true or false.
• When the condition is false, the execution looks like a normal branch.
• When the condition is true, a delayed branch first executes the instruction
immediately following the branch in sequential instruction order before jumping
to the specified branch target address.
• Delayed branches facilitate pipelining.
Creating a single Data path
• A simple implementation of a single data path is to execute all operations within
one clock cycle.
• The data path resources can be utilized only for one clock cycle. To facilitate
this, some resources must be duplicated for simultaneous access while other
resources will be shared.
• One example is having separate memory or instructions and memory.
• When a resource is used in shared mode, then multiple connections must be
made. The selection of which control will access the resource will be decided by
a multiplexer.
Digital Principles and System Design 4.11
The following image shows the block diagram of a Hardwired Control organization.
o The Control memory address register specifies the address of the micro-
instruction.
o The Control memory is assumed to be a ROM, within which all control
information is permanently stored.
o The control register holds the microinstruction fetched from the memory.
o The micro-instruction contains a control word that specifies one or more micro-
operations for the data processor.
o While the micro-operations are being executed, the next address is computed in
the next address generator circuit and then transferred into the control address
register to read the next microinstruction.
o The next address generator is often referred to as a micro-program sequencer, as
it determines the address sequence that is read from control memory.
4.4 PIPELINING
As computer systems evolve, greater performance can be achieved by taking
advantage of improvements in technology, such as faster circuitry. In addition,
organizational enhancements to the processor can improveperformance.
Pipelining is an implementation technique in which multiple instructions are
overlapped in execution.
4.14 Processor
Under ideal conditions and with a large number of instructions, the speed-up
from pipelining is approximately equal to the number of pipe stages; a five-stage
pipeline is nearly five times faster.
It should be clear that this process will speed up instruction execution. If the
fetch and execute stages were of equal duration, the instruction cycle time would be
halved.
1. The execution time will generally be longer than the fetch time. Execution will
involve reading and storing operands and the performance of some operation.
Thus, the fetch stage may have to wait for some time before it can empty its
buffer.
2. A conditional branch instruction makes the address of the next instruction to be
fetched unknown. Thus, the fetch stage must wait until it receives the next
instruction address from the execute stage. The execute stage may then have to
wait while the next instruction is fetched.
Digital Principles and System Design 4.17
When a conditional branch instruction is passed on from the fetch to the execute
stage, the fetch stage fetches the next instruction in memory after the branch instruction.
Then, if the branch is not taken, no time is lost. If the branch is taken, the fetched
instruction must be discarded and a new instruction fetched.
To increase speedup, the pipeline must have more stages.
Fetch instruction (FI): Read the next expected instruction into a buffer.
Decode instruction (DI): Determine the opcode and the operand specifiers.
Calculate operands (CO): Calculate the effective address of each source operand. This
may involve displacement, register indirect, indirect, or other forms of address
calculation.
Fetch operands (FO): Fetch each operand from memory. Operands in registers need
not be fetched.
Execute instruction (EI): Perform the indicated operation and store the result, if any,
in the specified destination operand location.
Write operand (WO): Store the result in memory.
In the figure above, you can see that result of the Add instruction is stored in the
register R2 and we know that the final result is stored at the end of the execution of the
instruction which will happen at the clock cycle t4.
But the Sub instruction need the value of the register R2 at the cycle t3. So the
Sub instruction has to stall two clock cycles. If it doesn’t stall it will generate an
incorrect result. Thus depending of one instruction on other instruction for data is data
dependency.
2. Memory Delay
When an instruction or data is required, it is first searched in the cache memory
if not found then it is a cache miss. The data is further searched in the memory which
may take ten or more cycles. So, for that number of cycle the pipeline has to stall and
this is a memory delay hazard. The cache miss, also results in the delay of all the
subsequent instructions.
3. Branch Delay
Suppose the four instructions are pipelined I1, I2, I3, I4 in a sequence. The
instruction I1 is a branch instruction and its target instruction is Ik. Now, processing
4.20 Processor
starts and instruction I1 is fetched, decoded and the target address is computed at the
4th stage in cycle t3.
But till then the instructions I2, I3, I4 are fetched in cycle 1, 2 & 3 before the
target branch address is computed. As I1 is found to be a branch instruction, the
instructions I2, I3, I4 has to be discarded because the instruction Ik has to be processed
next to I1. So, this delay of three cycles 1, 2, 3 is a branch delay.
Prefetching the target branch address will reduce the branch delay. Like if the
target branch is identified at the decode stage then the branch delay will reduce to 1
clock cycle.
Digital Principles and System Design 4.21
4. Resource Limitation
If the two instructions request for accessing the same resource in the same clock
cycle, then one of the instruction has to stall and let the other instruction to use the
resource. This stalling is due to resource limitation. However, it can be prevented by
adding more hardware.
In the above case, ADD instruction writes the result into the register R3 in t5. If
bubbles are not introduced to stall the next SUB instruction, all three instructions would
be using the wrong data from R3, which is earlier to ADD result. The program goes
wrong! The possible solutions before us are:
Solution 1: Introduce three bubbles at SUB instruction IF stage. This will facilitate
SUB – ID to function at t6. Subsequently, all the following instructions are also delayed
in the pipe.
4.22 Processor
Speedup from pipelining = [ 1/ (1+ pipeline stall cycles per instruction) ] * Pipeline
❖ With multiple pipelines there are contention delays for access to the registers
and to memory.
❖ Additional branch instructions may enter the pipeline (either stream) before the
original branch decision is resolved. Each such instruction needs an additional
stream.
Prefetch Branch Target When a conditional branch is recognized, the target of the
branch is prefetched, in addition to the instruction following the branch. This target is
then saved until the branch instruction is executed. If the branch is taken, the target has
already been prefetched.
Loop Buffer A loop buffer is a small, very-high-speed memory maintained by the
instruction fetch stage of the pipeline and containing the n most recently fetched
instructions, in sequence. If a branch is to be taken, the hardware first checks whether
the branch target is within the buffer.
Delayed Branch It is possible to improve pipeline performance by automatically
rearranging instructions within a program, so that branch instructions occur later than
actually desired.
The branch and jump instructions decide the program flow by loading the
appropriate location in the Program Counter (PC). The PC has the value of the next
instruction to be fetched and executed by CPU. Consider the following sequence of
instructions.
decoded as JMP and not until then. So the pipeline cannot proceed at its speed and
hence this is a Control Dependency (hazard). In case I3 is fetched in the meantime, it is
not only a redundant work but possibly some data in registers might have got altered
and needs to be undone.
Similar scenarios arise with conditional JMP or BRANCH.
Solutions for Conditional Hazards
1. Stall the Pipeline as soon as decoding any kind of branch instructions. Just not
allow anymore IF. As always, stalling reduces throughput. The statistics say that
in a program, at least 30% of the instructions are BRANCH. Essentially the
pipeline operates at 50% capacity with Stalling.
2. Prediction – Imagine a for or while loop getting executed for 100 times. We
know for sure 100 times the program flows without the branch condition being
met. Only in the 101st time, the program comes out of the loop. So, it is wiser to
allow the pipeline to proceed and undo/flush when the branch condition is met.
This does not affect the throttle of the pipeline as much stalling.
3. Dynamic Branch Prediction - A history record is maintained with the help of
Branch Table Buffer (BTB). The BTB is a kind of cache, which has a set of
entries, with the PC address of the Branch Instruction and the corresponding
effective branch address. This is maintained for every branch instruction
encountered. So, whenever a conditional branch instruction is encountered, a
lookup for the matching branch instruction address from the BTB is done. If hit,
then the corresponding target branch address is used for fetching the next
instruction. This is calleddynamic branch prediction. This method is successful
to the extent of the temporal locality of reference in the programs. When the
prediction fails flushing needs to take place.
4. Reordering instructions - Delayed branch i.e. reordering the instructions to
position the branch instruction later in the order, such that safe and useful
instructions which are not affected by the result of a branch are brought-in
earlier in the sequence thus delaying the branch instruction fetch. If no such
instructions are available then NOP is introduced. This delayed branch is applied
with the help of Compiler.
5
MEMORY AND I/O
Because the upper level is smaller and built using faster memory parts, the
hit time will be much smaller than the time to access the next level in the hierarchy,
which is the major component of the miss penalty.
Principle of Locality
The locality of reference or the principle of locality is the term applied to
situations where the same value or related storage locations are frequently accessed.
There are three basic types of locality of reference:
• Temporal locality: Here a resource that is referenced at one point in time is
referencedagain soon afterwards.
• Spatial locality: Here the likelihood of referencing a storage location is
greater if astorage location near it has been recently referenced.
• Sequential locality: Here storage is accessed sequentially, in descending or
ascendingorder.The locality or reference leads to memory hierarchy.
Need for memory hierarchy
Memory hierarchy is an approach for organizing memory and storage systems. It
consist of multiple levels of memory with different speeds and sizes. The following are
the reasons for such organization:
➢ Fast storage technologies cost more per byte and have less capacity
➢ Gap between CPU and main memory speed is widening
➢ Well-written programs tend to exhibit good locality.
The memory hierarchy is shown in Fig 5.1. The entire memory elements of
the computerfall under the following three categories:
• Processor Memory:
This is present inside the CPU for high-speed data access. This consists of
small set of registers that act as temporary storage. This is the costliest
memory component.
• Primary memory:
This memory is directly accessed by the CPU. All the data must be brought
inside main memory before accessing them. Semiconductor chips acts as main
memory.
• Secondary memory:
This is cheapest, large and relatively slow memory component. The data from
the secondary memory is accessed by the CPU only after it is loaded to main
memory.
Digital Principles and System Design 5.5
of DRAM are its simple design, speed and low cost in comparison to alternative
types of memory. The main disadvantages of DRAM are volatility and high
power consumption relative to other options.
• Local Disks (Local Secondary Storage):
A local drive is a computer disk drive that is installed directly within the
host or the local computer. It is a computer’s native hard disk drive (HDD), which
is directly accessed by the computer for storing and retrieving data. It is a cheaper
memory with more memory access time.
• Remote Secondary Storage:
This includes Distributed file system (DFS) and online storage like cloud. The
storage area is vast with low cost but larger access time.
Distinction between Static RAM and Dynamic RAM
SRAM DRAM
Stores data till the power is supplied. Stored data only for few milliseconds
irrespective of the power supply.
Uses nearly 6 transistors for each Uses single transistor and capacitor
memory cell. for each memory cell.
Do not refresh the memory cell. Refreshing circuitry is needed.
Faster data access. Slower access.
Consumes more power. Low power consumption.
Cost pet bit is high. Comparatively lower costs.
They are made of more number of They are made of less number of
components per cells. components per cells.
Best Fit: It allocates the process to the partition that is the first smallest partition among
the free partitions.
Worst Fit: It allocates the process to the partition, which is the largest sufficient freely
available partition in the main memory.
Next Fit: It is mostly similar to the first Fit, but this Fit, searches for the first sufficient
partition from the last allocation point.
What is Paging?
• Paging is a storage mechanism that allows OS to retrieve processes from the
secondary storage into the main memory in the form of pages.
• In the Paging method, the main memory is divided into small fixed-size blocks
of physical memory, which is called frames.
• The size of a frame should be kept the same as that of a page to have maximum
utilization of the main memory and to avoid external fragmentation. Paging is
used for faster access to data, and it is a logical concept.
What is Fragmentation?
Processes are stored and removed from memory, which creates free memory
space, which are too small to use by other processes.
After sometimes, that processes not able to allocate to memory blocks because
its small size and memory blocks always remain unused is called fragmentation. This
type of problem happens during a dynamic memory allocation system when free blocks
are quite small, so it is not able to fulfill any request.
Two types of Fragmentation methods are:
1. External fragmentation
2. Internal fragmentation
• External fragmentation can be reduced by rearranging memory contents to
place all free memory together in a single block.
• The internal fragmentation can be reduced by assigning the smallest
partition, which is still good enough to carry the entire process.
What is Segmentation?
• Segmentation method works almost similarly to paging.
• The only difference between the two is that segments are of variable-length,
5.10 Memory and I/O
CPU execution time=(CPU clock cycles + memory stall cycles (if any))x
Clock cycle time
The memory stall cycles are a measure of count of the memory cycles during
which the CPU is waiting for memory accesses. This is dependent on caches misses
and cost per miss (cache penalty).
Memory stall cycles = number of cache misses x miss penalty
= Instruction Count x (misses/ instruction) x miss penalty
= Instruction Count (IC) x (memory access/ instruction) x miss
penalty
= IC x Reads per instruction x Read miss rate X Read miss
penalty
+ IC x Write per instruction x Write miss rate X Write
miss penalty
Misses / instruction = (miss rate x memory access)/ instruction
Issues in Cache memory:
• Cache placement: where to place a block in the cache?
• Cache identification: how to identify that the requested information is
available in thecache or not?
• Cache replacement: which block will be replaced in the cache, making
way for anincoming block?
Cache Mapping Policies:
These policies determine the way of loading the main memory to the cache
block. Main memory is divided into equal size partitions called as blocks or frames.
The cache memory is divided into fixed size partitions called as lines. During
cache mapping, block of main memory is copied to the cache and further access is
made from the cache not fromthe main memory.
Cache mapping is a technique by which the contents of main memory are
brought into the cache memory.
Digital Principles and System Design 5.13
Write through is a scheme in which writes always update both the cache
and thememory, ensuring that data is always consistent between the two.
• With a write-through scheme, every write causes the data to be written to main
memory.These writes will take a long time.
• A potential solution to this problem is deploying write buffer.
• A write buffer stores the data while it is waiting to be written to memory.
• After writing the data into the cache and into the write buffer, the processor
can continueexecution.
• When a write to main memory completes, the entry in the write buffer is
freed.
• If the write buffer is full when the processor reaches a write, the processor must
stall until there is an empty position in the write buffer.
• If the rate at which the memory can complete writes is less than the rate at which
the processor is generating writes, no amount of buffering can help because
writes are being generated faster than the memory system can accept them.
Write buffer is a queue that holds data while the data are waiting to be written
to memory.
• The rate at which writes are generated may also be less than the rate at which the
memory can accept them, and yet stalls may still occur. To reduce the
occurrence of such stalls, processors usually increase the depth of the write
buffer beyond a single entry.
• Another alternative to a write-through scheme is a scheme called write-back.
When a write occurs, the new value is written only to the block in the
cache.
• The modified block is written to the lower level of the hierarchy when it is
replaced.
• Write-back schemes can improve performance, especially when processors can
generate writes as fast or faster than the writes can be handled by main memory;
a write-back scheme is, however, more complex to implement than write-
through.
Write-back is a scheme that handles writes by updating values only to the
block in the cache, then writing the modified block to the lower level of the
hierarchy whenthe block is replaced.
Digital Principles and System Design 5.15
Find CPU time. Assume sequentially executing CPU. Clock cycles for a
program = (3x + 2y + 4z + 5w)
= 910 x 106 clock cyclesCPU_time = Clock cycles for a program / Clock rate
= 910 x 106 / 500 x 106 = 1.82 sec
Example 5.4: Consider another implementation of MIPS ISA with 1 GHz clock
and
– each ALU instruction takes 4 clock cycles,
– each branch/jump instruction takes 3 clock cycles,
– each sw instruction takes 5 clock cycles,
– eachlw instruction takes 6 clock cycles.
Also, consider the same program as in Example 1.
Find CPI and CPU time. Assume sequentially executing CPU.CPI
= (4x + 3y + 5z + 6w) / (x + y + z + w)
= 4.03 clock cycles/ instruction
CPU time = Instruction count x CPI / Clock rate
= (x+y+z+w) x 4.03 / 1000 x 106
= 300 x106 x 4.03 /1000 x 106
= 1.21 sec
The direct mapping concept is if the ith block of main memory has to be
placed at the jth block of cache memory.j = i % (number of blocks in
cache memory)
• Consider a 128 block cache memory. Whenever the main memory blocks 0,
128, 256 are loaded in the cache, they will be allotted cache block 0, since j=
(0 or 128 or 256) % 128 is zero).
• Contention or collision is resolved by replacing the older contents with latest
contents.
• The placement of the block from main memory to the cache is determined
from the16 bit memory address.
• The lower order four bits are used to select one of the 16 words in the
block.
• The 7 bit block field indicates the cache position where the block has to
be stored.
• The 5 bit tag field represents which block of main memory resides inside
the cache.
• This method is easy to implement but is not flexible.
Drawback: The problem was that every block of main memory was directly
mapped to the cache memory. This resulted in high rate of conflict miss. Cache
memory has to be very frequently replaced even when other blocks in the cache memory
were present as empty.
5.18 Memory and I/O
• The tag bits of an address received from the processor are compared to the
tag bits of each block of the cache to check, if the desired block is present.
Hence it is knownas Associative Mapping technique.
• Cost of an associated mapped cache is higher than the cost of direct-mapped
because of the need to search all 128 tag patterns to determine whether a
block is in cache.
Set associative mapping:
• It is the combination of direct and associative mapping technique.
• Cache blocks are grouped into sets and mapping allow block of main memory to
reside into any block of a specific set.
• This reduces contention problem (issue in direct mapping) with low hardware
cost (issue in associative mapping).
• Consider a cache with two blocks per set. In this case, memory block 0, 64,
128,…..,4032 map into cache set 0 and they can occupy any two block
within this set.
• It does this by saying that instead of having exactly one line that a block
can map to in the cache, we will group a few lines together creating a set. Then
a block in memory can map to any one of the lines of a specific set.
• The 6 bit set field of the address determines which set of the cache might contain
the desired block. The tag bits of address must be associatively compared to
the tags of the two blocks of the set to check if desired block is present.
Replacement Algorithms
When a main memory block needs to be brought into the cache while all the
blocks are occupied, then one of them has to be replaced. This selection of the block to
be replaced is using cache replacement algorithms. Replacement algorithms are only
needed for associative and set associative techniques. The following are the common
replacementtechniques:
• Least Recently Used (LRU): This replaces the cache line that has been in
the cache the longest with no references to it.
• First-in First-out (FIFO): This replaces the cache line that has been in the
cache the longest.
• Least Frequently Used (LFU): This replaces the cache line that has
experienced the fewest references.
• Random: This picks a line at random from the candidate lines.
and uses it as a RAM. In that part of the secondary storage, the part of the program
which not currently being executed is stored and all the parts of the program that are
executed are first brought into the main memory.
This is the theory behind virtual memory.
Terminologies:
• Physical address is an address in main memory.
• Protection is a set of mechanisms for ensuring that multiple processes sharing
the processor, memory, or I/O devices cannot interfere, with one another by
reading or writing each other’s data.
• Virtual memory breaks programs into fixed-size blocks called pages.
• Page fault is an event that occurs when an accessed page is not present in main
memory.
• Virtual address is an address that corresponds to a location in virtual space and
is translated by address mapping to a physical address when memory is
accessed.
• Address translation or address mapping is the process by which a virtual address
is mapped to an address used to access memory.
Working mechanism
• In virtual memory, blocks of memory are mapped from one set of
addresses (virtual addresses) to another set (physical addresses).
• The processor generates virtual addresses while the memory is accessed using
physical addresses.
• Both the virtual memory and the physical memory are broken into pages, so that
a virtual page is really mapped to a physical page.
• It is also possible for a virtual page to be absent from main memory and not be
mapped to a physical address, residing instead on disk.
• Physical pages can be shared by having two virtual addresses point to the same
physical address. This capability is used to allow two different programs to
share data or code.
• Virtual memory also simplifies loading the program for execution by providing
relocation. Relocation maps the virtual addresses used by a program to different
physical addresses before the addresses are used to access memory. This
5.22 Memory and I/O
5.6 DMA
• Direct Memory Access (DMA) means CPU grants I/O module authority to
read fromor write to memory without involvement.
• DMA module controls exchange of data between main memory and the I/O
device.
• Because of DMA device can transfer data directly to and from memory, rather
than using the CPU as an intermediary, and can thus relieve congestion on
the bus.
• CPU is only involved at the beginning and end of the transfer and interrupted
only afterentire block has been transferred.
• The CPU programs the DMA controller by setting its registers so it knows
what totransfer where.
• It also issues a command to the disk controller telling it to read data from the
disk intoits internal buffer and verify the checksum.
• When valid data are in the disk controller’s buffer, DMA can begin. The DMA
controllerinitiates the transfer by issuing a read request over the bus to the
disk controller.
5.24 Memory and I/O
• This read request looks like any other read request, and the disk controller
does notknow whether it came from the CPU or from a DMA controller.
• At that time, the DMA controller interrupts the CPU to let it know that the
transfer isnow complete.
• When the operating system starts up, it does not have to copy the disk block to
memory;it is already there.
• The DMA controller requests the disk controller to transfer data from the disk
controller’s buffer to the main memory. In the first step, the CPU issues a
command to the disk controller telling it to read data from the disk into its
internal buffer.
5.7 I/O
• The method that is used to transfer information between internal storage and
external I/O devices is known as I/O interface.
• The CPU is interfaced using special communication links by the peripherals
connected to any computer system. These communication links are used to
resolve the differences between CPU and peripheral.
• There exists special hardware components between CPU and peripherals to
supervise and synchronize all the input and output transfers that are called
interface units.
Mode of Transfer:
• The binary information that is received from an external device is usually
stored in the memory unit.
• The information that is transferred from the CPU to the external device is
originated from the memory unit. CPU merely processes the information but
the source and target is always the memory unit.
• Data transfer between CPU and the I/O devices may be done in different
modes.
• Data transfer to and from the peripherals may be done in any of the three
possible ways
➢ Programmed I/O.
➢ Interrupt- initiated I/O.
➢ Direct memory access ( DMA).
5.26 Memory and I/O
• If the distance is larger, synchronization timing between more than one channel
becomes more sensitive. A constant clocking signal is used to provide the timing
in parallel communication.
• The signal is sent with the help of a separate wire within the parallel cable. So
we can say parallel interface is synchronous.
Working of Parallel interface
The parallel interface uses the various parallel paths (wires) to transfer many bits
once within the same cable in synchronization with the help of a single clock. The clock
uses these parallel paths and specifies the timing for transmission in the form of a
constant clocking signal.
5.10.5 Exceptions
• The term exception is used to refer to any event that causes an interruption.
Hence, I/O interrupts are one example of an exception.
▪ Recovery from errors – These are techniques to ensure that all hardware
components are operating properly.
▪ Debugging – find errors in a program, trace and breakpoints (only at specific
pointsselected by the user).
▪ Privilege exception – execute privileged instructions to protect OS of a
computer.
5.36 Memory and I/O
5.11.1 USB
• Universal Serial Bus ( USB) is a system for connecting a wide range of
peripherals to a computer, including pointing devices, displays, and data
storage and communications products.
• The Universal Serial Bus is a network of attachments connected to the host
computer.
• These attachments come in two types known as Functions and Hubs.
• Functions are the peripherals such as mice, printers, etc.
• Hubs basically act like a double adapter does on a power-point, converting
one socket, called a port, into multiple ports.
• Hubs and functions are collectively called devices.
• When a device is attached to the USB system, it gets assigned a number
called its address. The address is uniquely used by that device while it is
connected.
Digital Principles and System Design 5.37
Tablet computer: On the tablet, a USB connection is situated in the charging port and
is sometimes USB-C and usually micro USB.
Smartphone: In the form of micro USB or USB-C, a USB port is used for both data
transfer and charging, similar to tablets on smartphones.
USB connector types
There are different shapes and sizes available for the USB connector. Also, there
are numerous versions of USB connectors, such as Mini USB, Micro USB, etc.
Micro-A connector has a greater maximum over mild size. USB 3 micro is more
similar to micro B, but it has better speed as compared to micro B because it
includes an additional collection of pins on the side for twice the wires. Micro
versions are hot-swappable, and plug-and-play like standard USB and micro-
USB is still widely used with electronic devices.
3. USB Type-C: On most modern newer Android smart phones and other USB-
connected devices, a USB Type-C cable is a relatively new type of connector. It
is used for delivering data and power to computing devices. As compared to
other forms of USB connections, USB-C cables are reversible; they can be
plugged either way in the devices, whether they are upside down.
5.11.2 SATA
• SATA is abbreviated as Serial AT Attachment. The name "AT" Attachment was
introduced after the invention of the IBM personal computer in 1984.
• Serial ATA or SATA is a computer bus interface for connecting the storage
disks or drives to the motherboard of computer systems. SATA standards help in
transferring data from hard drives and optical disk drives to computer systems.
• Serial ATA (SATA) was created by the serial ATA working group in 2000.
Serial ATA was introduced to provide various benefits over the previous Parallel
ATA interface, which was announced around the 1980s. In January 2003,
Seagate Barracuda SATA V was the first hard disk drive in the world. In 2008,
the Serial ATA hard drive replaced the parallel ATA in the consumer's desktop
and laptop computers.
• The first version of SATA (SATA 1.0) can easily communicate 1.5 Gbps of
performance to each storage drive within a disk array. In comparison to earlier
ribbon cables which are used with ATA drives, the cable of serial ATA provides
the best airflow in the computer systems and makes the routing easier.
• SATA also uses external hard drives through external SATA. External SATA is
commonly referred to as eSATA.
• eSATA drives are hot-swappable and providing high transmitting speed with no
USB and FireWire issues.
• Fast transmission speed, high performance, and outstanding storage capacity are
the two main characteristics of SATA hard drives.
5.40 Memory and I/O
SATA Cables
The SATA cables are long, and both end-points of the cable are thin and flat.
SATA cables are of different types, but the following two are the main types of
SATA cables:
1. SATA Data Cables: These cables typically have seven pins for transferring
data. These connect the drives to the motherboard of the computer systems. One
end of the SATA cable plugs into the back of the hard drive of the computer
system and the other end plugs into the computer's motherboard.
2. SATA Power Cables: These cables typically have fifteenth pins. These connect
to the power supply.
Other Types of SATA Cables
Some other different types of SATA cables are given below:
1. e-SATA: This cable joins the external devices into our computer systems with a
length ranging from 0.5 - 2 meters long.
2. SATA Bracket: It is a dual-port eSATA expansion bracket which makes our
computer output compatible with the SATA external devices.
3. SATA Bridge: This SATA cable connects the ATA devices to the SATA
motherboard or PCI cards. This interface is a bridge between the SATA devices.
4. Low Profile SATA: It is a quite thin SATA cable with a very simple and low
profile connector. This SATA cable can be used easily with longer graphic
cards.
5. Micro SATA: This SATA cable is used for internal disks and backplane
applications.
6. SATA-SATA: It is a standard data cable which is available in various lengths
and can be used for standard SATA applications.
Revisions of SATA Interface
Following are the three major different revisions of the SATA interface:
SATA I: This interface is formally called SATA 1.5Gb/s. It is the first generation of
SATA, whose speed is running at 1.5 Gigabit per second.
SATA II: This interface is formally called SATA 3Gb/s. It is the second generation of
SATA, whose speed is running at 3.0 Gigabit per second.
Digital Principles and System Design 5.41
SATA III: This interface is formally called SATA 6Gb/s. It is the third generation of
SATA, whose speed is running at 6.0 Gigabit per second.