Lecture 2
Lecture 2
Model
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
4-3
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
4-4
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
4-5
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
IN P UT OUTP UT
K eyb o a rd M o n ito r
M ouse P R OCE S S IN G UN IT P rin ter
S canner LE D
D is k ALU TE M P D is k
CON TR OL UN IT
PC IR
4-9
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Memory
2k x m array of stored bits
Address
• unique (k-bit) identifier of location 0000
0001
Contents 0010
0011 00101101
• m-bit value stored in location 0100
0101
0110
•
Basic Operations: •
•
1101 10100010
LOAD 1110
• read a value from a memory location 1111
STORE
• write a value to a memory location
4-10
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Interface to Memory
How does processing unit get data to/from memory?
MAR: Memory Address Register
M E M OR Y
MDR: Memory Data Register
M AR M DR
To LOAD a location (A):
1. Write the address (A) into the MAR.
2. Send a “read” signal to the memory.
3. Read the data from MDR.
To STORE a value (X) to a location (A):
1. Write the data (X) to the MDR.
2. Write the address (A) into the MAR.
3. Send a “write” signal to the memory.
4-11
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Processing Unit
Functional Units
• ALU = Arithmetic and Logic Unit
• could have many functional units.
some of them special-purpose P R OCE S S IN G UN IT
(multiply, square root, …)
• LC-3 performs ADD, AND, NOT ALU TE M P
Registers
• Small, temporary storage
• Operands and results of functional units
• LC-3 has eight registers (R0, …, R7), each 16 bits wide
Word Size
• number of bits normally processed by ALU in one instruction
• also width of registers
• LC-3 is 16 bits
4-12
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Control Unit
Orchestrates execution of the program
CON TR OL U N IT
PC IR
Instruction Processing
Decode instruction
Evaluate address
Execute operation
Store result
4-15
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Instruction
The instruction is the fundamental unit of work.
Specifies two things:
• opcode: operation to be performed
• operands: data/locations to be used for operation
4-17
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
4-19
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
4-20
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Examples: D
• add offset to base register (as in LDR)
• add offset to PC EA
• add offset to zero
OP
EX
4-21
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Examples: D
• load data from memory (LDR)
• read data from register file (ADD) EA
OP
EX
4-22
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Examples: D
• send operands to ALU and assert ADD signal
• do nothing (e.g., for loads and stores) EA
OP
EX
4-23
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Examples: D
• result of ADD is placed in destination register
• result of memory load is placed in destination register EA
• for store instruction, data is stored to memory
write address to MAR, data to MDR OP
assert WRITE signal to memory
EX
4-24
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
4-25
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
4-26
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
4-27
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
4-29