Title: ECE 406
1ECE 406 Design of Complex Digital Systems
Lecture 12 Intro to the LC-3
Micro-architecture
Spring 2007 W. Rhett Davis NC State
University with significant material from Paul
Franzon, Bill Allen, Xun Liu
2Announcements
- Project 1 Posted
- Bring Lecture 11 slides and Project 1 Assignment
to lecture every day
3Todays Lecture
- Block-Diagram of the LC3
- LC3 Controller State Machine
- Control Signals
- Controller
- Fetch
- Execute
4Microarchitecture
- The von Neumann Model
- Memory
- Processor
- Input
- Output
- Control
memory
input
output
processor
control
5What Blocks Do We Need?
- Instructions
- ADD
- AND
- NOT
- BRx
- JMP/RET
- JSR
- JSRR
- LD
- ST
- LDR
- STR
- LDI
- STI
- ALU
- Register File
- Program Counter
- Status Register
- Instruction Register
- Logic to direct operands to/from ALU
- Logic to interface to Memory
6Conventions
- Control signals are omitted for simplicity
- Makes the diagram easier to read
- Usually far fewer control signals than data
signals - Wire bundles
- A set of nets going from one block to another is
represented as - When a set of nets contains signals that go in
both directions (both input and output for a
block), we use - A set of nets on a shared bus (a bus with
multiple drivers) is represented as - If a block only reads or writes one signal on a
shared bus, we use
7Simplified LC3 Microarchitecture
8Detail of Memory Bus
9Controller
- Maintains the master state-machine for the system
- Distributes this state to the rest of the system
(not shown)
10Fetch
- Maintains the program counter (PC) for the system
- Communicates with Memory to make sure instruction
is made available to Decode block - Master of the shared Memory bus during the all
states but the Read Memory, Write Memory, and
Indirect Address Read states. - Receives the next address from the Execute block
(if a branch is taken)
11Decode
- Maintains the Register File (R0R7) for the
system - Maintains Instruction Register (IR) and
Processor Status Register (PSR) which includes
N, Z, P - Receives instruction word from Main Memory
- Provides operands to Execute and MemAccess blocks
- Receives the value to write-back to the RegFile
from the Writeback block - Decodes every instruction and provides control
signals to most blocks (not shown)
12Execute
- Directs operands from the Decode block to the
Arithmetic Logic Unit (ALU) - Sends result to the Writeback block (for storage
in Register File), or Fetch block (with the next
address on a branch)
13MemAccess
- Receives Address to be read/written from Execute
block - Receives Data to be written from Decode block
- Master of the shared Memory bus during the Read
Memory, Write Memory, and Indirect Address
Read states. - Provides Data read from Memory to Writeback block
14Writeback
- Decides which value will be written back to the
Register file - Receives output of ALU from Execute Block
- Receives contents of MDR from MemAccess Block
- Sends result to Decode Block for storage in
Register File
15Todays Lecture
- Block-Diagram of the LC3
- LC3 Controller State Machine
- Control Signals
- Controller
- Fetch
- Execute
16Simplified State Machine
17Execution of ADD/AND/NOT
- Fetch Unit loads instruction from memory
- Decode Unit determines the operands
- Execute Unit applies operands to ALU
- Result stored in Register File
- PC incremented
1
2
5
3
4
18Execution of BRx/JMP/RET
- Fetch
- Decode
- Execute computes new PC
- PC updated
1
2
4
3
19Execution of JSR/JSRR
- Fetch
- Decode
- Execute computes new PC
- PC stored in R7
- PC updated
1
2
5
3
4
20Execution of LD/LDR
- Fetch
- Decode
- Execute Unit computes address
- MemAccess Unit reads Memory
- Write to Register File
- PC incremented
1
2
6
3
4
5
21Execution of ST/STR
- Fetch
- Decode
- Execute Unit computes address
- MemAccess Unit writes Memory
- Update PC
1
2
5
3
4
22Execution of LDI
- Fetch
- Decode
- Compute address
- Read Memory for Indirect Address
- Read Memory
- Update Register File
- PC incremented
1
2
7
3
4
5
6
23Execution of STI
- Fetch
- Decode
- Compute address
- Read Memory for Indirect Address
- Write to Memory
- Update PC
1
2
6
3
4
5
24Execution of LEA
- Fetch
- Decode
- Compute address
- Update Register File
- Update PC
1
2
5
3
4
25How Good Is Our Micro-architecture?
- What is the average number of cycles per
instruction - Modern microprocessors get this number close to
1.0 for scalar machines and less than 1.0 for
super-scalar and VLIW machines. - Take courses like ECE 463 ECE 464 to learn how.
26Todays Lecture
- Block-Diagram of the LC3
- LC3 Controller State Machine
- Control Signals
- Controller
- Fetch
- Execute
27Control Signal Tables
- It helps greatly in the debugging of the LC-3
System to have completed tables that give the
values of various control signals, depending on
the instruction that is being executed. - In this section, we will begin to fill out these
tables. - The instruction-set specification is needed to
complete these tables, and is included here for
convenience.
28ALU Operations
15 12 11 9 8 6 5 4
3 2 0
29Control Instructions
15 12 11 9 8 6 5 4
3 2 0
- BR
- JMP
- JSR
- JSRR
- RET
- RTI
- TRAP
30Load/Store Instructions
15 12 11 9 8 6 5 4
3 2 0
- LD
- LDR
- LDI
- LEA
- ST
- STR
- STI
31Complete the Table
C_Control C_Control C_Control C_Control
Operation mode Instr. Type Store PC Mem. Access Mode load
ADD 0
1
AND 0
1
NOT
BR
JMP/RET
JSR
JSRR
LD
LDR
LDI
LEA
ST
STR
STI
32Fetch Module Inputs Outputs
- Input Signals
- clock global system clock.
- reset when high, the PC should be synchronously
set to x3000 - state the state from the Controller block.
- taddr150 the next value of the PC if a
branch is taken. - br_taken signal to indicate that a branch is
taken. - Output Signals
- rd signal to indicate to the Memory that a read
is to be performed, rather than a write. This
signals should be high-impedence during the Read
Memory, Write Memory, and Indirect Address
Read states, because the MemAccess block will
drive the shared bus during these cycles. In all
other states, this signal should be high. - pc the current value of the program counter,
but should be high-impedence at the same times
that the rd signal is high-impedence. - npc should always be PC1
33Fetch Block Sketch
34Complete the Table
Operation mode br_taken
ADD 0
1
AND 0
1
NOT
BR
JMP/RET
JSR
JSRR
LD
LDR
LDI
LEA
ST
STR
STI
35Execute Block Sketch
36Complete the Table
E_Control E_Control E_Control E_Control E_Control
Operation mode ALU Op Sel ALU Op Sel PC Sel 1 PC Sel 2 OP 2 Sel
ADD 0
1
AND 0
1
NOT
BR
JMP/RET
JSR
JSRR
LD
LDR
LDI
LEA
ST
STR
STI