DOC PREVIEW
Berkeley COMPSCI 150 - Sequential Logic Examples

This preview shows page 1-2-3-26-27-28 out of 28 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 28 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 28 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 28 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 28 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 28 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 28 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 28 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Sequential Logic ExamplesGeneral FSM Design ProcedureFinite String Pattern Recognizer (Step 1)Finite String Pattern Recognizer (Step 2)Finite String Pattern Recognizer (Step 2, cont’d)Slide 6Finite String Pattern Recognizer (Step 3)Finite String Pattern RecognizerComplex CounterComplex Counter (State Diagram)Complex Counter (State Encoding)Traffic Light Controller as Two Communicating FSMsCommunicating Finite State MachinesDatapath and ControlDigital Combinational LockImplementation in SoftwareDetermining Details of the SpecificationDigital Combination Lock State DiagramDatapath and Control StructureState Table for Combination LockEncodings for Combination LockDatapath Implementation for Combination LockDatapath Implementation (cont’d)Tri-State GatesTri-State and MultiplexingOpen-Collector Gates and Wired-ANDDigital Combination Lock (New Datapath)Section SummaryCS 150 - Spring 2001 - Sequential Logic Examples - 1 Sequential Logic ExamplesFinite State Machine ConceptFSMs are the decision making logic of digital designs Partitioning designs into datapath and control elementsWhen inputs are sampled and outputs assertedBasic Design Approach: 4-step Design ProcessImplementation Examples and Case StudiesFinite-string pattern recognizerComplex counterTraffic light controllerDoor combination lockCS 150 - Spring 2001 - Sequential Logic Examples - 2General FSM Design Procedure(1) Determine inputs and outputs(2) Determine possible states of machine– State minimization(3) Encode states and outputs into a binary code– State assignment or state encoding– Output encoding– Possibly input encoding (if under our control)(4) Realize logic to implement functions for states and outputs– Combinational logic implementation and optimization– Choices in steps 2 and 3 have large effect on resulting logicCS 150 - Spring 2001 - Sequential Logic Examples - 3Finite String Pattern Recognizer(Step 1)Finite String Pattern RecognizerOne input (X) and one output (Z)Output is asserted whenever the input sequence …010… has been observed, as long as the sequence 100 has never been seenStep 1: Understanding the Problem StatementSample input/output behavior:X: 0 0 1 0 1 0 1 0 0 1 0 …Z: 0 0 0 1 0 1 0 1 0 0 0 …X: 1 1 0 1 1 0 1 0 0 1 0 …Z: 0 0 0 0 0 0 0 1 0 0 0 …CS 150 - Spring 2001 - Sequential Logic Examples - 4Finite String Pattern Recognizer (Step 2)Step 2: Draw State DiagramFor the strings that must be recognized, i.e., 010 and 100Moore implementationS1[0]S2[0]01S3[1]0S4[0]10 or 1S5[0]00S6[0]S0[0]resetCS 150 - Spring 2001 - Sequential Logic Examples - 5Finite String Pattern Recognizer (Step 2, cont’d)Exit conditions from state S3: have recognized …010If next input is 0 then have …0100 = ...100 (state S6)If next input is 1 then have …0101 = …01 (state S2)1...01...010 ...100S4[0]S1[0]S0[0]S2[0]101reset0 or 1S3[1]0S5[0]00S6[0]Exit conditions from S1: recognizes strings of form …0(no 1 seen); loop back to S1 if input is 0Exit conditions from S4: recognizes strings of form …1 (no 0 seen); loop back to S4 if input is 1...1...010CS 150 - Spring 2001 - Sequential Logic Examples - 6Finite String Pattern Recognizer (Step 2, cont’d)S2 and S5 still have incomplete transitionsS2 = …01; If next input is 1,then string could be prefix of (01)1(00) S4 handles just this caseS5 = …10; If next input is 1,then string could be prefix of (10)1(0) S2 handles just this caseReuse states as much as possibleLook for same meaningState minimization leads tosmaller number of bits torepresent statesOnce all states have completeset of transitions we havefinal state diagram1...01...010 ...100S4[0]S1[0]S0[0]S2[0]101reset0 or 1S3[1]0S5[0]00S6[0]...1...010...1011CS 150 - Spring 2001 - Sequential Logic Examples - 7module string (clk, X, rst, Q0, Q1, Q2, Z);input clk, X, rst;output Q0, Q1, Q2, Z;reg state[0:2];‘define S0 = [0,0,0]; //reset state‘define S1 = [0,0,1]; //strings ending in ...0‘define S2 = [0,1,0]; //strings ending in ...01‘define S3 = [0,1,1]; //strings ending in ...010‘define S4 = [1,0,0]; //strings ending in ...1‘define S5 = [1,0,1]; //strings ending in ...10‘define S6 = [1,1,0]; //strings ending in ...100assign Q0 = state[0];assign Q1 = state[1];assign Q2 = state[2];assign Z = (state == ‘S3);always @(posedge clk) begin if rst state = ‘S0; else case (state) ‘S0: if (X) state = ‘S4 else state = ‘S1; ‘S1: if (X) state = ‘S2 else state = ‘S1; ‘S2: if (X) state = ‘S4 else state = ‘S3; ‘S3: if (X) state = ‘S2 else state = ‘S6; ‘S4: if (X) state = ‘S4 else state = ‘S5; ‘S5: if (X) state = ‘S2 else state = ‘S6; ‘S6: state = ‘S6; default: begin $display (“invalid state reached”); state = 3’bxxx; endcaseendendmoduleFinite String Pattern Recognizer (Step 3)Verilog description including state assignment (or state encoding)CS 150 - Spring 2001 - Sequential Logic Examples - 8Finite String Pattern RecognizerReview of ProcessUnderstanding problemWrite down sample inputs and outputs to understand specificationDerive a state diagram Write down sequences of states and transitions for sequences to be recognizedMinimize number of states Add missing transitions; reuse states as much as possibleState assignment or encoding Encode states with unique patternsSimulate realization Verify I/O behavior of your state diagram to ensure it matches specificationCS 150 - Spring 2001 - Sequential Logic Examples - 9Mode Input M0011100Current State000001010110111101110Next State001010110111101110111Complex CounterSynchronous 3-bit counter has a mode control MWhen M = 0, the counter counts up in the binary sequenceWhen M = 1, the counter advances through the Gray code sequencebinary: 000, 001, 010, 011, 100, 101, 110, 111Gray: 000, 001, 011, 010, 110, 111, 101, 100Valid I/O behavior (partial)CS 150 - Spring 2001 - Sequential Logic Examples - 10Complex Counter (State Diagram)Deriving State DiagramOne state for each output combination Add appropriate arcs for the mode controlS0[000]S1[001]S2[010]S3[011]S4[100]S5[101]S6[110]S7[111]reset00 0 0 000011111111CS 150 - Spring 2001 - Sequential Logic Examples - 11Complex Counter (State Encoding)Verilog description including state encodingmodule string (clk, M, rst, Z0, Z1,


View Full Document

Berkeley COMPSCI 150 - Sequential Logic Examples

Documents in this Course
Lab 2

Lab 2

9 pages

Debugging

Debugging

28 pages

Lab 1

Lab 1

15 pages

Memory

Memory

13 pages

Lecture 7

Lecture 7

11 pages

SPDIF

SPDIF

18 pages

Memory

Memory

27 pages

Exam III

Exam III

15 pages

Quiz

Quiz

6 pages

Problem

Problem

3 pages

Memory

Memory

26 pages

Lab 1

Lab 1

9 pages

Memory

Memory

5 pages

Load more
Download Sequential Logic Examples
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Sequential Logic Examples and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Sequential Logic Examples 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?