ECE/Comp Sci 352 Digital Systems Fundamentals. Charles R. Kime Section 2 Fall Logic and Computer Design Fundamentals

Similar documents
Appendix B. Review of Digital Logic. Baback Izadi Division of Engineering Programs

CHW 261: Logic Design

Introduction EE 224: INTRODUCTION TO DIGITAL CIRCUITS & COMPUTER DESIGN. Lecture 6: Sequential Logic 3 Registers & Counters 5/9/2010

LOGIC CIRCUITS. Basic Experiment and Design of Electronics

EECS150 - Digital Design Lecture 23 - FSMs & Counters

LOGIC CIRCUITS. Basic Experiment and Design of Electronics. Ho Kyung Kim, Ph.D.

EECS150 - Digital Design Lecture 18 - Counters

EECS150 - Digital Design Lecture 18 - Counters

COEN 312 DIGITAL SYSTEMS DESIGN - LECTURE NOTES Concordia University

EECS150 - Digital Design Lecture 17 - Sequential Circuits 3 (Counters)

EECS150 - Digital Design Lecture 11 - Shifters & Counters. Register Summary

Review: Designing with FSM. EECS Components and Design Techniques for Digital Systems. Lec09 Counters Outline.

Counters. We ll look at different kinds of counters and discuss how to build them

King Fahd University of Petroleum and Minerals College of Computer Science and Engineering Computer Engineering Department

Review: Designing with FSM. EECS Components and Design Techniques for Digital Systems. Lec 09 Counters Outline.

ELCT201: DIGITAL LOGIC DESIGN

Chapter 6. Synchronous Sequential Circuits

PGT104 Digital Electronics. PGT104 Digital Electronics

Digital Circuits ECS 371

Vidyalankar S.E. Sem. III [ETRX] Digital Circuits and Design Prelim Question Paper Solution

EECS150 - Digital Design Lecture 16 Counters. Announcements

10/12/2016. An FSM with No Inputs Moves from State to State. ECE 120: Introduction to Computing. Eventually, the States Form a Loop

6 Synchronous State Machine Design

Reg. No. Question Paper Code : B.E./B.Tech. DEGREE EXAMINATION, NOVEMBER/DECEMBER Second Semester. Computer Science and Engineering

COE 202: Digital Logic Design Sequential Circuits Part 4. Dr. Ahmad Almulhem ahmadsm AT kfupm Phone: Office:

L4: Sequential Building Blocks (Flip-flops, Latches and Registers)

Philadelphia University Student Name: Student Number:

Digital Fundamentals

Roger L. Tokheim. Chapter 8 Counters Glencoe/McGraw-Hill

Models for representing sequential circuits

ECE 341. Lecture # 3

Chapter #7: Sequential Logic Case Studies Contemporary Logic Design

EECS150 - Digital Design Lecture 25 Shifters and Counters. Recap

ELEC Digital Logic Circuits Fall 2014 Sequential Circuits (Chapter 6) Finite State Machines (Ch. 7-10)

Digital Fundamentals

L4: Sequential Building Blocks (Flip-flops, Latches and Registers)

Parity Checker Example. EECS150 - Digital Design Lecture 9 - Finite State Machines 1. Formal Design Process. Formal Design Process


EECS Components and Design Techniques for Digital Systems. FSMs 9/11/2007

Present Next state Output state w = 0 w = 1 z A A B 0 B A C 0 C A C 1

King Fahd University of Petroleum and Minerals College of Computer Science and Engineering Computer Engineering Department

Digital Electronics Final Examination. Part A

S.Y. Diploma : Sem. III [CO/CM/IF/CD/CW] Digital Techniques

ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGN. Week 9 Dr. Srinivas Shakkottai Dept. of Electrical and Computer Engineering

UNIVERSITY OF BOLTON SCHOOL OF ENGINEERING BENG (HONS) ELECTRICAL & ELECTRONICS ENGINEERING EXAMINATION SEMESTER /2017

Chapter 7. Sequential Circuits Registers, Counters, RAM

CS221: Digital Design. Dr. A. Sahu. Indian Institute of Technology Guwahati

MAHALAKSHMI ENGINEERING COLLEGE TIRUCHIRAPALLI

EET 310 Flip-Flops 11/17/2011 1

Chapter 2. Review of Digital Systems Design

Sequential Circuits Sequential circuits combinational circuits state gate delay

Sequential vs. Combinational

CSE370 HW6 Solutions (Winter 2010)

University of Toronto Faculty of Applied Science and Engineering Edward S. Rogers Sr. Department of Electrical and Computer Engineering

CSC 322: Computer Organization Lab

EE40 Lec 15. Logic Synthesis and Sequential Logic Circuits

Preparation of Examination Questions and Exercises: Solutions

Sample Test Paper - I

Design of Sequential Circuits

Lecture 10: Synchronous Sequential Circuits Design

Unit 7 Sequential Circuits (Flip Flop, Registers)

DE58/DC58 LOGIC DESIGN DEC 2014

Adders allow computers to add numbers 2-bit ripple-carry adder

Digital Electronics Circuits 2017

Show that the dual of the exclusive-or is equal to its compliment. 7

Synchronous Sequential Logic

CSE140: Components and Design Techniques for Digital Systems. Midterm Information. Instructor: Mohsen Imani. Sources: TSR, Katz, Boriello & Vahid

EE 209 Logic Cumulative Exam Name:

Problem Set 9 Solutions

Appendix A: Digital Logic. Principles of Computer Architecture. Principles of Computer Architecture by M. Murdocca and V. Heuring

Lecture 7: Logic design. Combinational logic circuits

ELE2120 Digital Circuits and Systems. Tutorial Note 9

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified) State any two Boolean laws. (Any 2 laws 1 mark each)

Sequential Logic Worksheet

Ch 7. Finite State Machines. VII - Finite State Machines Contemporary Logic Design 1

ELCT201: DIGITAL LOGIC DESIGN

Chapter 7 Sequential Logic

Lecture 9: Digital Electronics

University of Toronto Faculty of Applied Science and Engineering Edward S. Rogers Sr. Department of Electrical and Computer Engineering

MAHALAKSHMI ENGINEERING COLLEGE TIRUCHIRAPALLI

Digital Electronics Sequential Logic

S.Y. Diploma : Sem. III [DE/ED/EI/EJ/EN/ET/EV/EX/IC/IE/IS/IU/MU] Principles of Digital Techniques

EEE2135 Digital Logic Design

Example: vending machine

CDA 3200 Digital Systems. Instructor: Dr. Janusz Zalewski Developed by: Dr. Dahai Guo Spring 2012

UMBC. At the system level, DFT includes boundary scan and analog test bus. The DFT techniques discussed focus on improving testability of SAFs.

Laboratory Exercise #8 Introduction to Sequential Logic

Lab 3 Revisited. Zener diodes IAP 2008 Lecture 4 1

FSM model for sequential circuits

Digital Logic Design - Chapter 4

ALU, Latches and Flip-Flops

Digital Electronics. Part A

Digital Electronics II Mike Brookes Please pick up: Notes from the front desk

Stop Watch (System Controller Approach)

I. Motivation & Examples

Chapter 5 Synchronous Sequential Logic

EECS 270 Midterm 2 Exam Answer Key Winter 2017

CPE/EE 422/522. Chapter 1 - Review of Logic Design Fundamentals. Dr. Rhonda Kay Gaede UAH. 1.1 Combinational Logic

3. Complete the following table of equivalent values. Use binary numbers with a sign bit and 7 bits for the value

Q: Examine the relationship between X and the Next state. How would you describe this circuit? A: An inverter which is synched with a clock signal.

Transcription:

University of Wisconsin - Madison ECE/Comp Sci 352 Digital Systems Fundamentals Charles R. Kime Section 2 Fall 2001 Lecture 5 Registers & Counters Part 2 Charles Kime Counters Counters are sequential circuits which "count" through a specific state sequence. They can count up, count down, or count through other fixed sequences. Two distinct types are in common usage: Ripple Counters ƒ Clocks are connected to flip-flop outputs, thus not truly synchronous ƒ Outputs are "delayed" for higher bits. ƒ Resurgent because of low power consumption Synchronous Counters ƒ Clocks are directly connected to the flip-flops. ƒ Logic is used to implement the desired state sequencing. Chapter 5 Part 2 2 1

Counter asics: Divide by 2 Consider the following circuit: "1" T D ' Draw Waveform and Chapter 5 Part 2 3 Divide Clock Frequency by 2 The waveforms look like a new clock with twice the period of (half the frequency). The flip-flops are said to "divide-by-2" since the frequency of the output waveform is 1/2 the frequency of clock. "1" T D ' Chapter 5 Part 2 4 2

Ripple Counter What happens now? (note clock change on ) "1" T D ' Draw the waveform for. Chapter 5 Part 2 5 Ripple Counter (Continued) Here's what happens: Note that "divides" the frequency in by 2 -- or doubles the period. Notice the count ( ) base 10 of: 3 2 1 0 3 2 1 What kind of counter is this? Down Counter! "1" T D ' 1 0 1 0 1 1 1 0 0 1 Chapter 5 Part 2 6 3

Ripple Counter (Continued) Now consider this (what has changed?): "1" T D ' ' 1 0 1 0 1 Draw waveform. Chapter 5 Part 2 7 Ripple Counter (Continued) Here's what happens: Note that "divides" the frequency in by 2 -- or doubles the period. Notice the count ( ) base 10 of: "1" T D ' ' 0 1 2 3 0 1 What type of counter is this? Up Counter! 1 0 0 1 1 0 1 1 0 0 Can also use negative edgetriggering Chapter 5 Part 2 8 4

Ripple Counter (Continued) The circuits designed this way are called Ripple Counters because each edge sensitive transition (positive in the example's case) causes a change in the next flipflop's state. The changes "ripple" up the chain. That is, each transition occurs after a clock to output delay from the stage before. To see this effect in detail look at the following circuit: What is the detailed waveform behavior? "1" T T T C Chapter 5 Part 2 9 Ripple Counter (Continued) "1 " T T T C Here is the detailed waveform behavior: 1 0 1 0 1 What "counts" are shown? C 0 0 0 1 1 0 0 0 1 1 Chapter 5 Part 2 10 5

Ripple Counter (Continued) Starting with ==C = "1", equivalent to (C,,) = 7 base 10, the next count will increment the count to (,,C) = 0 base 10. Here's what happens in fine timing detail: TpHL The clock to output delay t PHL causes an increasing delay from TpHL clock edge for each stage transition. TpHL Thus, the count "ripples" from least to most significant bit. C For n bits, total worst case delay is n tphl. Chapter 5 Part 2 11 Synchronous Counters In order to eliminate the "ripple" effect, we will use a common clock for each flip-flop and a combinatorial circuit to generate the next state. One way to generate a counter is with an dder/register circuit: Here "CNT" is the count constant: 0000 is HOLD, 1111 is DOWN and 0001 is UP. Note potential logic simplification due to constant applied to. CNT SUM 4-it dder D3 D2 D1 D0 3 2 1 0 Chapter 5 Part 2 12 6

Synchronous Counters (Continued) simple 2-bit synchronous counter can be made with two "T" Flip-Flops: Note that the from the first stage enables the second stage to toggle. Does it count "up" or "down"? How do you extend this to three stages? "1" T T 1 0 1 0 1 0 0 0 1 1 Chapter 5 Part 2 13 Synchronous Counters (Continued) "1" T T T The concept can be extended to multiple stages. For binary "UP" counters, the upper stages toggle when LL of the lower stages are at the value "1" and the clock occurs. y "NDing" in a count enable signal to each "T" input, we can produce a "HOLD" count signal. Chapter 5 Part 2 14 7

Synchronous Counters Serial Gating ƒ When a two-input ND gate is used for each stage of the counter with a ripplelike carry, this is referred to as serial gating. ƒ s the size of the counter increases the delay through the combinational logic increases roughly in proportion to n, the number of stages. Chapter 5 Part 2 15 Synchronous Counters Parallel Gating ƒ When a multiple-input ( >2) ND gates are used for each stage of the counter with logic dedicated to each stage or to a group of stages, this is referred to as parallel gating. It resembles carry lookahead in an adder. ƒ s the size of the counter increases the delay through the combinational logic increases roughly in proportion to n/m, the number of stages/the group size. Chapter 5 Part 2 16 8

Design: Synchronous CD We can use the sequential logic model to design a synchronous CD counter with T flip-flops. elow is the State Table. Don't care states have been left out here. Current State 8 4 2 1 Next State 8 4 2 1 T-FF Excitation T8 T4 T2 T1 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 1 0 0 1 0 0 0 1 1 0 0 1 0 0 0 1 1 0 0 0 1 0 0 1 1 0 1 0 0 0 1 1 1 0 1 0 0 0 1 0 1 0 0 0 1 0 1 0 1 0 1 1 0 0 0 1 1 0 1 1 0 0 1 1 1 0 0 0 1 0 1 1 1 1 0 0 0 1 1 1 1 1 0 0 0 1 0 0 1 0 0 0 1 1 0 0 1 0 0 0 0 1 0 0 1 Chapter 5 Part 2 17 Synchronous CD (Continued) Use K-Maps to minimize the next state function: T8 8 T8 = 8 1 + 4 2 1 1 1 2 0 1 3 2 4 5 7 6 x x x x 12 13 15 14 x 1 x 8 9 11 10 4 T4 8 1 1 2 0 1 3 2 1 4 5 7 6 x x x x 12 13 15 14 x x 8 9 11 10 4 T4 = 2 1 T2 2 T1 2 T2 = 8' 1 T1 = "1" Note: Don't Cares are included here. 8 1 1 0 1 3 2 1 1 4 5 7 6 x x x x 12 13 15 14 x 1 x 8 9 11 10 4 8 1 1 1 1 0 1 3 2 1 1 1 1 4 5 7 6 x x x x 12 13 15 14 1 1 x 8 9 11 10 1 x 4 Chapter 5 Part 2 18 9

Synchronous CD (Continued) The minimized circuit: "1" T 1 T 2 8*1 2*1 T 4 4*2*1 T 8 8*1 Chapter 5 Part 2 19 Synchronous CD (Continued) What about the Don't Cares now?. LL Next States are now specified!! Current State 8 4 2 1 Next State 8 4 2 1 T-FF Excitation T8 T4 T2 T1 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 1 0 0 1 0 0 0 1 1 1 0 0 0 1 0 0 1 0 0 0 1 1 0 0 1 0 0 0 0 1 0 0 1 1 0 1 0???? 0 0 0 1 1 0 1 1???? 1 1 0 1 1 1 0 0???? 0 0 0 1 1 1 0 1???? 1 0 0 1 1 1 1 0???? 0 0 0 1 1 1 1 1???? 1 1 0 1 Chapter 5 Part 2 20 10

Synchronous CD (Continued) Don't care states have now been specified by the logic. Current State 8 4 2 1 Next State 8 4 2 1 T-FF Excitation T8 T4 T2 T1 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 1 0 0 1 0 0 0 1 1 1 0 0 0 1 0 0 1 0 0 0 1 1 0 0 1 0 0 0 0 1 0 0 1 1 0 1 0 1 0 1 1 0 0 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 1 0 0 1 1 0 1 0 0 0 1 1 1 0 1 0 1 0 0 1 0 0 1 1 1 1 0 1 1 1 1 0 0 0 1 1 1 1 1 0 0 1 0 1 1 0 1 Chapter 5 Part 2 21 Synchronous CD (Continued) What does the complete state diagram look like? 1 2 3 0 15 14 12 13 4 How does the sequential machine get into some of the states? 9 8 10 7 11 6 5 Chapter 5 Part 2 22 11

Counter with Parallel Load COUNT LOD In "T" Load and Count To Othe r Cells Common Logic asic Cell J K CLR CLER If we replace the T flip-flop with a JK flip-flop and some other logic, we can introduce a Hold function and a Parallel Load function. This basic cell replaces the T-FFs from before. Note that the "T" input can be used as a normal T-FF if LOD is low and COUNT is high. The clock,, and CLER lines are tied to all flip-flops. Chapter 5 Part 2 23 Counting Modulo N The Load feature can be used to preset the counter synchronously on command. The Clear feature can asynchronously reset the counter to zero. (This can lead to counts which are present only a very short time). y detecting a "terminal" count of N-1 in a Modulo-N count sequence, we can synchronously load in "zero" to start over. y detecting a "terminal" count of N in a Modulo-N count sequence, we can clear the count asynchronously to "zero" to start over. lternatively, we can detect the "all-ones" terminal count and use load to preset a count of the maximum count value minus (N-1). Chapter 5 Part 2 24 12

Counting Modulo 7 synchronous 4-bit binary counter with a synchronous load and an asynchronous clear is to be 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... etc. "0" "0" "0" "0" CLOCK "1" IN8 8 IN4 4 IN2 2 IN1 1 LOD CLER Chapter 5 Part 2 25 Counting Modulo 7, syn.clear synchronous 4-bit binary counter with a synchronous load and an asynchronous clear is to be used to make a Modulo 7 counter. Use the Clear feature to detect the count "7" and clear the count to "zero". 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. CLOCK "0" IN8 IN4 IN2 IN1 8 4 2 1 LOD CLER DON T DO THIS! Referred to as a suicide counter! Chapter 5 Part 2 26 13

Counting Modulo 7, Preset 9 synchronous, 4-bit binary counter with a "1" IN8 8 synchronous load and an "0" IN4 4 asynchronous clear is to be "0" IN2 2 used to make a Modulo 7 "1" IN1 1 counter. CLOCK Use the Load feature to LOD preset the count to "9" "1" CLER when you detect the count "15". This gives a count of 9, 10, 11, 12, 13, 14, 15, 9, 10, 11, 12, 13, 14, 15, 0,... etc. Sometimes the "Detect 15" is built in to the counter. Chapter 5 Part 2 27 Timing Sequences For digital systems, useful to generate a multi-phase sequence of timing signals to perform different functions at different intervals. There are many ways to do this. Here are a few that start with a clock and use a "counter" to divide the clock into separate phases. Counter/Decoder - connect the output of a counter to a decoder. Ring Counter - shift a single pulse down a chain of flip-flops connected as a shift register. For "N" phases, use "N" flip-flops. There can be "unwanted" states if not initialized properly. Johnson Counter - (Switch-Tail Ring) uses an "N" bit shift register and decoders to produce 2*N phases. There can be "unwanted" states if not initialized properly. Chapter 5 Part 2 28 14

Counter Decoder Example Here is one variant of a counterdecoder multi-phase clock generator: Note the "Glitches" due to the ripple count. synchronous counter would have been better than the ripple counter. Even with a synchronous counter, glitches are possible although reduced in duration. Method OK if glitches not a problem, for example, if signals are used as enables in a positive edge-triggered system. C3 C2 C1 C0 "1" Ripple Co unter 2 2 1 1 "GLITCH" C3 C2 C1 C0 Chapter 5 Part 2 29 Ring Counter ring counter is just a shift register with feedback. ssuming the initial state CD is 1000 we get the timing diagram shown: The state must be initialized to operate correctly. Use logic to assure this. Same circuit can be used with positive edgetriggering. C D D D IF CD = 1000 t Start: D C D D Chapter 5 Part 2 30 15

Johnson Counter (Switch-Tail) Johnson counter is also a shift register with feedback. ssuming the initial state C is 000 we get the timing diagram shown: The state must be initialized to operate correctly. Use logic to assure this. C C C D D IF CD = 000 t Start: D C C Chapter 5 Part 2 31 Verilog for Registers and Counters ƒ Register same as flip-flop except multiple bits: reg[3:0] ; input[3:0] D; always@(posedge CLK or posedge RESET) begin if (RESET) <= 4'b0000; else <= D; end ƒ Shift Register use concatenate: <= {[2:0], SI}; ƒ Counter use increment/decrement: count <= count + 1; or count <= count - 1 Chapter 5 Part 2 32 16

Verilog Description of Left Shift Register // 4-bit Shift Register with Reset // (See Figure 5-3) module srg_4_r_v (CLK, RESET, SI,,SO); input CLK, RESET, SI; output [3:0] ; output SO; reg [3:0] ; assign SO = [3]; always@(posedge CLK or posedge RESET) begin if (RESET) <= 4'b0000; else <= {[2:0], SI}; end endmodule Chapter 5 Part 2 33 Verilog Description of inary Counter // 4-bit inary Counter with Reset // (See Figure 5-10) module count_4_r_v (CLK, RESET, EN,, CO); input CLK, RESET, EN; output [3:0] ; output CO; always@(posedge CLK or posedge RESET) begin if (RESET) count <= 4'b0; else if (EN) count <= count + 1; end endmodule reg [3:0] count; assign = count; assign CO = (count == 4'b1111 && EN == 1'b1)? 1 : 0; Chapter 5 Part 2 34 17