Uploaded by 김성훈

Lecture3 Computer architecture

advertisement
Fundamentals of Computer
Lecture 3
Computer system
• Hardware: The mechanical devices that make up a computer
• Software: A set of instructions that control the behavior of the hardware.
Computer
Hardware
CPU
Memory
Software
I/O Device
System SW
Application SW
Hardware configuration
CPU
ALU
Input
device
Output
device
Control Unit
Register
Main memory
Secondary
memory
Data flow
Hardware configuration
• Central Processing Unit (CPU)
• Reads and processes program instructions and data from the main memory.
• Consists of arithmetic and logic units, controls, and registers
• Memory
• Stores programs, data, intermediate results of operations, etc.
• Classified into main memory and secondary memory
• Main memory stores programs and data temporarily
• Secondary memory stores data permanently
• Input and output devices
• Input devices are devices that input various data into the computer.
• An output device is a device that expresses the results of computer
processing to the outside.
System bus
• Data bus: Carries data CPU and other devices (memory, I/O, etc.).
• Address bus: Carries the address of a memory device between CPU and a
memory device, I/O device, etc.
• Control bus: Carries control signals between CPU and memory or I/O devices.
Address bus
CPU
System bus
Main memory
I/O Device
Data bus
Control bus
CPU Configuration
• Arithmetic unit: Performs arithmetic operations such as addition, subtraction,
multiplication, and division, and logical operations such as logical product,
logical sum, and negation.
• Control Unit: A device that controls the execution of instructions in order.
• Register: A high-speed memory device that temporarily stores the instruction
address, instruction code, data required for the operation, and the result of the
operation.
ALU
Control Unit
Register
Data flow
Control flow
CPU Configuration
• Special Purpose Register
Purpose
Save address
Save command
Name
Function
Memory Address Register (MAR)
Storing addresses of main memory to
perform read and write operations.
Program Counter (PC)
Storing addresses of the next command
to perform.
Stack Pointer (SP)
Storing the top address of the stack.
Instruction Register (IR)
Storing the currently executing
command.
Memory Buffer Register (MBR)
Temporarily storing data read from
main memory or data to be stored in
main memory.
Accumulator (AC)
Temporarily storing the result of an
operation.
Save data
Save CPU status Program Status Register (PSR)
Storing current state information of the
CPU.
Behavior of the CPU
CPU
ALU
Input
device
Output
device
Control Unit
Register
Main memory
Data flow
Secondary
memory
Control flow
Command Set
• Instruction Format
OPCODE
OPERAND
Basic formats of instructions
• Operation code (OPCODE): Depending on the type of operation to be
executed, it is divided into operation, control, data transfer, and
input/output functions.
• Operand: Stores addresses, numbers, characters, logical data, etc.
Command Set
• Categorizing instructions by number of operands
0-Address instruction
OPCODE
1-Address instruction
OPCODE
OPERAND 1
2-Address instruction
OPCODE
OPERAND 1
OPERAND 2
3-Address instruction
OPCODE
OPERAND 1
OPERAND 2
OPERAND 3
Command Set
• Categorizing instructions by the number of address fields
• 0-address instructions: only opcodes exist, used in stack-structured
computers
PUSH Operation
Processing of X=(A+B)
PUSH A
// Top of the stack ← A
PUSH B
// Top of the stack ← B
ADD
// Top of the stack ← (A+B)
* POP A and B from the stack, add them together, and PUSH the result
STORE X
// X ← Top of the stack
POP Operation
Command Set
• Categorizing instructions by the number of address fields
• 1-address instructions:
• Used in single accumulator structure computers
• Performs a data operation using the accumulator registers.
• The operation uses data read from the main memory and data stored
in the accumulator.
• The result of the operation is stored back in the accumulator
Processing of X=(A+B)
LOAD A
// AC ← A
ADD B
// AC ← AC + B
* Add A stored in AC and B read from memory and store the result in AC
STORE X
// X ← AC
Command Set
• Categorizing instructions by the number of address fields
• 2-address instructions: Has two address fields and the most common form
Processing of X=(A+B)
MOV R1, A
// R1 ← A
ADD R1, B
// R1 ← R1 + B
* Add register R1 and B read from the main memory and store the result in R1
MOV X, R1
// X ← R1
• 3-address instructions: Has three address fields, and specify a register
number or the address of a main memory in the address field.
Processing of X=(A+B)
ADD X, A, B
// X ← A + B
* Add A and B, read from main memory, and store the result in main memory X.
Command Processing
• Instruction Cycle
• The sequence of activities required for CPU to fetch and execute one
instruction at a time from the main memory.
Start
Fetch cycle
Execute cycle
Fetch
Execute
End
Command Processing
• Fetch and execute cycles are always performed.
• Indirect cycles and interrupt cycles are performed only when needed,
depending on the addressing scheme and interrupt demands.
Fetch
Interrupt
Indirect
Execute
Command Processing
• Fetch cycles
• Retrieves an instruction from the main memory
• Increments the program counter (PC) value to fetch the next instruction
Control
Unit
Data bus
Main memory
Address bus
Command Processing
• Execution cycles
• Execute instructions by decoding fetched instructions and generating
control signals based on the results.
• Indirect cycles
• Divided into direct and indirect addressing methods
OPCODE
Address
OPCODE
Address
Address
Valid
address
Direct addressing
Data
Data
Indirect addressing
Valid
address
Command Processing
• Interrupt cycles
• Interrupt: An unexpected event that occurs inside or outside a computer
system while the CPU is executing a program.
Start
Fetch cycle
Fetch
Execute
No
Execute cycle
①
Interrupt
Yes
Interrupt
handling
routines.
Interrupt cycle
Hierarchy of memory devices
• Memory is divided into the following four devices based on access speed,
memory capacity, and purpose
Register
Increase access speed
Increased storage costs
Reduced memory capacity
Cache memory
Main memory
Secondary memory
• Data flows through a memory device as follows
Register
Cache memory
Main memory
Secondary memory
Main memory
• Stores programs, data, and intermediate results of computations while the
computer is running
• Early main memories utilized magnetic cores.
• Nowadays, semiconductor memory is mainly used
Magnetic core
Main memory
• RAM
• Volatile memory that erases all stored information when the power is
turned off.
• Random access memory that can be read or written to within a certain
amount of time, regardless of where it is stored.
RAM
Main memory
• DRAM
• Stores information by utilizing the electrical charge in a storage battery
within a transistor.
• The charge in the storage battery discharges over time, requiring periodic
recharging
• Low cost, low power consumption, fast operation, and high density
• Suitable for high-capacity memory
• SRAM
• Consists of flip-flop memory elements
• Does not require periodic recharging like DRAM because information is
retained as long as power is applied
• Complex circuitry, high power consumption, and expensive compared to
DRAM
• Mostly used for cache memory
Main memory
• ROM
• A memory device that only reads stored programs and data.
• Non-volatile memory that can permanently retain stored information even
when not powered.
• Used to store programs or data
• Masked ROM, PROM, EPROM, and EEPROM according to the number of
times information is written and how it is stored
• PROM: Programmable Read Only Memory
• EPROM: Erasable Programmable Read Only Memory
• EEPROM: Electrically Erasable PROM
Masked ROM
PROM
EPROM
EEPROM
Cache memory
• Memory space to prevent performance degradation due to long access times
from the CPU to the main memory.
CPU
Access speed
improvement
Access speed
degradation
Cache mem.
Main mem.
Cache hit rate (H) = #(cache hits) / #(total memory access)
Effective access time = H x (Memory access time for cache hit)
+ (1-H) x (Memory access time for cache miss)
Cache memory
• Example
• What is the effective access time if the cache memory access time is 20 ns,
the main memory access time is 100 ns, and the cache hit rate is 95%?
Effective access time = (0.95 × 20 ns) + (0.05 × 120 ns) = 25 ns
OR
Effective access time = 20 ns + (0.05 × 100 ns) = 25 ns
(Miss-penalty)
Cache memory
• Hierarchy of cache memory
CPU
L1 Cache
L2 Cache
Main mem.
• T1 = 1ns, T2 = 10ns and T3 = 500ns
• H1 = 0.8, H2 = 0.9
• Effective access time = T1 + (1-H1)*H2*(T1+T2) + (1-H1)*(1-H2)*(T1+T2+T3)
Secondary memory
• A large-capacity storage device that permanently stores programs or data.
• Sequential access memory and direct access memory
• Sequential access memory: Read or write information sequentially,
magnetic tape
• Direct-access memory: Reads and writes information by directly accessing
an arbitrary address regardless of where the information is stored,
magnetic disks and optical disks, etc.
Secondary memory
• Magnetic tape
0bit
1bit
Track
Secondary memory
• Magnetic Disk
• Stores information on circular plastic or metal plates coated with magnetic
material
• Can be accessed both sequentially and directly
Floppy Disk
Hard Disk (HDD)
Secondary memory
• Optical Disk
• A storage device that uses laser light to record and play back information,
such as documents, audio, and images, on the surface of a disk by
converting them into digital symbols.
• CD, DVD, Blu-ray Disc, etc.
CD
DVD
Blue-ray
Secondary memory
• CD vs. DVD vs. Blue ray
• Storage capacity
• CDs use a yellow laser with a wavelength of 780 nm
• DVDs use a red laser with a wavelength of 650 nm
• Blue Rays use a narrower blue-violet laser with a wavelength of 405 nm.
• The smaller size of the wavelength allows for a smaller pit, land, to be
read in the same area, resulting in more capacity. (CD=680MB,
DVD=4.7GB, Blue Ray=25GB).
• writing/reading speeds
• CD: 153.6 KB/s, DVD: 1,108 KB/s, Blue Ray: 36 MB/s.
• These differences are due to the way each disc is read and written. With
the development of yellow, red, and blue-violet lasers, respectively, and
their increasing density, there is a huge difference in read and write
speeds on the same area of storage media.
Secondary memory
• CD vs. DVD vs. Blue ray
• Player
• Blue Ray uses a blue-violet wavelength, so it is impossible to use it with
existing DVD and CD players.
• Increased storage capacity
• CDs have no way of adding capacity by using a single side.
• DVDs record information on both sides, doubling the original capacity.
• Blue Ray uses dual layers (two layers on a single side) to double the
capacity.
• Resolution
• CD=240P, DVD=720P Blue Ray=1080P
Secondary memory
• Flash Memory
• Non-volatile memory that consumes little power and retains stored
information even when not powered.
• Divided into two types: data storage with large storage capacity and code
storage with fast processing speeds
Secondary memory
• Flash Memory
Secondary memory
• NAND vs. NOR
Secondary memory
• Common types of NAND flash storage: SLC (Single-level cell), MLC, TLC, QLC
Low endurance, slow speed, cheap, high capacity
Secondary memory
Input devices
• Keyboard
Mini Bluetooth keyboard
Virtual keyboard
Xbox 360 keyboard
Two-part keyboard
Virtual keyboard in tablet
https://www.youtube.com/watch?v=wXulJKaDEdE
Input devices
• Mouse
Air mouse
• Joystick
Orbita
https://www.youtube.com/
watch?v=5qCwlw9DO7g&t=
14s
Magic mouse
Input devices
• Touch screen
Touch screen (1)
Touch screen (2)
Tablet PC
Input devices
• Resistive film touch panels vs. Capacitive touch panels
• Resistive film touch panels: The position on screen contacted by a finger, stylus, or
other object is detected using changes in pressure.
• Capacitive touch panels : The point at which the touch occurs is identified using
sensors to sense minor changes in electrical current generated by contact with a
finger or changes in electrostatic capacity (load)
Input devices
• Scanner
Flatbed scanners
Handy scanners
Output devices
• Monitor
CRT monitor
• Monitor: OLED
PDP
LCD
Output devices
• Printer
Inkjet
Laser
3D Printer
Output devices
• Haptic
Download