5 registers

75
0113611 COMPUTER HARDWARE Registers, Register Transfers and Counters Dr. Fethullah Karabiber

Upload: amr-galal

Post on 15-Jul-2016

32 views

Category:

Documents


0 download

DESCRIPTION

registers

TRANSCRIPT

Page 1: 5 Registers

0113611 COMPUTER HARDWARE

Registers, Register Transfers and Counters

Dr. Fethullah Karabiber

Page 2: 5 Registers

Overview

¨  Registers, Microoperations and Implementations ¤  Registers and load enable ¤  Register transfer operations ¤  Microoperations - arithmetic, logic, and shift ¤  Microoperations on a single register

n  Multiplexer-based transfers n  Shift registers

¨  Register Cells, Buses, & Serial Operations ¨  Control of Register Transfers ¨  Counters

2

Page 3: 5 Registers

Registers

¨  Register – a collection of binary storage elements ¨  In theory, a register is sequential logic which can be

defined by a state table ¨  More often, think of a register as storing a vector of

binary values ¨  Frequently used to perform simple data storage

and data movement and processing operations

Page 4: 5 Registers

Current State

A1 A0

Next State A1(t+ 1 ) A0(t+ 1 )

For In1 In0 = 00 01 10 11

Output (=A1 A0)

Y1 Y0

0 0 00 01 10 11 0 0 0 1 00 01 10 11 0 1 1 0 00 01 10 11 1 0 1 1 00 01 10 11 1 1

State Table:

Example: 2-bit Register

¨  How many states are there? ¨  How many input combinations?

Output combinations?

¨  What is the output function?

¨  What is the next state function?

¨  Moore or Mealy?

¨  What are the quantities above for an n-bit register?

C D Q

C D Q

CP In0

In1 A1

A0

Y1

Y0

Page 5: 5 Registers

Simple Register

5

© 2008 Pearson Education, Inc.M. Morris Mano & Charles R. KimeLOGIC AND COMPUTER DESIGN FUNDAMENTALS, 4e

7-9

(b) Symbol

Sl

SRG 4Clock

SO

(a) Logic diagram

D

C

Serialinput SI

Clock

D

C

D

C

D

C

Serialoutput SO

Page 6: 5 Registers

Register Design Models

¨  Due to the large numbers of states and input combinations as n becomes large, the state diagram/state table model is not feasible!

¨  What are methods we can use to design registers? ¤ Add predefined combinational circuits to registers

n  Example: To count up, connect the register flip-flops to an incrementer

¤ Design individual cells using the state diagram/state table model and combine them into a register n  A 1-bit cell has just two states n  Output is usually the state variable

Page 7: 5 Registers

Register Storage

¨  Expectations: ¤  A register can store information for multiple clock cycles ¤  To “store” or “load” information should be controlled by a signal

¨  Reality: ¤  A D flip-flop register loads information on every clock cycle

¨  Realizing expectations: ¤  Use a signal to block the clock to the register, ¤  Use a signal to control feedback of the output of the register back to its

inputs, or ¤  Use other SR or JK flip-flops, that for (0,0) applied, store their state

¨  Load is a frequent name for the signal that controls register storage and loading ¤  Load = 1: Load the values on the data inputs ¤  Load = 0: Store the values in the register

Page 8: 5 Registers

Registers with Clock Gating

¨  The Load signal enables the clock signal to pass through if 1 and prevents the clock signal from passing through if 0.

¨  Example: For Positive Edge-Triggered or Negative Pulse Master-Slave Flip-flop:

¨  What logic is needed for gating? ¨  What is the problem?

Clock

Load

Gated Clock to FF

Clock Skew of gated clocks with respect to clock or each other

Gated Clock = Clock + Load

Page 9: 5 Registers

Registers with Clock Gating

9

© 2008 Pearson Education, Inc.M. Morris Mano & Charles R. KimeLOGIC AND COMPUTER DESIGN FUNDAMENTALS, 4e

7-1

(d) Timing diagram

Clock

Load

C inputs

(b) Symbol

REG

Clear

D0 Q0

D2 Q2

D3 Q3

D1 Q1

(c) Load control input

C inputs (clock inputsof flip-flops)

LoadClock

(a) Logic diagram

D

C

R

D

C

R

D

C

D

C

R

R

D0

D1

D2

D3

Q0

Q1

Q2

Q3

Clock

Clear

© 2008 Pearson Education, Inc.M. Morris Mano & Charles R. KimeLOGIC AND COMPUTER DESIGN FUNDAMENTALS, 4e

7-1

(d) Timing diagram

Clock

Load

C inputs

(b) Symbol

REG

Clear

D0 Q0

D2 Q2

D3 Q3

D1 Q1

(c) Load control input

C inputs (clock inputsof flip-flops)

LoadClock

(a) Logic diagram

D

C

R

D

C

R

D

C

D

C

R

R

D0

D1

D2

D3

Q0

Q1

Q2

Q3

Clock

Clear

© 2008 Pearson Education, Inc.M. Morris Mano & Charles R. KimeLOGIC AND COMPUTER DESIGN FUNDAMENTALS, 4e

7-1

(d) Timing diagram

Clock

Load

C inputs

(b) Symbol

REG

Clear

D0 Q0

D2 Q2

D3 Q3

D1 Q1

(c) Load control input

C inputs (clock inputsof flip-flops)

LoadClock

(a) Logic diagram

D

C

R

D

C

R

D

C

D

C

R

R

D0

D1

D2

D3

Q0

Q1

Q2

Q3

Clock

Clear

Page 10: 5 Registers

Registers with Load-Controlled Feedback

¨  A more reliable way to selectively load a register: ¤  Run the clock continuously, and

¤  Selectively use a load control to change the register contents. ¨  Example: 2-bit register

with Load Control:

¨  For Load = 0, loads register contents (hold current values)

¨  For Load = 1, loads input values (load new values)

¨  Hardware more complex than clock gating, but free of timing problems C D Q

C D Q

Clock In0

In1

A1

A0

Y1

Y0

Load

2-to-1 Multiplexers

Page 11: 5 Registers

Registers with Load-Controlled Feedback

11

© 2008 Pearson Education, Inc.M. Morris Mano & Charles R. KimeLOGIC AND COMPUTER DESIGN FUNDAMENTALS, 4e

7-2

D

CEN

(b)(a)

D

CD Flip-flop with enable

ENDC

Q

(c)

D

CEN

D

CEN

D

CEN

D

CEN

Q0

Q1

Q2D2

D1

D0

Q3D3Load

Clock

© 2008 Pearson Education, Inc.M. Morris Mano & Charles R. KimeLOGIC AND COMPUTER DESIGN FUNDAMENTALS, 4e

7-2

D

CEN

(b)(a)

D

CD Flip-flop with enable

ENDC

Q

(c)

D

CEN

D

CEN

D

CEN

D

CEN

Q0

Q1

Q2D2

D1

D0

Q3D3Load

Clock

© 2008 Pearson Education, Inc.M. Morris Mano & Charles R. KimeLOGIC AND COMPUTER DESIGN FUNDAMENTALS, 4e

7-2

D

CEN

(b)(a)

D

CD Flip-flop with enable

ENDC

Q

(c)

D

CEN

D

CEN

D

CEN

D

CEN

Q0

Q1

Q2D2

D1

D0

Q3D3Load

Clock

Page 12: 5 Registers

Registers

12

© 2008 Pearson Education, Inc.M. Morris Mano & Charles R. KimeLOGIC AND COMPUTER DESIGN FUNDAMENTALS, 4e

T 7-6

TABLE 7-6Function Table for the Register of Figure 7-10

Shift Load Operation

001

01X

No changeLoad parallel dataShift down from Q0 to Q3

© 2008 Pearson Education, Inc.M. Morris Mano & Charles R. KimeLOGIC AND COMPUTER DESIGN FUNDAMENTALS, 4e

7-10

DC

DC

DC

DC

(b) Symbol

SHR 4

ShiftLoadSlD0

D1

D2

D3

Q0Q1Q2Q3

ShiftLoadSerialinput

D0

D1

D2

D3

Clock

Q0

Q1

Q2

Q3

© 2008 Pearson Education, Inc.M. Morris Mano & Charles R. KimeLOGIC AND COMPUTER DESIGN FUNDAMENTALS, 4e

7-10

DC

DC

DC

DC

(b) Symbol

SHR 4

ShiftLoadSlD0

D1

D2

D3

Q0Q1Q2Q3

ShiftLoadSerialinput

D0

D1

D2

D3

Clock

Q0

Q1

Q2

Q3

Function Table

Page 13: 5 Registers

Registers

13

© 2008 Pearson Education, Inc.M. Morris Mano & Charles R. KimeLOGIC AND COMPUTER DESIGN FUNDAMENTALS, 4e

7-11

(b) Symbol

SHR 4

S1

S0

LSI

D0

D1

D2

D3

Q0

Q1

Q2

Q3

RSI

Mode S1

Mode S0

Left serial input

Right serial input

Clock

(a) Logic diagram of one typical stage

D

C

D

C

D

C

S1

S0

Di

MUX

S1

S0

0

1

2

3

Clock

Qi

Qi 1

Qi 1

© 2008 Pearson Education, Inc.M. Morris Mano & Charles R. KimeLOGIC AND COMPUTER DESIGN FUNDAMENTALS, 4e

7-11

(b) Symbol

SHR 4

S1

S0

LSI

D0

D1

D2

D3

Q0

Q1

Q2

Q3

RSI

Mode S1

Mode S0

Left serial input

Right serial input

Clock

(a) Logic diagram of one typical stage

D

C

D

C

D

C

S1

S0

Di

MUX

S1

S0

0

1

2

3

Clock

Qi

Qi 1

Qi 1

© 2008 Pearson Education, Inc.M. Morris Mano & Charles R. KimeLOGIC AND COMPUTER DESIGN FUNDAMENTALS, 4e

T 7-7

TABLE 7-7Function Table for the Register of Figure 7-7

Mode controlRegisterOperationS1 S0

0011

0101

No changeShift downShift upParallel load

Function Table

Page 14: 5 Registers

Register Transfer Operations

¨  Register Transfer Operations – The movement and processing of data stored in registers

¨  Three basic components: ¤  set of registers ¤  operations ¤  control of operations

¨  Elementary Operations -- load, count, shift, add, bitwise "OR", etc. ¤  Elementary operations called microoperations

Page 15: 5 Registers

Register Transfer Operations

15

© 2008 Pearson Education, Inc.M. Morris Mano & Charles R. KimeLOGIC AND COMPUTER DESIGN FUNDAMENTALS, 4e

7-3

Controlinputs

Datainputs

Dataoutputs

Datapath

Controloutputs

Control signals

Status signalsControlunit

¨  The system is partitioned into 2 types of modules: ¤ Datapath: performs data processing operations. ¤ Control unit: determines the sequence of those

operations. ¨  Datapaths are defined by their registers and the

operations performed on binary data stored in the registers

Page 16: 5 Registers

Register Notation

© 2008 Pearson Education, Inc.M. Morris Mano & Charles R. KimeLOGIC AND COMPUTER DESIGN FUNDAMENTALS, 4e

7-4

R

(a) Register R

R2

(c) Numbering of 16-bit register

15 0

(b) Individual bits of 8-bit register

01234567

PC (H)

(d) Two-part 16-bit register

15 08 7

PC (L)

© 2008 Pearson Education, Inc.M. Morris Mano & Charles R. KimeLOGIC AND COMPUTER DESIGN FUNDAMENTALS, 4e

T 7-1

TABLE 7-1Basic Symbols for Register Transfers

selpmaxEnoitpircseDlobmyS

Letters(and numerals)

Denotes a register AR, R2, DR, IR

Parentheses Denotes a part of a register R2(1), R2(7:0), AR(L)Arrow Denotes transfer of dataComma Separates simultaneous transfersSquare brackets Specifies an address for memory

R1 R2R1 R2 R2 R1,DR M AR[ ]

Page 17: 5 Registers

Conditional Transfer

¨  If (K1 =1) then (R2 ← R1) is shortened to

K1: (R2 ← R1) where K1 is a control

variable specifying a conditional execution of the microoperation.

 

© 2008 Pearson Education, Inc.M. Morris Mano & Charles R. KimeLOGIC AND COMPUTER DESIGN FUNDAMENTALS, 4e

7-5

K1

Clock

Transfer occurs here

t t 1

K1

Clock

R1 R2

Load

n

© 2008 Pearson Education, Inc.M. Morris Mano & Charles R. KimeLOGIC AND COMPUTER DESIGN FUNDAMENTALS, 4e

7-5

K1

Clock

Transfer occurs here

t t 1

K1

Clock

R1 R2

Load

n

Page 18: 5 Registers

Microoperations

¨  Logical Groupings: ¤  Transfer - move data from one register to another

¤  Arithmetic - perform arithmetic on data in registers ¤  Logic - manipulate data or use bitwise logical operations

¤  Shift - shift data in registers

Arithmetic operations + Addition – Subtraction * Multiplication / Division

Logical operations ∨ Logical OR ∧ Logical AND ⊕ Logical Exclusive OR Not

Page 19: 5 Registers

Register Trasfers

19

© 2008 Pearson Education, Inc.M. Morris Mano & Charles R. KimeLOGIC AND COMPUTER DESIGN FUNDAMENTALS, 4e

T 7-2

TABLE 7-2Textbook RTL, VHDL, and Verilog Symbols for Register Transfers

Operation Text RTL VHDL Verilog

Combinational assignment = <= (concurrent) assign = (nonblocking)Register transfer <= (concurrent) <= (nonblocking)Addition + + +Subtraction – – –Bitwise AND ^ and &

|roRO esiwtiBBitwise XOR xor ^Bitwise NOT – (overline) not ~Shift left (logical) sl sll <<Shift right (logical) sr srl >>Vectors/registers A(3:0) A(3 down to 0) A[3:0]Concatenation || & { , }

Page 20: 5 Registers

Example Microoperations

¨  Add the content of R1 to the content of R2 and place the result in R1.

R1← R1 + R2 ¨  Multiply the content of R1 by the content of R6 and place the

result in PC. PC ← R1 * R6 ¨  Exclusive OR the content of R1 with the content of R2 and

place the result in R1. R1 ← R1 ⊕ R2

Page 21: 5 Registers

Example Microoperations (Continued)

¨  Take the 1's Complement of the contents of R2 and place it in the PC.

PC ← R2 ¨  On condition K1 OR K2, the content of R1 is Logic bitwise

Ored with the content of R3 and the result placed in R1. (K1 + K2): R1 ← R1 ∨ R3

¨  NOTE: "+" (as in K1 + K2) and means “OR.” In R1 ← R1 + R3, + means “plus.”

Page 22: 5 Registers

Control Expressions

¨  The control expression for an operation appears to the left of the operation and is separated from it by a colon

¨  Control expressions specify the logical condition for the operation to occur

¨  Control expression values of: ¤  Logic "1" -- the operation

occurs. ¤  Logic "0" -- the operation is

does not occur.

§  Example: X K1 : R1 ← R1 + R2 X K1 : R1 ← R1 + R2 + 1

§  Variable K1 enables the add or subtract operation.

§  If X =0, then X =1 so X K1 = 1, activating the addition of R1 and R2.

§  If X = 1, then X K1 = 1, activating the addition of R1 and the two's complement of R2 (subtract).

Page 23: 5 Registers

Arithmetic Microoperations

¨  Note that any register may be specified for source 1, source 2, or destination.

¨  These simple microoperations operate on the whole word

© 2008 Pearson Education, Inc.M. Morris Mano & Charles R. KimeLOGIC AND COMPUTER DESIGN FUNDAMENTALS, 4e

T 7-3

TABLE 7-3Arithmetic Microoperations

Symbolicdesignation Description

Contents of R1 plus R2 transferred to R0

Complement of the contents of R2 (1’s complement)

2’s complement of the contents of R2

R1 plus 2’s complement of R2 transferred to R0 (subtraction)

Increment the contents of R1 (count up)

Decrement the contents of R1 (count down)

R0 R1 R2+

R2 R2

R2 R2 1+

R0 R1 R2 1+ +

R1 R1 1+

R1 R1 1–

Page 24: 5 Registers

Adder/ Subtracter Unit

24 X’K1 : R1ß R1+R2 XK1 : R1ß R1+R2’+1

Overflow output

Page 25: 5 Registers

Logical Microoperations

© 2008 Pearson Education, Inc.M. Morris Mano & Charles R. KimeLOGIC AND COMPUTER DESIGN FUNDAMENTALS, 4e

T 7-4

TABLE 7-4Logic Microoperations

Symbolicdesignation Description

Logical bitwise NOT (1’s complement)Logical bitwise AND (clears bits)Logical bitwise OR (sets bits)Logical bitwise XOR (complements bits)

R0 R1R0 R1 R2R0 R1 R2R0 R1 R2

¨  Let R1 = 10101010, and R2 = 11110000 ¨  Then after the operation, R0 becomes:

R0 Operation 01010101 R0 ! R1 11111010 R0 ! R1 " R2 10100000 R0 ! R1 # R2 01011010 R0 ! R1 $ R2

Page 26: 5 Registers

Shift Microoperations

¨  Note: These shifts "zero fill". Sometimes a separate flip-flop is used to provide the data shifted in, or to “catch” the data shifted out.

¨  Other shifts are possible (rotates, arithmetic).

© 2008 Pearson Education, Inc.M. Morris Mano & Charles R. KimeLOGIC AND COMPUTER DESIGN FUNDAMENTALS, 4e

T 7-5

TABLE 7-5Examples of Shifts

TypeSymbolicdesignation

Eight-bit examples

Source R2After shift:Destination R1

shift left 10011110 00111100shift right 11100101 01110010

R1 sl R2R1 sr R2

Page 27: 5 Registers

Register Cell Design

¨  Assume that a register consists of identical cells ¨  Then register design can be approached as

follows: ¤  Design representative cell for the register ¤  Connect copies of the cell together to form the register ¤  Applying appropriate “boundary conditions” to cells

that need to be different and contract if appropriate

¨  Register cell design is the first step of the above process

Page 28: 5 Registers

Register Cell Specifications

¨  A register ¨  Data inputs to the register ¨  Control input combinations to the register

¤  Example 1: Not encoded n  Control inputs: Load, Shift, Add n  At most, one of Load, Shift, Add is 1 for any clock cycle

(0,0,0), (1,0,0), (0,1,0), (0,0,1)

¤  Example 2: Encoded n  Control inputs: S1, S0 n  All possible binary combinations on S1, S0

(0,0), (0,1), (1,0), (1,1)

Page 29: 5 Registers

Register Cell Specifications

¨  A set of register functions (typically specified as register transfers) ¤  Example:

Load: A ← B Shift: A ← sr B Add: A ← A + B

¨  A hold state specification ¤  Example:

n  Control inputs: Load, Shift, Add n  If all control inputs are 0, hold the current register state

Page 30: 5 Registers

Example 1: Register Cell Design

¨  Register A (m-bits) Specification: ¤ Data input: B ¤ Control inputs (CX, CY) ¤ Control input combinations (0,0), (0,1) (1,0) ¤ Register transfers: ¤ CX : A ← B v A ¤ CY : A ← B + A ¤ Hold state: (0,0)

Page 31: 5 Registers

Example 1: Register Cell Design (continued)

¨  Load Control Load = CX + CY

¨  Since all control combinations appear as if encoded (0,0), (0,1), (1,0) can use multiplexer without encoder:

S1 = CX S0 = CY D0 = Ai Hold A

D1 = Ai ← Bi + Ai CY = 1 D2 = Ai ← Bi v Ai CX = 1

¨  Note that the decoder part of the 3-input multiplexer can be shared between bits if desired

Page 32: 5 Registers

Sequential Circuit Design Approach

¨  Find a state diagram or state table ¤ Note that there are only two states with the state

assignment equal to the register cell output value

¨  Use the design procedure in Chapter 5 to complete the cell design

¨  For optimization: ¤ Use K-maps for up to 4 to 6 variables ¤ Otherwise, use computer-aided or manual optimization

Page 33: 5 Registers

Example 1 Again ¨  State Table:

¤  Four variables give a total of 16 state table entries ¤  By using:

n  Combinations of variable names and values n  Don’t care conditions (for CX = CY = 1)

only 8 entries are required to represent the 16 entries

Hold Ai v Bi Ai + Bi Ai

CX = 0 CY = 0

CX = 1 Bi = 0

CX = 1 Bi = 1

CY = 1 Bi = 0

CY = 1 Bi = 1

0 0 0 1 0 1 1 1 1 1 1 0

Page 34: 5 Registers

Example 1 Again (continued)

¨  K-map - Use variable ordering CX, CY, Ai Bi and assume a D flip-flop

1

CY

CX

Ai

X

Bi

X X X

0 0 1

0 1 1 1

0 1 1 0

Di

Page 35: 5 Registers

Example 1 Again (continued)

¨  The resulting SOP equation: Di = CX Bi + CY Ai Bi + Ai Bi + CY Ai

¨  Using factoring and DeMorgan’s law: Di = CX Bi + Ai (CY Bi) + Ai(CY Bi ) Di = CX Bi + Ai + (CY Bi)

The gate input cost per cell = 2 + 8 + 2 + 2 = 14 ¨  The gate input cost per cell for the previous version

is: Per cell: 19 Shared decoder logic: 8

¨  Cost gain by sequential design > 5 per cell ¨  Also, no Enable on the flip-flop makes it cost less

Page 36: 5 Registers

Register Transfer Structures

¨  Multiplexer-Based Transfers - Multiple inputs are selected by a multiplexer dedicated to the register

¨  Bus-Based Transfers - Multiple inputs are selected by a shared multiplexer driving a bus that feeds inputs to multiple registers

¨  Three-State Bus - Multiple inputs are selected by 3-state drivers with outputs connected to a bus that feeds multiple registers

¨  Other Transfer Structures - Use multiple multiplexers, multiple buses, and combinations of all the above

Page 37: 5 Registers

Multiplexer-Based Transfers

¨  Multiplexers connected to register inputs produce flexible transfer structures (Note: Clocks are omitted for clarity)

¨  The transfers are:

¤  K1: R0 ← R1

¤  K2⋅ K1: R0 ← R2

© 2008 Pearson Education, Inc.M. Morris Mano & Charles R. KimeLOGIC AND COMPUTER DESIGN FUNDAMENTALS, 4e

7-7

R2

R1

MUX

S0

1R0

Load

4

4

4

K2K1

(a) Block diagram

Clock

K2K1

D0D1

D2D3

Q0Q1Q2Q3

C

REGISTERLOAD

D0D1D2D3

Q0Q1Q2Q3

C

REGISTERLOAD

D0D1D2D3

Q0Q1Q2Q3

C

REGISTERLOAD

A0A1A2A3

Y0Y1Y2Y3

S

2–to–1 MUX

B0B1B2

B3

R2

R1

R0

(b) Detailed logic

Page 38: 5 Registers

Multiplexer Approach ¨  Uses an n-input multiplexer with a variety of transfer sources

and functions

© 2008 Pearson Education, Inc.M. Morris Mano & Charles R. KimeLOGIC AND COMPUTER DESIGN FUNDAMENTALS, 4e

7-8

Dedicatedlogic 0

Dedicatedlogic k 1

Encoder

.

.

.

.

.

.

.

.

.

.

.

....

.

.

.

MUX

Sm S0

k 1

n 1

k

Load

...

. . .

. . .

K0

Kn 1

Registers orshared logic

4

4

4

4

R04

0

Page 39: 5 Registers

Multiplexer Approach

¨  Load enable by OR of control signals K0, K1, … Kn-1 - assumes no load for 00…0

¨  Use Encoder + Multiplexer (shown) or n x 2 AND-OR to select sources and/or transfer functions

© 2008 Pearson Education, Inc.M. Morris Mano & Charles R. KimeLOGIC AND COMPUTER DESIGN FUNDAMENTALS, 4e

7-8

Dedicatedlogic 0

Dedicatedlogic k 1

Encoder

.

.

.

.

.

.

.

.

.

.

.

....

.

.

.

MUX

Sm S0

k 1

n 1

k

Load

...

. . .

. . .

K0

Kn 1

Registers orshared logic

4

4

4

4

R04

0

Page 40: 5 Registers

Multiplexer and Bus-Based Transfers for Multiple Registers

¨  Multiplexer dedicated to each register ¨  Shared transfer paths for registers

¤ A shared transfer object is a called a bus (Plural: buses)

¨  Bus implementation using: ¤ multiplexers ¤  three-state nodes and drivers

¨  In most cases, the number of bits is the length of the receiving register

Page 41: 5 Registers

Dedicated MUX-Based Transfers

¨  Multiplexer connected to each register input produces a very flexible transfer structure =>

¨  Characterize the simultaneous transfers possible with this structure.

© 2008 Pearson Education, Inc.M. Morris Mano & Charles R. KimeLOGIC AND COMPUTER DESIGN FUNDAMENTALS, 4e

7-19

(a) Dedicated multiplexers (b) Single bus

SelectS0

LoadL0

S0

12-to-1MUX

n

R0

S0

1

n

R1

S0

1

n

R2

n

n

n

2-to-1MUX

2-to-1MUX

S2S1 L2L1

0

Bus

R0

R1

R2

S10

1 3-to-1MUX

S0

Select

n

n

n

n

n

n

n

S10

1

2

LoadL0 L2L1

Page 42: 5 Registers

Multiplexer Bus

¨  A single bus driven by a multiplexer lowers cost, but limits the available transfers =>

¨  Characterize the simultaneous transfers possible with this structure.

¨  Characterize the cost savings compared to dedicated multiplexers

© 2008 Pearson Education, Inc.M. Morris Mano & Charles R. KimeLOGIC AND COMPUTER DESIGN FUNDAMENTALS, 4e

7-19

(a) Dedicated multiplexers (b) Single bus

SelectS0

LoadL0

S0

12-to-1MUX

n

R0

S0

1

n

R1

S0

1

n

R2

n

n

n

2-to-1MUX

2-to-1MUX

S2S1 L2L1

0

Bus

R0

R1

R2

S10

1 3-to-1MUX

S0

Select

n

n

n

n

n

n

n

S10

1

2

LoadL0 L2L1

© 2008 Pearson Education, Inc.M. Morris Mano & Charles R. KimeLOGIC AND COMPUTER DESIGN FUNDAMENTALS, 4e

T 7-13

TABLE 7-13Examples of Register Transfers Using the Single Bus in Figure 7-19(b)

daoLtceleS

Register Transfer S1 S0 L2 L1 L0

1 0 0 0 10 1 1 0 1

Impossible

R0 R2R0 R1 R2 R1,R0 R1 R1 R0,

Page 43: 5 Registers

Three-State Bus

¨  The 3-input MUX can be replaced by a 3-state node (bus) and 3-state buffers.

¨  Cost is further reduced, but transfers are limited

¨  Characterize the simultaneous transfers possible with this structure.

¨  Characterize the cost savings and compare

© 2008 Pearson Education, Inc.M. Morris Mano & Charles R. KimeLOGIC AND COMPUTER DESIGN FUNDAMENTALS, 4e

7-20

(c) Three-state bus usingregisters with bidirectionallines

Bus

LoadL2 L1 L0

EnableE2 E1 E0

R0n

EN

R1n

EN

R2n

EN

n

n

(b) Multiplexer bus

Bus

Select

n

n

nn

n

n

n

LoadL0 L1 L2

R0

R1

R2

3–to–1MUX

2

(a) Register with bidirectionalinput–output lines and symbol

R

LOAD

Load

n n

n

EN

R

Load

n

EN

© 2008 Pearson Education, Inc.M. Morris Mano & Charles R. KimeLOGIC AND COMPUTER DESIGN FUNDAMENTALS, 4e

7-20

(c) Three-state bus usingregisters with bidirectionallines

Bus

LoadL2 L1 L0

EnableE2 E1 E0

R0n

EN

R1n

EN

R2n

EN

n

n

(b) Multiplexer bus

Bus

Select

n

n

nn

n

n

n

LoadL0 L1 L2

R0

R1

R2

3–to–1MUX

2

(a) Register with bidirectionalinput–output lines and symbol

R

LOAD

Load

n n

n

EN

R

Load

n

EN

Page 44: 5 Registers

Serial Transfers and Microoperations

¨  Serial Transfers ¤ Used for “narrow” transfer paths ¤  Example 1: Telephone or cable line

n  Parallel-to-Serial conversion at source n  Serial-to-Parallel conversion at destination

¤  Example 2: Initialization and Capture of the contents of many flip-flops for test purposes n  Add shift function to all flip-flops and form large shift register n  Use shifting for simultaneous Initialization and Capture operations

¨  Serial microoperations ¤  Example 1: Addition ¤  Example 2: Error-Correction for CDs

Page 45: 5 Registers

Serial Transfer

45

© 2008 Pearson Education, Inc.M. Morris Mano & Charles R. KimeLOGIC AND COMPUTER DESIGN FUNDAMENTALS, 4e

7-21

(b) Timing diagram

T1 T2 T3 T4

Clock

ShiftC inputs

Register B SRG 4

Register A SRG 4

(a) Block diagram

SI

C

SO0 SI

C

SO

ShiftClock

© 2008 Pearson Education, Inc.M. Morris Mano & Charles R. KimeLOGIC AND COMPUTER DESIGN FUNDAMENTALS, 4e

T 7-14

TABLE 7-14Example of Serial Transfer

Timingpulse Shift Register A Shift Register B

Initial valueAfter T1After T2After T3After T4

10000

01000

10100

11010

01101

00110

10011

01001

Example of Serial Transfer

Page 46: 5 Registers

Serial Microoperations

¨  By using two shift registers for operands, a full adder, and a flip flop (for the carry), we can add two numbers serially, starting at the least significant bit.

¨  Serial addition is a low cost way to add large numbers of operands, since a “tree” of full adder cells can be made to any depth, and each new level doubles the number of operands.

¨  Other operations can be performed serially as well, such as parity generation/checking or more complex error-check codes.

¨  Shifting a binary number left is equivalent to multiplying by 2.

¨  Shifting a binary number right is equivalent to dividing by 2.

Page 47: 5 Registers

Serial Adder

¨  The circuit shown uses two shift registers for operands A(3:0) and B(3:0).

¨  A full adder, and one more flip flop (for the carry) is used to compute the sum.

¨  The result is stored in the A register and the final carry in the flip-flop

¨  With the operands and the result in shift registers, a tree of full adders can be used to add a large number of operands. Used as a common digital signal processing technique.

A3 A2 A1 A0

B3 B2 B1 B0

A B Cin

Sum

Cout

D Q CP

FA

Load/Right Shift Registers

Serial In

Serial In

Parallel Load

Parallel Load (Clock and Load/Shift Control not shown)

Page 48: 5 Registers

Serial Adder

48

Page 49: 5 Registers

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 ¤  Clock connected to the flip-flop clock input on the LSB bit flip-flop ¤  For all other bits, a flip-flop output is connected to the clock input,

thus circuit is not truly synchronous! ¤  Output change is delayed more for each bit toward the MSB. ¤  Resurgent because of low power consumption

¨  Synchronous Counters ¤  Clock is directly connected to the flip-flop clock inputs

¤  Logic is used to implement the desired state sequencing

Page 50: 5 Registers

Ripple Counter

¨  How does it work? ¤ When there is a positive

edge on the clock input of A, A complements

¤  The clock input for flip- flop B is the complemented output of flip-flop A

¤ When flip A changes from 1 to 0, there is a positive edge on the clock input of B causing B to complement

Chapter 7 - Part 2 50

Reset

Clock D

D CR

CR

B

A

CP

B

A

0 1 2 3 0 1

Page 51: 5 Registers

Ripple Counter (continued)

¨ The arrows show the cause-effect relation- ship from the prior slide =>

¨ The corresponding sequence of states => (B,A) = (0,0),

¨ Each additional bit, C, D, …behaves like bit B, changing half as frequently as the bit before it.

¨ For 3 bits: (C,B,A) = (0,0,0), (0,0,1), (0,1,0), (0,1,1), (1,0,0), (1,0,1), (1,1,0), (1,1,1), (0,0,0), …

(1,0), (0,1), (0,1), … (0,0), (1,1),

CP

B

A

0 1 2 3 0 1

Page 52: 5 Registers

Ripple Counter (continued)

¨  These circuits are called ripple counters because each edge sensitive transition (positive in the example) causes a change in the next flip-flop’s state.

¨  The changes “ripple” upward through the chain of flip-flops, i. e., each transition occurs after a clock-to-output delay from the stage before.

¨  To see this effect in detail look at the waveforms on the next slide.

© 2008 Pearson Education, Inc.M. Morris Mano & Charles R. KimeLOGIC AND COMPUTER DESIGN FUNDAMENTALS, 4e

7-12

D

D

Reset

Clock pulse

D

RCR

CR

CR

CR

D

Page 53: 5 Registers

Ripple Counter (continued)

¨  Starting with C = B = A = 1, equivalent to (C,B,A) = 7 base 10, the next clock increments the count to (C,B,A) = 0 base 10. In fine timing detail: ¤  The clock to output delay

tPHL causes an increasing delay from clock edge for each stage transition.

¤  Thus, the count “ripples” from least to most significant bit.

¤  For n bits, total worst case delay is n tPHL.

CP

A

B

C

tPHL

tPHL

tpHL

Page 54: 5 Registers

Synchronous Counters

¨  To eliminate the "ripple" effects, use a common clock for each flip-flop and a combinational circuit to generate the next state.

¨  For an up-counter, use an incrementer =>

Chapter 7 - Part 2 54

D3 Q3 D2 Q2 D1 Q1 D0 Q0

Clock

Incre-menter A3

A2 A1 A0

S3 S2 S1 S0

© 2008 Pearson Education, Inc.M. Morris Mano & Charles R. KimeLOGIC AND COMPUTER DESIGN FUNDAMENTALS, 4e

T 7-8TABLE 7-8Counting Sequence of Binary Counter

Upward Counting Sequence Downward Counting Sequence

Q3 Q2 Q1 Q0 Q3 Q2 Q1 Q0

0000000011111111

0000111100001111

0011001100110011

0101010101010101

1111111100000000

1111000011110000

1100110011001100

1010101010101010

Page 55: 5 Registers

Synchronous Counters (continued)

¨  Internal details => ¨  Internal Logic

¤  XOR complements each bit

¤  AND chain causes complement of a bit if all bits toward LSB from it equal 1

¨  Count Enable ¤  Forces all outputs of AND

chain to 0 to “hold” the state

¨  Carry Out ¤  Added as part of incrementer

¤  Connect to Count Enable of additional 4-bit counters to form larger counters

© 2008 Pearson Education, Inc.M. Morris Mano & Charles R. KimeLOGIC AND COMPUTER DESIGN FUNDAMENTALS, 4e

7-13

(c) Symbol

CTR 4

ENQ1Q2Q3

CO

Q0

(a) Logic diagram-serial gating

DC

D

C

D

C

DC

Count enable EN

Clock

Carryoutput CO

Q0

Q1

Q2

Q3

(b) Logic diagram-parallel gating

EN

Q0

Q1

C1

Q2

C2

C3

CO

Q3

Page 56: 5 Registers

Synchronous Counters (continued)

¨  Carry chain ¤  series of AND gates through which the

carry “ripples” ¤  Yields long path delays ¤  Called serial gating

¨  Replace AND carry chain with ANDs => in parallel ¤  Reduces path delays ¤  Called parallel gating ¤  Like carry lookahead ¤  Lookahead can be used on COs

and ENs to prevent long paths in large counters

¨  Symbol for Synchronous Counter

© 2008 Pearson Education, Inc.M. Morris Mano & Charles R. KimeLOGIC AND COMPUTER DESIGN FUNDAMENTALS, 4e

7-13

(c) Symbol

CTR 4

ENQ1Q2Q3

CO

Q0

(a) Logic diagram-serial gating

DC

D

C

D

C

DC

Count enable EN

Clock

Carryoutput CO

Q0

Q1

Q2

Q3

(b) Logic diagram-parallel gating

EN

Q0

Q1

C1

Q2

C2

C3

CO

Q3

© 2008 Pearson Education, Inc.M. Morris Mano & Charles R. KimeLOGIC AND COMPUTER DESIGN FUNDAMENTALS, 4e

7-13

(c) Symbol

CTR 4

ENQ1Q2Q3

CO

Q0

(a) Logic diagram-serial gating

DC

D

C

D

C

DC

Count enable EN

Clock

Carryoutput CO

Q0

Q1

Q2

Q3

(b) Logic diagram-parallel gating

EN

Q0

Q1

C1

Q2

C2

C3

CO

Q3

Page 57: 5 Registers

Other Counters

¨  See text for: ¤ Down Counter - counts downward instead of upward

¤ Up-Down Counter - counts up or down depending on value a control input such as Up/Down

¤  Parallel Load Counter - Has parallel load of values available depending on control input such as Load

¨  Divide-by-n (Modulo n) Counter ¤ Count is remainder of division by n; n may not be a power

of 2 or ¤ Count is arbitrary sequence of n states specifically designed

state-by-state ¤  Includes modulo 10 which is the BCD counter

Page 58: 5 Registers

Counter with Parallel Load

¨  Add path for input data ¤  enabled for Load = 1

¨  Add logic to: ¤  disable count logic for Load = 1

¤  disable feedback from outputs for Load = 1

¤  enable count logic for Load = 0 and Count = 1

¨  The resulting function table:

Load Count Action 0 0 Hold Stored Value 0 1 Count Up Stored Value 1 X Load D

© 2008 Pearson Education, Inc.M. Morris Mano & Charles R. KimeLOGIC AND COMPUTER DESIGN FUNDAMENTALS, 4e

7-14

D0 D

C

Q0

D1 D

C

Q1

D2 D

C

Q2

D3 D

C

Q3

Load

Count

Clock

CarryOutput CO

Page 59: 5 Registers

Counter w/ Unused States

¨  n flip-flops ⇒ 2n binary states ¨  Unused states: — states that are not used in

specifying the sequential ckt — maybetreatedasdon’t-careconditionsor

¨  may be assigned specific next states ␣ Self-correcting counter: ¤ Ensure that when a ckt enter one of its unused states, it

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

state after it is designed.

59

Page 60: 5 Registers

Counter w/ Unused States

¨  Example: 60

J.J. Shann 7-44

Example:

Two unused states: 011 & 111

BADA

CDBCBDC

The simplified f-f input eqs:

J.J. Shann 7-44

Example:

Two unused states: 011 & 111

BADA

CDBCBDC

The simplified f-f input eqs:

Page 61: 5 Registers

Counter w/ Unused States

61

© 2008 Pearson Education, Inc.M. Morris Mano & Charles R. KimeLOGIC AND COMPUTER DESIGN FUNDAMENTALS, 4e

7-16

(b)

000

011

ABC

Reset

110 001

111101 010

100

(a)

A

Clock

D

C

D

C

D

C

B

C

Reset

© 2008 Pearson Education, Inc.M. Morris Mano & Charles R. KimeLOGIC AND COMPUTER DESIGN FUNDAMENTALS, 4e

7-16

(b)

000

011

ABC

Reset

110 001

111101 010

100

(a)

A

Clock

D

C

D

C

D

C

B

C

Reset

Page 62: 5 Registers

Design Example: Synchronous BCD ¨ Use the sequential logic model to design a synchronous BCD

counter with D flip-flops ¨ Input combinations 1010 through 1111 are don’t cares

© 2008 Pearson Education, Inc.M. Morris Mano & Charles R. KimeLOGIC AND COMPUTER DESIGN FUNDAMENTALS, 4e

T 7-9

Present State Next State Output

Q8 Q4 Q2 Q1

D8 =Q8(t+1)

D4 =Q4(t+1)

D2 =Q2(t+1)

D1 =Q1(t+1) Y

0000000011

0000111100

0011001100

0101010101

0000000110

0001111000

0110011000

1010101010

0000000001

TABLE 7-9State Table and Flip-Flop Inputs for BCD Counter

Page 63: 5 Registers

Synchronous BCD (continued)

¨ Use K-Maps to two-level optimize the next state equations and manipulate into forms containing XOR gates:

D1 = Q1 D2 = Q2 + Q1Q8 D4 = Q4 + Q1Q2 D8 = Q8 + (Q1Q8 + Q1Q2Q4)

¨ The logic diagram can be draw from these equations

¤ An asynchronous or synchronous reset should be added

¨ What happens if the counter is perturbed by a power disturbance or other interference and it enters a state other than 0000 through 1001?

Page 64: 5 Registers

Synchronous BCD (continued)

¨  Find the actual values of the six next states for the don’t care combinations from the equations

¨  Find the overall state diagram to assess behavior for the don’t care states (states in decimal)

Chapter 7 - Part 2 64

Present State Next State Q8 Q4 Q2 Q1 Q8 Q4 Q2 Q1 1 0 1 0 1 0 1 1 1 0 1 1 0 1 1 0 1 1 0 0 1 1 0 1 1 1 0 1 0 1 0 0 1 1 1 0 1 1 1 1 1 1 1 1 0 0 1 0

0 1

8

7

6 5

4

3

2

9

10

11

14

15 12

13

Page 65: 5 Registers

Synchronous BCD (continued)

¨  For the BCD counter design, if an invalid state is entered, return to a valid state occurs within two clock cycles

¨  Is this adequate? If not: ¤  Is a signal needed that indicates that an invalid state has been

entered? What is the equation for such a signal? ¤  Does the design need to be modified to return from an invalid state

to a valid state in one clock cycle? ¤  Does the design need to be modified to return from a invalid state

to a specific state (such as 0)?

¨  The action to be taken depends on: ¤  the application of the circuit

¤  design group policy

¨  See pages 244 of the text.

Page 66: 5 Registers

Three Decade Decimal Counter

66

J.J. Shann 7-42

Three-decade BCD counter:

Page 67: 5 Registers

Counting Modulo N

¨  The following techniques use an n-bit binary counter with asynchronous or synchronous clear and/or parallel load: ¤  Detect a terminal count of N in a Modulo-N count sequence to

asynchronously Clear the count to 0 or asynchronously Load in value 0 (These lead to counts which are present for only a very short time and can fail to work for some timing conditions!)

¤  Detect a terminal count of N - 1 in a Modulo-N count sequence to Clear the count synchronously to 0

¤  Detect a terminal count of N - 1 in a Modulo-N count sequence to synchronously Load in value 0

¤  Detect a terminal count and use Load to preset a count of the terminal count value minus (N - 1)

¨  Alternatively, custom design a modulo N counter as done for BCD

Page 68: 5 Registers

A BCD Counter

68

© 2008 Pearson Education, Inc.M. Morris Mano & Charles R. KimeLOGIC AND COMPUTER DESIGN FUNDAMENTALS, 4e

7-15

CTR 4

Load

Count

D0

D1

D2

D3

Q0

Q1

Q2

Q3

CO

Clock

1

(Logic 0)

Q0

Q1

Q2

Q3

¨  Generate any count sequence: ¤  E.g.: design a BCD counter by using a counter w/ parallel load &

async clear

Page 69: 5 Registers

Counting Modulo 6: Synchronously Preset 9 on Reset and Load 9 on Terminal Count 14

¨  A synchronous, 4-bit binary counter with a synchronous Load is to be used to make a Modulo 6 counter.

¨  Use the Load feature to preset the count to 9 on Reset and detection of count 14.

¨  This gives a count of 9, 10, 11, 12, 13, 14, 9, 10, 11, 12, 13, 14, 9, …

¨  If the terminal count is 15 detection is usually built in as Carry Out (CO)

Clock

D3 Q3 D2 Q2 D1 Q1 D0 Q0

CLEAR

CP LOAD

0 0

1

1

Reset

1

Page 70: 5 Registers

Counting Modulo 7: Detect 7 and Asynchronously Clear

¨  A synchronous 4-bit binary counter with an asynchronous Clear is used to make a Modulo 7 counter.

¨  Use the Clear feature to detect the count 7 and clear the count to 0. 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.

¨  DON’T DO THIS! Existence of state 7 may not be long enough to reliably reset all flip-flops to 0. Referred to as a “suicide” counter! (Count “7” is “killed,” but the designer’s job may be dead as well!)

Chapter 7 - Part 2 70

Clock 0

D3 Q3 D2 Q2 D1 Q1 D0 Q0

CLEAR

CP LOAD

Page 71: 5 Registers

Counting Modulo 7: Synchronously Load on Terminal Count of 6

¨  A synchronous 4-bit binary counter with a synchronous load and an asynchronous clear is 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, ...

¨  Using don’t cares for states above 0110, detection of 6 can be done with Load = Q4 Q2

D3 Q3 D2 Q2 D1 Q1 D0 Q0

CLEAR

CP LOAD

Clock

0 0 0 0

Reset

Page 72: 5 Registers

4-bit Shift Register with Reset

72 library ieee; use ieee.std_logic_1164.all; entity srg_4_r is port(CLK, RESET, SI : in std_logic; Q : out std_logic_vector(3 downto 0); SO : out std_logic); end srg_4_r;

Page 73: 5 Registers

4-bit Shift Register with Reset

73

architecture behavioral of srg_4_r is signal shift : std_logic_vector (3 downto 0); begin process (RESET, CLK) begin if (RESET = '1') then shift <= "0000”; elsif (CLK'event and (CLK = '1')) then shift <= shift(2 downto 0) & SI; end if; end process; Q <= shift; SO <= shift(3); end behavioral;

Page 74: 5 Registers

4-bit Binary Counter with Reset

74 library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity count_4_r is port(CLK, RESET, EN : in std_logic; Q : out std_logic_vector(3 downto 0); CO : out std_logic); end count_4_r;

Page 75: 5 Registers

4-bit Binary Counter with Reset

75 architecture behavioral of count_4_r is signal count : std_logic_vector(3 downto 0); begin process (RESET, CLK) begin if (RESET = '1') then count <= "0000”; elsif (CLK'event and (CLK = '1') and (EN = '1')) then count <= count + "0001”; end if; end process; CO <= '1' when count = "1111" and EN = '1' else '0’; Q <= count; end behavioral;