EEE 270 Advanced Topics in Logic Design Control and Sequencing: Hardwired and Microprogrammed Control
EEE 270 Advanced Topics in Logic Design Control and Sequencing: Hardwired and Microprogrammed Control
References:
Chapter s 4,5 from textbook
Chapter 7 of M.M. Mano and C.R. Kime, Logic and Computer
Design Fundamentals, Pearson Prentice-Hall, 2008.
Cris Ababei, Marquette University
Overview
2
Multiplier Example
Example: (101 x 011)
3
Example (1 0 1) x (0 1 1) again
Reorganizing to follow hardware algorithm:
1 0 1 Multiplicand (B)
x 0 1 1 Multiplier (Q)
0 0 0 0 Clear C || A (Carry and register A)
+ 1 0 1 Multiplier0 = 1 => Add B
0 1 0 1 Addition
0 0 1 0 1 Shift Right (Zero-fill C)
+ 1 0 1 Multiplier1 = 1 => Add B
0 1 1 1 1 Addition
0 0 1 1 1 1 Shift Right
0 0 0 1 1 1 1 Multiplier2 = 0 => No Add, Shift
Right
Multiplier Example: Block Diagram
n- 1 IN
n
Multiplicand
Counter P Register B
log 2 n n
Zero detect
G (Go) C
out Parallel adder
Z n n
Control Qo Multiplier
unit
0 C Shift register A Shift register Q
4
n
MUL0
0 1
G
0 1
Q0
C ← 0, A ← 0
P ←n – 1
A ← A + B,
C ← Cout
MUL1
C ← 0, C || A || Q ← sr C || A || Q,
P← P–1
0 1
Z
7
Multiplier Example: ASM Chart (Contd.)
9
Control signals for multiplier
n- 1 IN
n
Multiplicand
Initialize
Load_B
Shift_dec Counter P Register B
log2 n n
Zero detect
G (Go) C
out Parallel adder
Z n Load n
Control Qo Multiplier
unit Load_Q
0 C Shift register A Shift register Q
4
n
Clear_C
Initialize Product
Control signals Shift_dec
OUT
10
Multiplier Example: Control Signal Table
Control Signals for Binary Multiplier
11
Multiplier Example: Control Signal Table (Contd.)
12
Multiplier Example – Sequencing part of ASM
represented by the
table, they can be
removed from the 0 1
G
ASM making the
ASM to represent MUL0 01
only the sequencing
(next state) behavior
Simplified ASM
MUL1 10
chart. Similar to a
state diagram/graph
but without outputs
specified. 0
Z
1
13
Overview
14
Control
Hardwired Control
• Implemented using gates and flip-flops
• Faster, less flexible, limited complexity
Microprogram Control
• Control Store
Memory storing control signals and next state info
Controller sequences through memory
• Slower, more flexible, greater complexity
15
Hardwired control
16
(2) Sequencer (sequence register) and Decoder
Input Logic
17
Multiplier Example: Sequencer and Decoder
Design - Specification
Define:
• States: IDLE, MUL0, MUL1
• Input Signals: G, Z, Q0 (Q0 affects outputs, not next state)
• Output Signals: Initialize, Load, Shift_Dec, Clear_C
• State Transition Diagram (Use Sequencing ASM)
• Output Function: Use Control Signal Table
• Decide on type of flip-flops to use
Find: State M1 M0
• State Assignments IDLE 0 0
• Use two state bits to encode MUL0 0 1
the three states IDLE, MUL0,
and MUL1. MUL1 1 0
Unused 1 1
18
Multiplier Example: Sequencer and Decoder
Design - Formulation
Current State Input Next State Current State Input Next State
G Z M1 M0 G Z M1 M0
IDLE 0 0 0 0 MUL1 0 0 0 1
IDLE 0 1 0 0 MUL1 0 1 0 0
IDLE 1 0 0 1 MUL1 1 0 0 1
IDLE 1 1 0 1 MUL1 1 1 0 0
MUL0 0 0 1 0 Unused 0 0 d d
MUL0 0 1 1 0 Unused 0 1 d d
MUL0 1 0 1 0 Unused 1 0 d d
MUL0 1 1 1 0 Unused 1 1 d d
19
State Table with Decoder Outputs
20
Multiplier Example: Sequencer and Decoder
Design - Equations Derivation/Optimization
Finding the equations for M1 and M0 using decoded states:
M1 = MUL0
M0 = IDLE · G + MUL1 · Z
The output equations using the decoded states:
Initialize = IDLE · G
Load = MUL0 · Q0
Clear_C = IDLE · G + MUL1
Shift_dec = MUL1
Doing multiple level optimization, extract IDLE·G:
START = IDLE · G
M1 = MUL0
M0 = START + MUL1 · Z
Initialize = START
Load = MUL0 · Q0
Clear_C = START + MUL1
Shift_dec = MUL1
The resulting circuit using flip-flops, a decoder, and the above
equations is given on the next slide.
21
Multiplier Example: Sequencer and Decoder
Design - Implementation
START
Initialize
G M0
D Clear_C
Z C DECODER
IDLE
A0 0
1 MUL0
2 MUL1 Shift_dec
A1 3
M1
D
Load
Q0
22
--Binary multiplier with n=4
library ieee; VHDL code: behavioral datapath_func : process (CLK)
use ieee.std_logic_unsigned.all; variable CA : std_logic_vector (4 downto 0);
3 processes begin
entity binary_multiplier is
port(CLK, RESET, G, LOADB, LOADQ : in std_logic; if (CLK'event and CLK='1') then
MULT_IN : in std_logic_vector (3 downto 0); if LOADB='1' then
MULT_OUT : out std_logic_vector (7 downto 0)); B <= MULT_IN;
end binary_multiplier; end if;
if LOADQ = '1' then
architecture behavior_4 of binary_multiplier is
type state_type is (IDLE, MUL0, MUL1); Q <= MULT_IN;
variable P :=3; end if;
signal state, next_state : state_type;
signal A, B, Q : std_logic_vector(3 downto 0); case state is
signal C, Z : std_logic;
when IDLE =>
begin
Z <= P(1) NOR P(0); if G = '1' then
MULT_OUT <= A & Q; C <= '0';
A <= "0000";
state_register : process (CLK, RESET) P <= "11";
begin
end if;
if (RESET = '1') then
state <= IDLE; when MUL0 =>
elsif (CLK'event and CLK='1') then if Q(0) ='1' then
state <= next_state; CA := ('0' & A) + ('0' & B);
endif; else
end process;
CA := C & A;
next_state_func : process (G, Z, state) end if;
begin C <= CA(4);
case state is A <= CA(3 downto 0);
when IDLE => when MUL1 =>
if G='1' then next_state <= MUL0;
C <= '0';
else next_state <= IDLE;
end if; A <= C & A(3 downto 1);
when MUL0 => Q <= A(0) & Q(3 downto 1);
next_state <= MUL1; P <= P - "01";
when MUL1 => end case;
if Z='1' then next_state <= IDLE;
end if;
else next_state <= MUL0;
end if; end process;
end case; 23
end process; end behavior_4;
(3) One Flip-Flop per State
24
State box and Scalar decision box transformations
Vector decision box transformation
Describe properties of
the state of the datapath
Status signals
Datapath:
• Registers
• MUXes, ALUs, Shifters, Combinational Circuits and Buses
• Implements microoperations (under control of the control
unit)
Control unit:
• Selects the microoperation
• Determines the sequence (based on status and input
signals)
• Design:
State diagram or ASM
Microoperations
Sequence
Multiplier Example
Microprogrammed Control
38
ASM of the Control Unit
Multiplicand
Load_B
Counter P Register B
log2 n n
Zero detect
C Parallel adder
out
We need four control
signals: Z n Load n
• Initialize Qo Multiplier
Load_Q
• Load 0 C Shift register A Shift register Q
• Clear_C
•
n
Clear_C
Shift_Dec Initialize Product
Status bits: Qo, Z Shift_dec
OUT
41
Control Signals and Register Transfers
42
Control Signals, Control Word Format
Four control signals needed.
We can use these signals as is or encode them to reduce the
number of bits needed in the control word.
If we do not encode these: 4 bits needed
• Initialize 0001
• Load 0010
• ClearC 0100
• Shift/Dec 1000
43
Sequencer
44
Control Sequences for the micro operations based
on decision boxes in the ASM chart:
45
SEL Field definition and Code in the Control Word
46
Design of Control Unit
ROM size:
• Word length: 12 bits (control word)
• Size: 5 storage location, one for each state
Address bits:
• 3 bits to address 5 locations
• CAR is 3 bits wide
The address loaded in the CAR:
• Comes from the next-address info in the
microinstruction: NXTADD0 or NXTADD1
Microprogrammed Control Unit
48
Register Transfer Description of the
Microprogram
50
Symbolic Microprogram
51
Binary Microprogram
52
Summary
Interaction between datapaths and control units
Two types of control units:
• Non-programmed
• Programmed
Two implementation approaches for Hardwired Control
(non-programmed):
• Sequence Register and Decoder
• One Flip-Flop per state
Use of ASM to specify control functions:
• Microoperations
• Sequence of operations
Microprogrammed control is a more structured approach
for complex systems
53
Appendix A: Speeding Up the Multiplier
54
Speeding Up Multiply (Contd.)
55
Speeding Up Multiply (Contd.)
By replacing the shift
register with a
IDLE
combinational shifter
and combining the
adder and shifter,
0 1
the states can be merged. G
A 0
P n –1
The C-bit is no longer needed.
MUL
56