Lecture 4: Lecture 4: Intro to Computer Intro to Computer
ArchitectureArchitecture
OrOr
WhatWhat’’s Goins Goin’’ on under the on under the hood….hood….
22
The Uber StackThe Uber Stack
Applications
Middleware
Operating Systems
Computers
Processors Memories Display Components Interconnects
Materials
Physics
HARDWARE
SOFTWARE
How We Interact with How We Interact with ComputersComputers
• Applications
Operating System
Hardware
User
““DigitalDigital””
• DIGITALDIGITAL - - Digital means discrete.Digital means discrete.
• Digital representation is comprised of a limited Digital representation is comprised of a limited number of data points to encode information. number of data points to encode information.
• Most of our electronic devices use Digital Most of our electronic devices use Digital techniques to work with data and informationtechniques to work with data and information
• Since we have a limited number of data points to Since we have a limited number of data points to work with, it means that many representations work with, it means that many representations are are approximationsapproximations of the real thing of the real thing
Analog vs. DigitalAnalog vs. Digital
Analog is continuous, Digital is discrete
The difference between The difference between ““analoganalog”” and and ““digitaldigital””
ANALOG DIGITAL
Analog vs DigitalAnalog vs Digital
Discrete Digital Sampling of an Analog Event
Bits ( = Binary Digits)Bits ( = Binary Digits)
• Internally, all data in a digital device is contained Internally, all data in a digital device is contained in memory locations that are either in memory locations that are either onon or or offoff. .
• Thus everything in memory can be thought of as Thus everything in memory can be thought of as being expressed in being expressed in ““bitsbits””,,
where where on = 1 and off = 0on = 1 and off = 0 a single a single ““bitbit”” can represent only 2 values, can represent only 2 values,
0 or 10 or 1
Binary numbersBinary numbers
• Obviously with Obviously with 11 bit we can only bit we can only represent represent twotwo values values 00 and and 11
• With With 2 bits2 bits we can represent only we can represent only four four differentdifferent values: values: 00, 01, 10, 1100, 01, 10, 11
• With With 88 bits ( bits (otherwise known as a otherwise known as a bytebyte) we can represent ) we can represent 256 values256 values ( 0-255)( 0-255)
NomenclatureNomenclature
• A A BITBIT is a single 1 / 0 position is a single 1 / 0 position
• A A NIBBLENIBBLE is 4 BITS is 4 BITS
• A A BYTEBYTE is 8 BITS is 8 BITS
• A A WORDWORD is a multiple of BYTES eg: 16 bits, 32 is a multiple of BYTES eg: 16 bits, 32 bits, 48 bits, 64bits……….bits, 48 bits, 64bits……….
• Common nomenclature today is to define memory Common nomenclature today is to define memory storage and data capacity in storage and data capacity in BYTESBYTES
More NomenclatureMore Nomenclature
• As computers have become capable of As computers have become capable of processing and storing more data, we have processing and storing more data, we have coined:coined:
• KiloKiloBytes (Thousands)Bytes (Thousands)• MegaMegaBytes (Millions)Bytes (Millions)• GigaGigaBytes (Billions)Bytes (Billions)• TeraTeraBytes (Trillions) –Library of Congress Bytes (Trillions) –Library of Congress
30Tb30Tb• PetaPetaByte (1000 Trillion)Byte (1000 Trillion)• ExaExaByte (Million Trillion)Byte (Million Trillion)
Base 2 (Binary) vs. Decimal Base 2 (Binary) vs. Decimal ComparisonComparison
101055 10 104 4 10 1033 10 1022 10 1011 10 1000
1010nn = = 100,000 10,000 1000 100 10 1100,000 10,000 1000 100 10 1
227 7 2 266 2 255 2 244 2 233 2 222 2 211 2 200
22nn = = 128128 64 32 16 8 4 2 164 32 16 8 4 2 1
Representing Data in the Representing Data in the ComputerComputer
• Internally, everything--data, programs, Internally, everything--data, programs, text, you name it--is represented in bits.text, you name it--is represented in bits.
• With an array of bits, we can represent With an array of bits, we can represent any number or, thru assignment, any any number or, thru assignment, any character so, for example:character so, for example:
• 0011 0000 = decimal 48 = 0011 0000 = decimal 48 = ““HH ””
(256 combinations, 0 to 255) (256 combinations, 0 to 255)
How could we represent letters How could we represent letters for instance? for instance?
For characters we need 26 letters, 10 For characters we need 26 letters, 10 numbers, special marks, etc. About 127 numbers, special marks, etc. About 127 possibilities including upper and lower case possibilities including upper and lower case including control charactersincluding control characters
AsciiAscii is an agreed upon code in which every is an agreed upon code in which every character, numbers, etc. is given a unique character, numbers, etc. is given a unique 8 8 bitbit code (1 byte). code (1 byte).
So we need 4 bytes to represent the word So we need 4 bytes to represent the word ““lovelove””
Good tutorial on BinaryGood tutorial on Binary
http://www.swansontec.com/binary.html
Remember, everything is Remember, everything is represented in bits!represented in bits!
• 2 Bits – 00, 01, 10, 2 Bits – 00, 01, 10, 11 =11 =
• 3 Bits – 3 Bits –
• 4 Bits-4 Bits-
• ..
• ..
• 8 Bits- 8 Bits-
• 16 Bits-16 Bits-
• 24 Bits-24 Bits-
• 4 values4 values
• 8 values8 values
• 16 values16 values
• 256 Values256 Values
• 65,536 Values 65,536 Values or (+/- or (+/- 32,767)32,767)
• 16,777,216 Values16,777,216 Values
What are computers made What are computers made of?of?• Primarily TransistorsPrimarily Transistors
• Invented in 1951, the Transistor is the basic electrical Invented in 1951, the Transistor is the basic electrical building block for all modern electronicsbuilding block for all modern electronics
• Called by many the greatest invention of the 20Called by many the greatest invention of the 20thth century century
• For Digital applications, transistors are packaged in what is For Digital applications, transistors are packaged in what is known as Integrated Circuits (ICs)known as Integrated Circuits (ICs)
• As many as 10+ Billion Transistors can be packaged in a As many as 10+ Billion Transistors can be packaged in a single large IC todaysingle large IC today
Anatomy of a TransistorAnatomy of a Transistor
• Transistors are fabricated using silicon (derived Transistors are fabricated using silicon (derived from quartz) and tiny amounts of impurities such from quartz) and tiny amounts of impurities such as selenium or gallium arsenide to create what is as selenium or gallium arsenide to create what is called a called a ““semiconductorsemiconductor””
• Semiconductors allow us to control the flow of Semiconductors allow us to control the flow of electrical charge (electrons) very precisely. electrical charge (electrons) very precisely.
• Billions of semiconductors can be placed on an Billions of semiconductors can be placed on an integrated circuit using a process called integrated circuit using a process called photolithographyphotolithography
Transistor FunctionalityTransistor Functionality• In various circuits Transistors can be made to:In various circuits Transistors can be made to:
• Amplify or Attenuate electrical signalsAmplify or Attenuate electrical signals• Invert electrical signalsInvert electrical signals• Store electrical voltage valuesStore electrical voltage values• Switch electrical signals off and onSwitch electrical signals off and on
• Transistors can be combined to create logic circuits Transistors can be combined to create logic circuits commonly known as commonly known as ““GATESGATES””
• Gates are packed into Integrated Circuits commonly known Gates are packed into Integrated Circuits commonly known as as ““ChipsChips””
Simple Silicon Semiconductor Simple Silicon Semiconductor DevicesDevices
Intel 4004 Processor Chip circa Intel 4004 Processor Chip circa 19711971
• It could only add and subtract 4 bits It could only add and subtract 4 bits at a time.at a time.
AMD Athlon64 Processor AMD Athlon64 Processor 20042004
Use of Logic Gates in Use of Logic Gates in ComputersComputers• Primary Uses:Primary Uses:
• Switches and logic circuits that can be switched between 0 and Switches and logic circuits that can be switched between 0 and 5 volts. In this way a Switch can signify a 5 volts. In this way a Switch can signify a ““bitbit”” that is a 1 or a that is a 1 or a 00
• Storage of voltage levels equivalent to 0 or 5 volts. In this way Storage of voltage levels equivalent to 0 or 5 volts. In this way a a ““bitsbits”” of memory can be implemented or pixels on an LCD of memory can be implemented or pixels on an LCD display on a laptop can be createddisplay on a laptop can be created
AND and OR GatesAND and OR Gates
NOT GateNOT Gate
By combining gates we can By combining gates we can create useful functions such as create useful functions such as a the ability to store a bit of a the ability to store a bit of informationinformation
• The purpose of a latch is to allow a data The purpose of a latch is to allow a data value to be stored temporarily. So that value to be stored temporarily. So that we can hold it and we can hold it and ““useuse”” it for awhile… it for awhile…like a like a ““bitbit”” of memory of memory
The Von Neumann MachineThe Von Neumann Machine
•
CPU = Central
Processing Unit
MemoryINPUT
OUTPUT
A Typical PC CPU BoardA Typical PC CPU Board
Fetch, Decode, Execute Fetch, Decode, Execute CycleCycle• Computer instructions are stored (as bits) in Computer instructions are stored (as bits) in
memory. To run a program, each memory. To run a program, each instruction is:instruction is:
• Fetched from memory.Fetched from memory.• Decoded (the computer figures out what it Decoded (the computer figures out what it
should do based on the number).should do based on the number).• Then the instruction is executed.Then the instruction is executed.• The speed at which this cycle occurs is The speed at which this cycle occurs is
determineddetermined• by the system clockby the system clock
Cycle TimesCycle Times
• Generally the faster your computer can Generally the faster your computer can get through a fetch-decode-execute cycle, get through a fetch-decode-execute cycle, the faster it will perform.the faster it will perform.
• Cycle times are measured in Cycle times are measured in ““gigahertzgigahertz””, a , a billion cycles per second.billion cycles per second.
• PCs these days reach 3500 Megahertz or PCs these days reach 3500 Megahertz or 3.5 Gigahertz (3 billion cycles/sec)3.5 Gigahertz (3 billion cycles/sec)
MemoryMemory
• Each memory unit has its own Each memory unit has its own addressaddress
• Memory units are organized in Memory units are organized in groups of Bytes (8 bits) or Words groups of Bytes (8 bits) or Words (16, 24, 32, 64 or 128 bits)(16, 24, 32, 64 or 128 bits)
0 1 2 3 4 …………………………………..127 million
Random Access MemoryRandom Access Memory
• The main computer memory is called The main computer memory is called RAM RAM (Random Access Memory)(Random Access Memory)
• It is It is ““randomrandom”” in that one may access any in that one may access any addressable memory unit independently of addressable memory unit independently of any other (and thus in any other (and thus in ““randomrandom”” order). order).
• In almost all modern machines the In almost all modern machines the smallest single addressable amount of smallest single addressable amount of memory is one byte.memory is one byte.
• Memory is measured in Memory is measured in megabytes or megabytes or gigabytes or terabytesgigabytes or terabytes
RAM chips on a Circuit RAM chips on a Circuit boardboard
•
DRAMDRAM
• RAM allows for both reading and RAM allows for both reading and writing in memory. Contrast this writing in memory. Contrast this with with ROMROM (read-only memory). (read-only memory).
• Most RAM is volatile, or Most RAM is volatile, or ““dynamicdynamic””. . When you turn off the power, the When you turn off the power, the contents of RAM is lost.contents of RAM is lost.
• Sometimes one talks about Sometimes one talks about DRAMDRAM which is short for dynamic RAM).which is short for dynamic RAM).
ROMROM
• Read Only MemoryRead Only Memory can only be read from can only be read from• ItIt’’s contents cannot be altered or written over easilys contents cannot be altered or written over easily
• This type of memory is used to hold instructions This type of memory is used to hold instructions that need to always be there and always be the that need to always be there and always be the samesame
• For example, the initial instructions that are For example, the initial instructions that are executed when your PC is turned on which instructs executed when your PC is turned on which instructs the machine to load the machine to load Windows from the disk driveWindows from the disk drive
RegistersRegisters
• Registers are memory locations that Registers are memory locations that are used to facilitate the movement are used to facilitate the movement of data inside a digital computerof data inside a digital computer
• Registers work in conjunction with Registers work in conjunction with the system clock which determines the system clock which determines the speed with which a computer the speed with which a computer fetches and executes instructionsfetches and executes instructions
Basic Registers in a Basic Registers in a computercomputer
• IR – Instruction registerIR – Instruction register
• ACC – Accumulator, used as a ACC – Accumulator, used as a scratchpadscratchpad
• MDR – Memory Data registerMDR – Memory Data register
• MAR - Memory Address registerMAR - Memory Address register
• PC – Program Counter, points to the PC – Program Counter, points to the next instruction to be fetchednext instruction to be fetched
Millionaire Quiz!Millionaire Quiz!
More about the CPUMore about the CPU
•
CPU
MemoryInstruction Register (IR)
Accumulator
Two of many “registers” in the CPU
Machine LanguageMachine Language
• Every computer CPU has its Every computer CPU has its machine machine languagelanguage, the set of instructions it , the set of instructions it knows how to execute. knows how to execute.
• A typical instruction might say, A typical instruction might say, ““get get the contents of a memory location the contents of a memory location and put it in the accumulator registeand put it in the accumulator registerr ”” (perhaps in preparation for adding (perhaps in preparation for adding it to another number).it to another number).
Machine InstructionsMachine Instructions
• Such an instruction would consist of Such an instruction would consist of two numbers:two numbers:
• One would be the address of the One would be the address of the memory unit to be accessed.memory unit to be accessed.
• The other would be the The other would be the operation operation codecode of the instruction - the of the instruction - the (somewhat arbitrary) number that (somewhat arbitrary) number that refers to a unique and particular type refers to a unique and particular type of instructionof instruction
Structure of InstructionsStructure of Instructions
Op code Memory address
Suppose we used 32 bits to encode a machine language instruction.
7 bits 25 bits
7 bits would allow us to have 128 different op codes.
25 bits would allow about 32 megabytes of addressable memory. We might need to fetch more bytes if we had to address a larger range of memory
Information Transfer inside Information Transfer inside the CPUthe CPU• Individual bits in a memory unit are Individual bits in a memory unit are
transferred to the CPU transferred to the CPU in parallelin parallel (all at (all at the same time).the same time).
• This is opposed to This is opposed to seriallyserially (one at at time). (one at at time).
• The same goes for information transferred The same goes for information transferred between registers in the CPU.between registers in the CPU.
• A A 64 bit machine64 bit machine can transfer 64 bits in can transfer 64 bits in parallel.parallel.
The Memory BottleneckThe Memory Bottleneck
• In almost all of todayIn almost all of today’’s machines, the s machines, the machine can perform dozens of machine can perform dozens of instructions in the time it takes to instructions in the time it takes to retrieve one item from memory.retrieve one item from memory.
• One solution is very fast memory in the One solution is very fast memory in the CPU call CPU call cache memorycache memory. A computer . A computer will typically have 1000s of bytes of will typically have 1000s of bytes of cache, as opposed to billions of bytes of cache, as opposed to billions of bytes of RAM.RAM.
Cache MemoryCache Memory
•
CPU
MemoryInstruction Register (IR)
Accumulator
Cache
Cache memory is on the CPU chip.
• manages the instruction-execution cyclemanages the instruction-execution cycle
• FETCH – DECODE – EXECUTEFETCH – DECODE – EXECUTE
• coordinates the activities of other devicescoordinates the activities of other devices
Central Processing UnitCentral Processing Unit
The CPU and Main MemoryThe CPU and Main Memory
Data Bus
Inside the CPUInside the CPU
memoryaddressregister
memoryaddressregister
Inside the CPUInside the CPU
memoryaddressregister
memoryaddressregister
memorydataregister
memorydataregister
Inside the CPUInside the CPU
memoryaddressregister
memoryaddressregister
memorydataregister
memorydataregister
programcounter
programcounter
Inside the CPUInside the CPU
memoryaddressregister
memoryaddressregister
instructionregister
instructionregister
memorydataregister
memorydataregister
programcounter
programcounter
Inside the CPUInside the CPU
memoryaddressregister
memoryaddressregister
instructionregister
instructionregister
memorydataregister
memorydataregister
programcounter
programcounter
arithmeticlogic unit
arithmeticlogic unit
Inside the CPUInside the CPU
memoryaddressregister
memoryaddressregister
instructionregister
instructionregister
memorydataregister
memorydataregister
programcounter
programcounter
accumulator(workregister)
accumulator(workregister)
arithmeticlogic unit
arithmeticlogic unit
Inside the CPUInside the CPU
memoryaddressregister
memoryaddressregister
instructionregister
instructionregister
memorydataregister
memorydataregister
programcounter
programcounter
accumulator(workregister)
accumulator(workregister)
arithmeticlogic unit
arithmeticlogic unitsystem
clocksystemclock
Inside the CPUInside the CPU
1. address of thenext instruction istransferred fromPC to MAR
2. the instruction islocated in memory
1. address of thenext instruction istransferred fromPC to MAR
2. the instruction islocated in memory
FETCH the instructionFETCH the instruction
3. instruction iscopied frommemory to MDR
3. instruction iscopied frommemory to MDR
FETCH the instructionFETCH the instruction
instruction istransferred to and decoded inthethe IR
instruction istransferred to and decoded inthethe IR
DECODE the instructionDECODE the instruction
control unitsends signalsto appropriatedevices to causeexecution of theinstruction
control unitsends signalsto appropriatedevices to causeexecution of theinstruction
EXECUTE the instructionEXECUTE the instruction
• Data Movement Data Movement OperationsOperations– moving data from moving data from
memory to the CPUmemory to the CPU– moving data from moving data from
memory to memorymemory to memory– input and outputinput and output
• Arithmetic and Arithmetic and Logical OperationsLogical Operations– integer arithmeticinteger arithmetic– comparing two comparing two
quantitiesquantities– shifting, rotating shifting, rotating
bits in a quantitybits in a quantity– testing, comparing, testing, comparing,
and converting bitsand converting bits
Types of Processor Types of Processor OperationsOperations
• Program ControlProgram Control– starting a programstarting a program– halting a programhalting a program– skipping to other skipping to other
instructionsinstructions– testing data to testing data to
decide whether to decide whether to skip over some skip over some instructionsinstructions
Types of Processor Types of Processor OperationsOperations
Smaller, Cheaper, Faster!Smaller, Cheaper, Faster!
The Mantra of the The Mantra of the Semiconductor Industry Semiconductor Industry
Clock FrequencyClock FrequencyLead microprocessors frequency doubles every 2 yearsLead microprocessors frequency doubles every 2 years
P6
Pentium ® proc486
38628680868085
8080
80084004
0.1
1
10
100
1000
10000
1970 1980 1990 2000 2010
Year
Fre
qu
ency
(M
hz)
2X every 2 years
Courtesy, Intel
Challenges to Continuing the Challenges to Continuing the TrendTrend
• The thickness (in atoms) between the silicon layers in The thickness (in atoms) between the silicon layers in transistors is getting very thin as we attempt to cram transistors is getting very thin as we attempt to cram more transistors into the same amount of space…so more transistors into the same amount of space…so much so that new materials need to be developedmuch so that new materials need to be developed
• HEAT!! As we put more and more transistors on a HEAT!! As we put more and more transistors on a chip, the ability to cool it and keep it from burning up chip, the ability to cool it and keep it from burning up is increasingly a problemis increasingly a problem
• Noise - As more transistors are packed ever more Noise - As more transistors are packed ever more tightly together, the noise level of the circuits tightly together, the noise level of the circuits increases which affects reliabilityincreases which affects reliability
Quad Core ProcessorQuad Core Processor
4 CPUs on one chip…..
A New Computing A New Computing Paradigm?Paradigm?• Quantum Computing Quantum Computing • Seeks to use the Seeks to use the ““spinspin”” of atomic particles of atomic particles
to implement binary digital systemsto implement binary digital systems
• Molecular computingMolecular computing• Using molecules to hold electrical charges Using molecules to hold electrical charges
instead of using transistorsinstead of using transistors
• Very much in preliminary research….not here yetVery much in preliminary research….not here yet
Read this !Read this !
http://http://computer.howstuffworks.com/computer.howstuffworks.com/
pc.htmpc.htm
Questions?Questions?