Get Logic Gates, Circuits, Processors, Compilers and Computers 13th Edition Jan Friso Groote PDF ebook with Full Chapters Now
Get Logic Gates, Circuits, Processors, Compilers and Computers 13th Edition Jan Friso Groote PDF ebook with Full Chapters Now
com
https://ebookmeta.com/product/logic-gates-circuits-
processors-compilers-and-computers-13th-edition-jan-friso-
groote/
OR CLICK BUTTON
DOWNLOAD NOW
https://ebookmeta.com/product/electronics-circuits-amplifiers-and-
gates-second-edition-d-v-bugg/
ebookmeta.com
https://ebookmeta.com/product/death-of-a-bookseller-1st-edition-alice-
slater/
ebookmeta.com
Web Data Mining Exploring Hyperlinks Contents and Usage
Data First Edition Bing Liu
https://ebookmeta.com/product/web-data-mining-exploring-hyperlinks-
contents-and-usage-data-first-edition-bing-liu-2/
ebookmeta.com
https://ebookmeta.com/product/deep-reinforcement-learning-with-python-
with-pytorch-tensorflow-and-openai-gym-1st-edition-nimish-sanghi-2/
ebookmeta.com
https://ebookmeta.com/product/cambridge-english-exam-booster-with-
answer-key-for-advanced-1st-edition-carole-allsop/
ebookmeta.com
https://ebookmeta.com/product/register-based-statistics-registers-and-
the-national-statistical-system-3rd-edition-britt-wallgren/
ebookmeta.com
Tempting Fate Black Shamrocks MC Australia Book 1 A dark
and angsty love triangle romance Bella Faust Kylie Hillman
https://ebookmeta.com/product/tempting-fate-black-shamrocks-mc-
australia-book-1-a-dark-and-angsty-love-triangle-romance-bella-faust-
kylie-hillman/
ebookmeta.com
Jan Friso Groote
Rolf Morel
Julien Schmaltz
Adam Watkins
Logic Gates,
Circuits,
Processors,
Compilers and
Computers
Logic Gates, Circuits, Processors, Compilers
and Computers
Jan Friso Groote Rolf Morel
• •
123
Jan Friso Groote Rolf Morel
Department of Mathematics Department of Computer Science
and Computer Science University of Oxford
Eindhoven University of Technology Oxford, UK
Eindhoven, Noord-Brabant, The Netherlands
This Springer imprint is published by the registered company Springer Nature Switzerland AG
The registered company address is: Gewerbestrasse 11, 6330 Cham, Switzerland
This book is for everyone who wants to
understand how a computer can do such
marvellous calculations, when it is
essentially only constructed of simple logic
gates.
Preface
Computers have revolutionised the world in well within a century. Dozens of com-
puter processors have been built for every inhabitant of this earth, and this number is
rapidly increasing. Most people have little idea of how a computer goes about doing
its job. And there is a reason for it. Computers have been designed such that the in-
ternal complexity is hidden, not only for those that use computers but even for those
who design computer controlled systems, such as hardware engineers, programmers
and maintenance staff.
Are computers complex? The answer is both yes and no. Let us first look into
the reasons why the answer is yes. Computers are constructed with integrated cir-
cuits such as micro-processors. These processors can contain well over a billion
components, such as transistors and resistors, all connected with each other in an
intricate pattern. And against all odds, this number of components is still growing
very rapidly, quickly increasing the complexity of these integrated circuits.
All these systems are man made. This also adds to the complexity as many in-
dependent development teams made their own designs. In the history of computer
design virtually any conceivable idea has been implemented, and traces of many of
these ideas can still be found almost anywhere in computers. The need for back-
ward compatibility makes it hard to remove such ideas. On top of all this hardware
many layers of software have been implemented. This makes computer systems very
complex objects indeed.
But from a different perspective computers are not at all complex. Many of the
essential ideas behind the construction of computers are actually quite straightfor-
ward. The purpose of this book is to give a concise, but precise, description of the
essence of a computer. After finishing this book the reader should in principle be
able to build a computer system from elementary logic components with most of
the features that modern computers have, including an elementary operating system
and a compiler.
The book starts out with the logic components, and-, not-, or-, and nand-gates,
that are constructed from transistors. It is explained how such gates can be used to
implement any logic function over the boolean values true and false given by truth
tables. These are called combinatorial circuits.
vii
viii Preface
Further reading. There are many books written about the structure of computer
systems [24, 25, 30, 29, 32, 22, 13, 21], which generally cover the structure of
computer systems more extensively, or focus on certain aspects, such as circuits, or
assembly programming. This book provides a minimal but complete exposition of
all aspects of a computer system such that the essence of how a computer works can
be understood completely.
Acknowledgements. This book has been written to support the course Computer
Systems (2IC30) at Eindhoven University of Technology, The Netherlands. The
course was previously given by Michael Franssen and Rob Hoogerwoord, and the
book is based on the structure of the course as developed by them.
Thanks go to the following people for assisting us in writing this book. Special
thanks go to Bram Bosch who formally verified many of the circuits, leading to
numerous improvements [8], and Alan Mycroft for his many useful comments com-
ing from proof reading large parts of this book. We are also grateful for the helpful
remarks by Max Crone, Nikola Djurendic, Bas van Geffen, Bas van Hoeflaken,
Quinten van Eijsden, Mohamed Hemza, Anneke Huijsmans, Christine Jacob, Erik
Luit, Sebastiaan Peters, Jeroen van Riel, Anson van Rooij, Richard Verhoeven, Sten
Wessel and Hans Zantema on drafts of this book.
xi
xii Contents
3 Sequential circuits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
3.1 A one-time latch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
3.2 The set-reset flip-flop/set-reset latch . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
3.3 The D-latch/D-flip-flop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
3.4 Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
3.5 Finite state machines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
3.5.1 An example state machine with four states . . . . . . . . . . . . . . . 61
3.5.2 Encoding the state machine . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
3.5.3 Realising the state machine using logic gates and flip-flops . 63
3.6 Random access memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
3.7 Finite state machines to control registers . . . . . . . . . . . . . . . . . . . . . . . 68
3.8 Hardware description languages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
3.9 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
4 An elementary processor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
4.1 The general structure of the processor . . . . . . . . . . . . . . . . . . . . . . . . . 74
4.2 The instruction set . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
4.3 The instruction fetch and the register transfer language . . . . . . . . . . . 81
4.4 The format of machine code instructions . . . . . . . . . . . . . . . . . . . . . . . 83
4.5 Implementing instructions on the processor . . . . . . . . . . . . . . . . . . . . . 85
4.6 Optimisation of the execution of instructions . . . . . . . . . . . . . . . . . . . . 88
4.7 More advanced instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
4.8 Input and output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
4.9 Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
4.10 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
5 Assembly programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
5.1 Labels and comments, EQU and CONS . . . . . . . . . . . . . . . . . . . . . . . . 99
5.2 Arithmetic calculations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
5.3 A timed loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
5.4 Basic data structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
5.4.1 Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
5.4.2 Stacks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
5.4.3 Linked lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
5.5 Memory layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
5.5.1 Allocation dependence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
5.5.2 Relocatable code and data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
5.6 Subroutines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
5.6.1 Saving the return address . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
Contents xiii
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 247
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249
Chapter 1
Basic components and combinatorial circuits
In this chapter we introduce logic gates because they are very useful to describe dig-
ital hardware such as computer processors. This was observed by Claude Shannon1
in his master thesis in 1937 [28]. We show how such gates are constructed using
electronic components, such as transistors, and illustrate how circuits with more
complex functionality can be constructed efficiently from such elementary gates.
In Figure 1.1 we find the symbols for three basic logic gates from which digital
circuits are built. Each logic gate, or gate for short, is a small hardware component
that implements a simple logic function from its inputs to its output. The and and
or gates have two inputs and one output. The not gate has one input and one output.
A truth table defines the relationship between the input and the output of that gate.
A 0 generally means a voltage of 0 V and a 1 represents a higher voltage, for in-
stance 5 V, although today lower voltages, such as 3.3 V, are typical. We discuss the
practical realisation of logic gates and their voltages and current flows later in this
chapter.
From the truth table it is obvious that the and gate has an output of 1 exactly if
both inputs are 1. For the or gate, the output is 1 if at least one of the inputs is 1.
For the not gate the output is 1 exactly when the input is 0. Because the not gate is
a simple gate occurring often it is also written as a single small circle, in particular
when joined to another gate.
Using these three basic gates more complex circuits can be made, for instance
circuits that add or multiply numbers. When gates are connected such that an output
of one gate is never connected to one of its inputs, not even via other gates, the
circuit is called combinatorial. In this chapter we restrict ourselves to combinatorial
1 Claude Elwood Shannon (1916-2001) was a mathematician and an electrical engineer. He
founded the field of information theory, and worked as a cryptanalyst on code breaking and se-
cure communication.
circuits. Chapter 3 deals with sequential circuits where outputs are connected to
inputs.
A simple but important component is a two-way multiplexer. It has three inputs
in1 , in2 and sel and one output out. If the selector sel is 0, the output out equals
in1 and if sel is 1, the output is equal to in2 . The truth table that reflects this is
depicted in Figure 1.2 on the left. The circuit representing this function is given on
the right. Note that there is a not gate just before the lower input of the upper and
gate, drawn as a small circle. Note also that input sel is connected to two input wires.
It is common to connect wires to the inputs of several gates, but there is a physical
limit to the number of gates that a single wire can drive.
Fig. 1.2 The truth table and the combinatorial circuit for a two-input multiplexer
These graphical representations of gates are useful when the circuits are small.
When the circuits become more complex a description in textual form tends to work
better. Therefore, in text we write in1 ∧in2 to represent the output of an and gate.
Alternative notations that one can encounter are in1 ·in2 , in1 ∗in2 and in1 &in2 . The
or gate is denoted as in1 ∨in2 , and also by in1 +in2 and in1 |in2 . The not gate is
denoted as ¬in, but also as in, and !in. The notations with ∧, ∨ and ¬ are more
common in text about logics and are referred to as the conjunction, disjunction,
and negation operators, respectively. The other symbols are more common in the
electronics literature.
1.1 The three basic logic gates 3
Exercise 1.1.1. Using logic notation, give the textual representation of the two-input
multiplexer depicted in Figure 1.2.
Exercise 1.1.2. Consider a circuit with three inputs in1 , in2 and in3 and one output.
Make a truth table in which the output is 1 only if exactly one input is equal to 0.
E.g., input 011 gives output 1, and input 111 produces 0 as output. Draw a circuit
realising this function.
Exercise 1.1.3. Implement an and gate with three inputs and a three-input or gate
using only the basic and, or and not gates. Generalise to an n input and gate and n
input or gate. How many basic gates are necessary? Can you give a proof?
in1 in1
out out in out
in2 in2
The nand gate. The nor gate. The buffer gate.
Fig. 1.3 The nand, nor, and buffer basic logic gates
in1 in1
out out
in2 in2
The xor gate. The xnor gate.
About the time the house was completed, Miss Bellingham, the
generous donor of the thousand dollars, came to Burma to see what
use we had made of the money. She spent a week on Thandaung, to
our great delight and hers. She consented that the building might
bear her name, and we have since called it “Bellingham Home.”
Shortly after we began operations on this hill, public interest in
the place began to be shown. I wrote some letters to the Rangoon
papers, and visitors did likewise. The advantages of the place were
laid before the Government. Officials began to come up on tours of
inspection. The place grew in favor, and it was planned to give
Government sanction to making it into a station. A new road up the
mountain, giving a better grade than the old road, and the cart road
across the plain was metalled. The old travelers’ bungalow on the
hill, that had fallen into decay since the military left the place, was
rebuilt. So the improvement goes on till now. The latest plan
contemplates a cart road running entirely up the mountain, and the
survey of the whole hill into building sites. There is every promise of
this becoming the favorite resort in Burma for the people who seek a
change from the heat of the plains.
In the meantime the scheme has had a good degree of
prosperity, in spite of the fact that it was pioneer in character and
location. The irresponsible gossips continue to attack it, the fearful in
heart who love their bondage to the old order still stand agape as
they see the school continue on its way. The people who have been
beating their way through the world still cry it down. But an
increasing number of people who believe in self-dependence, and
the character it develops, are in great sympathy with this work.
Some who can pay full boarding fees send their children to us. They
have adopted with us the theory that this self-help is to be accepted
as a necessary part of a well-appointed system of education.
There has been a specially significant growth in usefulness
among the girls. They have learned to bake excellent bread, cook
and serve a variety of food in a cleanly and orderly manner, and to
keep the entire house in good taste and comfort. This is realized as
a great accomplishment when one has seen the slovenly, untidy
houses commonly found where the woman in the house does not do
anything to keep the house in order herself, and counts it impossible
that she should do what she chooses to call “coolie’s work.” A
woman like this would not know enough even to instruct good
servants in keeping the house, much less the worthless servants she
can ill afford to keep, whose only qualification is that they are as
incompetent as servants as their mistress is as head of the
establishment. Yet almost universally such women would prefer to
exist in a hovel, and give orders to a miserable servant, rather than
have a decent abode, if they had to sweep, scrub, or dust it with
their own hands. In contrast to these are the girls trained in our
industrial school. They can do all things necessary to keeping a
house, and have almost forgotten that there are any servants in the
world. They have done all this, and at the same time they have been
in school, doing as good work as girls in other schools, where they
depend on servants for even buttoning their clothes.
Our girls are self-respecting young women, far beyond what they
could have been had they not received the advantages in character
that come from self-help in ordinary daily tasks.
The boys have generally profited by the outdoor work. Having
nothing to begin with, it has not been possible as yet to organize the
outdoor work as that within doors. Plans are under way, however, to
develop this branch of the school, hoping for a large industrial plant.
Enough has been done in these four years greatly to encourage
those of us who have sacrificed something in planning and carrying
forward this new feature of industrial mission work. There is to-day
more material advantage in this plant than can be shown in any
institution anywhere that I have been for the money invested. More
has been done in direct school work, for the money invested, than in
almost all the English schools with which I am acquainted. The effect
of the work on the boys and girls under our care has exceeded our
highest hopes. I am sure not one of us would be willing to go back
to the old order of Orphanages. The boys and girls themselves do
not want to return to the old order. The school has met with a
degree of favor from those whose judgment is counted of the
highest value to us, by reason of the fact that they have put money
into the plant under the old order and the new also, that we hardly
dared to hope for. We have also received a bequest of seventeen
hundred dollars with which we have put up a second building. The
patronage of the school by people of means and social standing is
such as to encourage us much. It reveals the fact that the school
meets a want felt most by the people who make a financial success
of life, but see that self-help should be taught to every child
regardless of financial circumstances. These people believe that
indolence, dependence, and slovenly habits are a disgrace, and
honest work in all things is honorable.
Miss Perkins, now in the eleventh year of her continuous service
on the field, has carried on this work for more than a year, being
aided by Miss Rigby, who went to her aid in 1900.
This industrial school was founded to reteach the truth long
since forgotten in Asia that all kinds of household and manual toil
are respectable. The Lord himself was a carpenter, and washed the
feet of his disciples, which many of those who bear his name would
be ashamed to do. The school has run four years without a servant,
and is stronger than when it began. In this it is the only institution
among Europeans in all Asia that is so managed. It is absolutely
unique in this. It promises much usefulness and a large growth. But
if it were closed up to-morrow, it would still have proved by four
successful years that such a plan is possible of successful operation
even in Asia.
While it is not directly a part of mission enterprise, it may be of
interest to some reader to have some account of experiences and
observations in a Burma forest. Some such experiences came to me
in connection with life on and about Thandaung. Nearly the entire
distance from Tomgoo to Thandaung is through a forest reserve of
the Government. Several miles of this forest are made up of the
great trees before mentioned. One variety produces an oil used in
Europe for making varnish. The method of extracting this oil is very
curious. A deep cut is made in the tree near the ground, and in this
cut a fire is built and kept burning until the tree is blackened ten feet
or more from the ground. Then the coals are taken out of the cut,
which has become a sort of cup, into which the oil oozes from the
wound made by the fire on the tender tree. It seems almost cruel to
treat the giant trees in this way. It is astonishing that they survive
and heal over the great blackened scars left on their sides.
Another remarkable thing observed in these forests is the growth
of notable vines and parasites. Here is to be seen a great vine, like
half a dozen grape-vines joined together, climbing high round and
into these splendid trees. The trunk is usually not large, though so
tall. Then high up on this tree a spore of the peepul-tree finds a
lodgment, and sprouts, the leaf upward, the root running downward,
hugging close to the tree as if drawing life from the trunk.
Sometimes the young growth starts a hundred feet from the ground.
As its main root descends it throws outside roots which encircle the
tree, and these roots branch again so the whole trunk is soon
inclosed in a great net, ever tightening. Here is seen a very strange
thing. These roots do not overlap, but grow right into each other
when they come in contact, and the union is made without a trace
or scar. As these meshes of the living net grow, they tighten into a
hug that kills, first the vine and then the tree. Each in turn is
devoured by the great parasite. Its net meantime becomes a solid
wooden shell, reaching to the ground and lifting its crown high
among the other giants; a tree made great by the death of two
others; a tree and vine, each seemingly having as much right to live
as this parasite that preys on other forest life.
Another singular circumstance annually occurs in the forest.
About the end of January a species of great bees, as large as the
American hornet, come from migrations, nobody knows where, and
rest upon the under side of the branches in the crowns of these
great monarchs of the forest, which sometimes rise two hundred
feet from the ground. About this time some varieties of these trees
are in heavy bloom, and no doubt it is this which brings the bees.
They locate on only one or two kinds of trees, and at once begin to
build honeycombs, suspending them from the under side of the limb.
They multiply rapidly, and by March there are sometimes as many as
twenty to thirty swarms on a tree. The honeycombs are sometimes
three feet long, and hang perpendicularly a foot and a half. The
study of these bees is very interesting. They build on the same trees
from year to year.
But the most impressive fact is to observe the method of
collecting the honey. The trees are perfectly smooth, and are often
without a limb for one hundred and fifty feet. The Karens usually
collect the honey, and the Burmese dealers come to the camps to
buy it when first secured, and take much of it away to the towns.
How do they get the honey? The Karens climb up these bare trunks.
But how? Some of them are seven feet thick, and can not be
grasped in a man’s arms so as to enable him to climb. The daring
man drives thin bamboo pegs into the bark of the tree, and goes up
on these. More, he drives in the pegs as he climbs! They are about
eight inches long outside of the small portion imbedded in the bark,
and twenty-two inches apart. So the climber, beginning at the
ground, can only place two or three pegs before he begins his
ascent. In all this perilous climb he never has the use of more than
two of these short projections at once. On these he clings with feet
and legs while he must use both hands in driving a new one. To get
the honey, he must wait till night, and then with material for a torch,
a vessel for the honey, and a rope to lower it, he climbs up into the
darkness and out onto the great branches, where with lighted torch
he drives the bees away and cuts off the well-filled honeycomb, and
lowers it to others on the ground. In this manner he takes all the
honey from a tree. A more daring feat for a small return can hardly
be imagined. And nerves of steadier poise are required to prevent
the destruction of the climber. He receives a dollar and a half for
clearing one tree. Surely a life is regarded of little value among these
people.
CHAPTER XVI
The Present Situation in Missions