COUNTERS Counters with Inputs Kinds of Counters Asynchronous vs

Slides:



Advertisements
Similar presentations
Lecture 23: Registers and Counters (2)
Advertisements

CSE 205: Digital Logic Design
State-machine structure (Mealy)
Registers and Counters
A. Abhari CPS2131 Sequential Circuits Most digital systems like digital watches, digital phones, digital computers, digital traffic light controllers and.
Digital Logic Chapter 5 Presented by Prof Tim Johnson
Multiplexors Sequential Circuits and Finite State Machines Prof. Sin-Min Lee Department of Computer Science.
Chapter 7 Henry Hexmoor Registers and RTL
Homework Reading Machine Projects Labs Tokheim Chapter 9.1 – 9.6
Contemporary Logic Design Sequential Case Studies © R.H. Katz Transparency No Chapter #7: Sequential Logic Case Studies 7.1, 7.2 Counters.
Logic and Computer Design Fundamentals Registers and Counters
ENGIN112 L27: Counters November 5, 2003 ENGIN 112 Intro to Electrical and Computer Engineering Lecture 27 Counters.
CS370 Counters. Overview °Counter: A register that goes through a prescribed series of states °Counters are important components in computers. °Counters.
ECE C03 Lecture 91 Lecture 9 Registers, Counters and Shifters Hai Zhou ECE 303 Advanced Digital Design Spring 2002.
Asynchronous and Synchronous Counters
Sequential Circuit Introduction to Counter
Registers and Counters
Lecture 21 Overview Counters Sequential logic design.
CHAPTER 3 Counters.  One of the common requirement in digital circuits/system is counting, both direction (forward and backward)  Digital clocks and.
A presentation on Counters
Chapter 1_4 Part II Counters
1 Sequential Circuits Registers and Counters. 2 Master Slave Flip Flops.
EE345: Introduction to Microcontrollers Register and Counters Prof. Ahmad Abu-El-Haija.
Lecture 27 Counters Give qualifications of instructors: DAP
Sequential Circuits Chapter 4 S. Dandamudi To be used with S. Dandamudi, “Fundamentals of Computer Organization and Design,” Springer,  S.
ECE2030 Introduction to Computer Engineering Lecture 15: Registers, Toggle Cells, Counters Prof. Hsien-Hsin Sean Lee School of Electrical and Computer.
Registers and Counters
Rabie A. Ramadan Lecture 3
© 2009 Pearson Education, Upper Saddle River, NJ All Rights ReservedFloyd, Digital Fundamentals, 10 th ed Digital Fundamentals Tenth Edition Floyd.
2017/4/24 CHAPTER 6 Counters Chapter 5 (Sections )
Counters By Taweesak Reungpeerakul
ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGN Lecture 17 Dr. Shi Dept. of Electrical and Computer Engineering.
Counters. November 5, 2003 Introduction: Counters  Counters are circuits that cycle through a specified number of states.  Two types of counters: 
CHAPTER 3 Counters.  One of the common requirement in digital circuits/system is counting, both direction (forward and backward)  Digital clocks and.
ENG241 Digital Design Week #8 Registers and Counters.
Registers and Counters Chapter 6. Digital Circuits 2 Clocked sequential circuits a group of flip-flops and combinational gates connected to form a feedback.
© 2009 Pearson Education, Upper Saddle River, NJ All Rights ReservedFloyd, Digital Fundamentals, 10 th ed Digital Fundamentals Tenth Edition Floyd.
Chapter 1_4 Part III more on … Counters Chapter 1_4 Part III more on … Counters.
Introduction to State Machine
© BYU 13 COUNTERS Page 1 ECEn 224 COUNTERS Counters Transition Tables Moore Outputs Counter Timing.
Analysis and Synthesis of Synchronous Sequential Circuits A “synchronizing” pulse/edge signal (clock) controls the operation of the memory portion of the.
Counters and Registers Synchronous Counters. 7-7 Synchronous Down and Up/Down Counters  In the previous lecture, we’ve learned how synchronous counters.
Counters.
Counters Transition Tables Moore Outputs Counter Timing
Synchronous Counter Design
1 Registers A register is a group of n flip-flops each of them capable of storing one bit of information There are two types of registers: parallel and.
1 Homework Reading –Tokheim Chapter 9.1 – 9.6 Machine Projects –Continue on mp3 Labs –Continue in labs with your assigned section.
Sequential logic circuits First Class 1Dr. AMMAR ABDUL-HAMED KHADER.
FLIP FLOPS Binary unit capable of storing one bit – 0 or 1
Homework Reading Machine Projects Labs Tokheim Chapter 9.1 – 9.6
Registers and Counters
EKT 124 / 3 DIGITAL ELEKTRONIC 1
EKT 221 – Counters.
Prof. Hsien-Hsin Sean Lee
EKT 221 : Digital 2 COUNTERS.
Sequential Logic Counters and Registers
FIGURE 5.1 Block diagram of sequential circuit
Sequential Circuits Most digital systems like digital watches, digital phones, digital computers, digital traffic light controllers and so on require.
Sequential Circuit - Counter -
ECE Digital logic Lecture 16: Synchronous Sequential Logic
Digital Fundamentals with PLD Programming Floyd Chapter 10
Registers and Counters Register : A Group of Flip-Flops. N-Bit Register has N flip-flops. Each flip-flop stores 1-Bit Information. So N-Bit Register Stores.
29-Nov-18 Counters Chapter 5 (Sections ).
CSE 370 – Winter Sequential Logic-2 - 1
Registers and Counters
CSE 370 – Winter Sequential Logic-2 - 1
EET107/3 DIGITAL ELECTRONICS 1
Chapter 8 Counters Changjiang Zhang
14 Digital Systems.
Digital Electronics and Logic Design
Presentation transcript:

COUNTERS Counters with Inputs Kinds of Counters Asynchronous vs COUNTERS Counters with Inputs Kinds of Counters Asynchronous vs. Synchronous Counters Cascaded Counters

General Sequential Systems D Q Current State State Memory Input Forming Logic Next State

Lecture Notes - SE 141: Digital Circuits and Systems Counters Counters are registers that go through a predefined sequence of states when inputs are applied Many counters follow the binary number sequence For example, a 3-bit binary ripple counter goes through the following state transitions when the clock is asserted: 000 → 001 → 010 → 011 → 100 → 101 → 110 → 111 → 000 … Counters are said to overflow when their sequence is complete Overflow causes counters to repeat a sequence of values over time April-10-17 Lecture Notes - SE 141: Digital Circuits and Systems

Lecture Notes - SE 141: Digital Circuits and Systems Types of Counters Two types of counters exist: Synchronous Counters Ripple Counters Synchronous counters are triggered by a common clock Ripple counters use flip-flop output transitions to serve as the trigger source for other flip-flops For example, a 1 to 0 transition on flip-flopi triggers a toggling transition on flip-flopi + 1 Ripple counters are not triggered by a common clock April-10-17 Lecture Notes - SE 141: Digital Circuits and Systems

Synchronous Counters In a synchronous counter, all flip flops are clocked by the same clock signal They all change at the same time Synchronous counters can be cascaded to create larger counters that are also globally synchronous

Transition Table for 2-Bit Counter It is the truth table for the input forming logic… It describes what the next state values are as a function of the current state (clock is assumed)

Implementation of 2-Bit Counter Q0 Q1 D Q CLK N1 N0 N0 = Q0’ N1 =Q1  Q0

Example 2 – A Gray Code Counter Q1 D Q Q0 CLK N1 N0 N1= Q0 N0 = Q1’

Example 3 – Not All Count Values Used Desired count sequence = 00 – 01 – 11 - 00 … What should next state for 10 be?

Example 3 – Not All Count Values Used N1 = Q0•Q1’ N0 = Q0’ Do the normal K-map minimization with don’t cares

Counters With Alternative FF’s Current State State Memory Input Forming Logic T Inputs T Q

Counter Design Procedure Introduction The process is a special case of the general sequential circuit design procedure. no decisions on state assignment or transitions current state is the output Example: 3-bit Binary Upcounter Decide to implement with Toggle Flipflops What inputs must be presented to the T FFs to get them to change to the desired state bit? We need to use the T FF excitation table to translate the present/next state values to FF inputs Present state Next state 1 1 1 1 1 1 55:032 - Introduction to Digital Design

TFF Counter Design Using Augmented Transition Table Next state values Inputs to apply to achieve desired next state

TFF Counter Design Using Augmented Transition Table Q2 Q1Q0 1 00 01 11 10 T2 = Q1•Q0 T1 = Q0 T0 = ‘1’ Next state values Inputs to apply to achieve desired next state

TFF Counter Design T Q Q2 CLK T Q Q1 CLK ‘1’ T Q Q0 CLK

4-Bit Synchronous Binary Counter NOTE: This is a well-designed circuit. It can operate at high clock frequencies. The maximum clock frequency can be easily calculated. For high-speed digital design, synchronous binary counters are preferred. April-10-17 Lecture Notes - SE 141: Digital Circuits and Systems

JKFF Gray Code Counter Design Next state values Inputs to apply to achieve desired next state

JKFF Gray Code Counter Design J2 = Q1•Q0’ K2 = Q1’•Q0’ J1 = Q2’•Q0 K1 = Q2•Q0 J0 = Q2•Q1 + Q2’•Q1’ = K0’ K0 = Q2’•Q1 + Q2•Q1’ = Q2  Q1 Next state values Inputs to apply to achieve desired next state

Outputs = f (CurrentState) Counters With Outputs Outputs D Q Current State Input Forming Logic Next State State Memory Output Forming Logic Outputs = f (CurrentState)

Counters With Outputs Z=1 when count={0,3,6} Z is called a Moore or static output. It is a function only of the current state.

Combined Transition Table Current state Next state Output Z = Q2’•Q1’•Q0’ + Q2’•Q1•Q0 + Q2•Q1•Q0’ (implement OFL with gates)

Counter With A Moore Output D Q N2 Q2 CLK N1 D Q Q1 Z CLK N0 D Q Q0 IFL OFL CLK

An Incrementable Counter Current State State Memory Next State Input Forming Logic Inputs D Q D Q Note that the next state is a function of the input ‘INC’ as well as the current state.

Incrementable Counter Derivation Doing the KMaps for this results in: INC Q1Q0 1 00 01 11 10 INC Q1Q0 1 00 01 11 10 N1 N0 N1 = INC•Q1’•Q0 + INC’•Q1 + Q1•Q0’ N0 = INC’•Q0 + INC•Q0’ = INC Q0

Incrementable Counter Behavior CLK INC Current State 00 01 10 The counter increments on the clock edge only when INC is asserted

Counters With More Inputs CLR = INC = 0 No state transition CLR = 0 INC = 1 Counter Increments CLR = 1 INC = 0 Counter resets to ‘00’ CLR = 1 INC = 1 What should it do?

Counters With More Inputs CLR = INC = 0 No state transition CLR = 0 INC = 1 Counter Increments CLR = 1 INC = 0 Counter resets to ‘00’ CLR = 1 INC = 1 What should it do?

Precedence of INC vs. CLR? Could do nothing Could give INC precedence Could give CLR precedence Assume INC=CLR=1 will never occur You decide when you draw the transition table!

Case 1 – Do Nothing N1 N0 N1 = CLR’•INC•Q1’•Q0 + CLR’•INC’•Q1 + 00 01 11 10 1 Clr Inc Q1Q0 00 01 11 10 1 N1 N0 N1 = CLR’•INC•Q1’•Q0 + CLR’•INC’•Q1 + CLR•INC•Q1 + INC•Q1•Q0’ N0 = CLR’•INC’•Q0 + CLR•INC•Q0 + CLR’•INC•Q0’

Case 2 – Give INC Precedence Clr Inc Q1Q0 00 01 11 10 1 Clr Inc Q1Q0 00 01 11 10 1 N1 N0 N1 = INC•Q1’•Q0 + CLR’•INC’•Q1 + INC•Q1•Q0’ N0 = CLR’•INC’•Q0 + INC•Q0’

Case 3 – Give CLR Precedence Clr Inc Q1Q0 00 01 11 10 1 Clr Inc Q1Q0 00 01 11 10 1 N1 N0 N1 = CLR’•INC•Q1’•Q0 + CLR’•INC’•Q1 + CLR’•Q1•Q0’ N0 = CLR’•INC’•Q0 + CLR’•INC•Q0’

Case 4 – Assume INC=CLR=1 Will Never Occur Clr Inc Q1Q0 00 01 11 10 X 1 Clr Inc Q1Q0 00 01 11 10 1 X N1 N0 N1 = CLR’•INC’•Q1 + INC•Q1’•Q0 + CLR’•Q1•Q0’ N0 = CLR’•INC’•Q0 + INC•Q0’ What happens in the real circuit when INC=CLR=1? It depends on the final equations…

4-Bit Up-Down Binary Counter NOTE: The Up control signal has priority. If Up is asserted, the Down signal will not pass through the AND gate. April-10-17 Lecture Notes - SE 141: Digital Circuits and Systems

4-Bit Binary Counter with Parallel Load April-10-17 Lecture Notes - SE 141: Digital Circuits and Systems

55:032 - Introduction to Digital Design A common 4-bit counter Synchronous Load and Clear Inputs Positive Edge Triggered FFs Parallel Load Data from D, C, B, A P, T Enable Inputs: both must be asserted to enable counting RCO: asserted when counter enters its highest state 1111, used for cascading counters "Ripple Carry Output" 74163 Synchronous 4-Bit Upcounter 74161: similar in function, asynchronous load and reset 55:032 - Introduction to Digital Design

55:032 - Introduction to Digital Design 74163 Detailed Timing Diagram 55:032 - Introduction to Digital Design

Self-Starting Counters Start-Up States At power-up, counter may be in any possible state Designer must guarantee that it (eventually) enters a valid state Especially a problem for counters that validly use a subset of states Self-Starting Solution: Design counter so that even the invalid states eventually transition to valid state S6 S5 S0 S4 S0 S4 S1 S3 S1 S3 S2 S2 S5 S7 S6 S7 Two Self-Starting State Transition Diagrams 55:032 - Introduction to Digital Design

55:032 - Introduction to Digital Design Twisted Ring (Johnson, Mobius) Counter Inverted End-Around J CLK K S R Q +V 1 Shift 2 3 4 \Reset 8 possible states, single bit change per state, useful for avoiding glitches +V 55:032 - Introduction to Digital Design

55:032 - Introduction to Digital Design Ring Counter +V +V +V End-Around 1 \Reset 4 possible states, single bit change per state, useful for avoiding glitches Must be initialized S Q 1 S Q 2 S Q 3 S Q 4 J Q J Q J Q J Q CLK CLK CLK CLK K Q K Q K Q K Q R R R R Shift V+ 1 Shift Q1 Q2 Q3 Q4 100 55:032 - Introduction to Digital Design

Lecture Notes - SE 141: Digital Circuits and Systems Binary Ripple Counter Consider the following binary sequence: 000 001 010 011 100 101 110 111 Indicates a toggling of the 2nd least significant bit Indicates a toggling of the most significant bit April-10-17 Lecture Notes - SE 141: Digital Circuits and Systems

4-Bit Binary Ripple Counter April-10-17 Lecture Notes - SE 141: Digital Circuits and Systems

Lecture Notes - SE 141: Digital Circuits and Systems BCD Ripple Counter It is possible to build counters that go through any fixed sequence of binary numbers For example, a BCD ripple counter can be specified by the following state diagram: April-10-17 Lecture Notes - SE 141: Digital Circuits and Systems

4-Bit BCD Ripple Counter April-10-17 Lecture Notes - SE 141: Digital Circuits and Systems

Lecture Notes - SE 141: Digital Circuits and Systems 12-Bit BCD Counter April-10-17 Lecture Notes - SE 141: Digital Circuits and Systems

Mod-N Counters Generally we are interested in counters that count up to specific count values Not just powers of 2 A mod-N counter has N states Counts from 0 to N-1 then rolls over Requires flip flops For example… A 4-bit binary counter is a mod-16 counter A counter that counts from 0-9 is a mod-10 counter

A Mod-4 Counter A.K.A. 2-bit counter CLR’•INC’ CLR 00 CLR’•INC CLR’•INC CLR’•INC’ CLR’•INC’ 11 01 CLR’•INC CLR’•INC 10 CLR’•INC’

A Mod-4 Counter With Rollover Signal CLR’•INC’ Mealy output CLR 00 CLR’•INC / RO CLR’•INC CLR’•INC’ CLR’•INC’ 11 01 CLR’•INC CLR’•INC The ROLL signal is used to tell other circuitry that the counter is rolling over to all 0’s. 10 CLR’•INC’

We could make a mod-4 counter from the block shown in red. Value D Q clr Terminal Count IFL clk D Q clk inc Roll Over We could make a mod-4 counter from the block shown in red.

Cascaded Counters MOD4 MOD4 MOD4 digit0[1:0] digit1[1:0] digit2[1:0] clk clr clr clr clr CV CV CV MOD4 MOD4 MOD4 TC TC TC inc inc inc inc

Cascaded Counters MOD4 MOD4 MOD4 digit0[1:0] digit1[1:0] digit2[1:0] clk clr clr clr clr CV CV CV Count Value MOD4 MOD4 MOD4 TC TC TC Terminal Count inc inc inc inc Rollover

Assume that the second timer is already at the terminal count. Cascaded Counters digit0[1:0] digit1[1:0] digit2[1:0] clk clr clr clr clr CV CV CV MOD4 MOD4 MOD4 TC TC TC inc inc inc inc Assume that the second timer is already at the terminal count.

Cascaded Counters MOD4 MOD4 MOD4 digit0[1:0] digit1[1:0] digit2[1:0] clk clr clr clr clr CV CV CV MOD4 MOD4 MOD4 TC TC TC inc inc inc inc

Cascaded Counters MOD4 MOD4 MOD4 digit0[1:0] digit1[1:0] digit2[1:0] clk clr clr clr clr CV CV CV MOD4 MOD4 MOD4 TC TC TC inc inc inc inc

Cascaded Counters MOD4 MOD4 MOD4 digit0[1:0] digit1[1:0] digit2[1:0] clk clr clr clr clr CV CV CV MOD4 MOD4 MOD4 TC TC TC inc inc inc inc

Cascaded Counters MOD4 MOD4 MOD4 digit0[1:0] digit1[1:0] digit2[1:0] clk clr clr clr clr CV CV CV MOD4 MOD4 MOD4 TC TC TC inc inc inc inc

Cascaded Counters MOD4 MOD4 MOD4 digit0[1:0] digit1[1:0] digit2[1:0] clk clr clr clr clr CV CV CV MOD4 MOD4 MOD4 TC TC TC inc inc inc inc

Cascaded Counters MOD4 MOD4 MOD4 digit0[1:0] digit1[1:0] digit2[1:0] clk clr clr clr clr CV CV CV MOD4 MOD4 MOD4 TC TC TC inc inc inc inc It looks like the inc signal ripples from counter to counter. How is this different from the ripple counter examples?

A Mod-4 Counter With consolidated rollover logic Value D Q clr Terminal Count IFL clk D Q clk Roll Over inc A good mod-4 counter includes the logic within the red block.

A Mod-4 Counter inc dout MOD4 clk roll clr

Cascading two Mod-4 Counters Count Sequence: digit1 digit0 Increment higher digit’s counter when lower digit’s counter is rolling over 00 01 02 03 10 11 12 13 20 21 22 23 30 31 32 33 00 … digit1 digit0 clk clk 2 2 MOD4 dout clr MOD4 dout clr clr clr roll0 inc roll1 roll inc roll inc

Three-digit Mod-4 Counter Can combine any counters that have a rollover signal to make larger counters Combine two 16-bit counters to make a 32-bit counter Combine three mod-4 counters to make a three-digit mod-4 counter digit2 digit1 digit0 clk clk clk 2 2 2 MOD4 dout clr MOD4 dout clr MOD4 dout clr clr clr clr roll1 roll1 roll0 inc roll inc roll inc roll inc

BCD Counter Combine to create non-binary counters BCD counter MOD10 digit2 digit1 digit0 clk clk clk 4 4 4 MOD10 dout clr MOD10 dout clr MOD10 dout clr clr clr clr roll1 roll1 roll0 inc roll inc roll inc roll inc

D Flip Flop with Asynchronous Clear and Clock Enable (a.k.a. Load) Clear (a.k.a. Reset)

Mod-4 Counter D0 CLK CEO CE CE D1

Cascaded Synchronous Counter Digit0 Digit1 CEO CLK Reset Digit0 CEO Digit1

Hybrid Counters Can combine different kinds of mod counters Combine an 8-bit counter with a 16-bit counter to create a 24-bit counter Combine mod-24 and mod-60 counters to create a digital H:M:S clock Hours Minutes Seconds clk clk clk 5 6 6 MOD24 dout clr MOD60 dout clr MOD60 dout clr clr clr clr day hour min sec roll inc roll inc roll inc