Chapter 01 - Abstraction

Download Report

Transcript Chapter 01 - Abstraction

CS/ECEn 124 – Computer Systems

Winter 2010





Section 001, MWF 1:00 – 1:50 pm
Section 002, MWF 2:00 – 2:50 pm
Help Sessions, MWF 4:00 – 4:45 pm
Instructor: Paul Roper
Office: TMCB 3370, 422-8149
Email: [email protected]
Office Hours: MWF 10:00 – 11:40 am
BYU CS/ECEn 124
Chapter 01 - Abstraction
1
Let’s Get Started…
What’s inside
this thing...
Concepts to Learn…








Computers
Power of Abstraction
Hardware vs. Software
Turing Machine
Universal Computing Devices
The “Gap”
Solving Problems w/Computer
Levels of Transformation
BYU CS/ECEn 124
Chapter 01 - Abstraction
3
Computers
Computers…





There is no magic to computing.
Computers do not have minds of their own. You
have to tell them exactly what to do.
Computers follow instructions exactly.
Computers are made of very simple parts…
albeit, fast parts and a whole lot of them!
We will study the MPS430 micro-controller, which
has all of the important characteristics of today’s
commercial computers.
BYU CS/ECEn 124
Chapter 01 - Abstraction
4
Computers
A Computer

A computer




figures out what to do next – control.
does the computations on the data – data path.
A computer uses a “program” for control and
the data path.
A computer is called a



a central processing unit,
or a CPU, MPU, MSP,
or simply, a processor.
BYU CS/ECEn 124
Chapter 01 - Abstraction
5
Computers
Digital vs. Analog






Wristwatches (numbers vs. hands)
LP’s vs. CD’s
Rotary phone vs.
Cell phone
NTSC vs. HDTV
Slide rule vs.
calculator
737’s vs. 787’s
BYU CS/ECEn 124
Chapter 01 - Abstraction
6
Computers
All Computers Are Created Equal…

In theory, any computer can compute anything
that’s possible to compute



given enough memory and
given enough time.
In practice, solving a problem is constrained by

time


cost


weather forecast, next frame of animation, ...
cell phone, automotive engine controller, ...
power

cell phone, handheld video game, ...
BYU CS/ECEn 124
Chapter 01 - Abstraction
7
Computers
Computing Machines

Ubiquitous (meaning everywhere!)




General purpose: servers, desktops, laptops, PDAs, …
Special purpose: cash registers, ATMs, games,
telephone switches, …
Embedded: cars, hotel doors, printers, VCRs, industrial
machinery, medical equipment, …
Distinguishing Characteristics





Speed
Cost
Ease of use, software support & interface
Scalability
Reliability
BYU CS/ECEn 124
Chapter 01 - Abstraction
8
Computers
Computing Machines

Use Abstraction





to manage complexity.
to enhance productivity.
to hide unnecessary details when everything works.
to focus on what is important.
Hardware verses Software



are just different parts of a computing system.
understanding together best solve computing
problems.
mastery makes you more capable.
BYU CS/ECEn 124
Chapter 01 - Abstraction
9
Abstraction
The Concept of Abstraction

We abstract naturally–






focus on the essential aspects of an entity.
hide the underlying complexity.
Avoid getting bogged down in unnecessary
details (when everything is working fine).
More efficient to think about something at the
highest possible level of abstraction.
Without abstraction, one would be overwhelmed
by the complexity of a computer.
But, when something doesn’t work, then
abstraction fails and you have to look at the
details.
BYU CS/ECEn 124
Chapter 01 - Abstraction
10
Hardware/Software
Hardware versus Software

Some people think that its OK for–



Software engineers to be clueless about hardware, or
Hardware engineers to be clueless about software.
Don’t believe it!




Hardware and software are both essential parts of a
computing system.
Computer systems work best when designed by
someone who understands both parts.
Hardware designers that understand programming
design the best computers.
Software designers that understand the capabilities and
limitations of hardware design more efficient programs.
BYU CS/ECEn 124
Chapter 01 - Abstraction
11
Turning Machine
Computing Devices

Alan Turing


In 1936 he proposed a way to define the
term “computable”
The Turing Machine



Basic abstract symbol-manipulating
devices which can be adapted to
simulate the logic of any computer
algorithm.
Anything that can be computed,
can be computed by a TM…
The TM is not a real machine,
but an abstract machine
BYU CS/ECEn 124
Chapter 01 - Abstraction
12
Turning Machine
Turing Machine

Mathematical model of a device that can perform
any computation – Alan Turing (1936)



ability to read/write symbols on an infinite “tape”
“state” transitions, based on current state and symbol
Every computation can be performed by some
Turing machine. (Turing’s thesis)
Tadd
a,b
a+b
Turing machine that adds
BYU CS/ECEn 124
a,b
Tmul
ab
Turing machine that multiplies
Chapter 01 - Abstraction
13
Turning Machine
Turing Machine Details
BYU CS/ECEn 124
Chapter 01 - Abstraction
14
Turning Machine
Turing Machine Example
“Action Table”
Old Read
State Sym
S1
S2
S2
S3
S3
S4
S4
S5
S5
1
1
0
0
1
1
0
1
0









BYU CS/ECEn 124
Step
Write
New
Sym Move State
0
1
0
1
1
1
0
1
1
R
R
R
L
R
L
L
L
R
S2
S2
S3
S4
S3
S4
S5
S5
S1
State
1
S1
2
S2
3
S2
4
S3
5
S4
6
S5
7
S5
8
S1
9
S2
10
S3
11
S3
12
S4
13
S4
14
S5
15
S1
--HALT-Chapter 01 - Abstraction
Start State
(State Register)
Tape
11
01
010
0100
0101
0101
0101
1101
1001
1001
10010
10011
10011
10011
11011
Tape Read Head
15
Universal Turning Machine
Universal Turing Machine

A Universal Turing Machine is a theoretical
device



that can simulate any other Turing machine.
that accepts both input data and instructions as to how
to operate on the data.
that is also a Turing Machine!
Tadd, Tmul
U
a,b,c
c(a+b)
Universal Turing Machine
A computer is a universal computing device.
BYU CS/ECEn 124
Chapter 01 - Abstraction
16
The “Gap”
The “Gap”
Implementation
Wordprocessing…
Games…
Surfing the web…
10101101011011…
Computational Problem
BYU CS/ECEn 124
Chapter 01 - Abstraction
17
The “Gap”
Overcoming the Gap
Problems
Algorithms
Language (Program)
Machine (ISA) Architecture
Computer Specific
Micro-architecture
Manufacturer Specific
As we move down,
many choices must
be made.
Circuits
This is how we make
our living!
Devices
BYU CS/ECEn 124
Programmable
Chapter 01 - Abstraction
18
Solving Problems
Problem Solving w/Computers
Problem
Software Design:
choose algorithms and data structures
Algorithm
Programming:
use language to express design
Program
Instruction Set
Architecture
BYU CS/ECEn 124
Compiling/Interpreting:
convert language to
machine instructions
Chapter 01 - Abstraction
19
Solving Problems
Deeper and Deeper…
Instruction Set
Architecture
MicroArchitecture
Instruction Set Design:
Design ISA that enables efficient
problem solving
Processor Design:
choose structures to implement ISA
Circuits
Logic/Circuit Design:
gates and low-level circuits to
implement components
Devices
Process Engineering & Fabrication:
develop and manufacture
lowest-level components
BYU CS/ECEn 124
Chapter 01 - Abstraction
20
Solving Problems
Which Levels
are Programmable?
Levels
of Transformation
Problems
Problems
Algorithms
Algorithms
Language
Language (Program)
(Program)
Programmable
Machine (ISA) Architecture
Fixed
Micro-architecture
Circuits
Devices
BYU CS/ECEn 124
Chapter 01 - Abstraction
21
Solving Problems
Problems

Why not use natural languages to program
computers?

Incomplete
Missing words and/or word structures for computer
procedures.

Imprecise
Words that mean the same thing are difficult to
translate into computer instructions.

Ambiguous – the most unacceptable attribute!
To infer the meaning of a sentence, a
listener is often helped by the tone of the
speaker, or at the very least, the context
of the sentence.
BYU CS/ECEn 124
Chapter 01 - Abstraction
Problems
Algorithms
Programs
Machine (ISA) Architecture
Micro-architecture
Circuits
Devices
22
Solving Problems
For example…

Consider the English sentence,
“Time flies like an arrow.”

One is noticing how fast time passes,

One is at a track meet for insects,

One is writing a letter to the Dear Abby of Insectville.
Problems
Algorithms
Programs
Machine (ISA) Architecture
Micro-architecture
Circuits
Devices
BYU CS/ECEn 124
Chapter 01 - Abstraction
23
Solving Problems
Algorithms

An algorithm is a step-by-step procedure that:




guarantees to terminate (finiteness)
each step is precisely stated (definiteness)
each step can be carried out (effective computability)
Examples


Starting a car
Computing the average of n integers
For any given problem, there are usually
multiple algorithms that will work.
BYU CS/ECEn 124
Chapter 01 - Abstraction
Problems
Algorithms
Programs
Machine (ISA) Architecture
Micro-architecture
Circuits
Devices
24
Solving Problems
Programs

The next step is to transform the algorithm into a
computer program using a computer language.





computer languages communicate with the computer
computer languages are defined by a grammar
computer languages are mechanical rather than
natural
computer languages are not ambiguous
More than 1,000 programming languages

different languages for different purposes




financial processing/report generation
manipulating lists of symbolic data
natural language processing
often, just a personal preference
BYU CS/ECEn 124
Chapter 01 - Abstraction
Problems
Algorithms
Programs
Machine (ISA) Architecture
Micro-architecture
Circuits
Devices
25
Solving Problems
The Program Level


Most computers run a
management program called the
operating system (OS).
Application programs interface to
the machine architecture via the
OS.
Application Program
Operating System
Program (Software)
An example:
This lecture
Data
PowerPoint
Application Program
Problems
Algorithms
Programs
Machine (ISA) Architecture
Windows XP
BYU CS/ECEn 124
Operating System
Chapter 01 - Abstraction
Micro-architecture
Circuits
Devices
26
Solving Problems
High-Level Languages (HLL’s)

Machine independent





not dependent on a particular machine’s organization
can be compiled to run anywhere
Easier to write than low-level languages
Usually result in higher programmer productivity
Incorporate higher levels of abstraction


data structures (stacks, arrays)
control structures (loops, switch statements, …)
Problems
Algorithms
Programs
Machine (ISA) Architecture
Micro-architecture
Circuits
Devices
BYU CS/ECEn 124
Chapter 01 - Abstraction
27
Solving Problems
Low-Level Languages (LLL’s)

Machine-specific


internal machine organization is exposed to the
programmer
they can access the nitty gritty details






numbers and types of registers
specific instructions
memory addressing modes
condition code flags, special purpose
hardware features
Assembly programming


lower productivity, but
higher performing code
Problems
Algorithms
Programs
Machine (ISA) Architecture
Micro-architecture
Circuits
Devices
BYU CS/ECEn 124
Chapter 01 - Abstraction
28
Levels of Transformation
Levels of Transformation
Problems
Algorithms
Language (Program)
Programmable
Machine (ISA) Architecture
Computer Specific
Micro-architecture
Manufacturer Specific
Circuits
Devices
BYU CS/ECEn 124
Chapter 01 - Abstraction
29
Levels of Transformation
Instruction Set Architecture (ISA)

Next is to translate the computer program
(language) into the instruction set of a particular
computer
Machine code, or the 1’s and 0’s
that instruct the machine.

Specific to a CPU

data types


operations on data


What functions can be done
addressable memory


What are the different representations of operands
Where are operands stored
addressing modes

Machine (ISA) Architecture
How to find operands in memory
BYU CS/ECEn 124
Problems
Algorithms
Programs
Chapter 01 - Abstraction
Micro-architecture
Circuits
Devices
30
Levels of Transformation
Micro-Architecture



8051
IA-32







386
486
Pentium
Pentium-II, III, IV
Xeon
faster and more complex
The micro-architecture transforms the ISA into an
implementation.
MSP430
How the operations in the ISA are implemented


how do you add two binary numbers?
or, how do you access memory?
Problems
Algorithms
Programs
Machine (ISA) Architecture
Micro-architecture
Circuits
Devices
BYU CS/ECEn 124
Chapter 01 - Abstraction
31
Levels of Transformation
Circuits

The next step is to implement each
element of the micro-architecture with
simple logic circuits.



Gates, adders, multiplexers
Flip flops, memory cells
Adders, subtracters, multipliers
Circuits are used to make the computer do
useful things like multiply or store a result.
Problems
Algorithms
Programs
Machine (ISA) Architecture
Micro-architecture
Circuits
Devices
BYU CS/ECEn 124
Chapter 01 - Abstraction
32
Levels of Transformation
Devices

Finally, each basic logic circuit is
implemented by a particular device
technology.


Wires and traces
Types of circuits (transistors)
CMOS
NMOS
Gallium arsenide
Devices are the building blocks for more
complex circuits.
Problems
Algorithms
Programs
Machine (ISA) Architecture
Micro-architecture
Circuits
Devices
BYU CS/ECEn 124
Chapter 01 - Abstraction
33
Levels of Transformation
High vs Low Level Programming
One task =
Many instructions
BYU CS/ECEn 124
temp=v[i];
v[i]=v[i+1];
v[i+1]=temp;
Compiler
Swap v[i]
and v[i+1]
High-level
language
statements
Interpreter
Very highlevel language
objectives
or tasks
More concrete, machine-dependent; error
-prone, harder to write, read, debug, maintain
One statement =
Several instructions
Assembly
language
instruction,
mnemonic
MOV.B 0x0001(SP),R14
MOV.W SP,R15
INCD.W R15
ADD.W R15,R14
MOV.B @R14,0x0000(SP)
MOV.B 0x0001(SP),R14
INC.W R14
MOV.W SP,R15
INCD.W R15
ADD.W R15,R14
MOV.B 0x0001(SP),R13
MOV.W SP,R15
INCD.W R15
ADD.W R15,R13
MOV.B @R14,0x0000(R13)
MOV.B 0x0001(SP),R15
INC.W R15
MOV.W SP,R14
INCD.W R14
ADD.W R15,R14
MOV.B @SP,0x0000(R14)
Chapter 01 - Abstraction
Assembler
More abstract, machine-independent;
easier to write, read, debug, maintain
Mostly one
for one
Machine
language
instructions
binary (hex)
415E 0001
410F
532F
5F0E
4EE1 0000
415E 0001
531E
410F
532F
5F0E
415D 0001
410F
532F
5F0D
4EED 0000
415F 0001
531F
410E
532E
5F0E
41EE 0000
34
Levels of Transformation
Example: Levels of Translation
Algorithm
Algorithm
by hand
C-language program (HLL)
c = a + b;
Language
compiler
Assembly language program (LLL)
ADD.W r4,r12
assembler
ISA
Machine language programs
0010110010010001111
program execution
BYU CS/ECEn 124
Chapter 01 - Abstraction
35
Levels of Transformation
Levels of Transformation
Labs 11-12
Problems
Labs 9-10
Algorithms
Language (Program)
Labs 6-8
Machine (ISA) Architecture
Labs 4-5
Micro-architecture
Circuits
Lab 3
Lab 2
Devices
BYU CS/ECEn 124
Chapter 01 - Abstraction
36
Levels of Transformation
Review: Descriptions of Each Level

Problem Statement



Algorithm



stated using "natural language“
ambiguous, imprecise
step-by-step procedure, guaranteed to finish
definiteness, effective computability, finiteness
Program


express the algorithm using a computer
language
high-level language, low-level language
BYU CS/ECEn 124
Chapter 01 - Abstraction
37
Levels of Transformation
Review of Each Level

Instruction Set Architecture (ISA)




detailed organization of a processor implementation
different implementations of a single ISA
Logic Circuits



set of instructions the computer can execute
data types, addressing mode
Micro-architecture


(continued…)
combine basic operations to realize microarchitecture
many different ways to implement a single function
Devices

properties of materials, manufacturability
BYU CS/ECEn 124
Chapter 01 - Abstraction
38
BYU CS/ECEn 124
Chapter 01 - Abstraction
39
Auxilliary Slides…
From Components to Applications
Highlevel
view
Circuit designer
Logic designer
Electronic components
Hardware
Computer designer
System designer
Application designer
Application domains
Software
Computer archit ecture
Computer organization
Lowlevel
view
Subfields or views in computer system engineering.
BYU CS/ECEn 124
Chapter 01 - Abstraction
41
What Is Computer Architecture?
Client’s requirements:
function, cost, . . .
Client’s taste:
mood, style, . . .
Goals
Interface
Architect
Means
Construction tec hnology:
material, codes, . . .
Engineering
Arts
The world of arts:
aesthetics, trends, . . .
Interface
Like a building architect, whose place at the engineering/arts and
goals/means interfaces is seen in this diagram, a computer architect
reconciles many conflicting or competing demands.
BYU CS/ECEn 124
Chapter 01 - Abstraction
42
Parts of a Computer System
Computer
Analog
Digital
Fixed-function
Stored-program
Electronic
General-purpose
Number cruncher
Nonelectronic
Special-purpose
Data manipulator
The space of computer systems, with what we normally mean by the
word “computer” highlighted.
BYU CS/ECEn 124
Chapter 01 - Abstraction
43
Price/Performance Pyramid
Super
$Millions
Mainframe
$100s Ks
Server
Differences in
scale,
not in substance
Workstation
Personal
Embedded
$10s Ks
$1000s
$100s
$10s
Classifying computers by computational power and price range.
BYU CS/ECEn 124
Chapter 01 - Abstraction
44
Automotive Embedded Computers
Impact sensors
Brakes
Airbags
Engine
Cent ral
controller
Navigation &
entert ainment
Embedded computers are ubiquitous, yet invisible. They are found in
our automobiles, appliances, and many other places.
BYU CS/ECEn 124
Chapter 01 - Abstraction
45
PC’s and Workstations
Notebooks, a common class of portable computers, are much
smaller than desktops but offer substantially the same
capabilities. What are the main reasons for the size difference?
BYU CS/ECEn 124
Chapter 01 - Abstraction
46
BYU CS/ECEn 124
Chapter 01 - Abstraction
47