1Wright State University, College of EngineeringDr. T. Doom, Computer Science & Engineering
EGR 191Intro. to Engineering
Dr. Travis Doom
Wright State University
Computer Science and Engineering
A beginning engineer’s guideA beginning engineer’s guideto the digital computerto the digital computer
2Wright State University, College of EngineeringDr. T. Doom, Computer Science & Engineering
EGR 191Intro. to Engineering
What What isis a computer? a computer?
What is computation? There are many sorts of computing devices, they fall into two categories:
– Analog: machines that produce an answer that measures some continuous physical property such as distance, light intensity, or voltage. Examples?
– Digital: machines that perform computations by manipulating a fixed finite set of elements. Examples?
– The difficulty with analog devices is that it is very hard to increase their accuracy. Before modern digital computers, the most common digital machines were
adding machines.– Adding machines perform exactly one sort of operation.
Computers also perform one operation… but their operation is to accept a set of instructions that tell it how to do any sort of computation.
3Wright State University, College of EngineeringDr. T. Doom, Computer Science & Engineering
EGR 191Intro. to Engineering
Universal computing devicesUniversal computing devices
Turing’s Thesis: Computer scientists believe that ANYTHING that can be computed, can be computed by a computer (provided that it has enough time and enough memory).
What does this imply?– All computers (from the least expensive to the most expensive) are capable of
computing EXACTLY the same things IF they are given enough time and enough memory.
– Some computers can do things faster, but none can do more than any other computer.
– All computers can do exactly the same same things!
Thus, any given problem is either computable or it is not computable– Problems may be computable, but still not feasible (NPC)
4Wright State University, College of EngineeringDr. T. Doom, Computer Science & Engineering
EGR 191Intro. to Engineering
How How dodo we get the electrons to do the work? we get the electrons to do the work?
We describe our problems in English or some other natural language. Computer problems are solved by electrons flowing around inside the computer.
It is necessary to transform our problem from a natural language to the voltages that influence the flow of electrons.
This transformation is really a sequence of systematic transformations, developed and improved over the last 50 years, which combine to give the computer the ability to carry out what may appear to be very complicated tasks. In reality, these tasks must be simple and straight-forward.
5Wright State University, College of EngineeringDr. T. Doom, Computer Science & Engineering
EGR 191Intro. to Engineering
The principle of design abstractionThe principle of design abstraction
General model for Engineering (Byrne, 1992)
Existing System Target System
Implementation
Design
Requirements Requirements
Con-ceptual
Con-ceptual
Design
Implementation
re-think
re-specify
re-design
re-build
Alteration
ReverseEngineeringAbstraction
ForwardEngineeringRefinement
6Wright State University, College of EngineeringDr. T. Doom, Computer Science & Engineering
EGR 191Intro. to Engineering
Levels of abstraction in digital computationLevels of abstraction in digital computation
Design Process
Algorithm & Language
The Problem
ISA & Microarchitecture
Circuits & Devices
Software level
Hardware level
Logic level
Computer Science
Computer Engineering
Computer/Elect. Engineering
7Wright State University, College of EngineeringDr. T. Doom, Computer Science & Engineering
EGR 191Intro. to Engineering
The statement of the problemThe statement of the problem
We describe problems that we wish to solve with a computer in a “natural language.”
Natural languages are fraught with a lot of things unacceptable for providing instructions to a computer.
The most important of these unacceptable attributes is ambiguity. To infer the meaning of a sentence, a listener is often helped by context that the computer does not have.
Example: “Time flies like an arrow.”– How fast time passes– Track meet– Gossip
A computer is an electronic idiot and can not deal with any ambiguity, thus…
Algorithm & Language
The Problem
ISA & Microarchitecture
Circuits & Devices
8Wright State University, College of EngineeringDr. T. Doom, Computer Science & Engineering
EGR 191Intro. to Engineering
The algorithmThe algorithm
The first step in the sequence of transformations is to transform the natural language description of the problem to an algorithm.
An algorithm is a step-by-step procedure:– That transforms an input (possibly NULL) into
some output (or output action)– That is guaranteed to terminate
Definiteness: Each step is precisely stated. Effective computability: Each step must be
something the computer can perform Finiteness: The procedure must terminate For any computable problem, there are an
infinite number of algorithms to solve it.– Which solution is best?
Algorithm & Language
The Problem
ISA & Microarchitecture
Circuits & Devices
9Wright State University, College of EngineeringDr. T. Doom, Computer Science & Engineering
EGR 191Intro. to Engineering
The programming languageThe programming language
The next step is to transform the algorithm into a computer program
Programming languages are unambiguous “mechanical” languages
There are two kinds of programming languages:– High-level languages are machine independent.
They are “far above” the (underlying) computer
– Low-level languages are machine dependent. They are tied to the computer on which the program will execute. There is generally only one such language per machine (referred to as its ASSEMBLY language).
Algorithm & Language
The Problem
ISA & Microarchitecture
Circuits & Devices
10Wright State University, College of EngineeringDr. T. Doom, Computer Science & Engineering
EGR 191Intro. to Engineering
The instruction set architecture (ISA)The instruction set architecture (ISA)
The next step is to translate the program into the instruction set of the particular computer that will be used to carry out the work of the program.
The Instruction Set Architecture (ISA) is the complete specification of the interface between programs that have been written and the underlying hardware that must carry out the work of those programs.
– Examples: IA-32 (Intel, AMD, and others), PowerPC (Motorola)
Programs are translated from high languages in to the ISA of the computer on which they will be run by a program called a compiler (specific to the ISA).
Programs are translated from assembly to the ISA by an assembler
Analogy: A car– The car’s ISA describes what the driver sees/uses.
Algorithm & Language
The Problem
ISA & Microarchitecture
Circuits & Devices
11Wright State University, College of EngineeringDr. T. Doom, Computer Science & Engineering
EGR 191Intro. to Engineering
The microarchitectureThe microarchitecture
The next step is to transform the ISA into an implementation. The detailed organization of an implementation is called its microarchitecture.
– The IA-32 has been implemented by several different processors over the past twenty years 8086 (Intel, 1979), 8286, 8386, 8486, Pentium, PentiumII, Athlon, PentiumIII.
– Each implementation is an opportunity for computer designers to make different trade-offs between cost and performance. [Computer design is always an exercise in trade-offs.]
Analogy: A car– The implementation of a car’s ISA is what goes on
under the hood. Here all automobiles makes and models are different. Some with fuel injection, some have eight cylinders, some are turbocharged… in each case the “microarchitecture” of a specific automobile is the result of the automobile designers’ decisions regarding cost and performance.
Algorithm & Language
The Problem
ISA & Microarchitecture
Circuits & Devices
12Wright State University, College of EngineeringDr. T. Doom, Computer Science & Engineering
EGR 191Intro. to Engineering
The logic circuitThe logic circuit
The next step is to implement each element of the microprocessor out of simple logic circuits.
Here there are also choices, as the logic designer decides how to best make the trade-offs between cost and performance.
Even in the case of addition, there are several choices of logic circuits to perform this operation and differing speeds and corresponding costs.
Algorithm & Language
The Problem
ISA & Microarchitecture
Circuits & Devices
13Wright State University, College of EngineeringDr. T. Doom, Computer Science & Engineering
EGR 191Intro. to Engineering
The devicesThe devices
Finally, each basic logic circuit is implemented in accordance with the requirements of the particular device technology used.
So, CMOS circuits are different from NMOS circuits, which are different, in turn, from gallium arsenide circuits.
Algorithm & Language
The Problem
ISA & Microarchitecture
Circuits & Devices
Vin
Vout
GND
Vcc
Rc
Rb
14Wright State University, College of EngineeringDr. T. Doom, Computer Science & Engineering
EGR 191Intro. to Engineering
Electronic aspects of digital designElectronic aspects of digital design
Vin low Ib = 0
– transistor cut off: Vout = Vcc
Vin high Ib > 0
– transistor “on”: Vout = GND
Vin
Vout
GND
Vcc
Rc
Rb
VccVIHminVOLmax
Vin
VOLmax
VOHmin
GND
Vcc
VCESat
Vout
Abnormal except for switching
VOLmax: max output voltage in low state
VOHmin: min output voltage in high state
VILmax: max input voltage recognized as low
VIHmin: min input voltage recognized as high
15Wright State University, College of EngineeringDr. T. Doom, Computer Science & Engineering
EGR 191Intro. to Engineering
Digital devicesDigital devices
Analog characteristics– Continuous signal levels
– Very small, smooth level changes
Digital characteristics– Discrete signal levels (voltage usually)
– Two levels: on/off, high/low 1/0 (binary)
– Disjoint or quantized level changes
Digital Concepts and Devices– Digital Design also called Logic Design
– Logic Gates - the most basic digital devices
– Digital devices have analog electronic aspect
t
v
v
t
16Wright State University, College of EngineeringDr. T. Doom, Computer Science & Engineering
EGR 191Intro. to Engineering
Basic logic circuitsBasic logic circuits
AND gate– Output Z = 1 only when inputs A and B are both 1
OR gate– Output Z = 1 only when inputs A or B or both are 1
NOT gate or inverter– Output Z = 1 only when input A is 0
Simple alone, but combine a few
million gates and…
A
BZ
A
BZ
ZA
/A
/ B
F
17Wright State University, College of EngineeringDr. T. Doom, Computer Science & Engineering
EGR 191Intro. to Engineering
Complex logic circuitsComplex logic circuits
Logic circuits divide into two major types:
Combinational Logic– Current output depends on current input only
– Examples: gates, decoders, multiplexors (MUXs), ALUs
Sequential Logic– Current output depends on past inputs as well as current input
– Thus has a memory (usually called the state)
– Examples: latches, flip-flops, state machines, counters, shift registers
+
*p
mn
p * (m + n)
Design:avg (w,x,y,z)a^2+2ab+b^2
18Wright State University, College of EngineeringDr. T. Doom, Computer Science & Engineering
EGR 191Intro. to Engineering
STATE- A collection of state variables whose values at any one time contain all the information about the past values necessary to account for future behavior.
Example: A TV tuner could have a current channel stored internally, so the next channel can be predicted as a function of the inputs, i.e. the UP button increases the channel by one, the DOWN button decreases the channel by one. What is the state of this TV tuner?
Digital sequential logic– State variables are binary values– Circuit with n binary state variables has 2n possible states– Also known as a finite state machine (FSM).– Changes usually synchronized with a system clock
Sequential logic definitions
19Wright State University, College of EngineeringDr. T. Doom, Computer Science & Engineering
EGR 191Intro. to Engineering
Bistable ElementBistable Element
The simplest possible feedback sequential logic circuit is shown below:
It is bistable because it has two stable states:– State 1: If Q (Q=Vout1=Vin2) is high, the bottom inverter output
(/Q =Vout2=Vin1) is low, which keeps the top inverter output Q high.
– State 2: If Q is low, the bottom inverter output /Q is high, which keeps the top inverter output Q low.
Vin1
Vin2
Vout1
Vout2
Q
/Q
20Wright State University, College of EngineeringDr. T. Doom, Computer Science & Engineering
EGR 191Intro. to Engineering
S-R LatchS-R Latch
S R Q /Q
0
0
1
1
0
1
0
1
Last Q
0
1
0
Last /Q
1
0
0
S
RQ
/Q
S
R
Q
Q
Schematic
Symbol
Hold
Reset
Set
ILLEGAL
Function Table
Set
Reset
Characteristic Equation: Q(t+1) = S + R’Q(t)
21Wright State University, College of EngineeringDr. T. Doom, Computer Science & Engineering
EGR 191Intro. to Engineering
Clocked Synchronous State-machine StructureClocked Synchronous State-machine Structure
Next-stateLogic
F
StateMemory
clock
OutputLogic
G
excitationinputs
clock
current state outputs
(Mealy machine)
R
22Wright State University, College of EngineeringDr. T. Doom, Computer Science & Engineering
EGR 191Intro. to Engineering
Random Access Memory (RAM)Random Access Memory (RAM)
A circuit with n + b inputs and b outputs:
2n x bRAM
Address n b Dataoutputs
Memory values determined by user Volatile contents lost without power Uniform (Random) Access delay is uniform for all addresses
b/Data inputs
Write Enable
23Wright State University, College of EngineeringDr. T. Doom, Computer Science & Engineering
EGR 191Intro. to Engineering
Instruction Format: Opcode [15:12], Op A [11:8], Op B [7:4], Op C [3:0]Example Instruction: x2021Opcode 2 Format: M[A] M[B]Instruction: M[0] M[2]
-processor
Instruction
Start
Reset
Clock >
RAM
Ready
AddressData In
Write
Data OutAddress Out
Data Out
Write Enable
Data In
4
4
4
16
Ram Contents (Before) ADDR DATA x0 x4 x1 xF x2 x9 … ...
Ram Contents (After) ADDR DATA x0 x9 x1 xF x2 x9 … ...
A simple microprocessorA simple microprocessor
24Wright State University, College of EngineeringDr. T. Doom, Computer Science & Engineering
EGR 191Intro. to Engineering
-processor
Instruction
Start
Reset
ClockReady
16 Address Out
Data Out
Write Enable
Data In
4
4
4
Control Unit Data Unit
VNCZ4
14
4Constant
ControlWord
>
>
Example Instruction: x2021Opcode 2 Format: M[A] M[B]Instruction: M[0] M[2]
• R0 Constant B• Address Out R0, R1 Data In• R0 Constant A• Address Out R0, Data Out R1, Write Enable• Return to IDLE state (Sequencing Instruction)
A simple microarchitectureA simple microarchitecture
25Wright State University, College of EngineeringDr. T. Doom, Computer Science & Engineering
EGR 191Intro. to Engineering
Instruction
Start
Reset
Clock
Ready
16
Write Enable
VNCZ4
14
4Constant
ControlWord
OperandSelect
>CLR
CAR
DATA LD/CNT’
Generate Data Signal Logic
Generate Load Signal Logic
CONTROLSTORE(ROM)
Generate Ready
Mode
Condition Code
Next Address
Operand Select
Address Datamicroinstruction
? ?
12:0
16:13
A simple microarchitectureA simple microarchitecture
• R0 Constant B• Address Out R0, R1 Data In• R0 Constant A• Address Out R0, Data Out R1, Write Enable• CAR x00 (IDLE STATE)
26Wright State University, College of EngineeringDr. T. Doom, Computer Science & Engineering
EGR 191Intro. to Engineering
A simple microprocessorA simple microprocessor
Central Processing Unit– Control Unit, Integer Datapath (Load/Store, Integer ALU)
Floating Point Unit– Floating Point Datapath
Internal Cache– SRAM for Instruction Cache (i-cache) and Data Cache (d-cache)
Memory Management Unit– Controls communication with Main Memory and other I/O
FPU
CPU
Internal Cache
MMU
Bus
27Wright State University, College of EngineeringDr. T. Doom, Computer Science & Engineering
EGR 191Intro. to Engineering
A simple computer architectureA simple computer architecture
Generic Computer System.– Current architectures are performance driven, and vary widely.
Processor– Uniprocessor systems
ASIC (Application Specific Integrated Circuit)– Performs a specific task, not a general purpose processor (e.g. Voodoo)
I/O Device– Accesses data devices (e.g. Graphics Adapter, Disk Controller, et al.)
Processor
Memory
ASIC
I/O Device
ASIC
I/O Device
Bus
28Wright State University, College of EngineeringDr. T. Doom, Computer Science & Engineering
EGR 191Intro. to Engineering
A contemporary architectureA contemporary architecture
Front Side Bus100 MHz?
MicroprocessorsMemory Chipset
Bridge Back Side BusPCI - 33MHz
Main Memory
Graphics Adapter(non-AGP)
AGP
External Cache
Disk Interface(EIDE,uSCSI-2)
Network Interface Card (NIC)
Serial/Parallel I/O(keyboard, mouse, printer)
ISA devices Compatibility Bridge(South-side, ISA)
Registers 2nsL1 On-chip 4nsL2 On-chip 5nsL3 Off-chip 30nsMemory 220nsPaged VM > 1 ms!
29Wright State University, College of EngineeringDr. T. Doom, Computer Science & Engineering
EGR 191Intro. to Engineering
The instruction setThe instruction set
High-Level Language - C A = B + C;
– Memory-Transfer Equivalent Mem[A] Mem[B] + Mem[C] Mem[EA00] Mem[EA08] + Mem[EA10]
Machine-Level Equivalent – Assembly (human readable) ex: Machine (for a simple architecture)
Load R2, B E2EA08 Load R3, C E3EA10 R2 R2 + R3 0223 Store A, R2 F2EA00
The bits of a machine instruction are divided into fields– eg: E2EA08– E: Operation “Load”; 2: Destination Address R2; EA08: Address Field– The operation field (opcode) defines the format for the instruction
30Wright State University, College of EngineeringDr. T. Doom, Computer Science & Engineering
EGR 191Intro. to Engineering
The instruction setThe instruction set
There are three basic types of computer instructions– Register Instructions: operate on values stored in registers
Arithmetic, Shift, and Logic instructions
– Move Instructions: move data between memory and registers Load/Store instructions Move/Copy portions of memory
– Branch Instructions: select one of two possible next instructions to execute Branch on condition, Unconditional branch (Jump) Only one address is explicit, the other operand is implict
– e.g.: Beq R2, R3, A
– If the contents of R2 = R3 then execute the instruction at location A next (explict)
– otherwise, execute the next instruction in the normal order (using the PC) (implict)
31Wright State University, College of EngineeringDr. T. Doom, Computer Science & Engineering
EGR 191Intro. to Engineering
The Von Neumann architectureThe Von Neumann architecture
The Von Neumann model of computer processing– Program and data are both stored as sequences of bits in the computer’s
memory.
– The program in executed on instruction at a time under the direction of the control unit.
The instruction-execution cycle– Instruction Fetch (IF) stage
Get next instruction from the memory address referenced by the PC Place the new instruction in the Instruction Register Increment the PC to the next instruction address
– Execute operation (EX) stage Execute the operation specified in the opcode
– Branch instructions may update the PC
– Repeat
32Wright State University, College of EngineeringDr. T. Doom, Computer Science & Engineering
EGR 191Intro. to Engineering
How do we specify the program?How do we specify the program?
Contemporary languages– C, C++, Perl, Java, and hundreds more.
Languages of Yore– Fortran, COBOL, and scores more.
Specialty languages– VHDL, simulation languages, and thousands more.
There are over 1,000 “standardized” programming languages today.
The only goal of these languages is to help humans implement their algorithms in the instructions available for a particular ISA
33Wright State University, College of EngineeringDr. T. Doom, Computer Science & Engineering
EGR 191Intro. to Engineering
How do we execute the program?How do we execute the program?
HARDWARE
CPU
Memory
I/O Devices
APPLICATION PROGRAMS
Compilers
Databases
Games
Productivity Tools
USERS
How do we use the
resources?
OS
Limited Resources Many Demands
SOFTWARE
34Wright State University, College of EngineeringDr. T. Doom, Computer Science & Engineering
EGR 191Intro. to Engineering
What is an Operating System?What is an Operating System?
Do we want all programs to have access to all instructions? The OS is a program that acts as an intermediary between the application
programs and the hardware resources– All communication requires hardware resources, thus the OS is also an
intermediary between users and applications The purpose of any OS is to provide an environment in which:
– users can (conveniently) execute programs and access data
– application programs can (efficiently and fairly) access system resources (processor time, memory, file space, I/O devices, etc.)
The OS need not perform any other useful function: it is a control environment (kernel) controls access to all resources– All other software is an application program
– How does the existence of an OS simplify coding an app?
– Do you trust others to protect your rights and data?
35Wright State University, College of EngineeringDr. T. Doom, Computer Science & Engineering
EGR 191Intro. to Engineering
The algorithmThe algorithm
Developing an algorithm to solve a problem is non-trivial As with many issues in engineering, there are trade-offs to be made
between performance (the correctness of the solution) and cost (the time it takes for the algorithm to complete.
Consider the Traveling salesman problem:– You must visit, by car, n different cities. From each city, you can get to
any other city – but the distances between them vary.
– Your “Problem” is to find the shortest route that visits every city exactly once.
36Wright State University, College of EngineeringDr. T. Doom, Computer Science & Engineering
EGR 191Intro. to Engineering
Exponential growthExponential growth
10^1 10^2 10^3 Number of students in the college of engineering 10^4 Number of students enrolled at Wright State University 10^6 Number of people in Dayton 10^8 Number of people in Ohio 10^10 Number of stars in the galaxy 10^20 Total number of all stars in the universe 10^80 Total number of particles in the universe 10^100 << Number of possible solutions to traveling salesman (100)
Travelling saleman (100) is computable but it is NOT feasible.
37Wright State University, College of EngineeringDr. T. Doom, Computer Science & Engineering
EGR 191Intro. to Engineering
Optimization algorithmsOptimization algorithms
The knapsack problem– You stumble across some valuable
artifacts while out in the wild. Unfortunately, you can only add ten lbs to your pack and still make it back to civilization.
– What do you take?
Item Value Weight $/lb
A $150 10 lbs. 15
B $140 7 lbs. 14
C $100 5 lbs. 10
D $60 3 lbs. 20
E $45 3 lbs. 15
38Wright State University, College of EngineeringDr. T. Doom, Computer Science & Engineering
EGR 191Intro. to Engineering
Bug brain demoBug brain demo
Your laboratory assignment this week is to gain some familiarity with the concept of solving relatively complex problems with very simple primitives.