Professional Documents
Culture Documents
Lecture 6
Pitxot, Antoni Figures of the Allegory of Memory 1981 Oil on canvas 180.30 x 90.40 cm. TEATRE-MUSEU DALI
http://www.salvador-dali.org/dali/coleccio
Lecture Template:
CPU Registers Register operations Memory implementation Computer Buses Instructions Using the Stacks Multiple Data Instructions
Computer unit
CPU
ALU Input/output interface
Highest Address
Memory
Lowest Address
Registers
Example: Program counter (PC) or instruction pointer determines next instruction for execution
4
Components of the CU (2 of 2)
Program counter (instruction pointer)
Contains the address of the current or next instruction Normally instructions are executed sequentially
I/O Interface
Provides mechanism for input/output of data sometimes combined with memory management unit in a single Bus Interface Unit
5
Concept of Registers
Single storage locations within the CPU used for a particular purpose Used to hold a binary value temporarily Manipulated directly by the Control Unit Each register is wired within the CPU directly (no address needed) for specific function Size in bits or bytes (not MB like memory) Can hold data, an address or an instruction
6
Hold data being processed Hold instruction being executed Memory or I/O address being accessed Keep status of the computer Conditional branch instructions
GeneralGeneral-Purpose Registers
User-visible registers Part of ALU Accumulators Typically several dozen in modern CPUs (R0, R1,) Hold data of arithmetic operations Hold intermediate results or data values, e.g., loop counters To transfer data between different memory locations and between I/0 and memory 8
Part of CU Program Counter Register (PC) (instruction pointer) Holds address of the currently executed instruction Instruction Register (IR) Holds the actual instruction being executed Memory Address Register (MAR) Holds the address of a memory location Memory Data Register (MDR) Holds the actual data value from location specified in MAR Flags (one-bit register) to track special conditions like arithmetic carry and overflow, power failure, internal computer error Status Registers Several flag registers grouped together 9
Register Operations
Load values from other locations (registers and memory)
Destroys (erases) previous value in destination Source register (or memory location) unchangeable
10
Program Counter ( PC )
A dedicated register in the CPU Contains the address in memory of the current instruction being executed. Incremented automatically after each instruction. May be forced to change: e.g. jump instruction. Usually initialized to zero when machine starts, or is reset.
11
Instruction Register ( IR )
Op Code What To Do
Simple 16-bit example:
1101 101101100100
12
Accumulator
A dedicated register (or set of registers) in the CP used for the actual manipulation of data Default source (or destination) register sually contains results of arithmetic or logical operations
13
Operation of Memory Each memory location has a unique address Address from an instruction is copied to the MAR which finds the location in memory CPU determines if it is a store or retrieval Transfer takes place between the MDR and memory MDR is a two way register 14
Program Counter ( PC ) Instruction Register ( IR ) Memory Address Register ( MAR ) Memory Data Register ( MDR ) Accumulator ( A or Acc ) Memory
16
Address
Data
17
MARMAR-MDR: Example
18
19
Memory Capacity
Typical values:
k: 16, 17, 18, 19, 20, 21, 22, etc. m: 8, 16, 32, 64
20
Memory Implementation Magnetic core (1949/51 late 1960s/early 1970s Random Access Memory (RAM) Read Only Memory (ROM) EEPROM Flash ROM Volatile Nonvolatile
21
Random any piece of data can be accessed in a constant time regardless of physical location (unlike tapes, magnetic or optical discs) Difference in technical design DRAM (Dynamic RAM)
Most common, cheap Volatile: must be refreshed (recharged with power) 1000s of times each second
RAM: Sample
Implemented in early stored-program computers (e.g., ENIAC, after 1948) If write protected, becomes read-only memory Non-volatile memory to hold built-in software that is not expected to change over the life of the computer (e.g., initial program that runs computer)
BIOS: initial boot instructions and diagnostics
Flash ROM
Modern type of EEPROM (invented in 1984), faster (erase and write in blocks of bytes) Higher endurance (up to 1,000,000 cycles) E.g., USB Flash Drives
24
ROM: Sample
25
Memory Maps The usage of memory space on a system is commonly depicted in a memory map The height of the map is determined by the number of addresses The width of the map is usually 8 bits E.g.,
Hexadecimal address
Memory maps are usually drawn to show what is where on a system what can be:
RAM, ROM, I/O, empty space
Where:
Determined by the starting/ending addresses for each block of RAM, ROM, I/O,,
E.g.,
a memory map for a system with a capacity of 224 bytes with two 1 MB RAM modules residing consecutively at the bottom of memory.
28
FFFFFF
empty
1 MB RAM 1 MB RAM
29
Memory Space: Exercise 1 Q: A system with a memory capacity of 128 GB has four 32 MB memory modules installed. The rest of the memory is unused. How much memory space is available for future expansion? (Give your answer in decimal in megabytes.) A: ?
Skip answer Answer
30
Q: A system with a memory capacity of 128 GB has four 32 MB memory modules installed. The rest of the memory is unused. How much memory space is available for future expansion? (Give your answer in decimal in megabytes.) A: 128 GB 4 x 32 MB = 27 x 210 MB - 22 x 25 MB = (217 27) MB = (131,072 128) MB = 130,944 MB 210
= 127.875 GB
31
Draw a memory map for a system with a capacity of 2 GB. Assume the system has three 32 MB memory modules residing consecutively at the bottom of memory. Illustrate the size of each block in MB and the starting and ending address of each block of memory in hexadecimal.
Skip answer Answer
32
7FFFFFFF
FetchFetch-Execute Cycle
Two-step process because both instructions and data are in memory Fetch
Decode or find instruction, load the code of the instruction from memory
Execute
Performs operation that instruction requires Move/transform data
34
Load Instruction
Next step: the address part of the instruction located in the IR is copied and placed in the MAR Computer retrieves actual data located at the address in memory and places it in the MDR IR [address] MAR (step 3) Memory MDR Next step: MDR copies data to the accumulator register MDR A (step 4) Last step: PC is incremented PC + 1 PC (step 5)
36
Task:
Simple Eight bit system. Thirty-two memory locations (0 to 31). oad instruction is 010. Value in location 15 is ten (i.e.: binary 00001010) PC is at 5, about to increment. The instruction, 01001111, is in location 6.
37
PC: IR:
00101 (previous)
15: 00001010
PC: IR:
00110 (previous)
15: 00001010
PC: IR:
00110 (previous)
15: 00001010
Memory
Location 31
PC: IR:
00110 (previous)
15: 00001010
Memory
Location 31
PC: IR:
00110 (previous)
15: 00001010
Memory
Location 31
PC: IR:
00110 01001111
15: 00001010
Memory
Location 31
PC: IR:
00110 01001111
15: 00001010
Memory
Location 31
PC: IR:
00110 01001111
15: 00001010
Memory
Location 31
PC: IR:
00110 01001111
15: 00001010
Memory
Location 31
PC: IR:
00110 01001111
15: 00001010
PC: IR:
00110 01001111
15: 00001010
1.
2.
3.
Transfer the instruction to the IR IR(address) -> MAR Address portion of the instruction loaded in MAR MDR -> A PC + 1 -> PC Actual data copied into the accumulator Program Counter incremented
49
4.
5.
1.
2.
3.
Transfer the instruction to the IR IR(address) -> MAR Address portion of the instruction loaded in MAR A -> MDR* PC + 1 -> PC Accumulator copies data into MDR Program Counter incremented
50
4.
5.
Fetch
PC MDR
PC + 1
51
1.
2.
3.
Transfer the instruction to the IR IR(address) -> MAR Address portion of the instruction loaded in MAR A + MDR -> A PC + 1 -> PC Contents of MDR added to contents of accumulator Program Counter incremented
52
4.
5.
Fetch
PC MDR
53
New: Task: Value in location 7 is 10110010. Add instruction is 101. Value in location 18 is seventy-one (i.e.: binary 01000111) Everything else is as we left it!
54
Memory
Location 31
PC: IR:
00111 01001111
18: 01000111 15: 00001010
Memory
Location 31
PC: IR:
00111 01001111
18: 01000111 15: 00001010
Memory
Location 31
PC: IR:
00111 01001111
18: 01000111 15: 00001010
Memory
Location 31
PC: IR:
00111 01001111
18: 01000111 15: 00001010
Memory
Location 31
PC: IR:
00111 10110010
18: 01000111 15: 00001010
Memory
Location 31
PC: IR:
00111 10110010
18: 01000111 15: 00001010
Memory
Location 31
PC: IR:
00111 10110010
18: 01000111 15: 00001010
Memory
Location 31
PC: IR:
00111 10110010
18: 01000111 15: 00001010
Memory
Location 31
PC: IR:
00111 10110010
18: 01000111 15: 00001010
Computer Buses
PCI Express BUS Card Slots (from top to bottom: x4, x16, x1, 64 x16) compared to a traditional 32-bit PCI bus card slot.
Buses (1 of 3)
Group
of electrical conductors (wires) for carrying signals from one location to another
Line: each conductor (or wire) in the bus
The
physical connection that makes it possible to transfer data from one location in the computer system to another 4 kinds of signals
Data (alphanumeric, numerical, instructions) Addresses Control signals Power (sometimes)
65
Buses (2 of 3)
Ports
Speakers
Buses (3 of 3) Connect CPU and Memory I/O peripherals: on same bus as CPU/memory or separate bus If connect CPU, Memory and I/O modules in the same Physical package, called backplane
Also called system bus or external bus Example of broadcast bus Common method of connecting CPU, Memory and I/O modules: to a printed circuit board called motherboard
67
Motherboard
68
Types of Buses (1 of 2)
Serial port
Modem
Control unit
ALU
69
Computer
Computer
71
Bus Interface
Bus interface bridges provide bridges: communication between different buses Special buses provide interconnections within the CPU chip Buses that form the backplane External CPU bus Peripheral control interface (PCI) bus Accelerated graphic processor (AGP) Industrial standard architecture (ISA)
72
Bus Characteristics
Protocol
Documented agreement for communication Specification that spells out the meaning of each line and each signal on each line
Throughput, Throughput i.e., data transfer rate in bits per second Data width in bits carried simultaneously Distance between two end points Type of signals unique/specialized or signals: shared Addressing capacity Etc. 74
Data bus Address bus Control bus CPU I/O Module Memory
Motherboard
Many configurations possible
I/O Device
75
Data Bus Carries data between the CPU and memory or I/O devices Bi-directional
Data transferred out of the CPU for write operations Data transferred into the CPU for read operations
76
Address Bus Carries an address from the CPU to Memory or I/O devices Unidirectional
Control Bus
Collection of signals for coordinating CPU activities Each signal has a unique purpose Typical sizes: 10-20 lines Signals are output, input, or bi-directional Typical signals
/RD (read) /WR (write CLK (clock) /IRQ (interrupt request) etc.
78
79
CPU Plug-in I/O (serial and parallel ports, sound cards, disc drives
Lines are non-specialized: carry addresses and data, labeled AD00 to AD31 (or AD63) Additional lines: control and power lines 80
Instructions
Instruction
Direction given to a computer Causes electrical signals to be sent through specific circuits for processing
Instruction set
Design defines functions performed by the processor Differentiates computer architecture by the
Number of instructions Complexity of operations performed by individual instructions Data types supported Format (layout, fixed vs. variable length) Use of registers Addressing (size, modes)
81
Instruction Format
MachineMachine-specific template that specifies
84
Instruction Types (1 of 2)
Arithmetic
Operators + - / * ^ Integers and floating point
Logical or Boolean
Relational operators: > < = Boolean operators AND, OR, XOR, NOR, and NOT
Instruction Types (2 of 2)
Privileged
Security Access control Not available to the application programs
Shift and rotate Program control Stack instructions Multiple data instructions I/O and machine control
86
87
88
Stack Instructions
St
IF It t
i
t r r
tr
ti
f r r i t i i i f r r r r ti r fr t ti i
Push
Pop
89
90
91
92
Thank you!
Reading: Lecture slides and notes, Chapter 7
http://www.visualjokes.com
93