0% found this document useful (0 votes)
29 views

02 Chapter03 Computer Architecture

Uploaded by

Tasuki Kobayashi
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views

02 Chapter03 Computer Architecture

Uploaded by

Tasuki Kobayashi
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 90

Objectives

• Learn why you need to understand how computers


work
• Learn what a CPU is, and what it is made of
• Learn how digital logic circuits are constructed
• Learn the basic Boolean operators
• Understand how the basic logic gates operate and
are used to build complex computer circuits
Connecting with Computer Science 2
Objectives (continued)
• Learn the importance of von Neumann architecture

• Understand how the computer uses memory

• Learn what a system bus is and what its purpose is

• Understand the difference between memory and


storage

Connecting with Computer Science 3


Objectives (continued)
• Be able to describe basic input/output devices

• Understand how a computer uses interrupts and


polling

Connecting with Computer Science 4


Why You Need to Know About...
Computer Architecture
• Computer: hardware designed to run software

– Purpose: accomplish desired tasks

• Professional’s need: understand logical connection


between hardware and software

• Computer architecture: organization of hardware


components into a computer system

Connecting with Computer Science 5


Inside the Box
• Computer system: an external view
– Monitor
– Keyboard and mouse
– Computer case
• CPU (central processing unit)
– Resides in case on main board or motherboard
– Computational center served by all other parts
– Touch point for the study of computer architecture

Connecting with Computer Science 6


Connecting with Computer Science 7
Connecting with Computer Science 8
PCI (Peripheral Component Interconnect)
The PCI bus came in both 32-bit (133MBps) and 64-bit versions
and was used to attach hardware to a computer. PCI has been
replaced with PCI Express.
AGP (Accelerated Graphics Port)
is an advanced port designed for Video cards and 3D accelerators.
IDE (Integrated Drive Electronics)
is a standard electronic interface used between a computer
motherboard's data paths or bus and the computer's disk storage
devices.
EIDE (Enhanced IDE)
EIDE supports data rates from 4 and 16.6 MBps.
Connecting with Computer Science 9
The CPU
• The CPU is the computer
– Contains digital components that do processing
– Fundamental component: transistor

• Transistor
– Electronic switch accommodates binary values
– Millions of transistors per chip
– Organized into a higher level called a circuit
Connecting with Computer Science 10
The CPU (continued)
• Four basic functions: Adding, Decoding, Shifting,
Storing

• Four corresponding transistor circuits


– Adder: adds, subtracts, multiplies, divides

– Decoder: reacts to specific bit patterns

– Shifter: moves bits to right or left

– Flip-flops (latches): used to store memory bits


Connecting with Computer Science 11
How Transistors Work
• Material composition: silicon or germanium (Ge)
• Logically organized into three parts: emitter,
collector, and base
• Transistor as electronic switch
– Base used to turn current on and off
– Capacity to control current translates into capacity to
manipulate binary values of 1 and 0
• Size considerations: Typical transistor 130
nanometers wide (Pentium IV)
Connecting with Computer Science 12
Connecting with Computer Science 13
Digital Logic Circuits
• Logic circuit
– Next level of organization above transistor
– Leverages switching function of transistor
– Performs operations of Boolean algebra
• Boolean algebra
– Functions relating binary input and output
– Chief operators: AND, OR, NOT
– Boolean variables are true (1) or false (0)
– Boolean expressions use Boolean operators and
variables
Connecting with Computer Science 14
Digital Logic Circuits (continued)
• Truth tables
– Convenient tabular representations of Boolean
expressions
– Column(s) represent inputs and output(s)
– Rows correspond to each possible combination of
inputs
• 2n rows needed for n inputs (n is positive integer)
• Example: two inputs require 2 2 = 4 rows

Connecting with Computer Science 15


The Basic Boolean Operators
• Three Basic Operators: AND, OR, NOT
• AND operator
– Takes two values as input (x and y) and generates one
output (z)
– Both inputs must be true (1) for output to be true (1)
• When x = 1 and y = 1, z = 1
– Any other combination yields output of false (0)
– Equivalent Boolean Expression: xy = z

Connecting with Computer Science 16


Connecting with Computer Science 17
The Basic Boolean Operators
(continued)
• OR operator
– Takes two values as input (x and y) and generates one
output (z)
– Either input valued true (1) will cause output to be
valued true (1)
– When both inputs are valued false (0), output will be
valued false (0)
– Equivalent Boolean expression: x + y = z
Connecting with Computer Science 18
Connecting with Computer Science 19
The Basic Boolean Operators
(continued)
• NOT operator
– Takes one value as input (x) and generates one output
(z) x

– Reverses value of input.


• When x = 1, z = 0
• When x = 0, z = 1

Equivalent Boolean expression: x = z or x = z

Connecting with Computer Science 20


Connecting with Computer Science 21
Digital Building Blocks
• Circuit Hierarchy
– Gates: transistor circuits implement Boolean operators
– Gates grouped into more complex circuits that carry out
computer tasks
• Reliability
– Binary values maintained with consistent voltage levels
– Output of gates completely determined by input
• Six fundamental gates
– AND, OR, NOT (primitive or basic)
– NAND, NOR, XOR (constructed from AND, OR, NOT)

Connecting with Computer Science 22


Digital Building Blocks
(continued)
• AND gate
– Allows for two inputs and has one output
– Truth table identical to that of AND Boolean Operator

Connecting with Computer Science 23


Digital Building Blocks
(continued)
• OR gate
– Allows for two inputs and has one output
– Truth table identical to that of Boolean OR

Connecting with Computer Science 24


Digital Building Blocks
(continued)
• NOT gate
– Allows for one input and one output
– Truth table identical to Boolean NOT

Connecting with Computer Science 25


Digital Building Blocks
(continued)
• NAND gate
– Reverses output of AND gate with NOT gate
– Output opposite that of AND gate

Connecting with Computer Science 26


Digital Building Blocks
(continued)
• NOR gate
– Reverses output of OR gate with NOT gate
– Truth table opposite of OR gate truth table

Connecting with Computer Science 27


Digital Building Blocks
(continued)
• XOR gate
– Exclusive OR (one or the other, but not both)
– Inputs with opposite values generate output of 1

Connecting with Computer Science 28


Gate Behavior
• Predictability of Gates
– Predicated on corresponding truth table
– Output for given input derived from truth table
• Scalability
– Complex circuits constructed with basic gates
– Output of one gate is connected as input to another
– Example: 3-input AND gate from two 2-input AND
gates
Connecting with Computer Science 29
Connecting with Computer Science 30
Complex Circuits
• Four Fundamental circuits of CPU
– ADDER, DECODER, SHIFTER, FLIP-FLOP
– Constructed from basic gates
• ADDER
– Function: adds two binary numbers, outputs result
– Inputs: two bits (x, y) to add and one carry-in (ci)
– Outputs: sum bit (s) and one carry-out bit (co)

Connecting with Computer Science 31


Connecting with Computer Science 32
Connecting with Computer Science 33
Complex Circuits (continued)
• Decoder
– Functions: Address memory, select I/O devices
– Given input pattern, output line selected
– Circuit with n inputs can control 2n lines
• Example: 32 inputs could control 4 billion lines
– Illustrate Decoder with two inputs
• Has four possible outputs
• Truth table incorporates four basic truth tables
Connecting with Computer Science 34
Connecting with Computer Science 35
Complex Circuits (continued)
• Flip-flop
– Special form of latch circuit
– Function: holds value at output even if input changes
– Inputs: S (set) and R (reset)
– Outputs: Q and Q
– Ideal for bit storage
• Used for high-speed memory in CPU
• Static RAM, SRAM, cache
Connecting with Computer Science 36
Connecting with Computer Science 37
Complex Circuits (continued)
• Shifter
– Purpose: support math operations such as
multiplication and division
– Function: shifts input bits to the left or right

Connecting with Computer Science 38


Complex Circuits (continued)

• Other circuits: multiplexer, parity generator, counter

• Three part design process

– Construct truth table relating inputs and outputs

– Build Boolean expression equivalent to truth table

– Represent Boolean expression in a circuit diagram

Connecting with Computer Science 39


Complex Circuits (continued)
• Modern design efforts supported with software

• Integrated Circuits (ICs)

– Whole circuits etched onto single semiconductor chip

– VLSI (Very Large-Scale Integration) chip

• Contains millions of transistors making up CPU circuits

Connecting with Computer Science 40


The Von Neumann Architecture

Von Neumann
Architecture
Designing Computers
• All computers more or less based on the same basic
design, the Von Neumann Architecture!

Connecting with Computer Science 42


The Von Neumann Architecture
• Model for designing and building computers,
based on the following three characteristics:
1) The computer consists of four main sub-systems:
• Memory
• ALU (Arithmetic/Logic Unit)
• Control Unit
• Input/Output System (I/O)
2) Program is stored in memory during execution.
3) Program instructions are executed sequentially.

Connecting with Computer Science 43


The Von Neumann Architecture
Bus

Processor (CPU)
Memory Input-Output
Control Unit

ALU
Store data and program Communicate with
"outside world", e.g.
• Screen
Execute program
• Keyboard
Do arithmetic/logic operations • Storage devices
requested by program • ...
Connecting with Computer Science 44
Memory Subsystem
• Memory, also called RAM (Random Access Memory),
– Consists of many memory cells (storage units) of a fixed size.
Each cell has an address associated with it: 0, 1, …
– All accesses to memory are to a specified address.
A cell is the minimum unit of access (fetch/store a complete cell).
– The time it takes to fetch/store a cell is the same for all cells.
• When the computer is running, both
– Program
– Data (variables)
are stored in the memory.

Connecting with Computer Science 45


RAM
• Need to distinguish between N
– the address of a memory cell and 0000000000000001
the content of a memory cell 1 bit
• Memory width (W): 0
– How many bits is each memory
1
cell, typically one byte (=8 bits)
2
• Address width (N):
– How many bits used to represent 2N
each address, determines the
maximum memory size = address ...
space
– If address width is N-bits, then
address space is 2N (0,1,...,2N-1) 2N-1

Connecting with Computer Science W


46
Memory Size / Speed
• Typical memory in a personal computer (PC):
– 64MB - 256MB
• Memory sizes:
– Kilobyte (KB) = 210 = 1,024 bytes ~ 1
thousand
– Megabyte(MB) = 220 = 1,048,576 bytes ~ 1 million
– Gigabyte (GB) = 230 = 1,073,741,824 bytes ~ 1
billion
• Memory Access Time (read from/ write to memory)
– 50-75 nanoseconds (1 nsec. = 0.000000001 sec.)
• RAM is
– volatile (can only store when power is on)
– relatively expensive
Connecting with Computer Science 47
Operations on Memory
• Fetch (address):
– Fetch a copy of the content of memory cell with the specified
address.
– Non-destructive, copies value in memory cell.
• Store (address, value):
– Store the specified value into the memory cell specified by
address.
– Destructive, overwrites the previous value of the memory cell.
• The memory system is interfaced via:
– Memory Address Register (MAR)
– Memory Data Register (MDR)
– Fetch/Store signal

Connecting with Computer Science 48


Structure of the Memory Subsystem

• Fetch(address)
MAR MDR – Load address into MAR.
F/S – Decode the address in MAR.
Memory – Copy the content of memory cell with
Fetch/Store
decoder specified address into MDR.
controller
circuit
• Store(address, value)
– Load the address into MAR.
– Load the value into MDR.
– Decode the address in MAR
... – Copy the content of MDR into
memory cell with the specified
address.

Connecting with Computer Science 49


Input/Output Subsystem
• Handles devices that allow the computer system to:
– Communicate and interact with the outside world
• Screen, keyboard, printer, ...
– Store information (mass-storage)
• Hard-drives, floppies, CD, tapes, …
• Mass-Storage Device Access Methods:
– Direct Access Storage Devices (DASDs)
• Hard-drives, floppy-disks, CD-ROMs, ...
– Sequential Access Storage Devices (SASDs)
• Tapes (for example, used as backup devices)

Connecting with Computer Science 50


I/O Controllers
• Speed of I/O devices is slow compared to RAM
– RAM ~ 50 nsec.
– Hard-Drive ~ 10msec. = (10,000,000 nsec)
• Solution:
– I/O Controller, a special purpose processor:
• Has a small memory buffer, and a control logic to
control I/O device (e.g. move disk arm).
• Sends an interrupt signal to CPU when done read/write.
– Data transferred between RAM and memory buffer.
– Processor free to do something else while I/O controller
reads/writes data from/to device into I/O buffer.

Connecting with Computer Science 51


Structure of the I/O Subsystem
Interrupt signal (to processor)
Data from/to memory

I/O controller
I/O Buffer

Control/Logic

I/O device

Connecting with Computer Science 52


The ALU Subsystem
• The ALU (Arithmetic/Logic Unit) performs
– mathematical operations (+, -, x, /, …)
– logic operations (=, <, >, and, or, not, ...)
• In today's computers integrated into the CPU
• Consists of:
– Circuits to do the arithmetic/logic operations.
– Registers (fast storage units) to store intermediate
computational results.
– Bus that connects the two.

Connecting with Computer Science 53


Structure of the ALU
• Registers:
– Very fast local memory cells, that R0
store operands of operations and R1
intermediate results.
R2
– CCR (condition code register), a
special purpose register that stores
the result of <, = , > operations
• ALU circuitry: Rn
– Contains an array of circuits to do
mathematical/logic operations.
• Bus: ALU circuitry
– Data path interconnecting the
registers to the ALU circuitry.
GT EQ LT
Connecting with Computer Science 54
The Control Unit
• Program is stored in memory
– as machine language instructions, in binary
• The task of the control unit is to execute programs
by repeatedly:
– Fetch from memory the next instruction to be
executed.
– Decode it, that is, determine what is to be done.
– Execute it by issuing the appropriate signals to the
ALU, memory, and I/O subsystems.
– Continues until the HALT instruction
Connecting with Computer Science 55
Machine Language Instructions
• A machine language instruction consists of:
– Operation code, telling which operation to perform
– Address field(s), telling the memory addresses of
the values on which the operation works.
• Example: ADD X, Y (Add content of memory locations X
and Y, and store back in memory location Y).
• Assume: opcode for ADD is 9, and addresses X=99, Y=100

Opcode (8 bits) Address 1 (16 bits) Address 2 (16 bits)


00001001 0000000001100011 0000000001100100

Connecting with Computer Science 56


Instruction Set Design
• Two different approaches:
– Reduced Instruction Set Computers (RISC)
• Instruction set as small and simple as possible.
• Minimizes amount of circuitry --> faster computers
– Complex Instruction Set Computers (CISC)
• More instructions, many very complex
• Each instruction can do more work, but require
more circuitry.

Connecting with Computer Science 57


Typical Machine Instructions
• Notation:
– We use X, Y, Z to denote RAM cells
– Assume only one register R (for simplicity)
– Use English-like descriptions (should be binary)
• Data Transfer Instructions
– LOAD X Load content of memory location X to
R
– STORE X Load content of R to memory location X
– MOVE X, Y Copy content of memory location X to
loc. Y
(not absolutely necessary)
Connecting with Computer Science 58
Machine Instructions (cont.)
• Arithmetic
– ADD X, Y, Z CON(Z) = CON(X) + CON(Y)
– ADD X, Y CON(Y) = CON(X) + CON(Y)
– ADD X R = CON(X) + R
– similar instructions for other operators, e.g. SUBTR,OR, ...
• Compare
– COMPARE X, Y
Compare the content of memory cell X to the content of
memory cell Y and set the condition codes (CCR) accordingly.
– E.g. If CON(X) = R then set EQ=1, GT=0, LT=0

Connecting with Computer Science 59


Machine Instructions (cont.)
• Branch
– JUMP X Load next instruction from memory loc.
X
– JUMPGT X Load next instruction from memory loc. X
only if GT flag in CCR is set, otherwise
load statement from next sequence loc. as
usual.
• JUMPEQ, JUMPLT, JUMPGE, JUMPLE,JUMPNEQ
• Control
– HALT Stop program execution.

Connecting with Computer Science 60


Example
• Pseudo-code: Set A to B + C
• Assuming variable:
– A stored in memory cell 100, B stored in memory
cell 150, C stored in memory cell 151
• Machine language (really in binary)
– LOAD 150
– ADD 151
– STORE 100
– or
– (ADD 150, 151, 100)

Connecting with Computer Science 61


Structure of the Control Unit
• PC (Program Counter):
– stores the address of next instruction to fetch
• IR (Instruction Register):
– stores the instruction fetched from memory
• Instruction Decoder:
– Decodes instruction and activates necessary circuitry

PC IR

+1
Instruction
Decoder

Connecting with Computer Science 62


Von Neumann Architecture overview

Connecting with Computer Science 63


von Neumann Architecture
in more details

Connecting with Computer Science 64


How does this all work together?
• Program Execution:
– PC is set to the address where the first program
instruction is stored in memory.
– Repeat until HALT instruction or fatal error
Fetch instruction
Decode instruction
Execute instruction
End of loop

Connecting with Computer Science 65


Program Execution (cont.)
• Fetch phase
– PC --> MAR (put address in PC into MAR)
– Fetch signal (signal memory to fetch value into
MDR)
– MDR --> IR (move value to Instruction Register)
– PC + 1 --> PC (Increase address in program counter)
• Decode Phase
– IR -> Instruction decoder (decode instruction in IR)
– Instruction decoder will then generate the signals to
activate the circuitry to carry out the instruction
Connecting with Computer Science 66
Program Execution (cont.)
• Execute Phase
– Differs from one instruction to the next.
• Example:
– LOAD X (load value in addr. X into register)
• IR_address -> MAR
• Fetch signal
• MDR --> R
– ADD X
• left as an exercise

(c) Yngvi Bjornsson 67


Instruction Set for Our Von Neumann Machine
Opcode Operation Meaning
0000 LOAD X CON(X) --> R
0001 STORE X R --> CON(X)
0010 CLEAR X 0 --> CON(X)
0011 ADD X R + CON(X) --> R
0100 INCREMENT X CON(X) + 1 --> CON(X)
0101 SUBTRACT X R - CON(X) --> R
DECREMENT CON(X) - 1 --> CON(X)
0101
X
COMPARE X If CON(X) > R then GT = 1 else 0
0111 If CON(X) = R then EQ = 1 else 0
If CON(X) < R then LT = 1 else 0
1000 JUMP X Get next instruction from memory location X
1001 JUMPGT X Get next instruction from memory loc. X if GT=1
... JUMPxx X xx = LT / EQ / NEQ
1101 IN X Input an integer value and store in X
1110 OUT X Output, in decimal notation, content of mem. loc. X
HALT Science
1111 with Computer
Connecting Stop program execution
68
Buses
• Bus: set of wires and rules facilitating data transfer
• Components connected via system bus
• Bus wires divided into three separate signal groups:
– Control
– Address
– Data
• Modern bus standard: PCI (Peripheral Component
Interconnect)

Connecting with Computer Science 69


Peripheral Buses
• SCSI: Small Computer System Interface

– Connects different types of I/O devices to computer

– Allows CPU to pass control to other devices (bus


mastering)

Connecting with Computer Science 70


Storage
• Storage: family of components used to store
programs and data

• Storage hierarchy

– Primary memory

– Secondary memory (mass storage)

Connecting with Computer Science 71


Memory
• Two basic flavors
– ROM (read-only memory)
• Memory etched into chip
• Generally cannot be modified
• BIOS (basic input/output system) in this category
– RAM (random access memory) basics
• Allows direct memory reference
• Allows reading and writing
• Volatile
• CPU fetches program instructions from RAM
Connecting with Computer Science 72
Memory (continued)
• Types of RAM
– DRAM (Dynamic RAM)
• Made of circuits using one transistor per bit
• Needs to be constantly refreshed to maintain data
• Access speeds ranging from 10 – 70 ns
– SRAM
• Made of flip flop circuits
• Fastest memory type
• Used chiefly in registers and cache

Connecting with Computer Science 73


Mass Storage
• Secondary memory characteristics

– Greater storage capacity than RAM or ROM

– Used for devices such as hard drive or CD-ROMS

– Cheaper storage per megabyte than RAM or ROM

– Non-volatile

– Slower than RAM or ROM


Connecting with Computer Science 74
Mass Storage (continued)
• Hard disk drives
– Most common form of mass storage
– Magnetic metal platters store information
• Organized into concentric circles called tracks
• Tracks divided into sectors
• Platters spin at about 7200 RPM
• Read/write heads interface with disk surface
– Low cost-unit storage ratio relative to RAM
– RAID (Redundant Array of Independent Discs)

Connecting with Computer Science 75


Connecting with Computer Science 76
Mass Storage (continued)
• Optical Storage
– Popular formats: CDs (compact disks) and DVDs
(digital video disks)
– Stores data using optical (laser) technologies
• Pits burned into disks interpreted as binary data
• Data written to disks in continuous spiral
• Like hard disks, CDs and DVDs spin
• Read/write heads interface with disk surface
– Low cost-unit storage ratio
Connecting with Computer Science 77
Mass Storage (continued)
• Flash (Thumb) drives

– Portable storage that plugs into USB (Universal Serial


Bus) port

– Replacing floppy drives

– Uses non-volatile flash memory

– Low cost-unit storage ratio


Connecting with Computer Science 78
Input/Output Systems
• Final component of Von Neumann architecture

• Input/Output (I/O) devices: computer’s connection to


user

Connecting with Computer Science 79


Input Devices
• Keyboard
– Chief input device for most users
– Connected to motherboard through port and then to CPU
by controller circuit and system bus
– Keystrokes are translated into binary signals for CPU
consumption
• Mouse
– Used in conjunction with keyboard
– Senses movement that can be translated into binary code
• Other devices: trackballs, styluses, touch pads/screens
Connecting with Computer Science 80
Connecting with Computer Science 81
Output Devices
• Communication channel to outside world
• Monitors
– Primary output device
– CRTs (cathode ray tubes)
• Utilizes raster scanning techniques
• Quality based on resolution and refresh rate
– LCD (Liquid Crystal Display)
• Thinner and cooler than CRTs
• Utilizes transistors rather than electron beams
• Quality based on resolution and refresh rate

Connecting with Computer Science 82


Connecting with Computer Science 83
Output Devices (continued)
• Printers
– Important output device
– Chief varieties: ink jet and laser printers
– Quality measured by resolution (dots per inch) and
speed (pages per minute)
• Sound cards
– Fit into PCI expansion slot on main boar
– Used to digitize sound for storage
– Also converts binary sound files into analog sounds

Connecting with Computer Science 84


Interrupts and Polling
• CPU instruction cycle equals clock speed

• CPU commits to cycle based on processing need

• Processing need determined by (2) techniques

– Polling: CPU interrogates I/O device

– Interrupt Handling: I/O device initiates request for


service

Connecting with Computer Science 85


Choosing the Best
Computer Hardware
• No one size fits all
• Circumstances drive selection process
• Some criteria
– Define objectives for machine
– Ascertain metrics such as clock speed, memory type,
bus speed, hard drive speed
– Compare models
– Solicit opinions
– Consider price

Connecting with Computer Science 86


One Last Thought
• All computer scientists need architectural concepts

• Advanced hardware studies highly recommended

• Stay current on latest industry developments

Connecting with Computer Science 87


Summary
• Computer architecture: hardware design
• Von Neumann architecture: design template for modern
machines
• Components of Von Neumann machine:
– Central Processing Unit (CPU)
– Memory (organized in a hierarchy)
– Input/Output Devices
• CPU: ALU/Controller/Registers
• System components are connected via buses

Connecting with Computer Science 88


Summary (continued)
• Instruction cycle: fetch-decode-execute

• Instructions processed at clock speed

• Basic circuits: Adder/Decoder/Flip-flop/Shifter

• Integrated circuits unite transistors and other


components into single chip

• Logical circuit scheme based on Boolean Algebra


Connecting with Computer Science 89
Summary (continued)
• Six fundamental circuits (or gates)

– AND, OR, NOT, NAND, NOR,XOR

• All circuits can be equivalently represented by truth


tables and Boolean expressions

Connecting with Computer Science 90

You might also like