chapter 6 registers and counters - national tsing hua...

17
Department of Computer Science National Tsing Hua University Chih-Tsun Huang (黃稚存) http://nthucad.cs.nthu.edu.tw/~cthuang/ Chapter 6 Registers and Counters Outline Registers Shift Registers Counters Ripple Counters Synchronous Counters Other Counters Fall 2010 CS2102 Chih-Tsun Huang 2

Upload: trantuyen

Post on 26-Jul-2018

245 views

Category:

Documents


0 download

TRANSCRIPT

Department of Computer ScienceNational Tsing Hua University

Chih-Tsun Huang (黃稚存)http://nthucad.cs.nthu.edu.tw/~cthuang/

Chapter 6Registers and Counters

Outline

Registers Shift Registers

Counters Ripple Counters

Synchronous Counters

Other Counters

Fall 2010 CS2102 Chih-Tsun Huang 2

Introduction

Registers A group of binary cells (FFs) suitable for holding

binary data information In addition to the FFs, a register may have

combinational gates to control when and how the new information is transferred into the register

Counters A register that goes through a predetermined

sequence of states upon the application of input pulses

The gates in a counter are connected in such a way as to produce a predefined sequence of binary states in the register

Fall 2010 CS2102 Chih-Tsun Huang 3

Registers (1/2) A register can be viewed as a bitwise extension of a FF

The simplest of the storage components: n inputs, n outputs, and a clock signal

All the n FFs are driven by the common clock signal

Fall 2010 CS2102 Chih-Tsun Huang 4

Registers (2/2) The register may be enhanced by asynchronous Preset

and Clear (Reset) signals, which are not controlled by the clock signal

Fall 2010 CS2102 Chih-Tsun Huang 5

Registers with Parallel Load (1/2) 4-bit register

with parallel load

Fall 2010 CS2102 Chih-Tsun Huang 6

Registers with Parallel Load (1/2) To control when the data will be entered into a

register, and for how long it will be stored before being sent to the output

Fall 2010 CS2102 Chih-Tsun Huang 7

Shift Registers

A shift register can shift its stored data right and/or left.

Fall 2010 CS2102 Chih-Tsun Huang 8

Serial Transfer Serial transfer vs. parallel transfer

Fall 2010 CS2102 Chih-Tsun Huang 9

All bits at the same time

Serial Adder Using D Flip-Flops Initially, augend is in register

A and addend is in register B

Shift control enables the triggering of clock and 1-bit addition of two operands from LSB to MSB.

A new sum (S) bit is transferred to shift register A

A carry-out (C) of the FA is transferred to Q as the z input of the next addition

Finally, when the shift control is disabled, summation result is stored in shift register A.

Fall 2010 CS2102 Chih-Tsun Huang 10

Universal Shift Register (1/3)

Shift register types Unidirectional shift register Shift in one direction

Bidirectional shift register Shift in both direction

Universal shift register Capable of both-direction shifting and parallel load/out

Fall 2010 CS2102 Chih-Tsun Huang 11

Universal Shift Register (2/3)

Fall 2010 CS2102 Chih-Tsun Huang 12

Universal Shift Register (3/3)

Fall 2010 CS2102 Chih-Tsun Huang 13

Counters Counter is a special type of register that

counts upward, downward, or in any pre-specified sequence. Ripple counters (asynchronous counter) The output transition of flip-flop serves as a source for

triggering other flip-flops

Synchronous counters The clock inputs of all flip-flops receive a common

clock

Fall 2010 CS2102 Chih-Tsun Huang 14

Binary Ripple Counter (1/4)

Fall 2010 CS2102 Chih-Tsun Huang 15

With T flip-flops With D flip-flops

Binary Ripple Counter (2/4) With D FFs

Fall 2010 CS2102 Chih-Tsun Huang 16

Binary Ripple Counter (3/4) With T FFs

Fall 2010 CS2102 Chih-Tsun Huang 17

Binary Ripple Counter (4/4) Down counter with T FFs Replace active-low clock with active-high clock

Fall 2010 CS2102 Chih-Tsun Huang 18

BCD Ripple Counter

Fall 2010 CS2102 Chih-Tsun Huang 19

Three Decade BCD Counter When Q8 in one decade goes from 1 to 0, it

triggers the count for the next higher decade while it own decade goes from 9 to 0.

Fall 2010 CS2102 Chih-Tsun Huang 20

4-bit Synchronous Binary Counter

Fall 2010 CS2102 Chih-Tsun Huang 21

4-bit Up/Down Binary Counter

Up=1, Down=0

Up=0, Down=1

Fall 2010 CS2102 Chih-Tsun Huang 22

4-bit Binary Counter with Parallel Load (1/2)

Fall 2010 CS2102 Chih-Tsun Huang 23

4-bit Binary Counter with Parallel Load (2/2)

Fall 2010 CS2102 Chih-Tsun Huang 24

BCD Counters (1/2)

Fall 2010 CS2102 Chih-Tsun Huang 25

BCD Counters (2/2)

Fall 2010 CS2102 Chih-Tsun Huang 26

Counters with Unused States (1/3)

n flops => 2n states Unused states States that are not used in specifying the FSM May be treated as don’t-care conditions or may be

assigned specific next states

Self-correcting counters Ensure that when a circuit enters one of its

unused states, it eventually goes into one of the valid states after one or more clock pulses so that it can resume normal operation Analyze the circuit to determine the next state from an

unused state after it is designed

Fall 2010 CS2102 Chih-Tsun Huang 27

Counters with Unused States (2/3)

Fall 2010 CS2102 Chih-Tsun Huang 28

Counters with Unused States (3/3)

Fall 2010 CS2102 Chih-Tsun Huang 29

Ring Counter A circular shift register with only one flip-flop

being set at any particular time, all others are cleared. (initial value 1000...000)

The single bit is shifted from one flip-flop to the next to produce the sequence of timing signals

Fall 2010 CS2102 Chih-Tsun Huang 30

A2 A2 A1 A0

1 0 0 0

0 1 0 0

0 0 1 0

0 0 0 1

1 0 0 0

Ring Counter Applications

Fall 2010 CS2102 Chih-Tsun Huang 31

Johnson Counter Ring counter vs. Switch-tail ring counter Ring counter A k-bit ring counter circulates a single bit among the

flip-flops to provide k distinguishable states

Switch-tail ring counter A circular shift register with its complement output of

the last flip-flop connected to the input of the first flip-flop.

A k-bit switch-tail ring counter will go through a sequence of 2k distinguishable states (initial value 0 0 ... 0)

Fall 2010 CS2102 Chih-Tsun Huang 32

Switch Tail Ring Counter

Fall 2010 CS2102 Chih-Tsun Huang 33

Johnson Counter

A k-bit switch-tail ring counter + 2k decoding gates

Provide outputs for 2k timing signals Eg. 4-bit Johnson’s counter

The decoding follows a regular pattern Two inputs per decoding gate

Fall 2010 CS2102 Chih-Tsun Huang 34