Professional Documents
Culture Documents
Inputs State Outputs Logic State Next Output Logic
Inputs State Outputs Logic State Next Output Logic
Next
State
Logic
State
Output
Logic
Outputs
Clock
Next
State
Logic
State
Clock
2001
Output
Logic
Outputs
In1
?
1
ONE
In2
?
1
TWO
THREE
Out2
Out3
2002
state box
In1
?
decision diamond
In2
?
state coding
1
TWO
Out2
a list of signals active in this state
THREE
Out3
2002
ASM1a
// ----------- state declaration ---------logic [1:0] state;
// ------- state + next state logic ------always_ff @(posedge Clock, negedge nReset)
if (!nReset)
state <= 0;
else
case (state)
0:
if (In1) state <= 1;
1:
if (In2) state <= 2;
else
state <= 3;
2:
state <= 3;
3:
state <= 0;
endcase
// ------------- output logic ------------logic Out2, Out3;
assign Out2 = (state == 2);
assign Out3 = (state == 3);
2003
2004
2005
2006
2007
2008
2009
here we predict in one state, the outputs that we need in the next state
it is hard to see which output is associated with which state error prone
2010
<= 0; end
<= 0; end
<= 0; end
<= 1; end
<= 1; end
<= 0; end
here the outputs are clearly associated with the appropriate states
includes duplicated sections of code error prone
2011
2012
0002
In1
?
1
ONE
1002
In2
?
1
TWO
THREE
0102
Out2
0012
Out3
2013
ONE;
IDLE;
TWO;
THREE;
THREE;
IDLE;
2014
In1 0
?
1
ONE
In2 1
?
TWO
0
Out2
THREE
In3 1
?
0
Out3
2015
ONE
In1 0
?
1
1
In2 1
?
TWO
0
THREE
Out2
Out3
2015
ASM2a
// ----------- state declaration ---------logic [1:0] state;
// ------- state + next state logic ------always_ff @(posedge Clock, negedge nReset)
if (!nReset)
state <= 0;
else
case (state)
0:
if (In1) state <= 1;
1:
if (In2) state <= 2;
else
state <= 3;
2:
state <= 3;
3:
state <= 0;
endcase
// ------------- output logic ------------logic Out2, Out3;
assign Out2 = (state == 2);
assign Out3 = (state == 3) && In3;
2016
2017
2018
<= 0; end
n.b. single procedural block solution not possible for Mealy machine since we have conditional outputs.
2019
Datapath Control
Datapath
Control
Unit
Function
Control
Functional
Units
& Bus Structure
Load
Control
Registers
For successful update we must simultaneously control function and register update:
INC_PC
Function=Increment
LoadPC
PC PC + 1
2020
Datapath Control
ADD_1st_Word
ADD_1st_Word
Function=Add_X0_imm
LoadZ0
LoadCarry
{Carry,Z0} X0 + imm
Function=Add_X0_imm
LoadZ0
LoadCarry
{Carry,Z0} X0 + imm
Carry
?
1
ADD_2nd_Word
Function=Add_X1_Carry
LoadZ1
Z1 X1 + Carry
Function=other
Function=Add_X1_Carry
LoadZ1
Z1 X1 + Carry
Carry
?
Function=other
Since datapath registers are updated at the end of the clock cycle, we must wait
until the next state before testing new values7.
7
in some cases it may be better to test values at the input to a register, e.g. if (nextCarry == 1)...
2021