Shankar Balachandran* Associate Professor, CSE Department Indian Institute of Technology Madras
*Currently a Visiting Professor at IIT Bombay
Digital Circuits and Systems
Spring 2015 Week 6 Module 30
State Machines 2: Design Problems
Systems State Machines 2: Design Problems Shankar Balachandran* - - PowerPoint PPT Presentation
Spring 2015 Week 6 Module 30 Digital Circuits and Systems State Machines 2: Design Problems Shankar Balachandran* Associate Professor, CSE Department Indian Institute of Technology Madras *Currently a Visiting Professor at IIT Bombay
Shankar Balachandran* Associate Professor, CSE Department Indian Institute of Technology Madras
*Currently a Visiting Professor at IIT Bombay
State Machines 2: Design Problems
Analysis and Design of Sequential Logic Circuits 2
Design a sequential circuit that produces “1” on its output if it detects the sequence “101” on it’s input. The detector should keep checking for the appropriate sequence and should not reset to the initial state after it has recognized the sequence.
1 1
Analysis and Design of Sequential Logic Circuits 3
1 1 1
Analysis and Design of Sequential Logic Circuits 4
Mealy outputs may change when an input changes (i.e., not necessarily on a clock edge). output may have glitches. This problem can be solved by making Mealy inputs synchronous. Moore outputs only change on clock edges since they depend only on the present state. Moore outputs may be delayed w.r.t. the corresponding outputs in a Mealy implementation. CLK Input x State Output z Mealy State Output z Moore s0 s1 s2 s1 s1 s2 s1 s1 s2 s0 s0 s1 s2 s3 s1 s2 s3 s1 s2 s0
Analysis and Design of Sequential Logic Circuits 5
State Diagram:
1/1 0/0 0/0 0/0
1/0
1/0
0/1 0/1 1/0 1/1
1/1 0/1
State Encoding: a 000 b 001 c 010 d 011 e 100 f 101
6 states 3-bit encoding
001 000 010 011 100 101
3-bit encoding 3 flip-flops
Analysis and Design of Sequential Logic Circuits 6
Input (X) Present State Next State Flip-flop Inputs Output (S) Q2 Q1 Q0 Q2* Q1* Q0* D2 D1 D0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
a e
1/1 0/0 0/0 0/0
b
1/0
c
1/0
d
0/1 0/1 1/0 1/1
f
1/1 0/1 001 000 010 011 100 101
Analysis and Design of Sequential Logic Circuits 7
1 2 2 1 1 2 2 1 2 1 1 1 2 1 1 2 2
Analysis and Design of Sequential Logic Circuits 8
1 2 2 1 1 2 2 1 2 1 1 1 2 1 1 2 2
Q Q Q Q XQ Q X S Q Q X Q Q XQ Q X D Q Q X Q Q Q X Q Q Q X D Q XQ XQ D
Analysis and Design of Sequential Logic Circuits 9
00,11/00
00 10 01
X X /01 X X /10
10/10 01/01
Analysis and Design of Sequential Logic Circuits 10
Design a bit-serial odd parity checker: It counts the number of 1’s in a bit- serial input stream and asserts its output when the input stream contains an
P.S. Q0 N.S. (Q0*) Out (z) x=0 x=1
even (0) even (0)
(1)
(1)
(1) even (0) 1
reset even
1 1 1
D x Q z Q
Using D flip-flops
T x z Q
Using T flip-flops
Analysis and Design of Sequential Logic Circuits 11
A bus controller, that receives requests on separate lines, R0 to R3
The bus controller has five states:
A: idle, no device is using the bus B: device 0 is using the bus C: device 1 is using the bus D: device 2 is using the bus E: device 3 is using the bus
Analysis and Design of Sequential Logic Circuits 12
A
0000
B
1000
C
0100
D
0010
E
0001
Outputs: G0G1G2G3
1XXX 0001 XX0X 1XXX 01XX X1XX 001X 1XXX X0XX 01XX 0000 0XXX 1XXX XXX0 0001 001X 1XXX X1XX XX1X
Inputs: R0R1R2R3
Sequential Circuits 13
Analysis and Design of Sequential Logic Circuits 14
5 7 4 7 9 3 1 3 2 9 2 7 1 3 1 5 1 5 2 9 2 7 2 Modulus Analogous to Decimal - Use long division
Take one digit at a time
Start at the most significant digit
Calculate remainder Shift in another digit
The previous modulus moves to
“tens” position
Shifted digit gets added
Calculate remainder Repeat until all digits are done
Analysis and Design of Sequential Logic Circuits 15
Take one bit at a time (MSB first) Calculate remainder
Three possible values – 0,1,2
Shift in the next bit
Shifting results in doubling the previous modulus value New digit gets added to this doubled value
Perform modulus of the resultant value
Analysis and Design of Sequential Logic Circuits 16
Present Modulus Next x = 0 x = 1 1 1 2 2 1 2
1 1 1 Present Modulus Next x = 0 x = 1 00 00 01 01 10 00 10 01 10
Analysis and Design of Sequential Logic Circuits 17
Input x Present State Next State Flip-flop Inputs
Q1 Q0 Q1* Q0* T1 T0 1 1 1 1 1 1 1 1
1
1 1
1
1 1
1
1 1
Analysis and Design of Sequential Logic Circuits 18
1.
2.
3.
Intro to State Machines 19