Lab7-1 Lab 6: FSM Description Separate combinational and memory circuits –State memory uses FFs –Others are combinational circuits.

Slides:



Advertisements
Similar presentations
VERILOG: Synthesis - Combinational Logic Combination logic function can be expressed as: logic_output(t) = f(logic_inputs(t)) Rules Avoid technology dependent.
Advertisements

//HDL Example 8-2 // //RTL description of design example (Fig.8-9) module Example_RTL (S,CLK,Clr,E,F,A);
Counters Discussion D8.3.
Traffic light contoller using FSM
Sequential logic examples
Implementation Strategies
Combinational Logic.
Table 7.1 Verilog Operators.
//HDL Example 5-1 // //Description of D latch (See Fig.5-6) module D_latch (Q,D,control); output Q; input.
Verilog. 2 Behavioral Description initial:  is executed once at the beginning. always:  is repeated until the end of simulation.
FSM Revisit Synchronous sequential circuit can be drawn like below  These are called FSMs  Super-important in digital circuit design FSM is composed.
//HDL Example 6-1 // //Behavioral description of //Universal shift register // Fig. 6-7 and Table 6-3 module shftreg.
Slide 1 7. Verilog: Combinational always statements. VHDL: Combinational Processes: To avoid (I.E. DO NOT What in your HDL code?) Cases that generate Synthesis.
Verilog Tutorial Speaker : T.A. Chung-Yuan Lin. Traditional approach Gate level design Schematic design.
CSE Spring Verilog for Sequential Systems - 1 Today: Verilog and Sequential Logic zFlip-flops yrepresentation of clocks - timing of state.
FSM examples.
Spring 20067W. Rhett Davis with minor modifications by Dean Brock ECE 406 at UNASlide 1 ECE 406 Design of Complex Digital Systems Lecture 10: 9: State.
Pulse-Width Modulated DAC
Digital System Design by Verilog University of Maryland ENEE408C.
ECE C03 Lecture 101 Lecture 10 Finite State Machine Design Hai Zhou ECE 303 Advanced Digital Design Spring 2002.
Verilog Sequential Circuits Ibrahim Korpeoglu. Verilog can be used to describe storage elements and sequential circuits as well. So far continuous assignment.
ELEN 468 Lecture 161 ELEN 468 Advanced Logic Design Lecture 16 Synthesis of Language Construct II.
Counters Discussion 12.1 Example 33. Counters 3-Bit, Divide-by-8 Counter 3-Bit Behavioral Counter in Verilog Modulo-5 Counter An N-Bit Counter.
Prof. John Nestor ECE Department Lafayette College Easton, Pennsylvania ECE Senior Design I Lecture 4 - Verilog 2 (Sequential.
ENEE 408C Lab Capstone Project: Digital System Design Fall 2005 Sequential Circuit Design.
COE 202 Introduction to Verilog Computer Engineering Department College of Computer Sciences and Engineering King Fahd University of Petroleum and Minerals.
1 COMP541 State Machines – 2 Registers and Counters Montek Singh Feb 8, 2007.
FPGA-Based System Design: Chapter 5 Copyright  2004 Prentice Hall PTR Verilog for sequential machines.

Sequential Logic in Verilog
FPGA-Based System Design: Chapter 5 Copyright  2004 Prentice Hall PTR Topics n Verilog styles for sequential machines. n Flip-flops and latches.
ECE 551 Digital System Design & Synthesis Fall 2011 Midterm Exam Overview.
Chapter 11: System Design Methodology Digital System Designs and Practices Using Verilog HDL and 2008, John Wiley11-1 Ders 8: FSM Gerçekleme ve.
ECE 551 Digital Design And Synthesis
Lab 1 and 2: Digital System Design Using Verilog
Slide 1 6. VHDL/Verilog Behavioral Description. Slide 2 Verilog for Synthesis: Behavioral description Instead of instantiating components, describe them.
ECE/CS 352 Digital System Fundamentals© 2001 C. Kime 1 ECE/CS 352 Digital Systems Fundamentals Spring 2001 Chapters 3 and 4: Verilog – Part 2 Charles R.
Register Transfer Level & Design with ASM
Verilog for Synthesis Ing. Pullini Antonio
Charles Kime & Thomas Kaminski © 2004 Pearson Education, Inc. Terms of Use (Hyperlinks are active in View Show mode) Terms of Use Verilog Part 3 – Chapter.
Finite State Machine (FSM) Nattha Jindapetch December 2008.
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL State Machines Anselmo Lastra.
IX - Sequential Logic TechnologyContemporary Logic Design1 Ch 9. Sequential Logic Technologies.
SYEN 3330 Digital SystemsJung H. Kim 1 SYEN 3330 Digital Systems Chapter 7 – Part 2.
1 COMP541 State Machines - II Montek Singh Feb 13, 2012.
Chapter 11: System Design Methodology Digital System Designs and Practices Using Verilog HDL and 2008, John Wiley11-1 Chapter 11: System Design.
ACCESS IC LAB Graduate Institute of Electronics Engineering, NTU 99-1 Under-Graduate Project Design of Datapath Controllers Speaker: Shao-Wei Feng Adviser:
SYEN 3330 Digital SystemsJung H. Kim Chapter SYEN 3330 Digital Systems Chapters 4 – Part4: Verilog – Part 2.
Lab5-1 張明峰 交大資工系 Lab 5: FSM and BCD counters Implement the vending machine of lab 2 A two-digit BCD counter –two BCD counters –can load data in parallel.
1 Workshop Topics - Outline Workshop 1 - Introduction Workshop 2 - module instantiation Workshop 3 - Lexical conventions Workshop 4 - Value Logic System.
COE 202 Introduction to Verilog Computer Engineering Department College of Computer Sciences and Engineering King Fahd University of Petroleum and Minerals.
1 Modeling of Finite State Machines Debdeep Mukhopadhyay Associate Professor Dept of Computer Science and Engineering NYU Shanghai and IIT Kharagpur.
EMT 351/4 DIGITAL IC DESIGN Verilog Behavioral Modeling  Finite State Machine -Moore & Mealy Machine -State Encoding Techniques.
1 Lecture 3: Modeling Sequential Logic in Verilog HDL.
Figure Implementation of an FSM in a CPLD..
Supplement on Verilog FF circuit examples
Figure 8.1. The general form of a sequential circuit.
Last Lecture Talked about combinational logic always statements. e.g.,
Supplement on Verilog Sequential circuit examples: FSM
Sequential logic examples
HDL Compiler Unsupport (Do NOT use in your verilog code)
FSM MODELING MOORE FSM MELAY FSM. Introduction to DIGITAL CIRCUITS MODELING & VERIFICATION using VERILOG [Part-2]
COE 202 Introduction to Verilog
Topics Verilog styles for sequential machines. Flip-flops and latches.
Supplement on Verilog Sequential circuit examples: FSM
Sequential logic implementation
Dr. Tassadaq Hussain Introduction to Verilog – Part-3 Expressing Sequential Circuits and FSM.
The Verilog Hardware Description Language
Dr. Tassadaq Hussain Introduction to Verilog – Part-4 Expressing FSM in Verilog (contd) and FSM State Encoding Dr. Tassadaq Hussain.
Presentation transcript:

lab7-1 Lab 6: FSM Description Separate combinational and memory circuits –State memory uses FFs –Others are combinational circuits

lab7-2 Another approach

lab7-3 Traffic Light Controller TL FF’s Comb. circuits Comb. circuits staten_state C TS l The block diagram HR HG HY FR FG FY ST ST_o

lab7-4 State transition diagram S0: HG S1: HY S2: FG S3: FY Reset TL + C S0 TLC/ST TS S1S3 S2 TS/ST TL + C/ST TS TL C

lab7-5 Verilog Description module traffic_light(HG, HY, HR, FG, FY, FR,ST_o, tl, ts, clk, reset, c) ; output HG, HY, HR, FG, FY, FR, ST_o; input tl, ts, clk, reset, c ; reg ST_o, ST ; reg[0:1] state, next_state ; parameter EVEN= 0, ODD=1 ; parameter S0= 2'b00, S1=2'b01, S2=2'b10, S3=2'b11; assign HG = (state == S0) ; assign HY = (state == S1) ; assign HR = ((state == S2)||(state == S3)) ; assign FG = (state == S2) ; assign FY = (state == S3) ; assign FR = ((state == S0)||(state == S1)) ;

lab7-6 // flip-flops (posedge clk or posedge reset) if(reset)// an asynchronous reset begin state = S0 ; ST_o = 0 ; end else begin state = next_state ; ST_o = ST ; end

lab7-7 (state or c or tl or ts) case(state)// state transition S0: if(tl & c) begin next_state = S1 ; ST = 1 ; end else begin next_state = S0 ; ST = 0 ; end Reset TL + C S0 TLC/ST TS S1S3 S2 TS/ST TL + C/ST TS TL C

lab7-8 S1: if (ts) begin next_state = S2 ; ST = 1 ; end else begin next_state = S1 ; ST = 0 ; end S2: if(tl | !c) begin next_state = S3 ; ST = 1 ; end else begin next_state = S2 ; ST = 0 ; end Reset TL + C S0 TLC/ST TS S1S3 S2 TS/ST TL + C/ST TS TL C

lab7-9 S3: if(ts) begin next_state = S0 ; ST = 1 ; end else begin next_state = S3 ; ST = 0 ; end endcase endmodule Reset TL + C S0 TLC/ST TS S1S3 S2 TS/ST TL + C/ST TS TL C

lab7-10

lab7-11 Counter Design ST –when active, clear and enable the counter TL/TS –terminal count –active to disable the counter ST options –latched or non-latched output Counter options –synchronous or asynchronous clear

lab7-12 Timer Design Timer/counter clk ST TL/TS TL/TS Sync. Clear Async. Clear

lab7-13 Non-latched Output Synchronous/asynchronous clear clk state TL C ST Sync. Clear (ST to TL) Async. Clear (ST to TL) S0 S1 S0

lab7-14 Latched Output Timing Diagram clk state TL/TS C ST_o Sync. Clear (ST to TL) Async. Clear (ST to TL) S0 S1S2 S0 S1

lab7-15 FSM Directive // synopsys state_vector state parameter [2:0] /* synopsys enum bus_states */ S0 = 3'b000, S1 = 3'b001, S2 = 3'b010, S3 = 3'b011, S4 = 3'b100, S5 = 3'b101; reg [2:0] /* synopsys enum bus_states */ state, next_state;

lab7-16 An Inefficient Use of Nested If (posedge CLK) begin if (RESET == 1’b1) begin if (ADDR_A == 2’b00) begin DEC_Q[5:4] <= ADDR_D; DEC_Q[3:2] <= 2’b01; DEC_Q[1:0] <= 2’b00; if (ADDR_B == 2’b01) begin DEC_Q[3:2] <= ADDR_A + 1’b1; DEC_Q[1:0] <= ADDR_B + 1’b1; if (ADDR_C == 2’b10)

lab7-17 begin DEC_Q[5:4] <= ADDR_D + 1’b1; if (ADDR_D == 2’b11) DEC_Q[5:4] <= 2’b00; end else DEC_Q[5:4] <= ADDR_D; end else DEC_Q[5:4] <= ADDR_D; DEC_Q[3:2] <= ADDR_A; DEC_Q[1:0] <= ADDR_B + 1’b1; end else DEC_Q <= 6’b000000; end

lab7-18 Nested If = priority-encoded logic –complex nested if => inefficient

lab7-19 (posedge CLK) begin if (RESET == 1’b1) begin casex (ADDR_ALL) 8’b : begin DEC_Q[5:4] <= 2’b00; DEC_Q[3:2] <= ADDR_A + 1; DEC_Q[1:0] <= ADDR_B + 1’b1; end 8’b000110xx: begin DEC_Q[5:4] <= ADDR_D + 1’b1; DEC_Q[3:2] <= ADDR_A + 1’b1; DEC_Q[1:0] <= ADDR_B + 1’b1; end

lab7-20 8’b0001xxxx: begin DEC_Q[5:4] <= ADDR_D; DEC_Q[3:2] <= ADDR_A + 1’b1; DEC_Q[1:0] <= ADDR_B + 1’b1; end 8’b00xxxxxx: begin DEC_Q[5:4] <= ADDR_D; DEC_Q[3:2] <= 2’b01; DEC_Q[1:0] <= 2’b00; end default: begin DEC_Q[5:4] <= ADDR_D; DEC_Q[3:2] <= ADDR_A; DEC_Q[1:0] <= ADDR_B + 1’b1; end endcase end else DEC_Q <= 6’b000000; end

lab7-21 Case statements creates balanced logic –reduces the delay by 3 ns

lab7-22 Case Statement - Avoid Inferred Latch Use a default assignment or add // synopsys full_case directive (bcd) begin case (bcd) // synopsys full_case 4’d0: begin out2=0; out1=0; out0=1; end 4’d1: begin out2=0; out1=1; out0=0; end 4’d0: begin out2=1; out1=0; out0=0; end endcase end

lab7-23 Case Statement - Avoid Priority Decoder To prevent priority decoder inferred, add // synopsys parallel_case directive (u or v or w or x or y or z) begin case (2’b11) // synopsys parallel_case u: decimal=10’b ; v: decimal=10’b ; w: decimal=10’b ; x: decimal=10’b ; y: decimal=10’b ; z: decimal=10’b ; default: decimal=10’b ; endcase end

lab7-24 Case Statement - Inferred Priority Decoder A priority decoder may be used (depending on the capability of the synthesis tool) (u or v or w or x or y or z) begin case (2’b11) u: decimal=10’b ; v: decimal=10’b ; w: decimal=10’b ; x: decimal=10’b ; y: decimal=10’b ; z: decimal=10’b ; default: decimal=10’b ; endcase end

lab7-25 Case Statement - Avoid Priority Decoder To prevent priority decoder inferred, add // synopsys parallel_case directive (u or v or w or x or y or z) begin case (2’b11) // synopsys parallel_case u: decimal=10’b ; v: decimal=10’b ; w: decimal=10’b ; x: decimal=10’b ; y: decimal=10’b ; z: decimal=10’b ; default: decimal=10’b ; endcase end