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.

Slides:



Advertisements
Similar presentations
Modulo-N Counters Module M10.4 Section 7.2.
Advertisements

Lecture 23: Registers and Counters (2)
Shift Registers Module M11.1 Section 7.3.
Registers and Counters
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.
//HDL Example 6-1 // //Behavioral description of //Universal shift register // Fig. 6-7 and Table 6-3 module shftreg.
Finite State Machine (FSM)  When the sequence of actions in your design depend on the state of sequential elements, a finite state machine (FSM) can be.
Latches and Flip-Flops Discussion D8.1 Section 13-9.
1 Sequential Circuits Dr. Pang. 2 Outline Introduction to sequential circuits Basic latch Gated SR latch and gated D latch D flip-flop, T flip-flop, JK.
CSE Spring Verilog for Sequential Systems - 1 Today: Verilog and Sequential Logic zFlip-flops yrepresentation of clocks - timing of state.
FSM examples.
A/D Converter Control Discussion D8.6 Rev. B – 3/14/2006.
Contemporary Logic Design Sequential Case Studies © R.H. Katz Transparency No Chapter #7: Sequential Logic Case Studies 7.1, 7.2 Counters.
A/D Converter Control Discussion D8.6. Analog-to-Digital Converters Converts analog signals to digital signals –8-bit: 0 – 255 –10-bit: 0 – 1023 –12-bit:
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.
ENGIN112 L27: Counters November 5, 2003 ENGIN 112 Intro to Electrical and Computer Engineering Lecture 27 Counters.
ENEE 408C Lab Capstone Project: Digital System Design Fall 2005 Sequential Circuit Design.
Chapter 7 - Part 2 1 CPEN Digital System Design Chapter 7 – Registers and Register Transfers Part 2 – Counters, Register Cells, Buses, & Serial Operations.
CS370 Counters. Overview °Counter: A register that goes through a prescribed series of states °Counters are important components in computers. °Counters.
ELEN 468 Advanced Logic Design
COE 202 Introduction to Verilog Computer Engineering Department College of Computer Sciences and Engineering King Fahd University of Petroleum and Minerals.
ECE 331 – Digital System Design Counters (Lecture #18)
Registers and Shift Registers Discussion D8.2. D Flip-Flop X 0 Q 0 ~Q 0 D CLK Q ~Q D gets latched to Q on the rising edge of the clock. Positive.
1 COMP541 State Machines – 2 Registers and Counters Montek Singh Feb 8, 2007.
KU College of Engineering Elec 204: Digital Systems Design
ECE 301 – Digital Electronics Counters (Lecture #16)
Dr. H.v.d.Biggelaar / Mar3-Ver2 / 1 Engineering Technology Dr. H.v.d.Biggelaar March 22, 2000 State Machines in VHDL.
Sequential Logic in Verilog
Figure 7.1. Control of an alarm system. Memory element Alarm Sensor Reset Set OnOff 
Counters By Taweesak Reungpeerakul
Lab7-1 Lab 6: FSM Description Separate combinational and memory circuits –State memory uses FFs –Others are combinational circuits.
ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGN Lecture 17 Dr. Shi Dept. of Electrical and Computer Engineering.
Digital Design Lectures 11 & 12 Shift Registers and Counters.
Chapter 1_4 Part III more on … Counters Chapter 1_4 Part III more on … Counters.
Slide 1 6. VHDL/Verilog Behavioral Description. Slide 2 Verilog for Synthesis: Behavioral description Instead of instantiating components, describe them.
Module : FSM Topic : types of FSM. Two types of FSM The instant of transition from the present to the next can be completely controlled by a clock; additionally,
Review of Digital Logic Design Concepts OR: What I Need to Know from Digital Logic Design (EEL3705)
Computer Organization & Programming Chapter 5 Synchronous Components.
Digital Logic Design.
MSI Counters Counter ICs Technician Series ©Paul Godin Updated Feb 2015 gmail.com.
Finite State Machine (FSM) Nattha Jindapetch December 2008.
Figure 7.6. Gated SR latch. (a) Circuit Q Q R S R S R Clk Q Q S Time (c) Timing diagram Clk ? ? SR xx Q(t) (no change) 0 1.
1 COMP541 State Machines – 2 Registers and Counters Montek Singh Feb 11, 2010.
Digital Electronics.
Counters.
ECE/CS 352 Digital System Fundamentals© T. Kaminski & C. Kime 1 ECE/CS 352 Digital Systems Fundamentals Fall 2000 Chapter 5 – Part 2 Tom Kaminski & Charles.
SYEN 3330 Digital SystemsJung H. Kim 1 SYEN 3330 Digital Systems Chapter 7 – Part 2.
© 2009 Pearson Education, Upper Saddle River, NJ All Rights ReservedFloyd, Digital Fundamentals, 10 th ed Digital Logic Design Dr. Oliver Faust.
CHAPTER 14 Digital Systems. Figure 14.1 RS flip-flop symbol and truth table Figure
EMT 351/4 DIGITAL IC DESIGN Verilog Behavioral Modeling  Finite State Machine -Moore & Mealy Machine -State Encoding Techniques.
Pusat Pengajian Kejuruteraan Mikroelektronik EMT 351/4 DIGITAL IC DESIGN Verilog Behavioural Modeling (Part 4) Week #
1 Lecture 3: Modeling Sequential Logic in Verilog HDL.
Figure 8.1. The general form of a sequential circuit.
Verilog Modules for Common Digital Functions
EMT 351/4 DIGITAL IC DESIGN Week # Synthesis of Sequential Logic 10.
HDL for Sequential Circuits
EKT 221 – Counters.
EKT 221 : Digital 2 COUNTERS.
Lecture Part A Combinational Logic Design & Flip Flop
SYNTHESIS OF SEQUENTIAL LOGIC
FSM MODELING MOORE FSM MELAY FSM. Introduction to DIGITAL CIRCUITS MODELING & VERIFICATION using VERILOG [Part-2]
6. Registers and Counters
Register-Transfer Level Components in Verilog
Switching Theory and Logic Design Chapter 5:
The Verilog Hardware Description Language
14 Digital Systems.
Presentation transcript:

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

lab5-2 張明峰 交大資工系 Vending Machine module machine (ti,fi,out,state,rst); output out; output [1:0] state; input ti,fi; input rst; reg [1:0] state,nextstate; reg t1,t2,f1,f2;

lab5-3 張明峰 交大資工系 Vending Machine BUFG g1 (.O(clk_hi),.I(clki)) ; BUFG g2 (.O(clk),.I(clk_sl)) ; (posedge clk_hi) cnt = cnt +1 ; assign clk_sl = (cnt >= 15’h4000) ; assign out = (state == 3); (posedge clk) begin t2 = t1 ; t1 = ti ; f2 = f1 ; f1 = fi ; end assign t = t1 & ~t2 ; assign f = f1 & ~f2 ;

lab5-4 張明峰 交大資工系 Vending Machine or f ) case(state) 0: begin if (f) nextstate = 1; else if (t) nextstate = 2; else nextstate =0; end 1: begin if (f) nextstate = 2; else if (t) nextstate = 3; else nextstate =1; end

lab5-5 張明峰 交大資工系 Vending Machine 2: begin if(f) nextstate = 3; else if(t) nextstate = 3; else nextstate =2; end 3: nextstate = 0; endcase endmodule

lab5-6 張明峰 交大資工系 Global Clock Buffers Clock Buffers are low-skew, high drive buffers –Also known as Global Buffers –Drive low-skew, high-speed long line resources –Drive all Flip-Flops and Latches in FPGA –Can also be used for high-fanout signals Instantiation: if the BUFG component is instantiated, software will select one of these buffers based on the design –BUFG u1 (.I(clki),.O(clk)) ;

lab5-7 張明峰 交大資工系 IOBs Organized As Independent Banks As many as eight banks on a device –Package dependent Each bank can be assigned any of the 16 signal standards XC2S50 PQ208 –GCK 0: pin 80 –GCK 1: pin 77 –GCK 2: pin 182 –GCK 3: pin 185

lab5-8 張明峰 交大資工系 4-bit binary counter w/ parallel load

lab5-9 張明峰 交大資工系 async count load' load c_en c_en A 0

lab5-10 張明峰 交大資工系

lab5-11 張明峰 交大資工系 Generate any count sequence: –E.g.: BCD counter  Counter w/ parallel load

lab5-12 張明峰 交大資工系 A synchronous 4-bit binary counter with an asynchronous Clear is used to make a Modulo 7 counter. Use the Clear feature to detect the count 7 and clear the count to 0. This gives a count of 0, 1, 2, 3, 4, 5, 6, 7(short)0, 1, 2, 3, 4, 5, 6, 7(short)0, etc. DON ’ T DO THIS! Referred to as a “ suicide ” counter! (Count “ 7 ” is “ killed, ” but the designer ’ s job may be dead as well!) Counting Modulo 7: Detect 7 and Asynchronously Clear Clock 0 D3 Q3 D2 Q2 D1 Q1 D0 Q0 CLEAR CP LOAD

lab5-13 張明峰 交大資工系 A synchronous 4-bit binary counter with a synchronous load and an asynchronous clear is used to make a Modulo 7 counter Use the Load feature to detect the count "6" and load in "zero". This gives a count of 0, 1, 2, 3, 4, 5, 6, 0, 1, 2, 3, 4, 5, 6, 0,... Using don ’ t cares for states above 0110, detection of 6 can be done with Load = Q4 Q2 Counting Modulo 7: Synchronously Load on Terminal Count of 6 D3 Q3 D2 Q2 D1 Q1 D0 Q0 CLEAR CP LOAD Clock Reset

lab5-14 張明峰 交大資工系 A synchronous, 4-bit binary counter with a synchronous Load is to be used to make a Modulo 6 counter. Use the Load feature to preset the count to 9 on Reset and detection of count 14. This gives a count of 9, 10, 11, 12, 13, 14, 9, 10, 11, 12, 13, 14, 9, … If the terminal count is 15 detection is usually built in as Carry Out (CO) Clock D3 Q3 D2 Q2 D1 Q1 D0 Q0 CLEAR CP LOAD Counting Modulo 6: Synchronously Preset 9 on Reset and Load 9 on Terminal Count 14 Reset 1

lab5-15 張明峰 交大資工系 BCD Counter Function table TC = 1, if Q== 9; otherwise, TC = 0 asyn_rstclk_enclkloadfunction 0XXXreset 1Xposedge1load 10posedge0hold 11posedge0count

lab5-16 張明峰 交大資工系 A two-digit BCD counter –two synchronous BCD counters –two 7-segment decoders