CMPE12 5) LC-3 Architecture: (Textbook's Chapter 4-Ish)
CMPE12 5) LC-3 Architecture: (Textbook's Chapter 4-Ish)
5) LC-3 Architecture
(Textbooks Chapter 4-ish)
MDR
INPUT
Keyboard
Mouse
Scanner
Disk
OUTPUT
PROCESSING UNIT
ALU
TEMP
Monitor
Printer
LED
Disk
CONTROL UNIT
PC
IR
What is Modern
For embedded applications and for
workstations there exist a wide variety of
CISC and RISC and CISCy RISC and RISCy
CISC.
Most current PCs use the best of both
worlds to achieve optimal performance.
LC-3 Architecture
o RISC - only 15 instructions
o 16-bit data and address
o 8 general-purpose registers (GPR)
Plus 4 special-purpose registers:
o Program Counter (PC)
o Instruction Register (IR)
o Condition Code Register (CC)
o Process Status Register (PSR)
7
Memory
2 k x m array of stored bits:
Address
unique (k-bit) identifier of location
LC-3: k = 16
Contents
m-bit value stored in location
LC-3: m = 16
Basic Operations:
LOAD
read a value from a memory location
STORE
write a value to a memory location
address
0000
0001
0010
0011
0100
0101
0110
1101
1110
1111
00101101
10100010
contents
Interface to Memory
How does the processing unit get data to/from memory?
MAR: Memory Address Register
MEMORY
MDR: Memory Data Register
To LOAD from 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.
MAR
MDR
INPUT
OUTPUT
Keyboard
Mouse
Scanner
Disk
Monitor
Printer
LED
Disk
10
11
Processing Unit
Functional Units
ALU = Arithmetic/Logic Unit
could have many functional units.
some of them special-purpose
(multiply, square root, )
LC-3 performs ADD, AND, NOT
PROCESSING UNIT
ALU
TEMP
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
12
Control Unit
Controls the execution of the program
CONTROL UNIT
PC
IR
Control unit:
reads an instruction from memory
the instructions address is in the PC
interprets the instruction, generating signals that tell the other
components what to do
an instruction may take many machine cycles to complete
CMPE12 Fall 2006 A. Di Blas (Orig. by C. Barzeghi)
13
LC-3
Can you
identify the 5
Von Neumann
components?
14
Instructions
The instruction is the fundamental unit of work.
Specifies two things:
opcode: operation to be performed
operands: data/locations to be used for operation
15
a, b, c
ADD
a b c
Source registers/immediate
Opcode
Destination register
16
data)
17
Instruction encoding
What meaning which bits have, depending on the
situation
Ex: in LC-3, the most-significant four bits contain
the instructions OPCODE always.
15 14 13 12
18
19
20
10
Instruction Processing
Fetch instruction from memory
Decode instruction
Evaluate address
Fetch operands from memory
Execute operation
Store result
CMPE12 Fall 2006 A. Di Blas (Orig. by C. Barzeghi)
21
F D EA OP EX S
NOTE:
Not all phases are needed by every
instruction
All instructions will go through F and D at
least
Phases may take more than 1 machine cycle
CMPE12 Fall 2006 A. Di Blas (Orig. by C. Barzeghi)
22
11
FETCH
F
EA
OP
PC becomes PC+1.
EX
S
23
DECODE
First identify the opcode.
In LC-3, this is always the first four bits of
instruction.
A 4-to-16 decoder asserts a control line
corresponding to the desired opcode.
F
D
EA
OP
EX
S
24
12
EVALUATE
ADDRESS
For instructions that require memory access,
compute address used for access.
F
D
EA
Examples:
add offset to base register (as in LDR)
add offset to PC
add offset to zero
OP
EX
S
FETCH
OPERANDS
Obtain source operands needed to
perform operation.
Examples:
load data from memory (LDR)
read data from register file (ADD)
25
F
D
EA
OP
EX
S
26
13
EXECUTE
F
Perform the operation, using the source
operands.
Examples:
D
EA
OP
EX
S
27
STORE RESULT
Write results to destination.
(register or memory)
Examples:
result of ADD is placed in destination register
result of memory load is placed in destination
register
for store instruction, data is stored to memory
write address to MAR, data to MDR
assert WRITE signal to memory
F
D
EA
OP
EX
S
28
14
29
Flow-control instructions
We need special instructions that change the
contents of the PC.
These are the flow-control instructions:
jumps are unconditional -- they always change
the PC
branches are conditional -- they change the PC
only if some condition is true (e.g., the result of
an ADD is zero)
30
15
31
Recommended exercises:
Ex 4.5 (excluding point b3 for now)
Ex 4.7, 4.8, 4.10
Ex 4.13 and 4.16 (a little bit more advanced)
32
16