Presentation is loading. Please wait.

Presentation is loading. Please wait.

ACCESS IC LAB Graduate Institute of Electronics Engineering, NTU 99-1 Under-Graduate Project Design of Datapath Controllers Speaker: Shao-Wei Feng Adviser:

Similar presentations


Presentation on theme: "ACCESS IC LAB Graduate Institute of Electronics Engineering, NTU 99-1 Under-Graduate Project Design of Datapath Controllers Speaker: Shao-Wei Feng Adviser:"— Presentation transcript:

1 ACCESS IC LAB Graduate Institute of Electronics Engineering, NTU 99-1 Under-Graduate Project Design of Datapath Controllers Speaker: Shao-Wei Feng Adviser: Prof. An-Yeu Wu Date: 2010/10/14

2 ACCESS IC LAB Graduate Institute of Electronics Engineering, NTU P. 2 Outline  Sequential Circuit Model  Finite State Machines  Useful Modeling Techniques

3 ACCESS IC LAB Graduate Institute of Electronics Engineering, NTU P. 3 Model of Sequential Circuits  System outputs depend not only on current input  Depend on inputs  Depend on current state  Fundamental components  Combinational circuits  Memory elements Combinational Logic Memory Elements Inputs Outputs Next State Current State clock

4 ACCESS IC LAB Graduate Institute of Electronics Engineering, NTU P. 4 Types of Memory Elements  Flip-Flop  Latch  Registers  Others  Register Files  Cache  Flash memory  ROM  RAM

5 ACCESS IC LAB Graduate Institute of Electronics Engineering, NTU P. 5 D-FF vs. D-Latch  FF is edge sensitive (can be either positive or negative edge)  At trigger edge of clock, input transferred to output  Latch is level sensitive(can be either active-high or active-low)  When clock is active, input passes to output (transparent)  When clock is not active, output stays unchanged D Q FF clk in out D Q E clk inout clk in out Latch clk in out

6 ACCESS IC LAB Graduate Institute of Electronics Engineering, NTU P. 6 FF Based, Edge Trigger Clocking  T d = delay of combinational logic  T cycle = cycle time of clock  Duty cycle does not matter  Timing requirements for T d  T dmax < T cycle –T setup – T cq  no setup time violation  T dmin > T hold – T cq  no hold time violation FF clk T cycle Combinational Logic T d T cq TdTd T setup

7 ACCESS IC LAB Graduate Institute of Electronics Engineering, NTU P. 7 Latch Based, Single Phase Clocking  Pulse Mode clocking  T cycle = cycle time of clock; T w = pulse width of clock  Timing requirements for T d  T dmax < T cycle –T dq  data latched correctly  T dmin > T w – T dq  no racing through next stage clk Combinational Logic Td Latch T cycle T dq TdTd TwTw

8 ACCESS IC LAB Graduate Institute of Electronics Engineering, NTU P. 8 Comparison  Flip-Flop Based − Larger in area − Larger clocking overhead (T setup, T cq )  Design more robust Only have to worry about T dmax T dmin usually small, can be easily fixed by buffer  Pulse width does not matter  Latch Based Single Phase  Smaller area  Smaller clocking overhead ( only T dq ) − Worry about both T dmax and T dmin − Pulse width does matter (unfortunately, pulse width can vary on chip)

9 ACCESS IC LAB Graduate Institute of Electronics Engineering, NTU P. 9 D Flip-Flop with Positive-Edge Clock module flop (Q, D, C, S, R); output Q; // Flip-Flop Output input D; // Data Input input C; // Positive Edge Clock input E; // Clock Enable reg Q; // Register Type always @(posedge C) begin if (E) // Check Enable Q <= D; end endmodule DQ C DQ C E

10 ACCESS IC LAB Graduate Institute of Electronics Engineering, NTU P. 10 D Flip-Flop with Positive-Edge Clock module flop (Q, D, C, S, R); output Q; // Flip-Flop Output input D; // Data Input input C; // Positive Edge Clock input R; // Asynchronous Reset input S; // synchronous Set reg Q; // Register Type always @(posedge C or negedge R) begin if (!R) Q <= 1’b0; else if (S) Q <= 1’b1; else Q <= D; end endmodule DQ C S R

11 ACCESS IC LAB Graduate Institute of Electronics Engineering, NTU P. 11 Latch Issue  Latches are to be avoided in most designs!  Prone to timing violations and glitches  Cannot implement synchronous operations  Common mistakes that generate latches always@( a or b ) begin if( a == 2’d0 ) z = 1’b0; else if( a == 2’d1 ) z = ~b; else if( a == 2’d2 ) z = b; // no else statement! end always@( a or b ) begin case( a ) 2’d0: z = b; 2’d1: z = ~b; 2’d2: z = c; // no default statement! endcase end always@( /*forget edge!*/ clk ) begin z <= b; end

12 ACCESS IC LAB Graduate Institute of Electronics Engineering, NTU Finite State Machine

13 ACCESS IC LAB Graduate Institute of Electronics Engineering, NTU P. 13 What is FSM  A model of computation consisting of  a set of states, (limited number)  a start state,  input symbols,  a transition function that maps input symbols and current states to a next state.

14 ACCESS IC LAB Graduate Institute of Electronics Engineering, NTU P. 14 Elements of FSM  Memory Elements (ME)  Memorize Current States (CS)  Usually consist of FF or latch  N-bit FF have 2 n possible states  Next-state Logic (NL)  Combinational Logic  Produce next state  Based on current state (CS) and input (X)  Output Logic (OL)  Combinational Logic  Produce outputs (Z)  Based on current state  Based on current state and input

15 ACCESS IC LAB Graduate Institute of Electronics Engineering, NTU P. 15 Mealy Machine  Output (Z) is function of both  Input (X)  Current state (CS)

16 ACCESS IC LAB Graduate Institute of Electronics Engineering, NTU P. 16 Moore Machine  Output(Z) is function of  Current state (CS) only

17 ACCESS IC LAB Graduate Institute of Electronics Engineering, NTU P. 17 Mealy Finite State Machine A serially-transmitted BCD (8421 code) word is to be converted into an Excess-3 code. An Excess-3 code word is obtained by adding 3 to the decimal value and taking the binary equivalent. Excess-3 code is self-complementing [Wakerly, p. 80], i.e. the 9's complement of a code word is obtained by complementing the bits of the word.

18 ACCESS IC LAB Graduate Institute of Electronics Engineering, NTU P. 18 Mealy Finite State Machine  The vertices of the state transition graph of a Mealy machine are labeled with the states.  The branches are labeled with (1) the input that causes a transition to the indicated next state, and (2) with the output that is asserted in the present state for that input.  The state transition is synchronized to a clock.  The state table summarizes the machine's behavior in tabular format. The serial code converter is described by the state transition graph of a Mealy FSM. State Transition Graph

19 ACCESS IC LAB Graduate Institute of Electronics Engineering, NTU P. 19 Design of a Mealy Finite State Machine To design a D-type flip-flop realization of a FSM having the behavior described by a state transition graph, (1) select a state code, (2) encode the state table, (3) develop Boolean equations describing the input of a D-type flip-flop, and (4) using K-maps, optimize the Boolean equations.

20 ACCESS IC LAB Graduate Institute of Electronics Engineering, NTU P. 20 Design of a Mealy Finite State Machine Note: We will optimize the equations individually. In general - this does not necessarily produce the optimal (area, speed) realization of the logic. We'll address this when we consider synthesis.

21 ACCESS IC LAB Graduate Institute of Electronics Engineering, NTU P. 21 Design of a Mealy Finite State Machine Realization of the sequential BCD-to-Excess-3 code converter (Mealy machine):

22 ACCESS IC LAB Graduate Institute of Electronics Engineering, NTU P. 22 Design of a Mealy Finite State Machine Simulation results for Mealy machine:

23 ACCESS IC LAB Graduate Institute of Electronics Engineering, NTU Building Behavioral Models

24 ACCESS IC LAB Graduate Institute of Electronics Engineering, NTU P. 24 Modeling FSM in Verilog  Sequential Circuits  Memory elements of States (CS)  Combinational Circuits  Next-state Logic (NL)  Output Logic (OL)  Three coding styles  (1) Separate CS, OL and NL  (2) Combines NL+ OL, separate CS  (3) Combine CS + NL, separate OL

25 ACCESS IC LAB Graduate Institute of Electronics Engineering, NTU P. 25 Coding Style 1 – Separate CS, NL, OL  CS  NL  OL

26 ACCESS IC LAB Graduate Institute of Electronics Engineering, NTU P. 26 Coding Style 2 – Combine NL+OL; Separate CS  CS  NL+OL

27 ACCESS IC LAB Graduate Institute of Electronics Engineering, NTU P. 27 Coding Style 3 – Combine CS+NL; Separate OL  CS+NL  OL

28 ACCESS IC LAB Graduate Institute of Electronics Engineering, NTU P. 28 State Encoding

29 ACCESS IC LAB Graduate Institute of Electronics Engineering, NTU P. 29 Behavioral Models of FSM Example: Speed Machine

30 ACCESS IC LAB Graduate Institute of Electronics Engineering, NTU P. 30 FSM Architecture Modeling Coding style 2 Coding style 2 fits this architecture very well! Build combinational and sequential parts separately!

31 ACCESS IC LAB Graduate Institute of Electronics Engineering, NTU P. 31 Verilog Sample Code (using coding style 2)

32 ACCESS IC LAB Graduate Institute of Electronics Engineering, NTU Gate-Level Simulation of the Speed Machine P. 32

33 ACCESS IC LAB Graduate Institute of Electronics Engineering, NTU P. 33 Conclusion  FSM Design  Partition FSM and non-FSM logic  Partition combinational part and sequential part  Use parameter to define names of the state vector  Assign a default (reset) state


Download ppt "ACCESS IC LAB Graduate Institute of Electronics Engineering, NTU 99-1 Under-Graduate Project Design of Datapath Controllers Speaker: Shao-Wei Feng Adviser:"

Similar presentations


Ads by Google