hello everybody welcome to the first lecture
which is a lecture on introduction to computer
architecture the aim of this particular lecture
is to first give you an overview of the field
which is computer architecture and then also
to give you an overview of the book that this
particular chapter is based on is the first
chapter of the book computer organization
and architecture published by mcgraw hill
in two thousand fifteen so ah towards the
end of this chapter i will show you the outline
of the way concepts are presented in the book
and how the rest of the lectures will proceed
let us begin by describing what exactly is
computer architecture so the answer is very
very simple its a study of computers so computers
as you know us ah are there everywhere ah
the computer that i am using at the moment
to record this video ah computers are used
in cell phones and cameras ah then nowadays
computers are there in watches so they are
almost there everywhere so lets distinguish
between two kinds of terms that are used for
the study of computers the first is computer
architecture and the second is computer organization
so computer architecture is a view of a computer
that is presented to software designers which
essentially means that it is an interface
or a specification that the software designers
see its a view that they see of this is how
the computer works and this is how they should
write software for it
whereas computer organization is the actual
implementation of a computer in hardware oftentimes
the terms computer architecture and computer
organization are actually confused or computer
architecture is used for both so that is common
but we should keep in mind that there are
two separate terms one of them is computer
architecture and the other is computer organization
so what again is a computer we have computers
everywhere we have a computer on the desktop
over here we have a computer in a laptop or
phone an i pad so we can define a computer
as a general purpose device that can be programmed
to process information and yield meaningful
results so mind you this definition has several
facets to it the first is that a computer
you should be able to program it so circuit
that does a specific action is actually not
a computer
so for example lets say ah that you have a
small thermometers ah on top of the room which
is showing what is the current temperature
thats not a computer even though you know
is showing its temperature on a nice screen
the reason is that this device cannot be programmed
second it needs to be able to process some
information that is given from outside like
you enter some keyboards ah some information
why a keyboard or a mouse its processing that
information it needs to yield meaningful results
so all these three ah facets are important
ah for defining what a computer is so how
does the computer work a computer has a program
which tells the computer what needs to be
done that is because ah the way that we have
defined a computer is that it should be possible
to instruct it to do something so the ah having
a program is point number one second there
needs to be some information that the program
will work on for example lets say you are
trying to you reclick click the photograph
and the photograph has some red eyes so we
are trying to remove ah the red eye effect
in photographs so in this case the photograph
will be the information stored and the program
will be ah the piece of code that is ah working
on the information photographs in this example
and then the finished good looking photographs
is the result
ah so what is the program again its a list
of instructions given to the computer ah the
information store is all the data image images
files videos that a computer might process
and the computer once again is an intelligent
device that can be instructed to do something
on the basis of the instructions it processes
some known information to generate new and
better and meaningful results so let us take
the lid off a desktop computer and see whats
over there so ah if you take if you open a
desktop computer the first thing that you
see over here is a green board and this is
called the motherboard so this is a circuit
board for the rest of the circuits are the
two most important circuits that at least
we are interested in at the moment is the
c p u the central processing unit which is
the main brain of the computer this is the
c p u you would also see a small fan on top
of it the job of the fan is to remove heat
and its the other rectangle over here which
is called the memory of the main memory ah
so this temporarily stores the information
that the c p u the processor is going to use
and the computer processor ah reads data from
main memory processes it and writes it back
we also another very important unit over here
which is the hard disk this also saves information
ah what are the key differences between the
memory in the hard disk ah number one the
memory storage capacity is small ah maybe
in todays day and age it might be like thirty
two gigabytes ah whereas the hard disk storage
capacity might be ten times more or twenty
times more so so we will get into the definition
of how much what is a kilobyte or megabyte
or gigabyte in chapter two but essentially
its a unit of storage so the hard disk can
typically store ten times more data but it
is also significantly slower
the other advantage of a hard disk is that
if i turn the power off all the data in the
memory will get erased whereas the data in
the hard disk will remain so those are the
differences so in this course will primarily
be interested in these three units which are
the c p u the memory and the hard disk but
mind you there are many other ah smaller processors
ah all over the motherboard so will not have
a chance to talk to them but we will have
a chance to at least discuss some of them
in the last chapter in chapter twelve not
at the moment so what does a simple computer
look like ah simple computer like the one
that we looked at right now has this computer
a c p u which does the processing it has the
me memory and a hard disk so the hard disk
maintains all the informations when a computer
is powered off when it is powered on some
of the information comes to the memory then
the computer reads information from the memory
works on it and again writes the results back
ah what more do we need to add to make this
a full functioning system ah we need to add
i o devices input output devices ah this can
include a keyboard a mouse for entering information
and for displaying information it can be a
monitor or a printer ah to display the kind
of information that a computer has computed
it can be other media also like the network
or a u s b port but we will gradually see
what these are at the moment let us confine
ourselves to a very very simple system so
some food for thought
what do you think is the most intelligent
computer so we will have many of these burger
icons throughout the presentations ah so this
will stimulate the student to think a little
bit more so the answer is our brilliant brains
they are clearly the best computers by far
and so how does a computer differs from our
brilliant bring well our brilliant brains
are extremely intelligent they can do very
complicated things they can think about the
meaning of life they are endowed with abstract
thought so basically they can think about
the difference between thought thinking memory
consciousness computers have none of that
they are very very dumb machines all that
they can do is they can add they can multiply
they can subtract but the advantage here is
and thats mind you a very very big advantage
that ah the speed of basic calculations in
a computer is very very high so it might be
doing dumb things ah like addition and subtraction
but its doing them a billion times a second
as a result it becames becomes ultra powerful
whereas even the fastest human beings will
not be able to do even a thousand or a hundred
or even ten additions a second so this essentially
says that we might be capable of very very
abstract and profound thought but we are not
capable of doing a lot of simple things very
very quickly that is where computers excel
well some more advantageous computers never
get tired they never get bored then never
get disinterested whereas we human beings
after some time we get tired almost always
we get bored and disinterested so in a nutshell
computers are ultra fast and yet ultra dumb
thats fine so how exactly do we tell a computer
what needs to be done so what we typically
do is that we write a program and the program
ah is written in any other languages that
you people know it can be c it can be c plus
plus it can be java ah it can pretty much
be any language that students know it doesnt
matter so after that this is compiled into
another program called an executable so the
issue is that computers do not understand
complicated languages such as c c plus plus
or java we only understand a language comprising
of zeros and ones so the language only has
a zero and a one so any kind of a computer
program would just be a sequence of zeros
and ones like the sequence that i am writing
right now
after we have created an executable so by
the way an executable is also called a binary
it is also referred to as a binary once you
have built the executable the executable can
be sent to the processor ah so i need to have
a processor over here and the processor will
execute the program and ah get the desired
output so what exactly is the job of a compiler
the job of a compiler is to compile compile
what ah compiled programs written in a programming
language such as c or c plus plus and convert
it to a sequence of zeros and ones what is
the job of a processor the job of a processor
is to take the sequence of zeros and ones
understand what they are telling it to do
do it and generate some meaningful output
so what can a computer understand so computers
are not smart enough to understand instructions
of the form multiply two matrices or compute
the determinant of a matrix find the shortest
path between mumbai and delhi so they are
simply not that smart that they can do such
problems with such high level of difficulty
they are not even smart enough to answer a
question what is the time right now so what
do they understand they understand very simple
statements add a plus b to get c multiply
a and b a times b to get c so now the question
is that how does this differ from humans humans
can understand very very complicated sentences
in very complicated languages english french
spanish in hindi chinese japanese italian
computers in comparison can understand very
very simple instructions extremely simple
instructions the semantics of all of the instructions
so what is whats the meaning of semantics
is a meaning its a way that instructions are
used as what they stand for so the semantics
of all the instructions supported by a processor
is known as its instruction set architecture
or i s a so this includes the semantics of
the instructions themselves right how the
instructions are written along with their
operands and interfaces with peripheral devices
so just to summarize what is an instruction
set architecture or an i s a it is pretty
much the set of instructions that an architecture
provides or alternatively a processor understands
right it is basically the set of instructions
that are given processor understands and these
are a ah very simple set of instructions add
subtract multiply types but different processors
might understand different kinds of instructions
or the instructions might be written in different
ways thats the reason you will have different
i s as but pretty much the idea is the same
so what would be examples of instructions
in i s a arithmetic instructions add subtract
multiply divide logical instructions and or
a not and data transfer instructions to move
data between the memory and the processor
slash c p u so what are the desirable features
that you want of an i s a and what are the
absolutely critical features that you want
so the most critical feature that you wanted
it needs to be complete what i mean by complete
is that it should be possible it should be
able to implement all the prog programs that
users may want to write so you ah one user
might want to write a program to read ah todays
temperature and send it over the internet
one user might want to ah write a program
so take a photograph or the blackboard and
recognize all the characters so irrespective
of whatever is the program the i s a should
be able to ah in a sense realize all the programs
that users may want to write so we will discuss
this later but this is the notion of completeness
that whatever i want to write it should be
possible on a given processor next the russell
ah needs to be the i s a needs to be concise
in the sense we dont want too many instructions
we dont want ten thousand instructions we
want a relatively smaller set of instructions
what is small is a debatable point but it
ah as if now i s a contained somewhere between
thirty two to a thousand instructions and
different i s as contain a different number
of instructions
and instruction should also be generic in
the sense it should not be too specialized
we should not have an instruction of the form
lets say add fourteen that adds a number with
just fourteen because this instruction is
too specialized its very unlikely that this
instruction will ah be used by all the programmers
or even a large number of programmers so this
is probably a bad idea and we also want the
instructions to be simple what again is simple
is a subjective thing but the instruction
should not be extremely complicated
now lets come to designing an i s a so we
already know that an i s a should be complete
concise generic and simple ah completeness
is a necessary criteria ah being generic and
concise and simple they are very subjective
criteria so we can that there is a massive
leeway there so there are very important questions
that need to be answered like how many instructions
should we have what exactly should they do
how complicated should they be so there are
different paradigms ah with which we can design
instruction set architectures so we can have
what are called risc architectures and we
can have cisc architectures so risc architecture
is called a reduced instruction set computer
or computing architecture here the idea is
that we will have a fewer set of instructions
the instructions themselves will be really
simple such that it is very easy to understand
them inside a processor so arm processors
which are typically used in all the cell phones
are examples of risc processors
ah similarly we have cisc processors which
have a very different paradigm so instead
of having fewer instructions cisc processors
will have a lot of instructions and they will
also be ah as we see on this slide highly
regular meaning that it is possible one instruction
might take one argument another instruction
might take three arguments they might take
multiple arguments operands and implement
very very complex functionalities so this
would be an example of a cisc construction
set and the number of ah examples of such
instruction sets are intel at eighty six intel
processors power most of the desktops and
laptop computers today to summarize whatever
been saying we have two kinds of instruction
sets risc and cisc risc means reduced instruction
set where you you will have few instructions
they are simple and have a very regular structure
the biggest example as of today is the arm
instruction set and arm processes are used
in almost all cell phones and tablets and
smaller computing devices
cisc instruction sets are complicated they
have a lot of instructions and some of them
are complex and intel uses them intel and
a m d processors use them so they have their
ah positives and their negatives and we will
get a lot of chance to discuss them ah as
we go ah as we move through this lecture series
and but we are not in a position right now
to evaluate the tradeoffs so whats the summary
up till now computers are dumb yet ultra fast
machines instructions are basic rudimentary
commands ah used to communicate with the processor
very basic simple commands the compilers job
is to transform a user program written in
a language such as c to the language of instructions
which are encoded in terms of zeros and ones
such that the processor can understand it
the instruction set architecture refers to
all the instructions that a processor supports
including how exactly an instruction works
what are its semantics this means what is
the meaning what does an instruction do how
many arguments does it take and what are the
other features of an instruction so we want
an instruction set to be complete in a sense
it should be possible to write any kind of
program with it
it is additionally desirable if it is also
concise generic and simple but then again
we are getting into the risc verses cisc debate
which has been a very consuming debate in
the computer architecture community ah so
we will thats the reason i said that you would
want a concise generic and simple i s a but
there are other tradeoffs as well we are just
not in a position to discuss the tradeoffs
right now so coming to the outline what we
have studied up till now is pretty much the
language of instructions and what exactly
is an instruction what is an i s a this part
of how to decide if an i s a is complete or
not is optional and students ah who are not
really interested in theoretical computer
science can skip this part and directly move
to the next part
so lets start this part a little bit and then
i will have an arrow which the students will
be able to click when they download the slides
and they would be able to skip the part so
ah this particular subsection of the book
in this particular part of the lecture deals
with the following aspect how do we ensure
that an i s a is complete which means it can
implement all kinds of programs let me give
an example let us assume that we just have
add instructions if you just have add instructions
can we subtract can we compute five minus
three the answer is no but if you just have
subtract instructions can we we can definitely
subtract but can we also add the answer is
yes the reason answer is yes is as follows
that a plus p is equal to so as you see what
i have done is that using subtract instructions
you can implement addition but using addition
in a using add instructions you will not be
able to implement subtraction so clearly subtract
is a much more powerful instruction than addition
so there are some other instructions that
are more powerful than others so what we need
to see is that we need to have a set of instructions
such that no other instruction is more powerful
than the entire set and all programs that
we want to write can be implemented in that
set
so how do we ensure that we have just enough
instructions such that we can implement every
possible program that we might want to write
well ah to answer this we need to take recourse
to theoretical computer science some of this
material ah can be slightly complicated so
ah students who are interested can skip this
part and directly go to slide thirty five
and is the power point is in front of you
all that you need to do is essentially click
the arrow ah over here ah essentially click
this arrow it will take you to slide thirty
five but in the lecture lets just get an overview
of what is this part so ah what we want is
a universal i s a universal i s a is an i
s a which can implement all programs known
to mankind this is the same as implementing
a universal machine for a machine and a processor
are being used synonymously ah the universal
machine has a set of basic actions and each
such basic action can be interpreted as an
instruction so they are more or less the same
thing because after the instruction is an
action when you are asking the processor to
add two numbers we are asking it to do an
action so the fact that i am asking the processor
to do something that is an instruction and
the fact that the processor is doing it is
an action so every instruction is correlated
with every action so in that sense a universal
i s a and universal machine pretty much mean
the same thing so how do we build one such
universal machine that can compute the results
of all kinds of programs well the the answer
to this is attributed to a gentleman for alan
turing whos the father of computer science
and he discovered the turing machine that
is the most powerful computing machine known
to man so his father there is an indian connection
to alan turing his father worked with indian
civil service at the time that he was born
and but again this is disconnected with the
lecture per say
so what is the turing machine its a theoretical
device its not a practical device but at least
theoretically it can compute the results of
almost all the programs that we are interested
in writing what is it its a simple device
very simple device so let us consider an infinite
tape ah a tape is ah as shown in the diagram
it consists of basic cells and each cell contains
a symbol a symbol can be a letter a number
you can define anything a symbol is basically
an element of a certain set where the set
can be the set of letter set of numbers set
of words it doesnt really matter so every
cell contains a symbol and the tape is semi
infinite in the sense it i am sorry the tape
is infinite so the tape extends in both directions
infinitely there is a tape head that points
to a current symbol on the tape it can either
move to the left or to the right in every
ah show in every round it can either move
to the left or to the right there is an additional
structure called a state register which maintains
what is the current state and the current
state is one among a set of finite possible
states so the way that a turing machine works
is as possible and the way it works is encoded
in the action table so we look at the old
state the ah i am sorry we look at the old
state over here what is the old state or the
current state over here and what is the symbol
under the tape head using the old state and
the old symbol we find out the new state so
the new state is written into the state register
we find the new symbol so the current symbol
is overwritten with a new symbol and we move
the tape head one step to either the left
or to the right
so this is an incredible ah machine in the
sense that it might not be obvious to you
but this can implement any program that you
and i are interested in writing so how will
such a simple tape head that can only move
left or right to it well ah lets take a look
at an example then only we will find out how
it works so i am skipping this particular
slide because this summarizes what i just
described about the operation of a turing
machine so lets take a look at a simple example
there are a few more examples in the book
ah with far more details i would advise you
to go to the book and read that part but lets
at least take a look at a very simple example
over here let us assume that we have a number
that is written on the tape of the turing
machine where each cell contains a single
digit and it is demarcated on both sides for
the dollar signs the tape head starts from
the units place and what we want to do is
increment the number by one add one to it
so what we need to do is we need to figure
out two things
one is that what wu what would be the states
that we keep in a state register and how do
we construct the action table well the states
that we want to keep lets have two kinds of
states one and zero the state one basically
means that we need to add one to the current
digit that is under the tape head so you can
think of it as a carry right that one needs
to be added and zero means that nothing needs
to be added so lets have only these two states
one and zero so here is how we would start
out to construct the action table we will
start from the rightmost position with a state
equal to one which means that one needs to
be added if the state is equal to one we replace
whatever number x that is there over here
with x plus one mod ten which means that we
replace nine with zero in the first round
so the new state will be equal to the value
of the carry so since i added one to nine
ah we still have a carry of one so the next
state will be equal to the value of the carry
which is still one and the tape head will
now move over here so the tape head will then
see that it has six under the tape head so
it will come to this line over here replace
six by seven but since there is no carry here
the state will be equal to zero subsequently
the tape head will move to each of these locations
and since the state will be zero ah nothing
needs to be changed and finally the computation
will complete when it hits the dollar sign
over here so what we have seen over here is
an example of how the turing machine can be
used and how it can be used to effect a very
simple computation which is to add one to
a number so this machine looks simple it actually
is simple yet it is extremely powerful we
can solve all kinds of problems starting from
mathematical problems engineering problems
protein folding gains you name it you can
do it the question is how well ah start by
reading the book and then read a book on theoretical
computer science ah any languages in formal
language or any book on formal languages or
automata theory will give you the answer
so you can try using the turing machine to
solve many more kinds of problems so now i
should discuss what is the church during thesis
so during the time that turing was doing his
work there was another mathematician could
alonzo church so both of them alonzo church
also came up with another formalism which
can be used to ah write programs for anything
that we possibly want to write for so together
the thesis is attributed to them what is the
thesis its not a theorem it is essentially
a statement which is said without proof and
it is up to others to find a counter example
but in the last sixty years or so we have
not found a counter example so this charge
during thesis so you can think of a thesis
as a hypothesis the church turing thesis says
that any real world computation can be translated
to an equivalent computation involving a turing
machine so what i can do is that if i have
a program which is a real world computation
i can translate it to exactly the same and
equivalent competition which does exactly
the same on a turing machine
so what do i need to do this in the turing
machine all that i need to do is create a
set of symbols that need to be written on
the tape create a set of states and then populate
the action table that is all that i need to
do to basically create a turing machine for
any possible program so mind you there is
no proof of this is just that we have not
found a problem that cannot be solved on a
turing machine in the last sixty years so
any computing system that is equivalent to
a turing machine is said to be turing complete
and so we will be using this term ah fre frequently
at least as an excuse slides
so now for every problem in the world we can
design a turing machine this the church during
thesis tells us now can we design a universal
turing machine that can simulate any other
turing machine so what is a universal turing
machine so lets call it an u t m so what a
u t m does is as follows that if a turing
machine is given to it and the inputs are
given to it so whatever is written on the
tape is given to it can it produce an output
the output that the original turing machine
would have produced can it in a sense simulate
the turing machine and simulate its action
table all of its actions and produce the output
to the original turing machine would have
produced if we can design such a machine we
will call it the universal turing machine
or (Refer Time: 37 :00) the u t m and the
u t m it unit is a truly universal machine
because every program every program can be
mapped to a turing machine and if the turing
machine can run on a universal turing machine
we basically have a universal machine that
can produce the results for any program so
the question is why not the logic of a turing
machine is really simple what do we do we
read the current state and the symbol that
is pointed to by the tape head update take
it then consult action table change the current
state write a new value in the tape write
overwrite the ah earlier symbol if required
and then move the tape head left or right
if this is all that needs to be done a u t
m or universal turing machine can easily do
this it can take a turing machine as input
and then easily simulate it a u t m needs
to have its own action table state registerent
and a tape to simulate any arbitrary turing
machine but thats not very hard to do and
definitely some of you who are listening to
this video can take a crack at doing this
its not that ah very hard at all so where
do we stand right now we stand at this point
where we know from the church turing thesis
that given every program given any program
we can make it during machine ah to implement
the logic of the program and given inputs
a turing machine and provide the output
so basically given any program or any problem
that we want to solve we can always create
a turing machine for it and we have a universal
turing machine which given the turing machine
and the input ah we will be able to produce
the meaningful output so the universal turing
machine by itself is a computer which can
be programmed how is it being pre told what
to do essentially the turing machine is that
is being given as input is telling that turing
u t m what to do and the tape of this turing
machine has the information ah that needs
to be processed and its the job of the u t
m to simulate the turing machine that is being
given to it and generate meaningful output
so how does a universal turing machine work
well its very simple so it has a generic action
table which is the action table of the u t
m it has a generic state register and it has
its tape head on the tape it has the action
table of the turing machine that it is simulating
called the simulated action table it simulates
the state register of the turing machine that
it is ah simulating so it has a simulated
state register it also simulates the tape
of the turing machine that it is simulating
plus its plus it has its own ah temporary
symbols that it uses so we can refer to the
tape and a temporary symbol area the work
area so this is pretty much how you would
design a universal turing machine and it is
fairly simple to do so
so how exactly is this related to a modern
process the way it is related is actually
very simple and very obvious the generic action
table that you have so what exactly is it
doing it is finding out that what does the
simulate a turing machine want to get done
and it is doing it so we can think of the
generic action table as the c p u as the processor
which is a general purpose computing device
you give it instructions the processor will
give you meaningful results the work area
the work area is pretty much the tape of the
simulated turing machine plus ah an area where
you can keep some temporary data and symbols
is can be referred to the data memory but
this is where contains all the information
the simulated action table which tells the
u t m what needs to be done essentially contains
all the instructions so that we can think
of it as the instruction memory and the simulated
state register is basically telling you that
at what point are we in the simulated turing
machine and what needs to be done next so
we can think of this as a program counter
so these are essentially the four basic elements
of any computing system
let me go over there once again the c p u
is pretty much the brain of the system its
a generic computing device were given an instruction
it does whatever its told to do the instructions
pretty much come from the instruction memory
which holds all the instructions and ah the
instructions work on the data so they come
from the data memory and we also need to know
that given a certain instruction ah of what
do we need to do next right in a given the
current instruction that we are doing what
exactly do we need to do next and what should
be the behavior of the next few instructions
and this can only be done by having some kind
of a storage area to at least save the fact
that where exactly are we there inside the
program and the pretty much like the current
state and this ah in a modern processor is
called a program counter and this concepts
so mind you this ah you can take a look at
the book at the relevant chapter and you can
see a better mapping between a universal turing
machine and these concepts so i am just presenting
a very very high level view out here the job
of a program counter is basically to indicate
to the hardware as well as to the software
what exactly is the point in the program at
which the processor is currently there so
think of a program and the program program
counter is typically abbreviated as p c so
it holds for which point in the program are
we currently there at and it cont continuously
keeps changing as the program keeps executing
so it keeps on changing its position so the
simulated state register has sort of become
the program counter ah in a practical implementation
so you have not understood possibly most of
the theoretical aspects of this here is the
important takeaway point which will also do
summarized in the next slide that from a theoretical
device we have created a practical device
with pretty much cutting down the theoretical
device into multiple chunks and assigning
a practical device to each chunk so the generic
action table may merit the c p u the simulated
action table we merit the instruction memory
which has all the instructions the state register
we merit the simulated state register we made
that the program counter or the p c so what
this essentially tells us is that where exactly
are we they are inside a program and ah the
data memory ah pretty much tells us that what
is the data that we need to work on
for all of those who skip the theoretical
part welcome back so the computer that we
have designed ah with you know after getting
inspired from a theoretical device called
a turing machine so for those who skip the
discussion on theoretical devices a turing
machine is a theoretical device which inspired
a practical device the practical device being
the modern computer so the modern computer
has certain components ah so the components
are the c p u or the central processing unit
whose job is to read instructions interpret
them and execute them so it has an arithmetic
unit so the arithmetic unit ah the job of
that is to add subtract multiply divide it
has a control unit to pretty much run ah programs
with if statements and for loops it has a
program counter which says which line of the
program we are currently executing so a small
animation over here to visually show what
a program counter is like so it points to
a certain instruction that we are currently
executing
we have a program which is the physical set
of instructions in the instruction memory
and we have the data in the data memory so
what again are the elements of a computer
ah lets just go through so the memory is an
array of bytes we will discuss what exactly
the byte ah byte is in the next chapter but
we can think of it as a unit of information
so the pro memory is a large array of bytes
in that it contains the program which is a
sequence of instructions we can maybe divide
the memory into two types instruction memory
and data memory
the program data which is the variables that
you use the constants that you use the files
that you work with are all there in the program
data memory so this is the memory part the
program counter points to a given instruction
in a program after executing an instruction
you move to the next instruction and just
in case you have a f like in c e a of s statement
in some languages have a go to statement so
this so at that point the processor jumps
to a new point in the program and the program
counter reflects that finally you have the
c p u or the central processing unit which
contains all the execution units and the program
counter
so let us now design an i s a which is turing
complete for those who missed the theoretical
part what this means is that the i s a is
equivalent to a turing machine or it can be
in other words you can say that it can be
used to implement all kinds of programs so
surprisingly a single instruction just one
instruction is during complete in a sense
i can write a program with it and in fact
i can write all kinds of programs with it
so this instruction is s b n subtract and
branch is negative so ah let me maybe slightly
ah digress and tell the readers what exactly
an s b n is so consider that you want to add
two numbers a plus b and assume the variable
temp initially has zero so the v that an s
b n instruction works is as follows
so what an s b n does is that it essentially
subtract b from a so it compute a is equal
to a minus b and if the result is negative
now if the result is negative it will go to
the line number that is mentioned over here
otherwise the program will go to the next
instruction so in this case what we do is
if we assume temp is zero so what we are essentially
computing is temp is equal to zero minus b
so irrespective of the outcome we from instruction
one we come to instruction two and here again
we compute a is equal to a minus temp which
is pretty much equal to a plus b
so in this case we are adding a plus b width
s b n instruction and we can assume that the
next instruction is exit so in both cases
you you respected the result being positive
or negative we just leave the program so the
very very surprising thing which also can
be proven is that this simple instruction
can be used to implement all kinds of programs
why would you want to or not want to do it
lets discuss later so lets discuss one more
example which is to add the numbers from one
to ten a simple arithmetic ah se progression
series is being added so lets assume that
the following variables have the following
values to begin with one as the name suggests
contains one index contains ten and the sum
is zero so the we that we would essentially
write a program to add numbers from one to
ten is actually very easy in such kind of
an instruction set ah it is all that it requires
is only six lines and here is how it works
so we take a variable temp and subtract it
with itself so temp is equal to temp minus
temp the temp is equal to zero irrespective
of the outcome we go to instruction two there
we compute temp is equal to zero minus index
or temp is minus one times index then we come
to the third line where we add some plus equal
to the index so this is same as the addition
trick that we showed in the last slide we
are essentially computing sum is equal to
sum plus index using these three lines and
mind you here irrespective of the outcome
from three we go to four
then what we do is that we subtract one from
the index we are essentially adding ah some
plus equal to ten then some plus equal to
nine some plus equal to eight and in that
fashion so we subtract one from index and
if we see that it has become negative means
it is time to get out of the loop so we just
jump and we come here to the exit point otherwise
we do the same trick we set temp to zero and
we subtract one from temp so since the outcome
is known it is minus one this essentially
acts like a go to statement where we go to
statement number one and we jump from here
to here so we have also implemented a for
loop where we loop for we loop till ah the
exit condition is satisfied once the exit
condition is satisfied we come out so what
is the final outcome of this piece of code
is that we are doing an addition in this line
see initially sum is zero so first we do some
plus equal to ten then we decrement index
so in the next iteration we do some plus equal
to nine and similarly we just keep going keep
going till we have some plus equal to zero
so ultimately sum contains the sum of all
the numbers from zero till ten and this is
exactly what we wanted to compute so we have
written our first simple program using ah
a very very simple instruction using only
one instruction is being subtractive negative
and within six lines you have achieved quite
a bit
so such kind of method or a style is also
called low level programming where instead
of using any high level primitive you have
just used very simple machine instructions
so this is also the first assembly program
that we have written so what is an assembly
program it is well its the kind of low level
program that we just wrote and ah as you can
see its very easy to actually simulate this
run this on a computer so ah we are all set
when it comes to writing such simple instruction
based programs
now the question is that this exercise was
partly theoretical also in modern i s as you
will have multiple instructions you will have
separate instructions for add subtract multiply
divide in our logical instructions for and
or and not you will have move instructions
to transfer values between memory locations
and you will have branch instructions to move
to new program locations like implemented
go to as we did in the last slide based on
the values of memory locations you will have
all kinds of branch instructions to implement
if statements for loops while loops since
all
finally we look at the design of practical
machines ah so how exactly would we extend
our theoretical results to practical results
so there are two kinds of ah machine categories
so one practical machine is known as the harvard
architecture say in this we have the c p u
we have a separate data memory and a separate
instruction memory and once the results are
computed they are communicated to input output
i o devices such as a monitor or a printer
and we can see the results the other is a
one neumann architecture where the data if
it is you know almost the same it is just
the data and instruction memory is fused into
one thats all thats the only difference
so whatever we assumed up till now that the
memory is assumed to be one large array of
bytes a byte is a unit of information we will
discuss it in detail ah in the next chapter
but if you assume such a large structure the
main problem that comes is that larger is
a structure slower it is so thats the reason
i mean we need to introduce a small concept
here but we will have a lot of opportunities
to discuss this in detail in great detail
so we want to introduce a small array of named
locations called registers which are there
inside the c p u itself so it is very fast
so our model of computing would be like this
that if you have the c p u will be small array
of registers inside it so most of the data
will be coming from the array of registers
mainly because we tend to use the same data
again and again over the small same window
in time and whenever a data is not there in
registers we can read it from memory put it
in registers work on it from register to register
the very fast and once we dont have any more
space we can write it back to memory and then
again read something else from memory so memory
is large and slow the set of registers are
small and fast so typically ah we will have
somewhere between ah eight to sixty four registers
and this makes ah accessing in ah the set
of registers extremely fast and the reason
that this paradigm works is because accesses
exhibit locality which means that you sort
of tend to use the same kind variables same
variables actually frequently in the same
window of time you keep them in registers
you can very quickly access them you dont
have to access a large and slow structure
like memory
so the users of registers of the name storage
ah locations is as follows that we read them
from memory to the set of registers using
load instructions we do whatever we want to
do with them ah with our arithmetic and logical
operation set of processor supports
finally data is stored back into their memory
locations so its a simple example over here
so it is a tradition to write registers as
r one r two r three and so on so here what
you see is a register r one we are reading
something from every location b into register
r one we are reading something from memory
location c into register r two then we are
adding the contents of the two registers saving
it in r three and again we are saving the
contents of r three in memory so of course
we can write a much bigger program where we
read in more locations into more registers
and then ah do a lot of arithmetic operations
on registers so this will ensure that programs
run really fast and just to recapitulate if
we have the c p u over here and the set of
registers the set of registers are very fast
so whatever we want to read comes from memory
to the registers and we operate on the register
that is typically the case and then again
when you want to get in something else from
memory we write back the value back to memory
so what does a new machine look like right
now well is the same one neumann architecture
only with registers inside the c p u so what
is left the row ahead so what we have done
in this small lecture is that we have derived
this structure of a computer processing unit
from theoretical fundamentals from extremely
theoretical ah arguments we have sort of derived
what a computer should look like so one is
it needs to have a c p u which is the brain
of the computer which pretty much runs all
the instructions we need to tell have a program
counter to tell us where we are in the current
program which instruction we are executing
we need to have storage locations such as
registers and memory and finally we need input
output devices like mice or keyboards or monitors
printers
so we learned a lot about the instruction
set architectures which is basically the link
between hardware and software in the sense
that software is written in c or c plus plus
or java or some such language the compiler
converts it to the language that the processor
can understand which is a set of instructions
then the set of instructions are sent to the
processor which is implemented in hardware
such that the results can be generated and
we display to the user via i o devices
so once again the i s a is an interface between
hardware and software so what we shall do
is we shall first look at the software aspect
of the i s a and how to write low level programs
using processor instructions called assembly
programs then we shall look at how to implement
the i s a by actually designing a processor
from scratch then we look at making the computer
more efficient by designing fast memory and
storage systems and it chapter eleven its
not exactly the end but one chapter before
the end we will also look at this interesting
field of multi process where multiple processes
are used to achieve a common objective or
a common goal so we will look at all of that
ah during the course of this book
so what is the road map of the course the
road map of the course is simple that we subsequently
take a look at the language of bits which
is pretty much ah what we can do ah with bits
and bytes and how to represent information
in zeros and ones we will study three kinds
of low level assembly languages to program
processers one is arm assembly mainly for
arm processors used in phones
we look at a generic assembly language that
we will design from scratch then we shall
look at x eighty six assembly the assembly
language use in intel and a m d processors
the middle half of the course we will look
at processor design where processor design
looks at well many things we look start from
the building blocks gates registers and memories
to look at how ah basic ah logic gates and
how registers are made how memories are made
we look at all of that from the circuit point
of view and then we will have slides on how
to add subtract and multiply numbers computer
arithmetic
and then design processors in chapter eight
and nine ah so we will start with simpler
processor designs and move into more complicated
once after designing a simple processor we
look at designing a larger system a more complicated
memory system a system with many many processes
multi processing systems and also integrate
i o devices and storage devices so this is
pretty much the overview of the book which
is divided into twelve chapters we just covered
chapter number one so we have eleven more
to go
thank you
