Unit 5a - CPU Design
Unit 5a - CPU Design
Unit 5a - CPU Design
CPU Design
Introduction
FETCH1: AR PC
FETCH2: DR M, PC PC + 1
AND1: DR M
AND2: AC AC ^ DR INC1: AC AC + 1
Complete State Diagram for the Simple CPU
Jump back to
Microsequencer
Slide (40)
Establishing Required Data Paths
PC: PC PC + 1;
PC DR[5..0]
DR: DR M
IR: IR DR[7..6]
AC: AC AC + DR;
AC AC ^ DR;
AC AC + 1
Preliminary Register Section for
the Simple CPU
• Registers: AR, PC, DR,
AC and IR
• Buffers
• 8-bit bus
Further Optimization
Observations:
1. AR only supplies its data to
memory – no need to connect to
any other component/internal bus
2. IR and AC also do not supply data
to any other component – remove
output connection
3. Bus is 8 bits wide, but not all data
transfers are 8 bits (some are 6,
some are 2) – need to specify
which registers send and receive
to and from which bus
• In practice, just connect as
required: AR/PC to lower
order 6 bits, IR to higher order
2 bits, etc.
4. AC must be able to load the sum
of AC and DR, logical AND of AC
and DR. CPU needs to include an
ALU to do that.
A Simple ALU
Create separate
hardware for each
function and use a
multiplexer to
select the function
results
Final Register Section for
the Simple CPU
Next: Control Unit Design
• At this point our CPU can perform every
operation necessary to fetch, decode and execute
the entire instruction set.
– Next task: to design the circuitry to generate the
control signals in proper sequence.
• Control Unit Design
– Two main methodologies:
• Hardwired control – uses sequential and combinatorial logic
to generate control signals
• Micro-sequenced control – uses a lookup memory to output
the control signals.
Control Unit Design
HARDWIRED DESIGN
Hardwired Control Unit for our CPU
Requirements
• Counter: contains current state
• Decoder: generates individual state signals from current
state
• Additional logic: to take individual state signals and
generate control signals for each component, as well as
the signals to control counter itself
Our Example CPU has Nine States
9 states, so 4 bit counter and a 4-to-16 bit decoder suffice in this case.
(Seven outputs of decoder will not be used)
Heuristic guidelines:
1. Assign FETCH1 to counter value 0 and use the CLR input of the counter
to reach this state.
2. Assign sequential states to sequential counter values and use the INC
input of the counter to traverse these states.
CPU would assign FETCH2 to counter value 1 and FETCH3 to counter value 2
ADD1 and ADD2, AND1 and AND2 to consecutive counter values as well
3. Assign the first state of each execute routine based on the instruction
opcodes and the maximum number of states in the execute routines.
4. Use the opcodes to generate the data input to the counter and the LD input
to the counter to reach the proper execute routine.
Choosing a proper mapping function
• Instructions, first states and op codes for the CPU
Instruction First State IR
ADD ADD1 00
AND AND1 01
JMP JMP1 10
INC INC1 11
• Once we decide which decoder output is assigned to each state, we can use
these signals to generate the control signals for the counter and the
components of the rest of the CPU
Counter Control Signals
• DR: placed onto the internal data bus during FETCH3, ADD2,
AND2 and JMP1
DRBUS = FETCH3 ˅ ADD2 ˅ AND2 ˅ JMP1
• Similarly, we have:
MEMBUS = FETCH2 ˅ ADD1 ˅ AND1
PCBUS = FETCH1
…
• Control unit must generate a READ signal, output from CPU
READ = FETCH2 ∨ ADD1 ∨ AND1
Hardwired Control Unit for our CPU
Control Signal Generation
Slide 48
Verify
0:ADD 4
1: AND 5
2: INC
3: JMP 0
4:10H
5:20H
Example
MICRO-SEQUENCER
DESIGN
Micro-sequencer Design
State Address
FETCH1 0000 (0)
FETCH2 0001 (1)
FETCH3 0010 (2)
ADD1 1000 (8)
ADD2 1001 (9)
AND1 1010 (10)
Assign each state of the FSM to an
AND2 1011 11)
address in microcode
JMP1 1100 (12)
INC1 1110 (14)
Back to slide 53
Data Paths
MI M2
Value Micro Operation Value Micro Operation
000 NOP 0 NOP
001 DRM 1 PCIN
010 ARPC 2 PCDR
011 AIDR
100 PLUS • M1 requires 3 bits, M2 2
101 AND bits, so total of 5 bits
110 ACIN
Micro operation field assignments and values
MI M2
Value Micro Operation Value Micro Operation
000 NOP 0 NOP
001 DRM 1 PCIN
010 ARPC
011 AIDR
100 PCDR • To optimize, it is best to
101 PLUS maximize to a power of
110 AND two, so if possible, put eight
111 ACIN micro operations in M1 and
two in M2.
• M1 requires 3 bits, M2 only
one bit, for total of 4 bits
Vertical microcode for the Simple Microsequencer