1 Review: Counters and Registers CS 231 Review October 26, 2007 By Joshua Smith Please note the NOTES in the PPT file for help with the examples.

Slides:



Advertisements
Similar presentations
The CPU The Central Presentation Unit What is the CPU?
Advertisements

COUNTERS Counters with Inputs Kinds of Counters Asynchronous vs
Lecture 23: Registers and Counters (2)
Chapter 7 Henry Hexmoor Registers and RTL
ARITHMETIC LOGIC SHIFT UNIT
Charles Kime & Thomas Kaminski © 2004 Pearson Education, Inc. Terms of Use (Hyperlinks are active in View Show mode) Terms of Use Chapter 7 – Registers.
Digital Logic Chapter 5 Presented by Prof Tim Johnson
October 16, 2002Flip-flops1 Summary : Latches A sequential circuit has memory. It may respond differently to the same inputs, depending on its current.
Flip-Flops Last time, we saw how latches can be used as memory in a circuit. Latches introduce new problems: We need to know when to enable a latch. We.
Random access memory Sequential circuits all depend upon the presence of memory. A flip-flop can store one bit of information. A register can store a single.
Henry Hexmoor1 Chapter 7 Henry Hexmoor Registers and RTL.
Chapter 7 Henry Hexmoor Registers and RTL
The Control Unit: Sequencing the Processor Control Unit: –provides control signals that activate the various microoperations in the datapath the select.
Chapter 7. Register Transfer and Computer Operations
1 COMP541 Sequencing – III (Sequencing a Computer) Montek Singh April 9, 2007.
Registers and Counters
Shift Registers and Shift Register Counters
Logic and Computer Design Fundamentals Registers and Counters
Introduction Flip-flops are synchronous bistable devices. The term synchronous means the output changes state only when the clock input is triggered. That.
REGISTER A Register is a group of binary storage cells suitable for holding binary information. A group of flip-flops constitutes a register, since each.
Counters and Registers
Lecture 21 Overview Counters Sequential logic design.
A presentation on Counters
More Basics of CPU Design Lecture for CPSC 5155 Edward Bosworth, Ph.D. Computer Science Department Columbus State University.
Registers and 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.
1 Shift Registers. –Definitions –I/O Types: serial, parallel, combinations –Direction: left, right, bidirectional –Applications –VHDL implementations.
Last Mod: March 2014  Paul R. Godin Shift Registers Registers 1.1.
Registers CPE 49 RMUTI KOTAT.
Rabie A. Ramadan Lecture 3
CS1Q Computer Systems Lecture 11 Simon Gay. Lecture 11CS1Q Computer Systems - Simon Gay2 The D FlipFlop A 1-bit register is called a D flipflop. When.
1 Registers & Counters Logic and Digital System Design - CS 303 Erkay Savaş Sabancı University.
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.
Charles Kime & Thomas Kaminski © 2008 Pearson Education, Inc. (Hyperlinks are active in View Show mode) Chapter 7 – Registers and Register Transfers Part.
Sequential logic circuits
Instructor: Alexander Stoytchev CprE 281: Digital Logic.
Digital System Design using VHDL
Simple ALU How to perform this C language integer operation in the computer C=A+B; ? The arithmetic/logic unit (ALU) of a processor performs integer arithmetic.
DIGITAL SYSTEMS TCE Shift Registers and Shift Register Counters Week 10 and Week 11 (Lecture 2 of 2)
REGISTER TRANSFER LANGUAGE (RTL) INTRODUCTION TO REGISTER Registers1.
Control Unit Operation
REGISTER TRANSFER LANGUAGE (RTL)
Registers and Counters
Random access memory Sequential circuits all depend upon the presence of memory. A flip-flop can store one bit of information. A register can store a single.
Chap 7. Register Transfers and Datapaths
Random access memory Sequential circuits all depend upon the presence of memory. A flip-flop can store one bit of information. A register can store a single.
Counters Next, we’ll look at different kinds of counters and discuss how to build them. These are not only examples of sequential analysis and design,
Register Transfer and Microoperations
29th Oct Review Session 8.
The Processor and Machine Language
Datapaths For the rest of the semester, we’ll focus on computer architecture: how to assemble the combinational and sequential components we’ve studied.
CSC 220: Computer Organization
Overview Part 1 - Registers, Microoperations and Implementations
CSC 220: Computer Organization
Flip-Flops Last time, we saw how latches can be used as memory in a circuit. Latches introduce new problems: We need to know when to enable a latch. We.
Recall: ROM example Here are three functions, V2V1V0, implemented with an 8 x 3 ROM. Blue crosses (X) indicate connections between decoder outputs and.
Counters Next, we’ll look at different kinds of counters and discuss how to build them. These are not only examples of sequential analysis and design,
ECE 352 Digital System Fundamentals
Random access memory Sequential circuits all depend upon the presence of memory. A flip-flop can store one bit of information. A register can store a single.
Registers and Counters
EGR 2131 Unit 12 Synchronous Sequential Circuits
Counters Next, we’ll look at different kinds of counters and discuss how to build them. These are not only examples of sequential analysis and design,
Registers Today we’ll see some common sequential devices: counters and registers. They’re good examples of sequential analysis and design. They are also.
CHAPTER-3 REGISTER TRANSFER LANGUAGE AND MICROOPERATIONS
Week 11 Flip flop & Latches.
Instruction execution and ALU
Digital Electronics and Logic Design
Presentation transcript:

1 Review: Counters and Registers CS 231 Review October 26, 2007 By Joshua Smith Please note the NOTES in the PPT file for help with the examples

2 Announcements HW 7 – Due at 5:00pm on 10/29/2007 (Mon) – Contains one LogicWorks problem Midterm Exam 2 – Monday, November 5, 7-9pm – 1404 SC – ~10 days from today – Cover ALU through PLA ’ s HW 8 – Not due until November 12 – 1 week after Midterm 2

3 Agenda Counters Registers

4 Introducing counters Counters are a specific type of sequential circuit. The state, or the flip-flop values themselves, serves as the “output.” 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: We’ll soon look at some extensions to this basic idea

5 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.

6 Unused states The examples shown so far have all had 2 n states, and used n flip-flops. But sometimes you may have unused, leftover states. For example, here is a state table and diagram for a counter that repeatedly counts from 0 (000) to 5 (101). What should we put in the table for the two unused states?

7 Unused states can be don’t cares… To get the simplest possible circuit, you can fill in don’t cares for the next states. This will also result in don’t cares for the flip-flop inputs, which can simplify the hardware. If the circuit somehow ends up in one of the unused states (110 or 111), its behavior will depend on exactly what the don’t cares were filled in with

8 …or maybe you do care To get the safest possible circuit, you can explicitly fill in next states for the unused states 110 and 111. This guarantees that even if the circuit somehow enters an unused state, it will eventually end up in a valid state. This is called a self-starting counter

9 LogicWorks counters There are a couple of different counters available in LogicWorks. The simplest one, the Counter-4 Min, just increments once on each clock cycle. – This is a four-bit counter, with values ranging from 0000 to – The only “input” is the clock signal.

10 More complex counters More complex counters are also possible. The full-featured LogicWorks Counter-4 device below has several functions. – It can increment or decrement, by setting the UP input to 1 or 0. – You can immediately (asynchronously) clear the counter to 0000 by setting CLR = 1. – You can specify the counter’s next output by setting D 3 -D 0 to any four-bit value and clearing LD. – The active-low EN input enables or disables the counter. When the counter is disabled, it continues to output the same value without incrementing, decrementing, loading, or clearing. – The “counter out” CO is normally 1, but becomes 0 when the counter reaches its maximum value, 1111.

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 A restricted 4-bit counter We can also make a counter that “starts” at some value besides In the diagram below, when CO=0 the LD signal forces the next state to be loaded from D 3 -D 0. The result is this counter wraps from 1111 to 0110 (instead of 0000).

13 Another restricted counter We can also make a circuit that counts up to only 1100, instead of Here, when the counter value reaches 1100, the NAND gate forces the counter to load, so the next state becomes 0000.

14 Example Below is a Counter-4 from LogicWorks. The possible operations on every positive clock edge are summarized in the abbreviated table.

15 Example Also, the output CO is 0 only when the counter’s current state is 1111 and UP=1, or when the current state is 0000 and UP=0: CO = ( Q3Q2Q1Q0UP + Q3’Q2’Q1’Q0’UP’ )’

16 Example Show how you can add primitive gates only to make Q3Q2Q1Q0 count in the following repeating sequence. 7, 6, 5, 4, 3, 2, 1, 0, 8, 9, 10, 11, 12, 13, 14, 15, …

17 Example Show how you can add primitive gates only to make Q3Q2Q1Q0 count in the following repeating sequence. 7, 6, 5, 4, 3, 2, 1, 0, 8, 9, 10, 11, 12, 13, 14, 15, …

18 Example UP = Q3 LD = Q3’Q2’Q1’Q0’ + Q3Q2Q1Q0 D3 = Q3’ D2 = Q2 D1 = Q1 D0 = Q0

19 Example UP = Q3 LD = Q3’Q2’Q1’Q0’ + Q3Q2Q1Q0 = CO D3 = Q3’ D2 = Q2 D1 = Q1 D0 = Q0

20 Agenda Counters Registers

21 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. We’ll discuss RAM next time, and later we’ll also see how registers are used in designing and programming CPUs.

22 A better parallel load Another idea is to modify the flip-flop D inputs and not the clock signal. – 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.

23 A shift register “shifts” its output once every clock cycle. SI is an input that supplies a new bit to shift “into” the register. For example, if on some positive clock edge we have: SI = 1 Q 0 -Q 3 = 0110 then the next state will be: Q 0 -Q 3 = 1011 The current Q 3 (0 in this example) will be lost on the next cycle. Shift registers 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)

24 Shift direction The circuit and example make it look like the register shifts “right.” 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! 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)

25 Shift registers 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.

26 Shift registers in LogicWorks Here is a block symbol for the Shift Reg-4 from LogicWorks. The implementation is shown on the previous page, except the LD input here is active-low instead.

27 Other types of shift registers Logical shifts – Standard shifts like we just saw. In the absence of a SI input, 0 occupies the vacant position. – Left: > 1100 – Right: > 0011 Circular shifts (also called ring counters or rotates) – The shifted out bit wraps around to the vacant position. – Left: > 0011 – Right: > 1100 Switch-tail ring counter (aka Johnson counter) – Similar to the ring counter, but the serial input is the complement of the serial output. – Left: > 0010 – Right: > 0100 Arithmetical shifts – Left shifting is the same as a logical shift. Right shifting however maintains the MSB. – Left: > 1100 – Right: > 0011; > 1101

28 Arithmetic Shift Left Shift

29 Arithmetic Shift Right Shift