LC-3 as a von Neumann Machine

10/27/2016
Build an LC-3 Processor as a von Neumann Machine
University of Illinois at Urbana-Champaign
Dept. of Electrical and Computer Engineering
Let’s talk about a specific
von Neumann machine.
ECE 120: Introduction to Computing
The Little Computer-3 (LC-3) ISA
◦ was developed by Patt & Patel
◦ as an educational tool.
As Yale (Patt) says, it took them
three tries to get it right, hence LC-3.
LC-3 as a von Neumann Machine
In our class, we will build up towards the
LC-3 microarchitecture in Appendix C of P&P.
ECE 120: Introduction to Computing
© 2016 Steven S. Lumetta. All rights reserved.
slide 1
Recall the Five Parts of the von Neumann Model
memory
reg.
file
MAR MDR
Let’s start again with the memory. Call this
number X.
In the LC-3 ISA,
◦ memory has 216 addresses, and
◦ 16-bit addressability.
output
And call this Y.
How many bits in the MAR, X or Y? X (16)
How many bits in the MDR? Y (also 16)
control unit
PC
ECE 120: Introduction to Computing
IR
slide 2
memory
black is data
processing unit
ALU
© 2016 Steven S. Lumetta. All rights reserved.
The LC-3 Memory is 216×16-Bit
MAR MDR
input
ECE 120: Introduction to Computing
blue is control
© 2016 Steven S. Lumetta. All rights reserved.
slide 3
ECE 120: Introduction to Computing
© 2016 Steven S. Lumetta. All rights reserved.
slide 4
10/27/2016
The LC-3 ALU Supports ADD, AND, and NOT Operations
memory
The ALU in the
LC-3 supports
MAR MDR
three
operations:
ADD, AND,
processing unit
and NOT.
reg.
ALU
And
remember
DeMorgan’s
Law:
A+B = [A’B’]’
The register
file contains
eight
registers.
file
The ALU
operates on
16-bit
operands.
Donner, Blitzen…
slide 5
ECE 120: Introduction to Computing
No. R0 through R7.
© 2016 Steven S. Lumetta. All rights reserved.
memory
memory
MAR MDR
MAR MDR
processing unit
ALU
black is data
processing unit
input
reg.
file
© 2016 Steven S. Lumetta. All rights reserved.
slide 6
The LC-3 Includes a Keyboard and a Display
ALU
Each register in the register file
stores 16 bits.
ECE 120: Introduction to Computing
reg.
file
Guess what their names are…
The LC-3’s Word Size is 16 Bits
The LC-3’s
word size is
16 bits.
MAR MDR
ALU
Apply logical completeness.
© 2016 Steven S. Lumetta. All rights reserved.
The “R” is
just for
humans,
of course.
memory
processing unit
What if someone wants another function?
ECE 120: Introduction to Computing
The LC-3 Register File Has Eight Registers
reg.
file
output
The LC-3 has one input device: a keyboard.
And one output device: a monitor/display.
slide 7
ECE 120: Introduction to Computing
© 2016 Steven S. Lumetta. All rights reserved.
slide 8
10/27/2016
***********************************
***********************************
keyboard input uses two registers
◦ Keyboard Status Register (KBSR)
used to handshake when a key arrives
◦ Keyboard Data Register (KBDR)
used to delivers keystrokes, coded as ASCII
display output also uses two registers
◦ Display Status Register (DSR)
used to handshake (processor must wait
for the display!)
◦ Display Data Register (DDR)
used to send characters to print,
coded as ASCII
Details of the LC-3 Input Device
Using these registers is a topic for ECE220
(see Ch. 8-9 of Patt & Patel).
ECE 120: Introduction to Computing
© 2016 Steven S. Lumetta. All rights reserved.
Details of the LC-3 Output Device
Again, using these is a topic for ECE220
(see Ch. 8-9 of Patt & Patel).
slide 9
ECE 120: Introduction to Computing
© 2016 Steven S. Lumetta. All rights reserved.
The LC-3 Also Has a Control Unit
What About the IR?
Recall that
◦ the program counter (PC) stores the
address of the next instruction, and
◦ LC-3 memory is 2X×Y-bit,
where X and Y are both 16.
Recall that the instruction register (IR)
stores the encoded bits of the instruction
being executed.
How many bits in the IR?
Did you read ahead? If not, you can’t
know the answer yet.
How many bits in the PC, X or Y? X (16)
control unit
PC
ECE 120: Introduction to Computing
control unit
IR
© 2016 Steven S. Lumetta. All rights reserved.
slide 10
PC
slide 11
ECE 120: Introduction to Computing
IR
© 2016 Steven S. Lumetta. All rights reserved.
slide 12
10/27/2016
What About the IR?
A Datapath for an LC-3 Processor
How do we encode instructions?
Here’s a diagram of a
datapath for an LC-3
processor (Patt and
Patel Figure C.3). control
unit
The heavy black
line is a
16-bit bus. processing
unit
The ISA defines a representation.
Instructions may require a variable
number of bits (as in x86).
However, in the LC-3 ISA,
every instruction requires 16 bits.
This design choice is deliberately equal to the
addressability of the memory so that each
memory location holds one instruction.
input/output*
*Again, we leave the details
of I/O for ECE220.
So, yes, the IR requires 16 bits.
memory
ECE 120: Introduction to Computing
© 2016 Steven S. Lumetta. All rights reserved.
slide 13
Control Unit Elements for an LC-3 Processor
slide 14
And a closer look at the
processing unit.
Miscellaneous instruction
execution logic
Let’s take a closer look
at the control unit.
FSM generating
control signals
Register file with
eight 16-bit registers
(two reads and one
write per cycle)
Arithmetic Logic Unit (ALU)
supports ADD, AND, NOT
(all 16-bit, 2’s comp. ADD)
Instruction
Register (IR)
© 2016 Steven S. Lumetta. All rights reserved.
© 2016 Steven S. Lumetta. All rights reserved.
Processing Unit Elements for an LC-3 Processor
Program
Counter (PC)
ECE 120: Introduction to Computing
ECE 120: Introduction to Computing
slide 15
ECE 120: Introduction to Computing
© 2016 Steven S. Lumetta. All rights reserved.
slide 16
10/27/2016
Memory Elements for an LC-3 Processor
Memory Address
Register
Memory Data
Register
I/O
logic
And a closer
look at the
memory.
216×16-bit memory
ECE 120: Introduction to Computing
© 2016 Steven S. Lumetta. All rights reserved.
slide 17