Download 02_cpu

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
Computer Organization
Boolean Logic and the CPU
i206 Fall 2010
John Chuang
Some slides adapted from Marti Hearst, Brian Hayes, or Glenn Brookshear
Boolean Logic
CPU Operation
C/S, P2P
Caching
Distributed
Systems
Security
Cryptography
Network
Confidentiality
Integrity
Authentication
…
Standards
& Protocols
sockets
Inter-process
Communication
Methodologies/
Tools
TCP/IP,
RSA, …
Principles
UML, CRC
I/O
Operating
System
Process
Context switch
Process vs. Thread
Locks and deadlocks
Memory
hierarchy
Memory
Register, Cache
Main Memory,
Secondary Storage
ALUs, Registers,
Compiler/
Program Counter,
Instruction Register Interpreter
Program
Assembly
Instructions
Op-code, operands
Instruction set arch
Circuits
Lossless v. lossy
Info entropy &
Huffman code
Decimal,
Hexadecimal,
Binary
Data
compression
Data
Data
Representation
John Chuang
Gates
Adders, decoders,
Memory latches,
ALUs, etc.
Boolean
Logic
AND, OR, NOT,
XOR, NAND, NOR,
etc.
Number
Systems
Binary
Numbers
Bits & Bytes
Design
Formal models
Finite automata
regex
Machine
Instructions
CPU
Data
storage
Numbers, text,
audio, video,
image, …
Application
Algorithms
Analysis
Big-O
Data Structures
Searching, sorting,
Encryption, etc.
Stacks, queues,
maps, trees,
graphs, …
Truth table
Venn Diagram
DeMorgan’s Law
2
Central Processing Unit (CPU)
 Software programs consist of arithmetic and logical
operations
 The CPU or processor of a machine is responsible for
executing these operations in hardware
 Modern CPUs are implemented using tens of millions of
transistors (switches)
John Chuang
3
Central Processing Unit (CPU)
 CPU components:
-
Arithmetic/Logic Units (ALU)
Control Unit
Registers
Cache Memory
http://www.ischool.berkeley.edu/~chuang/images/mips_r10000.jpg
John Chuang
4
Boolean Logic
 Boolean algebra = logical calculation of
truth values (true/false values)
 Basic boolean operators
-
AND
OR
XOR (exclusive-OR)
NOT
John Chuang
5
AND, OR, XOR, and NOT:
Gates and Truth Tables
John Chuang
6
Boolean Notation
Operator Symbol
Example
AND
* or • or
A*B = A•B = A B = AB
OR
+ or U
A+B = A U B
NOT
¬ or ¯ or -
¬(A+B) = (A+B) = -(A+B)
XOR
+
A + B = AB + AB
U
U
John Chuang
7
Boolean Logic Relationships
 C = A*B
 D = (A+B)
 X+X = 1; X*X = 0
 X+Y=Y+X; XY = YX
 X(Y+Z) = XY + XZ
 DeMorgan’s Law:
D
A
C
B
Venn Diagram
- (A*B) = A + B
- (A+B) = A * B
John Chuang
8
Exercise
 Let’s solve a problem using Boolean Logic
- First express the problem using Boolean
expressions and/or truth table
- Then implement solution using Boolean gates
John Chuang
9
NAND, NOR, XNOR
 NAND and NOR gates easier to implement
in hardware than AND and OR gates
 Example: AND logic can be implemented
with two NOTs and a NOR (DeMorgan’s
Law)
A
A
B
=
B
John Chuang
10
Gates
 The Richest Man in the World
 Devices that produce the outputs of Boolean operations
when given the operations’ input values
- Often implemented as electronic circuits called transistors
- Provide the building blocks from which computers are
constructed
- Gates are used to build up circuits that perform computations (e.g.,
addition, subtraction), or store values to be used later
John Chuang
11
Inverter (NOT Gate)
 Implements the simplest Boolean operator
“NOT” using two transistors
http://www.csee.umbc.edu/~plusquel/vlsi/slides/chap3_2.html
 Photolithography techniques used in
fabrication of integrated circuit (IC) chips
Image and further reading at:
http://www.lithoguru.com/scientist/lithobasics.html
John Chuang
12
NAND Gate
 NAND gate implemented using 4
transistors
John Chuang
13
Integrated Circuit (IC) Chips
Contain Gates & Connectors
John Chuang
Images from http://www.ee.ed.ac.uk/~gaa/DigilabNotes/Digilab/Components/node7.html
14
Circuits for Binary Addition
Half Adder
John Chuang
Images from http://www.play-hookey.com/digital/adder.html
15
Circuits for Binary Addition
Full Adder
John Chuang
Images from http://www.play-hookey.com/digital/adder.html
16
Circuits for Binary Addition
Full Adder, 4 bit output + carry
 Can link up an arbitrary
number of input bits
 Can modify this easily to
do subtraction
John Chuang
17
Images from http://www.play-hookey.com/digital/adder.html
Arithmetic Logic Unit (ALU)
Add, Subtract, and Logic Operations
multiplexer
John Chuang
18
http://www.seas.upenn.edu/~ee201/lab/LabALU/ALU.html
C/S, P2P
Caching
CPU Operation
Distributed
Systems
Security
Cryptography
Network
Confidentiality
Integrity
Authentication
…
Standards
& Protocols
sockets
Inter-process
Communication
Methodologies/
Tools
TCP/IP,
RSA, …
Principles
UML, CRC
I/O
Operating
System
Process
Context switch
Process vs. Thread
Locks and deadlocks
Memory
hierarchy
Memory
Register, Cache
Main Memory,
Secondary Storage
ALUs, Registers,
Compiler/
Program Counter,
Instruction Register Interpreter
Program
Assembly
Instructions
Op-code, operands
Instruction set arch
Circuits
Lossless v. lossy
Info entropy &
Huffman code
Decimal,
Hexadecimal,
Binary
Data
compression
Data
Data
Representation
John Chuang
Gates
Adders, decoders,
Memory latches,
ALUs, etc.
Boolean
Logic
AND, OR, NOT,
XOR, NAND, NOR,
etc.
Number
Systems
Binary
Numbers
Bits & Bytes
Design
Formal models
Finite automata
regex
Machine
Instructions
CPU
Data
storage
Numbers, text,
audio, video,
image, …
Application
Algorithms
Analysis
Big-O
Data Structures
Searching, sorting,
Encryption, etc.
Stacks, queues,
maps, trees,
graphs, …
Truth table
Venn Diagram
DeMorgan’s Law
21
Central Processing Unit (CPU)
 Software programs consist of arithmetic and logical
operations
 The CPU or processor of a machine is responsible for
executing these operations in hardware
 CPU components
-
Arithmetic/Logic Units (ALU)
Control Unit
Registers
Cache Memory
John Chuang
22
Program execution
 Controlled by two special-purpose registers
- Program counter: address of next instruction
- Instruction register: current instruction
 Steps performed by control unit
- Fetch
- Decode
- Execute
John Chuang
23
Machine language
 Machine instruction: an instruction coded as
a bit pattern directly recognizable by the CPU
 Machine language: the set of all instructions
recognized by a machine
- Also known as instruction set architecture (ISA)
- E.g., Intel x86, IA-64, MIPS, PowerPC, …
- Brookshear Appendix C provides an example
John Chuang
24
Example Machine Architecture
(Brookshear Appendix C)
John Chuang
25
Machine instruction types
 Data Transfer: copy data between CPU and
main memory
 Arithmetic/Logic: use existing data values to
compute a new data value
 Control: direct the execution of the program
John Chuang
26
Parts of a machine
instruction
 Op-code: specifies which machine operation to execute
- One per instruction
 Operand: more detailed information about this
operation
- Number of operands varies depending on op-code
 Example:
John Chuang
27
Example: Decoding the
instruction 35A7
John Chuang
28
Example: Addition Operation
John Chuang
29
Readings for Next Week




Read: Brookshear Chapter 5.1-5.5, 6.1
Review: Brookshear Chapter 6.2-6.5
Read: Brookshear Chapter 7.1-7.7
Read:
- http://en.wikipedia.org/wiki/Unified_Modeling_Language
John Chuang
30
Related documents