Counters and Registers. Dr. Anurag Srivastava

Similar documents
Digital Logic Design Sequential circuits

Module 3: Floyd, Digital Fundamental

Asynchronous Counters. Asynchronous Counters

Sequential Logic. (Materials taken from: Principles of Computer Hardware by Alan Clements )

Counters and Decoders

Chapter 2 Logic Gates and Introduction to Computer Architecture

Lecture 8: Synchronous Digital Systems

Experiment # 9. Clock generator circuits & Counters. Eng. Waleed Y. Mousa

Copyright Peter R. Rony All rights reserved.

CpE358/CS381. Switching Theory and Logical Design. Class 10

DIGITAL COUNTERS. Q B Q A = 00 initially. Q B Q A = 01 after the first clock pulse.

Decimal Number (base 10) Binary Number (base 2)

Counters are sequential circuits which "count" through a specific state sequence.

Registers & Counters

To design digital counter circuits using JK-Flip-Flop. To implement counter using 74LS193 IC.

Digital Logic Design. Basics Combinational Circuits Sequential Circuits. Pu-Jen Cheng

Upon completion of unit 1.1, students will be able to

Digital Electronics Detailed Outline

Contents COUNTER. Unit III- Counters

ETEC 2301 Programmable Logic Devices. Chapter 10 Counters. Shawnee State University Department of Industrial and Engineering Technologies

CHAPTER IX REGISTER BLOCKS COUNTERS, SHIFT, AND ROTATE REGISTERS

Logical Operations. Control Unit. Contents. Arithmetic Operations. Objectives. The Central Processing Unit: Arithmetic / Logic Unit.

The components. E3: Digital electronics. Goals:

Asynchronous counters, except for the first block, work independently from a system clock.

Having read this workbook you should be able to: recognise the arrangement of NAND gates used to form an S-R flip-flop.

RAM & ROM Based Digital Design. ECE 152A Winter 2012

Design Example: Counters. Design Example: Counters. 3-Bit Binary Counter. 3-Bit Binary Counter. Other useful counters:

Counters. Present State Next State A B A B

Computers. Hardware. The Central Processing Unit (CPU) CMPT 125: Lecture 1: Understanding the Computer

CHAPTER 2: HARDWARE BASICS: INSIDE THE BOX

Flip-Flops, Registers, Counters, and a Simple Processor

Combinational Logic Design Process

Memory Elements. Combinational logic cannot remember

Lecture 12: More on Registers, Multiplexers, Decoders, Comparators and Wot- Nots

Latches, the D Flip-Flop & Counter Design. ECE 152A Winter 2012

WEEK 8.1 Registers and Counters. ECE124 Digital Circuits and Systems Page 1

DIGITAL ELECTRONICS. Counters. By: Electrical Engineering Department

Chapter 4 System Unit Components. Discovering Computers Your Interactive Guide to the Digital World

Chapter 4 Register Transfer and Microoperations. Section 4.1 Register Transfer Language

Digital Electronics Part I Combinational and Sequential Logic. Dr. I. J. Wassell

MICROPROCESSOR AND MICROCOMPUTER BASICS

Discovering Computers Living in a Digital World

Chapter 5. Sequential Logic

Communicating with devices

CHAPTER 3 Boolean Algebra and Digital Logic

CS311 Lecture: Sequential Circuits

LAB #4 Sequential Logic, Latches, Flip-Flops, Shift Registers, and Counters

Computer Performance. Topic 3. Contents. Prerequisite knowledge Before studying this topic you should be able to:

Take-Home Exercise. z y x. Erik Jonsson School of Engineering and Computer Science. The University of Texas at Dallas

Chapter 6. Inside the System Unit. What You Will Learn... Computers Are Your Future. What You Will Learn... Describing Hardware Performance

1. True or False? A voltage level in the range 0 to 2 volts is interpreted as a binary 1.

Design: a mod-8 Counter

Gates, Circuits, and Boolean Algebra

BINARY CODED DECIMAL: B.C.D.

The Central Processing Unit:

DIGITAL TECHNICS II. Dr. Bálint Pődör. Óbuda University, Microelectronics and Technology Institute 5. LECTURE: REGISTERS AND RELATED

Let s put together a Manual Processor

Chapter 7. Registers & Register Transfers. J.J. Shann. J. J. Shann

Lecture-3 MEMORY: Development of Memory:

INTRODUCTION TO DIGITAL SYSTEMS. IMPLEMENTATION: MODULES (ICs) AND NETWORKS IMPLEMENTATION OF ALGORITHMS IN HARDWARE

what operations can it perform? how does it perform them? on what kind of data? where are instructions and data stored?

Counters & Shift Registers Chapter 8 of R.P Jain

CHAPTER 11: Flip Flops

A+ Guide to Managing and Maintaining Your PC, 7e. Chapter 1 Introducing Hardware

We r e going to play Final (exam) Jeopardy! "Answers:" "Questions:" - 1 -

MULTIPLE CHOICE FREE RESPONSE QUESTIONS

Lab 1: Study of Gates & Flip-flops

COMBINATIONAL and SEQUENTIAL LOGIC CIRCUITS Hardware implementation and software design

2.0 Chapter Overview. 2.1 Boolean Algebra

Lesson 12 Sequential Circuits: Flip-Flops

Machine Architecture and Number Systems. Major Computer Components. Schematic Diagram of a Computer. The CPU. The Bus. Main Memory.

Systems I: Computer Organization and Architecture

DEPARTMENT OF INFORMATION TECHNLOGY

Gray Code Generator and Decoder by Carsten Kristiansen Napier University. November 2004

ASYNCHRONOUS COUNTERS

Digital Systems Based on Principles and Applications of Electrical Engineering/Rizzoni (McGraw Hill

Digital circuits make up all computers and computer systems. The operation of digital circuits is based on

Modeling Registers and Counters

CSCA0102 IT & Business Applications. Foundation in Business Information Technology School of Engineering & Computing Sciences FTMS College Global

Engr354: Digital Logic Circuits

Cascaded Counters. Page 1 BYU

SECTION C [short essay] [Not to exceed 120 words, Answer any SIX questions. Each question carries FOUR marks] 6 x 4=24 marks

DIGITAL TECHNICS II. Dr. Bálint Pődör. Óbuda University, Microelectronics and Technology Institute. 2nd (Spring) term 2012/2013

CSE140 Homework #7 - Solution

MACHINE ARCHITECTURE & LANGUAGE

2 : BISTABLES. In this Chapter, you will find out about bistables which are the fundamental building blocks of electronic counting circuits.

Computer organization

Flip-Flops and Sequential Circuit Design. ECE 152A Winter 2012

Flip-Flops and Sequential Circuit Design

Modeling Sequential Elements with Verilog. Prof. Chien-Nan Liu TEL: ext: Sequential Circuit

Chapter 8. Sequential Circuits for Registers and Counters

CHAPTER 11 LATCHES AND FLIP-FLOPS

Lecture 2: Computer Hardware and Ports.

EXPERIMENT 8. Flip-Flops and Sequential Circuits

CHAPTER 4 MARIE: An Introduction to a Simple Computer

MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question.

A New Paradigm for Synchronous State Machine Design in Verilog

The 104 Duke_ACC Machine

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

Transcription:

Counters and Registers Dr. Anurag Srivastava 1

Basic of digital design Basic gates (AND,OR, NOR, NAND and INVERTER) Universal gates (NAND and NOR) Design of any function using basic gates F=xy+(xyz+zx+xz)xy Truth table verification K-map for solving a complex functions Difference between the Combinational circuits and Sequential Circuits 2

Combinational functional blocks Combinatorial Logic Circuit m Boolean Inputs n Boolean Outputs Block of sequential

Introducing counters Counters are a specific type of sequential circuit The state serves as the output (Moore) A counter that follows the binary number sequence is called a binary counter n-bit binary counter: n flip-flops, count in binary from 0 to 2ⁿ-1 Counters are available in two types: Synchronous Counters Ripple Counters Synchronous Counters: A common clock signal is connected to the C input of each flip-flop 4

Synchronous Binary Up Counter The output value increases by one on each clock cycle After the largest value, the output wraps around back to 0 Using two bits, we d get something like this: Present State Next State A B A B 0 0 0 1 0 1 1 0 1 0 1 1 1 1 0 0 00 01 11 10 5

Synchronous Binary Up Counter Present State Next State A B A B 0 0 0 1 0 1 1 0 1 0 1 1 1 1 0 0 D1= A B + AB D0= B A B clock 6

What good are counters? Counters can act as simple clocks to keep track of time You may need to record how many times something has happened How many bits have been sent or received? How many steps have been performed in some computation? All processors contain a program counter, or PC Programs consist of a list of instructions that are to be executed one after another (for the most part) The PC keeps track of the instruction currently being executed The PC increments once on each clock cycle, and the next program instruction is then executed. 7

Synch Binary Up/Down Counter 2-bit Up/Down counter Counter outputs will be 00, 01, 10 and 11 There is a single input, X. > X= 0, the counter counts up > X= 1, the counter counts down We ll need two flip-flops again. Here are the four possible states: 00 01 11 10 8

The complete state diagram and table Here s the complete state diagram and state table for this circuit 0 00 01 1 0 1 1 0 1 11 10 0 Present State Inputs Next State Q 1 Q 0 X Q 1 Q 0 0 0 0 0 1 0 0 1 1 1 0 1 0 1 0 0 1 1 0 0 1 0 0 1 1 1 0 1 0 1 1 1 0 0 0 1 1 1 1 0 9

D flip-flop inputs If we use D flip-flops, then the D inputs will just be the same as the desired next states Equations for the D flip-flop inputs are shown at the right Why does D 0 = Q 0 make sense? Present State Inputs Next State Q 1 Q 0 X Q 1 Q 0 0 0 0 0 1 0 0 1 1 1 0 1 0 1 0 0 1 1 0 0 1 0 0 1 1 1 0 1 0 1 1 1 0 0 0 1 1 1 1 0 Q 0 0 1 0 1 Q 1 1 0 1 0 X D 1 = Q 1 Q 0 X Q 0 1 1 0 0 Q 1 1 1 0 0 X D 0 = Q 0 10

Synchronous Binary Up/Down Counter X Q1 Q0 clock 11

An 8-bit counter As you might expect by now, we can use these general counters to build other counters Here is an 8-bit counter made from two 4-bit counters The bottom device represents the least significant four bits, while the top counter represents the most significant four bits When the bottom counter reaches 1111 (i.e., when CO = 0), it enables the top counter for one cycle Other implementation notes: The counters share clock and clear signals Hex displays are used here 12

Ripple Counter Simple, yet asynchronous circuits!!! 13

Summary Counters serve many purposes in sequential logic design There are lots of variations on the basic counter Some can increment or decrement An enable signal can be added The counter s value may be explicitly set There are also several ways to make counters You can follow the sequential design principles to build counters from scratch You could also modify or combine existing counter devices 14

Registers A common sequential device: Registers They re a good example of sequential analysis and design They are also frequently used in building larger sequential circuits Registers hold larger quantities of data than individual flip-flops Registers are central to the design of modern processors There are many different kinds of registers We ll show some applications of these special registers 15

What good are registers? Flip-flops are limited because they can store only one bit We had to use two flip-flops for our two-bit counter examples Most computers work with integers and single-precision floating-point numbers that are 32-bits long A register is an extension of a flip-flop that can store multiple bits Registers are commonly used as temporary storage in a processor They are faster and more convenient than main memory More registers can help speed up complex calculations 16

A basic register Basic registers are easy to build. We can store multiple bits just by putting a bunch of flip-flops together! A 4-bit register is given below This register uses D flip-flops, so it s easy to store data without worrying about flip-flop input equations All the flip-flops share a common CLK and CLR signal 17

74x175 4-bit register 18

Adding a parallel load operation The input D 3 -D 0 is copied to the output Q 3 -Q 0 on every clock cycle How can we store the current value for more than one cycle? Let s add a load input signal LD to the register If LD = 0, the register keeps its current contents If LD = 1, the register stores a new value, taken from inputs D 3 -D 0 LD Q(t+1) 0 Q(t) 1 D 3 -D 0 19

Register with parallel load When LD = 0, the flip-flop inputs are Q 3 -Q 0, so each flip-flop just keeps its current value When LD = 1, the flip-flop inputs are D 3 -D 0, and this new value is loaded into the register. 20

Shift Register A shift register shifts its output once every clock cycle. Q 0 (t+1) = SI Q 1 (t+1) = Q 0 (t) Q 2 (t+1) = Q 1 (t) Q 3 (t+1) = Q 2 (t) SI is an input that supplies a new bit to shift into the register For example, if on some positive clock edge we have: then the next state will be: SI = 1 Q 0 -Q 3 = 0110 Q 0 -Q 3 = 1011 The current Q 3 (0 in this example) will be lost on the next cycle 21

Shift direction Q 0 (t+1) = SI Q 1 (t+1) = Q 0 (t) Q 2 (t+1) = Q 1 (t) Q 3 (t+1) = Q 2 (t) The circuit and example make it look like the register shifts right. Present Q 0 -Q 3 SI Next Q 0 -Q 3 ABCD X XABC But it really depends on your interpretation of the bits. If you consider Q3 to be the most significant bit instead, then the register is shifting in the opposite direction! Present Q 3 -Q 0 SI Next Q 3 -Q 0 DCBA X CBAX 22

Shift register with parallel load We can add a parallel load, just like we did for regular registers When LD = 0, the flip-flop inputs will be SIQ 0 Q 1 Q 2, so the register shifts on the next positive clock edge When LD = 1, the flip-flop inputs are D 0 -D 3, and a new value is loaded into the shift register, on the next positive clock edge 23

Serial data transfer One application of shift registers is converting between serial data and parallel data Computers typically work with multiple-bit quantities ASCII text characters are 8 bits long Integers, single-precision floating-point numbers, and screen pixels are up to 32 bits long But sometimes it s necessary to send or receive data serially, or one bit at a time. Some examples include: Input devices such as keyboards and mice Output devices like printers Any serial port, USB or Firewire device transfers data serially Recent switch from Parallel ATA to Serial ATA in hard drives 24

Receiving serial data To receive serial data using a shift register: The serial device is connected to the register s SI input The shift register outputs Q3-Q0 are connected to the computer The serial device transmits one bit of data per clock cycle These bits go into the SI input of the shift register After four clock cycles, the shift register will hold a four-bit word The computer then reads all four bits at once from the Q3-Q0 outputs. serial device computer 25

Sending data serially To send data serially with a shift register, you do the opposite: The CPU is connected to the register s D inputs The shift output (Q3 in this case) is connected to the serial device The computer first stores a four-bit word in the register, in one cycle The serial device can then read the shift output One bit appears on Q3 on each clock cycle After four cycles, the entire four-bit word will have been sent computer serial device 26

Registers in Modern Hardware Registers store data in the CPU - Used to supply values to the ALU - Used to store the results If we can use registers, why bother with RAM? CPU GPR's Size L1 Cache L2 Cache Pentium 4 8 32 bits 8 KB 512 KB Athlon XP 8 32 bits 64 KB 512 KB Athlon 64 16 64 bits 64 KB 1024 KB Pow erpc 970 (G5) 32 64 bits 64 KB 512 KB Itanium 2 128 64 bits 16 KB 256 KB MIPS R14000 32 64 bits 32 KB 16 MB Answer: Registers are expensive! Registers occupy the most expensive space on a chip the core L1 and L2 are very fast RAM but not as fast as registers. 27

Registers summary A register is a special state machine that stores multiple bits of data Several variations are possible: Parallel loading to store data into the register Shifting the register contents either left or right Counters are considered a type of register too! One application of shift registers is converting between serial and parallel data Most programs need more storage space than registers provide We ll introduce RAM to address this problem Registers are a central part of modern processors 28