Difference between revisions of "CSC103: DT's Notes 1"

From dftwiki3
Jump to: navigation, search
Line 1,014: Line 1,014:
 
having a conversation is an ultra-logical being: a robot, who is not fully aware of the subtleties of the art of (human) conversation:
 
having a conversation is an ultra-logical being: a robot, who is not fully aware of the subtleties of the art of (human) conversation:
 
<br />
 
<br />
<center><videoflash>REuNQvcN8tg?t=7m10s</videoflash></center>
+
<center><videoflash>REuNQvcN8tg</videoflash>
 +
<br />(advance the movie to 7 minutes and 10 seconds)<br /></center>
 
<br />
 
<br />
  
Line 1,022: Line 1,023:
  
 
# we  give a number to each student in the class, starting with 0 (in computer science we always like to start with 0 when we count) for the student who is closest to the left front corner of the room.
 
# we  give a number to each student in the class, starting with 0 (in computer science we always like to start with 0 when we count) for the student who is closest to the left front corner of the room.
# we give the number to the neighbor of Student 0, and keep giving numbers to everybody, in a logical way, until everybody in class has a number.
+
# we give the number 1 to the neighbor of Student 0, and keep giving numbers to everybody, in a logical way, until everybody in class has a number.
# we introduce a new number and sentence combination.  
+
# we introduce new number and sentence combinations to our code:  
  
 
   30  Start with Person...
 
   30  Start with Person...
Line 1,031: Line 1,032:
  
 
# pick the first person in the class (the one associated with Number 0).
 
# pick the first person in the class (the one associated with Number 0).
# say a few mondane sentences to this person ("hello")
+
# exchange a few sentences to this person ("hello")
# move to the next person
+
# move on to the next person
 
# repeat the same conversation with this person.
 
# repeat the same conversation with this person.
  
Line 1,047: Line 1,048:
 
   04: 20 00    ''(Go back to Line 00)''
 
   04: 20 00    ''(Go back to Line 00)''
  
So now, even though this simple game is far from sophisticated or even fully functional, it should illustrate the principle that are at play when a processor executes a program that resides in memory.  We explore this in the next section.  By the way, if while reading the last ''algorithm'' shown above you thought to yourself "Hmmm... something strange is going to happen when we reach the last student in the class...", then you have a very logical mind, and Yes, indeed, you are right, our algorithm is not quite correct.  But it has allowed us to get the idea of what's ahead of us.
+
So now, even though this simple game is far from sophisticated or even fully functional, it should illustrate the principles that are at play when a processor executes a program that resides in memory.  We explore this in the next section.  By the way, if while reading the last ''algorithm'' shown above you thought to yourself "Hmmm... something strange is going to happen when we reach the last student in the class...", then you have a very logical mind, and Yes, indeed, you are right, our algorithm is not quite correct.  But it has allowed us to get the idea of what's ahead of us.
  
  
Line 1,057: Line 1,058:
  
  
We are very close to understanding how the processor runs programs.  We have seen that computers work with electricity, and that information is coded as 0s and 1s.  We refer to an information cell that contains a 0 or a 1 as a ''bit''.    The memory is a collection of boxes that contain bits.  We refer to these boxes as ''words'', or  ''Memory words''.
+
We are very close to looking into how the processor runs programs.  We have seen that computers work with electricity, and that information is coded as 0s and 1s.  We refer to an information cell that contains a 0 or a 1 as a ''bit''.    The memory is a collection of boxes that contain bits.  We refer to these boxes as ''words'', or  ''Memory words''.
  
 
Now is a good time for  a bit of magic!  The magic requires building a simple circuit with AND and NOT gates, as shown below:
 
Now is a good time for  a bit of magic!  The magic requires building a simple circuit with AND and NOT gates, as shown below:
Line 1,066: Line 1,067:
 
You may want to spend the time building it up with our [http://tinyurl.com/103applets| circuit simulator].  
 
You may want to spend the time building it up with our [http://tinyurl.com/103applets| circuit simulator].  
  
When you have your circuit built, why don't you turn the power on and activate the two inputs (on the left) randomly, and when you are done, bring the two inputs back to 1 1, i.e. both  red.  Observe the output.  Is it red?  black?  Anyhow, activate the inputs again, randomly, bringing them back to 1 1 (red red) at the end of your experiment.  Chances are the output will be different from the last time you stopped.  This is pretty amazing, if you think about it.  We are using logic circuit, gates that implement the truth table of mathematically immutable laws, the laws of logic, but this circuit that we have built does not always output the same information, even when the two inputs are identical.  
+
When you have your circuit built, why don't you turn the power on and activate the two inputs (on the left) randomly, and when you are done, bring the two inputs back to 1 1, i.e. both  <font color="red">red</font>.  Observe the output.  Is it red?  black?  Make a note of it.  Now activate the inputs again, randomly, bringing them back to 1 1 (red red) at the end of your experiment.  Chances are the output will be different from the last time you stopped.  This is pretty amazing if you think about it.  We are using logic circuit, gates that implement the truth table of mathematically immutable laws, the laws of logic, but this circuit that we have built does not always output the same result, even when the two inputs are identical.  
  
 
Below is an image of the same circuit with a different output:
 
Below is an image of the same circuit with a different output:
Line 1,076: Line 1,077:
 
When you play some more with this circuit you will discover that what it does is remember which input is the last one you set to 0.  If the last input that was 0 before you brought both of them back to 1 1 is the top input, then the output will be 1 (red).  If the last input that was 0 is the bottom one, then the output will be 0 (black).
 
When you play some more with this circuit you will discover that what it does is remember which input is the last one you set to 0.  If the last input that was 0 before you brought both of them back to 1 1 is the top input, then the output will be 1 (red).  If the last input that was 0 is the bottom one, then the output will be 0 (black).
  
This circuit has '''memory'''!  That's magic.  We are using purely combinational gates, gates that have no memory whatsoever in them, but by creating a loop (look for the figure 8  in the logic diagram above) with the wiring, we create a ''feedback'' loop that helps information cycle around the loop.  We won't study this more, as it is beyond the scope of our study, but if you are interested in this circuit, it is refered to in digital design as a ''flipflop''.  The idea is that it behaves like a ''scale'' with two platters to weigh produce.  The scale can be tilting left, or tilting right, and remains stable in that state until one of the inputs is activated.  That's the idea of a digital flipflop.  We are in the presence of a '''bit'''!
+
This circuit has '''memory'''!  That's magic.  We are using purely combinational gates, gates that have no memory whatsoever in them, but by creating a cycle (look for the figure 8  in the logic diagram above) with the wiring, we create a ''feedback'' loop that helps information cycle around the loop.  We won't study this more, as it is beyond the scope of our study, but if you are interested in this circuit, it is referred to in digital design as a ''flipflop''.  The idea is that it behaves like a ''scale'' with two platters to weigh produce.  The scale can be tilting left, or tilting right, and remains stable in that state until one of the inputs is activated.  That's the idea of a digital flipflop.  We are in the presence of a memory '''bit'''!   Bits in computers are implemented
 +
with similar circuits.
  
 
<br /><center>[[Image:animatedScale.gif]]</center>
 
<br /><center>[[Image:animatedScale.gif]]</center>
Line 1,119: Line 1,121:
 
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;+-------------+
 
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;+-------------+
 
   
 
   
It's a long structure made up of words.  Words are numbered, from 0, to a large number, which is actually equal to the size of the memory, in increments of 1.  For example, when you read the sticker for a computer on sale at the local store, it may say that the computer sports 4 Gigabytes of RAM.  What this means is that the memory, the ''Random Access Memory'' (RAM), is comprised of words containing numbers, the first one associated with a label of 0, the last one with a label (almost) equal to 4,000,000,000.  By the way, ''Giga'' means billion, ''Mega'', million, and ''Kilo'', a thousand.
+
It's a long structure made up of binary words.  Words are numbered, from 0, to a large number, which is actually equal to the size of the memory, in increments of 1.  When you read the sticker for a computer on sale at the local store, it may say that the computer contains 4 Gigabytes of RAM.  What this means is that the memory, the ''Random Access Memory'' (RAM), is comprised of words containing numbers, the first one associated with a label of 0, the last one with a label (almost) equal to 4,000,000,000.  By the way, ''Giga'' means billion, ''Mega'', million, and ''Kilo'', a thousand.
  
 +
Now that we are more familiar with the memory and how it is organized, we switch to the processor.
 +
<br />
 
{| style="width:100%; background:#FFD373"
 
{| style="width:100%; background:#FFD373"
 
|-
 
|-
Line 1,128: Line 1,132:
  
 
Before we figure out what kind of number ''code'' the processor can understand, let's talk for an instant about the role of the processor relative to the memory.  The processor is a machine that constantly reads numbers from memory.  It normally starts with the word stored in the cell with label 0 (we'll say the ''memory cell at Address 0''), reads its contents, then moves on to the next word at ''Address 1'', then the next one at ''Address 2'', and so on.  In order to keep track of where to go next, it keeps the address of the cell it is going to access in a special word it keeps internally called '''Program Counter''', or '''PC''' for short.  PC is a special memory word that is '''inside''' the processor.  It doesn't have an address.  We call such memory words when they are inside the processor '''registers'''.   
 
Before we figure out what kind of number ''code'' the processor can understand, let's talk for an instant about the role of the processor relative to the memory.  The processor is a machine that constantly reads numbers from memory.  It normally starts with the word stored in the cell with label 0 (we'll say the ''memory cell at Address 0''), reads its contents, then moves on to the next word at ''Address 1'', then the next one at ''Address 2'', and so on.  In order to keep track of where to go next, it keeps the address of the cell it is going to access in a special word it keeps internally called '''Program Counter''', or '''PC''' for short.  PC is a special memory word that is '''inside''' the processor.  It doesn't have an address.  We call such memory words when they are inside the processor '''registers'''.   
 +
 +
;Definition
 +
: A ''register'' is a memory word inside the processor.  A processor contains only a handful of registers.
  
 
The processor has three important registers that allow it to work in this machine like fashion: the '''PC''', the '''Accumulator''' (shortened to '''AC'''), and the '''Instruction Register''' ('''IR''' for short).  The PC is used to "point" to the address in memory of the next word to bring in.  When this number enters the processor, it must be stored somewhere so that the processor can figure out what kind of action to take.  This holding place is the '''IR''' register.  The way the '''AC''' register works is best illustrated by the way we use a regular calculator.  Whenever you enter a number into a calculator, it appears in the display of the calculator, indicating that the calculator actually holds this value somewhere internally.  When you type a new number that you want to add to the first one, the first number disappears from the display, but you know it is kept inside because as soon as you press the = key the sum of the first and of the second number appears in the display.  It means that while the calculator was displaying the second number you had typed, it still had the first number stored somewhere internally.  For the processor there is a similar register used to keep intermediate results.  That's the '''AC''' register.
 
The processor has three important registers that allow it to work in this machine like fashion: the '''PC''', the '''Accumulator''' (shortened to '''AC'''), and the '''Instruction Register''' ('''IR''' for short).  The PC is used to "point" to the address in memory of the next word to bring in.  When this number enters the processor, it must be stored somewhere so that the processor can figure out what kind of action to take.  This holding place is the '''IR''' register.  The way the '''AC''' register works is best illustrated by the way we use a regular calculator.  Whenever you enter a number into a calculator, it appears in the display of the calculator, indicating that the calculator actually holds this value somewhere internally.  When you type a new number that you want to add to the first one, the first number disappears from the display, but you know it is kept inside because as soon as you press the = key the sum of the first and of the second number appears in the display.  It means that while the calculator was displaying the second number you had typed, it still had the first number stored somewhere internally.  For the processor there is a similar register used to keep intermediate results.  That's the '''AC''' register.

Revision as of 18:43, 28 September 2013

--© D. Thiebaut 08:10, 30 January 2012 (EST)



This section is only visible to computers located at Smith College













.