ee 109 unit 12 computer organization - usc...
TRANSCRIPT
1
EE 109 Unit 12 – Computer Organization
2
A BRIEF SUMMARY Review of some key concepts from the first half of the semester
3
A Few Big Ideas 1
• Setting and clearing bits in a register tells the hardware what do and when (this is SW interacting with HW)
• Speed matters – Your software is executing quickly compared to how fast a human can
do something
– You can use that to your advantage: blinking an LED at a fast rate can give the illusion it's always on but just more dim
– Or it can work to your disadvantage: One button press may look like many because a loop may see one press on multiple iterations.
– We must write our software with this in mind
4
A Few Big Ideas 2 • Clocking or enables are necessary to say "when"
– Digital signals are always 1's and 0's so just looking at the bits doesn't tell us how many we have
– We usually need clocks (pulses) to tell the hardware when we want it to grab the data
Just looking at this set of digital values,
are we sending 0101 once, twice, three
times, how many? Once because we
use the clock/enable to indicate that.
But without the clock we'd have no clue
how many times we are trying to write
0101
5
A Few Big Ideas 3
• External events happen asynchronously with your software (don't know "when" something has happened)
– Your software program is the brains for how to process information but it doesn't magically know "when" something has happened?
– We have to keep checking it (polling) or
– Hardware designers built "interrupt" mechanisms to help
• Many tasks can be done in either SW or HW; SW may be easier to code/use but HW provides parallelism
– A 0.1 second timer can be done in SW using delays but then software can't do much else
– Or in HW using timers allowing SW to do other tasks
6
REVISITING CECS Big picture ideas of what the CECS major prepares you for
7
Remember Day 1
http://www.cmu.edu/news/image-archive/Boss.jpg
http://prisonerofclass-5933.zippykid.netdna-cdn.com/wp-content/uploads/2013/05/iphone.jpg
http://firstcallappliance.com/wp-content/uploads/image/microwave.jpg
http://www.amazon.com/Fisher-Price-T-M-X-Tickle-Me-Elmo/dp/B000ETRE0Q
http://oeatech.net/wp-content/uploads/2011/03/RADARSAT2-satellite.jpg
• Computer engineering prepares you for a broad set of fields
– You could work in the SW industry
– You could work in the HW industry
– You will be most qualified for jobs that combine that knowledge
• We've been focused on the software/hardware interaction embodied in embedded systems
8
You Can Do That…
C / C++ / Java
Logic Gates
Transistors
HW
S
W
Voltage / Currents
Assembly /
Machine Code
Applications
Libraries OS
Processor / Memory / I/O
Functional Units
(Registers, Adders, Muxes)
Devices & Integrated Circuits
(Semiconductors & Fabrication)
Architecture
(Processor & Embedded HW)
Systems & Networking
(Embedded Systems, Networks)
Applications
(AI, Robotics, Graphics, Mobile)
Cloud & Distributed Computing
(CyberPhysical, Databases, Data
Mining,etc.)
Scripting &
Interfaces Networked
Applications
What we've been focusing on thus far
9
Dive Into a SmartPhone
• Here's a picture of what's inside the iPhoneTM 6
• Both sides of the circuit board are populated with chips
http://www.techinsights.com/teardown.com/apple-iphone-6/
https://d3nevzfk7ii3be.cloudfront.net/igi/6MaZk5cEE2tm1uCj.huge Battery
2-sided Circuit Board
10
What's Inside Your SmartPhone
• What's inside an iPhone 6?
• Microcontrollers/microprocessors – Apple A8 APL1011 SoC + Elpida 1 GB LPDDR3 RAM
– SoC = System on Chip…Not just a processor but a processor with custom hardware to do specialized tasks…on-board graphics processor in this case
– NXP LPC18B1UK ARM Cortex-M3 Microcontrollers
– Similar on-board I/O modules as the Arduino. Take a look…
– http://www.nxp.com/products/microcontrollers/cortex_m3/
• Modem + Amplifiers + Transceivers for wireless communication – Qualcomm MDM9625M LTE Modem + many others
http://www.techinsights.com/teardown.com/apple-iphone-6/
11
What's Inside?
• A gyroscope, accelerometer, and touchscreen – InvenSense MP67B 6-axis gyroscope and accelerometer
combo
– Broadcom BCM5976 Touchscreen Controller
– Both use some form of A-to-D conversion to sense motion or touch
• Memory Storage – SK Hynix H2JTDG8UD1BMS 128 Gb (16 GB) NAND Flash
• Other specialized HW I/O modules – Murata 339S0228 Wi-Fi Module
– Qualcomm PM8019 power management IC
– Cirrus Logic 338S1201 audio codec
http://www.techinsights.com/teardown.com/apple-iphone-6/
12
Computer Engineering & HW
• Computer engineering prepares you to work in jobs that design these kinds of systems by: – Learning how to design digital circuits
using logic gates [AND, OR, NOT] (EE 154 and EE 254 Digital System Design)
– Learning how to optimize processors to execute software as efficiently as possible (EE 457 Computer Architecture)
– Learn how to assemble many HW pieces (processor cores, RAM, specialized HW) to form systems-on-chip (EE 454L – SoC Design)
– Learn some of the physics and science of fabricating these designs on silicon (EE 277L and EE 477L VLSI Design) http://www.anandtech.com/show/8562/chipworks-a8
Die Photo of the Apple A8
SoC Processor
13
BASIC COMPUTER ORGANIZATION
14
You Can Do That…
C / C++ / Java
Logic Gates
Transistors
HW
S
W
Voltage / Currents
Assembly /
Machine Code
Applications
Libraries OS
Processor / Memory / I/O
Functional Units
(Registers, Adders, Muxes)
Devices & Integrated Circuits
(Semiconductors & Fabrication)
Architecture
(Processor & Embedded HW)
Systems & Networking
(Embedded Systems, Networks)
Applications
(AI, Robotics, Graphics, Mobile)
Cloud & Distributed Computing
(CyberPhysical, Databases, Data
Mining,etc.)
Scripting &
Interfaces Networked
Applications
Where we will head now…
15
Computer Engineering as Abstraction Levels
C / C++ / Java
Logic Gates
Transistors
HW
S
W
Voltage / Currents
Assembly /
Machine Code
Applications
Libraries OS
Processor / Memory / I/O
Functional Units
(Registers, Adders, Muxes)
Controlling
Input
(Gate )
Output
(Drain )
Source
Fx
y
z
+ B
A
S
if (x > 0) then
x = x + y - z;
a = b*x;
Transistors
Logic AND
gate
Functional
Units
Chips
(Processors)
Software
Code
CMPR X,0
JLE SKIP
ADD X,X,Y
SUB X,X,Z
SKIP MUL A,B,X
- -
- -
- -
-
1110010101…
16
Motivation
• We will start to learn assembly language so that…
– …we understand why high level code has some of the constructs it has (if, while, etc)
– …we understand the basic hardware inside a computer and why certain structures are there
– …we can start to understand why HW companies create the structures they do (multicore processors)
– …we can start to understand why SW companies deal with some of the issues they do (efficiencies, etc.)
17
Computer Organization
• Three primary sets of components – Processor
– Memory
– I/O (everything else)
• Tell us where things live? – Running code
– Compiled program (not running)
– Circuitry to execute code
– Source code file
– Data variables
– Data for the pixels being displayed on your screen
18
Input / Output • Processor performs reads and writes to communicate with I/O
devices just as it does with memory – I/O devices have locations (i.e. registers) that contain data that the
processor can access
– These registers are assigned unique addresses just like memory
Video
Interface
FE may
signify a
white dot at
a particular
location
…
800
Processor Memory
A D C
800
FE
WRITE
…
0
3FF
FE
01
Keyboard
Interface
61 400
‘a’ = 61 hex
in ASCII
19
Processor
• 3 Primary Components inside a processor – ALU – Registers – Control Circuitry
• Connects to memory and I/O via address, data, and control buses (bus = group of wires)
Processor
Addr
Data
Control
Memory
0
1
2
3
4
5
6
Bus
20
Arithmetic and Logic Unit (ALU)
• Executes arithmetic operations like addition and subtraction along with logical operations (AND, OR, etc.)
Processor
Addr
Data
Control
Memory
0
1
2
3
4
5
6
ALU ADD,
SUB,
AND,
OR
op.
in1
in2
out
21
Registers
• Some are for general use by software
– Registers provide fast, temporary storage locations within the processor (to avoid having to read/write slow memory)
• Others are required for specific purposes to ensure proper operation of the hardware
Processor
Addr
Data
Control
Memory
0
1
2
3
4
5
6
ALU ADD,
SUB,
AND,
OR
op.
in1
in2
out
PC
R0-R31
22
General Purpose Registers
• Registers available to software instructions for use by the programmer/compiler
• Instructions use these registers as inputs (source locations) and outputs (destination locations)
Processor
Addr
Data
Control
Memory
0
1
2
3
4
5
6
ALU ADD,
SUB,
AND,
OR
op.
in1
in2
out
R0-R31
PC
23
What if we didn’t have registers?
• Example w/o registers: F = (X+Y) – (X*Y) – Requires an ADD instruction, MULtiply instruction, and SUBtract
Instruction – w/o registers
• ADD: Load X and Y from memory, store result to memory • MUL: Load X and Y again from mem., store result to memory • SUB: Load results from ADD and MUL and store result to memory • 9 memory accesses
Processor
Addr
Data
Control
Memory
0
1
2
3
4
5
6
ALU ADD,
SUB,
AND,
OR
op.
in1
in2
out
R0-R31
X
Y
F
PC
24
What if we have registers?
• Example w/ registers: F = (X+Y) – (X*Y) – Load X and Y into registers
– ADD: R0 + R1 and store result in R2
– MUL: R0 * R1 and store result in R3
– SUB: R2 – R3 and store result in R4
– Store R4 back to memory
– 3 total memory access
Processor
Addr
Data
Control
Memory
0
1
2
3
4
5
6
ALU ADD,
SUB,
AND,
OR
op.
in1
in2
out
R0-R31
X
Y
X
Y F
PC
25
Other Registers
• Some bookkeeping information is needed to make the processor operate correctly
• Example: Program Counter (PC) – Recall that the processor must fetch instructions from memory before
decoding and executing them
– PC register holds the address of the currently executing instruction
Processor
Addr
Data
Control
Memory
0
1
2
3
4
5
6
ALU ADD,
SUB,
AND,
OR
op.
in1
in2
out
PC
R0-R31
26
Fetching an Instruction
• To fetch an instruction – PC contains the address of the instruction
– The value in the PC is placed on the address bus and the memory is told to read
– The PC is incremented, and the process is repeated for the next instruction
Processor
Addr
Data
Control
Memory
inst. 2
0
1
2
3
4
FF
ALU ADD,
SUB,
AND,
OR
op.
in1
in2
out
0 PC
R0-R31
inst. 1
inst. 3
inst. 4
inst. 5
…
PC = Addr = 0
Data = inst.1 machine code
Control = Read
27
Fetching an Instruction
• To fetch an instruction – PC contains the address of the instruction
– The value in the PC is placed on the address bus and the memory is told to read
– The PC is incremented, and the process is repeated for the next instruction
Processor
Addr
Data
Control
Memory
inst. 2
0
1
2
3
4
ALU ADD,
SUB,
AND,
OR
op.
in1
in2
out
1 PC
R0-R31
inst. 1
inst. 3
inst. 4
inst. 5
PC = Addr = 1
Data = inst.2 machine code
Control = Read
FF
…
28
Control Circuitry
• Control circuitry is used to decode the instruction and then generate the necessary signals to complete its execution
• Controls the ALU
• Selects Registers to be used as source and destination locations
Processor
Addr
Data
Control
ALU ADD,
SUB,
AND,
OR
op.
in1
in2
out
R0-R31
Control
Memory
inst. 2
0
1
2
3
4
inst. 1
inst. 3
inst. 4
inst. 5
0 PC
FF
…
29
Control Circuitry
• Assume 0201 hex is machine code for an ADD instruction of R2 = R0 + R1
• Control Logic will… – select the registers (R0 and R1)
– tell the ALU to add
– select the destination register (R2)
Processor
Addr
Data
Control
ALU ADD
ADD
in1
in2
out
0 PC
R0-R31
Control
Memory
inst. 2
0
1
2
3
4
0201
inst. 3
inst. 4
inst. 5
0
0201
FF
…
30
BACKUP
31
Dive Into A Smartphone
• What's inside? – Apple A8 APL1011 SoC + Elpida 1 GB LPDDR3 RAM
– NXP LPC18B1UK ARM Cortex-M3 Microcontrollers (which is the proper name for the M8 motion coprocessor)
– Qualcomm MDM9625M LTE Modem
– InvenSense MP67B 6-axis gyroscope and accelerometer combo
– SK Hynix H2JTDG8UD1BMS 128 Gb (16 GB) NAND Flash
– Murata 339S0228 Wi-Fi Module
– Broadcom BCM5976 Touchscreen Controller
– Qualcomm PM8019 power management IC
– Cirrus Logic 338S1201 audio codec
http://www.zdnet.com/whats-inside-the-iphone-6-plus-7000033873/