Digital System Design-Synchronous Sequential Circuits
118 views
67 slides
Jul 26, 2022
Slide 1 of 67
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
About This Presentation
Behavioral modeling of sequential logic modules: Latches, Flip Flops, counters and shift registers applications
Synchronous Sequential Circuits: Analysis and synthesis of synchronous sequential circuits: Mealy and Moore FSM models for completely and incompletely specified circuits, State Minimizatio...
Behavioral modeling of sequential logic modules: Latches, Flip Flops, counters and shift registers applications
Synchronous Sequential Circuits: Analysis and synthesis of synchronous sequential circuits: Mealy and Moore FSM models for completely and incompletely specified circuits, State Minimization-Partitioning Minimization Procedure, sequence detector with verilog HDL modeling Design of a Modulo-8 Counter using the Sequential Circuit Approach and its verilog implementation. One-Hot Encoding
Size: 1.35 MB
Language: en
Added: Jul 26, 2022
Slides: 67 pages
Slide Content
MATRUSRI ENGINEERING COLLEGE
DEPARTMENT OF ELECTRONICS AND COMMUNICATION
ENGINEERING
SUBJECT NAME: DIGITAL SYSTEM DESIGN WITH VERILOG
FACULTY NAME: Mrs. B. Indira Priyadarshini
MATRUSRI
ENGINEERING COLLEGE
Shift Register
MATRUSRI
ENGINEERING COLLEGE
Serial In Serial Out:
module shift (C, SI, SO);
input C,SI;
output SO;
reg[7:0] tmp;
always @(posedgeC)
begin
tmp= tmp<< 1;
tmp[0] = SI;
end
assign SO = tmp[7];
endmodule
Parallel In Parallel Out:
module pipo(pin, clk, reset, pout);
input [3:0] pin;
input clk, reset;
output reg[3:0] pout;
always @ (posedgeclkor posedgereset)
begin
if (reset)
pout <= 4'b0000;
else
pout <= pin;
end
endmodule
Shift Register
MATRUSRI
ENGINEERING COLLEGE
Parallel In Serial Out:
moduleShiftregister_PISO(
Clk, Parallel_In,load,
Serial_Out);
inputClk,load;
input[3:0]Parallel_In;
outputregSerial_Out;
reg[3:0]tmp;
always@(posedgeClk)
begin
if(load)
tmp<=Parallel_In;
else
begin
Serial_Out<=tmp[3];
tmp<={tmp[2:0],1'b0};
end
end
endmodule
Serial In Parallel Out:
moduleShiftRegister_SIPO(Clk, SI, PO);
inputClk,SI;
output[7:0] PO;
reg[7:0] tmp;
always@(posedgeClk)
begin
tmp= {tmp[6:0], SI};
end
assignPO = tmp;
endmodule
CONTENTS:
Design Procedure
Moore state Model
Mealy state Model
OUTCOMES:
StudentswillbeabletodesignMealyandMooreFSMmodelsforcompletely
andincompletelyspecifiedcircuits.
MODULE-II: Synchronous Sequential
Circuits
MATRUSRI
ENGINEERING COLLEGE
Synchronous Sequential Circuits
MATRUSRI
ENGINEERING COLLEGE
A circuit whose output(s) depend on past behaviour, and present inputs
•Clock is used => synchronous sequential circuits
•No clock => asynchronous sequence circuits
Also called Finite state machine (FSM)
State elements in synchronous sequential circuits are edge triggered
•To ensure state changes only once in a single cycle.
Synchronous Sequential Circuits
MATRUSRI
ENGINEERING COLLEGE
Synchronous sequential circuits are of two types:
•Moore output depends only on state
•Mealy: output depends on state and inputs
Develop State Diagram
MATRUSRI
ENGINEERING COLLEGE
The conceptually simplest method is to use a pictorial representation in the
form of a state diagram.
Optional to develop
One form to represent a FSM:
• How many states: States are circles
• Transitions between states: Transitions are directed edges
• Starting state: i.e. after reset/clear
Note in figure, reset is not treated as input: To simplify figure.
Develop State Table
MATRUSRI
ENGINEERING COLLEGE
AnotherwaytodescribeaFSM
Whenimplementedinalogiccircuit,eachstateisrepresentedbyaparticular
valuation(combinationofvalues)ofstatevariables.
Itcontainsinformationon:
•Statesofthemachine
•Transitionsfromallstates,forallpossibleinputs
•Outputvalues
•Resetinformationignored:StateAisassumedtobe“start”statePresent
state
Next state Output
Z w = 0 w = 1
A
B
C
A B
A C
A C
0
0
1
Develop State Assignment
MATRUSRI
ENGINEERING COLLEGE
Y1=w.y1y2
Y2=w(y1+y2)
z=y2
•Stateassignmentshasdirectrelationtothecostofderivedimplementation
Somestateassignmentsarebetterthanothers
•Usingthenewstateassignmentamorecosteffectiverealizationinpossible
Y1=w,cheaper
Y2=wy1,cheaper
z=y2,samecost
Present state
y
2y
1
Next state Output
Zw = 0 w = 1
Y
2Y
1 Y
2Y
1
A
B
C
D
00
01
10
11
00 01
00 10
00 10
d d
0
0
1
d
Present state
y
2y
1
Next state Output
Zw = 0 w = 1
Y
2Y
1 Y
2Y
1
A
B
C
D
00
01
11
10
00 01
00 10
00 10
d d
0
0
1
d
Function Realization
MATRUSRI
ENGINEERING COLLEGE
Resulting Logic Circuit
MATRUSRI
ENGINEERING COLLEGE
Timing Diagram of Realization
MATRUSRI
ENGINEERING COLLEGE
Mealy Machine Implementation
MATRUSRI
ENGINEERING COLLEGE
Outputvaluesaregeneratedusingstate&presentinputs
Statediagram StateTable
StateAssignedTable LogicDiagram
Y = D = w z = wyClock cycle: t0 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10
w: 0 1 0 1 1 0 1 1 1 0 1
z: 0 0 0 0 1 0 0 1 1 0 0
Present
state
Next state Output z
w = 0 w = 1 w = 0 w = 1
A
B
A B
A B
0 0
0 1
Present
state
Next state Output z
w = 0 w = 1 w = 0 w = 1
y Y Y z z
A
B
0
1
0 1
0 1
0 0
0 1
Timing Diagram of Mealy Machine
MATRUSRI
ENGINEERING COLLEGE
MealyimplementationismorecosteffectivethanMooreimplementation
•However,circuitcanbemodifiedsothatitbehaveslikeaMooremachine
Notehowoutputchangebasedonstateandinput
1.Moore machine produces an output over the change of transition states.
2.In mealymachine, the O/P depends upon present states and inputs.
3.The relationship that exists among the inputs, outputs, present states and
next states can be specified by either thestate tableor thestate diagram.
4.A state-transitiontable is a table showing what state a finite-state
machine will move to, based on the current state and other inputs.
Questions & Answers
MATRUSRI
ENGINEERING COLLEGE
CONTENTS:
State Minimization
Partitioning Minimization Procedure
OUTCOMES:
StudentswillbeabletodesignamorecomplexFSMwithfewerflips-flops.
MODULE-III: State Minimization
MATRUSRI
ENGINEERING COLLEGE
State Minimization
MATRUSRI
ENGINEERING COLLEGE
TwostatesSiandSjaresaidtobeequivalentifandonlyifforeverypossible
inputsequence,thesameoutputsequencewillbeproducedregardlessof
whetherSiorSjistheinitialstate.
Lowerno.ofstates=>lowerno.ofFFs
Solvedusing“partitioningminimizationprocedure”
Partition:Asetofstates
Apartitionconsistsofoneormoreblocks,whereeachblockcomprisesa
subsetofstatesthatmaybeequivalent,butthestatesinagivenblockare
definitelynotequivalenttothestatesinotherblocks.
Statesinapartitionmaybeequivalent
Notequivalenttostatesinotherpartitions
State Minimization
MATRUSRI
ENGINEERING COLLEGE
•P1 = (ABCDEFG)
Partition based on output z
•P2 = (ABD)(CEFG),
Partition based on 0-& 1-successor for
block (ABD) & (CEFG)
•P3 = (ABD)(CEG)(F),
Partition based on 0-& 1-successor for
block (ABD) & (CEG),
•P4 = (AD)(B)(CEG)(F)
Partition based on 0-& 1-successor for
block (AD) & (CEG), => Final
•Final Partitions: P5 = (AD)(B)(CEG)(F)
2 FFs are sufficient after state minimization instead of 3Present
state
Next state Output
z w = 0 w = 1
A
B
C
D
E
F
G
B C
D F
F E
B G
F C
E D
F G
1
1
0
1
0
0
0
Present
state
Next state Output
z w = 0 w = 1
A
B
C
F
B C
A F
F C
C A
1
1
0
0
Incompletely Specified FSMs
MATRUSRI
ENGINEERING COLLEGE
Thepartitioningschemeforminimizationofstatesworkswellwhenall
entriesinthestatetablearespecified.FSMsofthistypearesaidtobe
completelyspecified.
Ifoneormoreentriesinthestatetablearenotspecified,correspondingto
don’t-careconditions,thentheFSMissaidtobeincompletelyspecified.
Affectsthenumberofminimizedstates
Assumex’sarezeros:
P1=(ABCDEFG)
P2=(ABDG)(CEF),
P3=(AB)(D)(G)(CE)(F),
P4=(A)(B)(D)(G)(CE)(F),
P5=P4=>6states
Assumex’sareones:
P1=(ABCDEFG)
P2=(AD)(BCEFG),
P3=(AD)(B)(CEFG),
P4=(AD)(B)(CEG)(F),
P5=P4=>4statesPresent
state
Next state Output z
w = 0 w = 1 w = 0 w = 1
A
B
C
D
E
F
G
B C
D -
F E
B G
F C
E D
F -
0 0
0 -
0 1
0 0
0 1
0 1
0 -
CONTENTS:
Moore FSM Model
Mealy FSM Model
OUTCOMES:
Studentswillbeabletowriteaverilogcodeforanysequencedetector.
MODULE-IV: Sequence detector with
verilogHDL modeling
MATRUSRI
ENGINEERING COLLEGE
module simple (Clock, Resetn, w, z);
input Clock, Resetn, w;
output z;
reg[2:1] y, Y;
parameter [2:1] A = 2'b00, B = 2'b01, C = 2'b10;
always @(w or y)
case (y)
A: if (w) Y = B;
else Y = A;
B: if (w) Y = C;
else Y = A;
C: if (w) Y = C;
else Y = A;
default: Y = 2'bxx;
endcase
always @(negedgeResetnor posedgeClock)
if (Resetn== 0)
y <= A;
else
y <= Y;
assign z = (y == C);
endmodule
Moore FSM Model
MATRUSRI
ENGINEERING COLLEGE
MATRUSRI
ENGINEERING COLLEGE
module mealy (Clock, Resetn, w, z);
input Clock, Resetn, w;
output z;
regy, Y, z;
parameter A = 0, B = 1;
always @(w or y)
case (y)
A: if (w) begin z = 0; Y = B; end
else begin z = 0; Y = A; end
B: if (w) begin z = 1; Y = B; end
else begin z = 0; Y = A; end
endcase
always @(negedgeResetnor posedgeClock)
if (Resetn== 0)
y <= A;
else
y <= Y;
endmodule
Mealy FSM Model
1.Mealy machine will have same or fewer states than Moore machine.
2.In MooreMachine both output and state change synchronous to the clock
edge.
3.Moore Machine requires morehardware to design than mealy machine.
4.In Mealymachine, asynchronous output generation through the state
changes synchronous to the clock.
Questions & Answers
MATRUSRI
ENGINEERING COLLEGE
CONTENTS:
Modulo –8 Counter
D Flip-flop
JK Flip-flop
Verilogcode
OUTCOMES:
Studentswillbeabletodesigndifferentcountersusingsequentialciruit
approach.
MODULE-V: Modulo-8 Counter Using the
Sequential Circuit Approach
MATRUSRI
ENGINEERING COLLEGE
Modulo-8 Counter
MATRUSRI
ENGINEERING COLLEGE
Mod8counter(0,1,..7,0,1..){MooreDesign}
StateDiagram:
Stateasignedtable
Statetable
Present
state
Next stateOutput
w= 0 w= 1
A
B
C
D
E
F
G
H
A B
B C
C D
D E
E F
F G
G H
H A
1
2
3
4
5
6
7
8
Present
state
y
2y
1y
0
Next stateOutput
z
2z
1z
0w= 0 w= 1
Y
2Y
1Y
0Y
2Y
1Y
0
A
B
C
D
E
F
G
H
000
001
010
011
100
101
110
111
0 0 0 0 0 1
0 0 1 0 1 0
0 1 0 0 1 1
0 1 1 1 0 0
1 0 0 1 0 1
1 0 1 1 1 0
1 1 0 1 1 1
1 1 1 0 0 0
000
001
010
011
100
101
110
111
Implementation Using D-Type Flip-Flops
MATRUSRI
ENGINEERING COLLEGE
21010210210210210212022
1010101010100111
0000
yywyyywyyyywyywyyyywyyywyyyyywD
ywyywyyywywyyywywyyyywD
ywywywD
Implementation Using D-Type Flip-Flops
MATRUSRI
ENGINEERING COLLEGE
One-Hot Encoding
MATRUSRI
ENGINEERING COLLEGE
•Asanalternativestateassignment,wecanuseone-hotencoding:
UseasmanyFFsasstates
•Inone-hotencodingmethod,foreachstateallbutoneofthestatevariables
areequalto0.Thevariablewhosevalueis1isdeemedtobe“hot.”
•Usuallyleadstosimpleroutputexpressions,fastercircuits
Y
1=w͞
Y
2=wy
1
Y
3=wy͞
1
z=y3
Present state
y
3y
2y
1
Next stateOutput
Zw = 0w = 1
Y
3Y
2Y
1 Y
3Y
2Y
1
001
010
100
001 010
001 100
001 100
0
0
1Present
state
Next state Output
Z w = 0 w = 1
A
B
C
A B
A C
A C
0
0
1
1.The variable whose value is 1 is deemed to be hot.
2.One-hot state assignment leads to simpler output expressions than do
assignments with the minimal number of state variables.
3.Simpler output expressions may lead to a fastercircuit.
Questions & Answers
MATRUSRI
ENGINEERING COLLEGE
CONTENTS:
Analysis of Synchronous Circuits
OUTCOMES:
StudentswillbeabletoanalysisofvariousSynchronousCircuits.
MODULE-VII: Analysis of Synchronous
Circuits
MATRUSRI
ENGINEERING COLLEGE
Analysis of Synchronous Circuits
MATRUSRI
ENGINEERING COLLEGE
Analysisisthereverseofsynthesis:Givenacircuit,findoutwhatdoesitdo
Reversesynthesissteps:
•Constructstatetable(FFs’typeisafactor)
•Symbolicstatetable
•Statediagram
State assigned table
State table21
212
211
yyz
wywyY
wyywY
Present
state
Next stateOutput
Zw= 0 w= 1
A
B
C
D
A C
A D
A B
A D
0
0
0
1
Present
state
y
1y
2
Next stateOutput
zw= 0 w= 1
Y
1Y
2 Y
1Y
2
00
01
10
11
00 10
00 11
00 01
00 11
0
0
0
1
Analysis of Synchronous Circuits
MATRUSRI
ENGINEERING COLLEGE
Excitation table State tablewK
wyJ
ywK
wJ
2
12
21
1
Present
state
y
1y
2
Next state Output
zw= 0 w= 1
J
2K
2 J
1K
1 J
2K
2 J
1K
1
00
01
10
11
01 01 00 11
01 01 00 10
01 01 10 11
01 01 10 10
0
0
0
1
Present
state
Next state Output
zw= 0 w= 1
A
B
C
D
B BA D
B BA C
B BC D
B BC C
0
0
0
1
1.The analysis task is much simpler than the synthesis task.
2.To analyze a circuit, reverse the steps of the synthesis process.
3.To design a synchronous sequential circuit, the designer has to be able to
analyzethe behaviorof an existing circuit.
Questions & Answers
MATRUSRI
ENGINEERING COLLEGE
CONTENTS:
Serial Adder
Mealy-Type FSM
Moore-Type FSM
VerilogCode
OUTCOMES:
Student will able to design and implement a FSM for serial adder
MODULE-VIII: Additional Topic
MATRUSRI
ENGINEERING COLLEGE
Mealy-Type FSM
MATRUSRI
ENGINEERING COLLEGE
State Diagram State Table
Present
state
Next state Output
ab= 00 01 10 1100 01 10 11
G
H
G G G H
G H H H
0 1 1 0
1 0 0 1
Mealy-Type FSM
MATRUSRI
ENGINEERING COLLEGE
State Assigned Table Output equations:
Circuit Diagram
Present
state
Next state Output s
ab= 00 01 10 1100 01 10 11
y Y S
0
1
0 0 0 1
0 1 1 1
0 1 1 0
1 0 0 1 ybaS
byayabY
Moore-Type FSM
MATRUSRI
ENGINEERING COLLEGE
State Diagram State Table
State Assigned Table
Circuit Diagram
Present
state
Next state Output
S ab = 00 01 10 11
G0
G1
H0
H1
G0 G1 G1 H0
G0 G1 G1 H0
G1 H0 H0 H1
G1 H0 H0 H1
0
1
0
1
Present
state
y
2y
1
Next state Output
sab= 00 01 10 11
Y
2Y
1
00
01
10
11
00 01 01 10
00 01 01 10
01 10 10 11
01 10 10 11
0
1
0
11
222
21
ys
byayabY
ybaY
module serialadder(A, B, Reset, Clock, Sum);
input [3:0] A, B;
input Reset, Clock;
output wire [3:0] Sum;
reg[3:0] Count;
regs, y, Y;
wire [3:0] QA, QB;
wire Run;
parameter G = 1'b0, H = 1'b1;
shift shift_A(A, Reset, 1'b1, 1'b0, Clock, QA);
shift shift_B(B, Reset, 1'b1, 1'b0, Clock, QB);
shift shift_S(4'b0, Reset, Run, s, Clock, Sum);
always @(QA, QB, y)
case (y)
G: begin
s = QA[0]^QB[0];
if (QA[0] & QB[0]) Y = H;
else Y = G;
end
VerilogCode
MATRUSRI
ENGINEERING COLLEGE
H: begin
s = QA[0]~^QB[0];
if (~QA[0] & ~QB[0])
Y = G;
else
Y = H;
end
default: Y = G;
endcase
always @(posedgeClock)
if (Reset)
y <= G;
else
y <= Y;
always @(posedgeClock)
if (Reset) Count = 4;
else if (Run) Count = Count-1;
assign Run =|Count;
endmodule
1.In a serialadder, bits are added a pair at a time.
2.Fast adders are morecomplex and moreexpensive.
3.A serial adder is a cost-effectiveand less speed.
4.Moore-type circuit is delayed by one clock cycle with respect to the Mealy-
type sequential circuit.
Questions & Answers
MATRUSRI
ENGINEERING COLLEGE
Question Bank
MATRUSRI
ENGINEERING COLLEGE
Long Answer Question
S.No Question
Blooms
Taxonomy
Level
Course
Outcome
1Brieflyexplainaboutshiftregisterandwriteaverilogcodefor
4bitshiftrightandleftregister.
L2 CO3
2Explainthestateminimizationprocessinsynchronous
sequentialcircuits.
L5 CO3
3Designasynchronous3bitup-downcounter.Writeverilog
codewithitstestbenchandwaveforms.
L1 CO3
4Designandwriteverilogcodeformodulo-8counterusing
sequentialapproachuseTflipflopmemoryelement..
L4 CO3
5Explainserialadderwithaneatdiagramandimplementin
VeriloglanguageusingMealyandmooretypemodels.
L2 CO3
6Design sequential circuit for given state table and write verilog
code in behavioural modeling
L1 CO3 X
0 1
A
B
C
D
E
B/0 E/0
A/1 C/1
B/0 C/1
C/0 E/0
D/1 A/0
Question Bank
MATRUSRI
ENGINEERING COLLEGE
Long Answer Question
S.No Question
Blooms
Taxonomy
Level
Course
Outcome
7Performthepartitioningprocedureonthestatetableshown
below
L2 CO3
8Analyserthegivensynchronoussequentialcircuitandwriteits
veilogcode.
L5 CO3Present
state
Next State output
input=0 input = 1
A B C 1
B D F 1
C F E 0
D B G 1
E F C 0
F E D 0
G F G 0
Assignment Questions
MATRUSRI
ENGINEERING COLLEGE
1.Design a counter which moves through the sequence 0,4,2,6,1,5,3,7,0,4
and so on using synchronous sequential circuit approach.
2.Design a Mealy and Moore type Sequence detector for detecting the
sequence 1010 and Implement in verilogHDL.
3.Reduce the state table given below and draw the minimized state diagram. Present
State
Next State Output (z)
Input (x) Input (x)
X = 0 X = 1 X = 0 X = 1
A A B 0 0
B D C 0 1
C F E 0 0
D D F 0 0
E B G 0 0
F G C 0 1
G A F 0 0
Assignment Questions
MATRUSRI
ENGINEERING COLLEGE
4.Analyser the given synchronous sequential circuit and write its veilogcode.
5.Design synchronous sequential circuit of state machine M1 shown using D
flip –flop. Assume state assignment as A = 00, B = 01and C= 10.
PS Next State , z
x = 0x = 1
A B, 0 A, 1
B C, 0 A, 1
C A,1 B, 0