register transfer methodology i · sequential add-and-shift multiplier. rtl hardware design by p....

68
RTL Hardware Design by P. Chu Chapter 11 1 Register Transfer Methodology I

Upload: others

Post on 03-Apr-2020

7 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Register Transfer Methodology I · Sequential add-and-shift multiplier. RTL Hardware Design by P. Chu Chapter 11 3 1. Introduction •How to realize an algorithm in hardware? •Two

RTL Hardware Design

by P. Chu

Chapter 11 1

Register Transfer

Methodology I

Page 2: Register Transfer Methodology I · Sequential add-and-shift multiplier. RTL Hardware Design by P. Chu Chapter 11 3 1. Introduction •How to realize an algorithm in hardware? •Two

RTL Hardware Design

by P. Chu

Chapter 11 2

Outline

1. Introduction

2. Overview of FSMD

3. FSMD design of a repetitive-addition multiplier

4. Alternative design of a repetitive-addition multiplier

5. Timing and performance analysis of FSMD

6. Sequential add-and-shift multiplier

Page 3: Register Transfer Methodology I · Sequential add-and-shift multiplier. RTL Hardware Design by P. Chu Chapter 11 3 1. Introduction •How to realize an algorithm in hardware? •Two

RTL Hardware Design

by P. Chu

Chapter 11 3

1. Introduction

• How to realize an algorithm in hardware?

• Two characteristics of an algorithm:

– Use of variables (symbolic memory location)

e.g., n = n + 1 in C

– Sequential execution

(execution order is important)

Page 4: Register Transfer Methodology I · Sequential add-and-shift multiplier. RTL Hardware Design by P. Chu Chapter 11 3 1. Introduction •How to realize an algorithm in hardware? •Two

RTL Hardware Design

by P. Chu

Chapter 11 4

• E.g., an algorithm:

– Sum 4 numbers

– Divide the result by 8

– Round the result

• Pseudocode

Page 5: Register Transfer Methodology I · Sequential add-and-shift multiplier. RTL Hardware Design by P. Chu Chapter 11 3 1. Introduction •How to realize an algorithm in hardware? •Two

RTL Hardware Design

by P. Chu

Chapter 11 5

• “Dataflow” implementation in VHDL

– Convert the algorithm in to combinational

circuit

– No memory elements

– The sequence is embedded into the “flow of

data”

Page 6: Register Transfer Methodology I · Sequential add-and-shift multiplier. RTL Hardware Design by P. Chu Chapter 11 3 1. Introduction •How to realize an algorithm in hardware? •Two

RTL Hardware Design

by P. Chu

Chapter 11 6

• VHDL code

Page 7: Register Transfer Methodology I · Sequential add-and-shift multiplier. RTL Hardware Design by P. Chu Chapter 11 3 1. Introduction •How to realize an algorithm in hardware? •Two

RTL Hardware Design

by P. Chu

Chapter 11 7

• Block diagram

Page 8: Register Transfer Methodology I · Sequential add-and-shift multiplier. RTL Hardware Design by P. Chu Chapter 11 3 1. Introduction •How to realize an algorithm in hardware? •Two

RTL Hardware Design

by P. Chu

Chapter 11 8

• Problems with dataflow implementation:

– Can only be applied to trivial algorithm

– Not flexible

• Can we just share one adder in a time-

multiplexing fashion to save hardware

resources?

• What happen if input size is not fixed?

(i.e., size is determined by an external input)

Page 9: Register Transfer Methodology I · Sequential add-and-shift multiplier. RTL Hardware Design by P. Chu Chapter 11 3 1. Introduction •How to realize an algorithm in hardware? •Two

RTL Hardware Design

by P. Chu

Chapter 11 9

Register Transfer Methodology

• Realized algorithm in hardware

• Use register to store intermediate data and

simulate variables

• Use a datapath to realize all register

operations

• Use a control path (FSM) to specify the

order of register operation

Page 10: Register Transfer Methodology I · Sequential add-and-shift multiplier. RTL Hardware Design by P. Chu Chapter 11 3 1. Introduction •How to realize an algorithm in hardware? •Two

RTL Hardware Design

by P. Chu

Chapter 11 10

• The system is specified as sequence of

data manipulation/transfer among

registers

• Realized by FSM with a datapath (FSMD)

Page 11: Register Transfer Methodology I · Sequential add-and-shift multiplier. RTL Hardware Design by P. Chu Chapter 11 3 1. Introduction •How to realize an algorithm in hardware? •Two

RTL Hardware Design

by P. Chu

Chapter 11 11

2. Overview of FSMD

Page 12: Register Transfer Methodology I · Sequential add-and-shift multiplier. RTL Hardware Design by P. Chu Chapter 11 3 1. Introduction •How to realize an algorithm in hardware? •Two

RTL Hardware Design

by P. Chu

Chapter 11 12

Basic RT operation

• Basic form:

• Interpretation:

– At the rising edge of the clock, the output of

registers rsrc1 rsrc2 . etc are available

– The output are passed to a combinational

circuit that performs f( )

– At the next rising edge of the clock, the result

is stored into rdest

Page 13: Register Transfer Methodology I · Sequential add-and-shift multiplier. RTL Hardware Design by P. Chu Chapter 11 3 1. Introduction •How to realize an algorithm in hardware? •Two

RTL Hardware Design

by P. Chu

Chapter 11 13

• E.g.,

Page 14: Register Transfer Methodology I · Sequential add-and-shift multiplier. RTL Hardware Design by P. Chu Chapter 11 3 1. Introduction •How to realize an algorithm in hardware? •Two

RTL Hardware Design

by P. Chu

Chapter 11 14

• Implementation example

Page 15: Register Transfer Methodology I · Sequential add-and-shift multiplier. RTL Hardware Design by P. Chu Chapter 11 3 1. Introduction •How to realize an algorithm in hardware? •Two

RTL Hardware Design

by P. Chu

Chapter 11 15

• Multiple RT operations

Page 16: Register Transfer Methodology I · Sequential add-and-shift multiplier. RTL Hardware Design by P. Chu Chapter 11 3 1. Introduction •How to realize an algorithm in hardware? •Two

RTL Hardware Design

by P. Chu

Chapter 11 16

FSM as control path

• Why FSM to control RT operation

– State transition is on clock-by-clock basis

– FSM can enforce order of execution

– FSM allows branches on execution sequence

• Normally represented in an extended ASM

chart known as ASMD (ASM with

datapath) chart

Page 17: Register Transfer Methodology I · Sequential add-and-shift multiplier. RTL Hardware Design by P. Chu Chapter 11 3 1. Introduction •How to realize an algorithm in hardware? •Two

RTL Hardware Design

by P. Chu

Chapter 11 17

• E.g.

• Note: new value of r1 is only available when the

FSM exits s1state

Page 18: Register Transfer Methodology I · Sequential add-and-shift multiplier. RTL Hardware Design by P. Chu Chapter 11 3 1. Introduction •How to realize an algorithm in hardware? •Two

RTL Hardware Design

by P. Chu

Chapter 11 18

Basic Block Diagram of FSMD

Page 19: Register Transfer Methodology I · Sequential add-and-shift multiplier. RTL Hardware Design by P. Chu Chapter 11 3 1. Introduction •How to realize an algorithm in hardware? •Two

RTL Hardware Design

by P. Chu

Chapter 11 19

3. FSMD design example:

Repetitive addition multiplier

• Basic algorithm: 7*5 = 7+7+7+7+7

• Pseudo code

Page 20: Register Transfer Methodology I · Sequential add-and-shift multiplier. RTL Hardware Design by P. Chu Chapter 11 3 1. Introduction •How to realize an algorithm in hardware? •Two

RTL Hardware Design

by P. Chu

Chapter 11 20

• ASMD-friendly code

Page 21: Register Transfer Methodology I · Sequential add-and-shift multiplier. RTL Hardware Design by P. Chu Chapter 11 3 1. Introduction •How to realize an algorithm in hardware? •Two

RTL Hardware Design

by P. Chu

Chapter 11 21

• Input:– a_in, b_in: 8-bit unsigned

– clk, reset

– start: command

• Output:– r: 16-bit unsigned

– ready: status

• ASMD chart– Default RT operation: keep the previous value

– Note the parallel execution in op state

Page 22: Register Transfer Methodology I · Sequential add-and-shift multiplier. RTL Hardware Design by P. Chu Chapter 11 3 1. Introduction •How to realize an algorithm in hardware? •Two

RTL Hardware Design

by P. Chu

Chapter 11 22

• Construction of the data path

– List all RT operations

– Group RT operation according to the destination register

– Add combinational circuit/mux

– Add status circuits

• E.g

Page 23: Register Transfer Methodology I · Sequential add-and-shift multiplier. RTL Hardware Design by P. Chu Chapter 11 3 1. Introduction •How to realize an algorithm in hardware? •Two

RTL Hardware Design

by P. Chu

Chapter 11 23

• E.g., Circuit associated with r register

Page 24: Register Transfer Methodology I · Sequential add-and-shift multiplier. RTL Hardware Design by P. Chu Chapter 11 3 1. Introduction •How to realize an algorithm in hardware? •Two

RTL Hardware Design

by P. Chu

Chapter 11 24

Page 25: Register Transfer Methodology I · Sequential add-and-shift multiplier. RTL Hardware Design by P. Chu Chapter 11 3 1. Introduction •How to realize an algorithm in hardware? •Two

RTL Hardware Design

by P. Chu

Chapter 11 25

• VHDL code: follow the block diagram

Page 26: Register Transfer Methodology I · Sequential add-and-shift multiplier. RTL Hardware Design by P. Chu Chapter 11 3 1. Introduction •How to realize an algorithm in hardware? •Two

RTL Hardware Design

by P. Chu

Chapter 11 26

Page 27: Register Transfer Methodology I · Sequential add-and-shift multiplier. RTL Hardware Design by P. Chu Chapter 11 3 1. Introduction •How to realize an algorithm in hardware? •Two

RTL Hardware Design

by P. Chu

Chapter 11 27

Page 28: Register Transfer Methodology I · Sequential add-and-shift multiplier. RTL Hardware Design by P. Chu Chapter 11 3 1. Introduction •How to realize an algorithm in hardware? •Two

RTL Hardware Design

by P. Chu

Chapter 11 28

Page 29: Register Transfer Methodology I · Sequential add-and-shift multiplier. RTL Hardware Design by P. Chu Chapter 11 3 1. Introduction •How to realize an algorithm in hardware? •Two

RTL Hardware Design

by P. Chu

Chapter 11 29

Page 30: Register Transfer Methodology I · Sequential add-and-shift multiplier. RTL Hardware Design by P. Chu Chapter 11 3 1. Introduction •How to realize an algorithm in hardware? •Two

RTL Hardware Design

by P. Chu

Chapter 11 30

Page 31: Register Transfer Methodology I · Sequential add-and-shift multiplier. RTL Hardware Design by P. Chu Chapter 11 3 1. Introduction •How to realize an algorithm in hardware? •Two

RTL Hardware Design

by P. Chu

Chapter 11 31

• Use of register in decision box– Register is updated when the FSM exits current state

– How to represent count_0=‘1’ using register?

Page 32: Register Transfer Methodology I · Sequential add-and-shift multiplier. RTL Hardware Design by P. Chu Chapter 11 3 1. Introduction •How to realize an algorithm in hardware? •Two

RTL Hardware Design

by P. Chu

Chapter 11 32

• Other VHDL coding styles:

– Various code segments can be combined

– Should always separate registers from

combinational logic

– May be a good idea to isolate the main

functional units

Page 33: Register Transfer Methodology I · Sequential add-and-shift multiplier. RTL Hardware Design by P. Chu Chapter 11 3 1. Introduction •How to realize an algorithm in hardware? •Two

RTL Hardware Design

by P. Chu

Chapter 11 33

• E.g., 2-segment code

Page 34: Register Transfer Methodology I · Sequential add-and-shift multiplier. RTL Hardware Design by P. Chu Chapter 11 3 1. Introduction •How to realize an algorithm in hardware? •Two

RTL Hardware Design

by P. Chu

Chapter 11 34

Page 35: Register Transfer Methodology I · Sequential add-and-shift multiplier. RTL Hardware Design by P. Chu Chapter 11 3 1. Introduction •How to realize an algorithm in hardware? •Two

RTL Hardware Design

by P. Chu

Chapter 11 35

Page 36: Register Transfer Methodology I · Sequential add-and-shift multiplier. RTL Hardware Design by P. Chu Chapter 11 3 1. Introduction •How to realize an algorithm in hardware? •Two

RTL Hardware Design

by P. Chu

Chapter 11 36

4. Alternative design of a repetitive-

addition multiplier

• Resource sharing

– Hardware can be shared in a time-multiplexing fashion

– Assign the operation in different states

– Most complex circuits in the FSMD design is normally the functional units of the datapath

• Sharing in repetitive addition multiplier

– Addition and decrementing

– The same adder can be used in 2 states

Page 37: Register Transfer Methodology I · Sequential add-and-shift multiplier. RTL Hardware Design by P. Chu Chapter 11 3 1. Introduction •How to realize an algorithm in hardware? •Two

RTL Hardware Design

by P. Chu

Chapter 11 37

Page 38: Register Transfer Methodology I · Sequential add-and-shift multiplier. RTL Hardware Design by P. Chu Chapter 11 3 1. Introduction •How to realize an algorithm in hardware? •Two

RTL Hardware Design

by P. Chu

Chapter 11 38

Page 39: Register Transfer Methodology I · Sequential add-and-shift multiplier. RTL Hardware Design by P. Chu Chapter 11 3 1. Introduction •How to realize an algorithm in hardware? •Two

RTL Hardware Design

by P. Chu

Chapter 11 39

Page 40: Register Transfer Methodology I · Sequential add-and-shift multiplier. RTL Hardware Design by P. Chu Chapter 11 3 1. Introduction •How to realize an algorithm in hardware? •Two

RTL Hardware Design

by P. Chu

Chapter 11 40

Page 41: Register Transfer Methodology I · Sequential add-and-shift multiplier. RTL Hardware Design by P. Chu Chapter 11 3 1. Introduction •How to realize an algorithm in hardware? •Two

RTL Hardware Design

by P. Chu

Chapter 11 41

Page 42: Register Transfer Methodology I · Sequential add-and-shift multiplier. RTL Hardware Design by P. Chu Chapter 11 3 1. Introduction •How to realize an algorithm in hardware? •Two

RTL Hardware Design

by P. Chu

Chapter 11 42

• Mealy-controlled operation

– Control signals is edge-sensitive

– Mealy output is faster and requires fewer states

– E.g.,

Page 43: Register Transfer Methodology I · Sequential add-and-shift multiplier. RTL Hardware Design by P. Chu Chapter 11 3 1. Introduction •How to realize an algorithm in hardware? •Two

RTL Hardware Design

by P. Chu

Chapter 11 43

• Mealy control signal

for multiplier

– load and ab0 states

perform no

computation

– Mealy control can

be used to

eliminate ab0 and

load states

Page 44: Register Transfer Methodology I · Sequential add-and-shift multiplier. RTL Hardware Design by P. Chu Chapter 11 3 1. Introduction •How to realize an algorithm in hardware? •Two

RTL Hardware Design

by P. Chu

Chapter 11 44

• r, n, b register

loaded using Mealy

signal

Page 45: Register Transfer Methodology I · Sequential add-and-shift multiplier. RTL Hardware Design by P. Chu Chapter 11 3 1. Introduction •How to realize an algorithm in hardware? •Two

RTL Hardware Design

by P. Chu

Chapter 11 45

Page 46: Register Transfer Methodology I · Sequential add-and-shift multiplier. RTL Hardware Design by P. Chu Chapter 11 3 1. Introduction •How to realize an algorithm in hardware? •Two

RTL Hardware Design

by P. Chu

Chapter 11 46

5. Clock rate and Performance

of FSMD

• Maximal clock rate

– More difficult to analyze because of two

interactive loops

– The boundary of the clock rate can be found

Page 47: Register Transfer Methodology I · Sequential add-and-shift multiplier. RTL Hardware Design by P. Chu Chapter 11 3 1. Introduction •How to realize an algorithm in hardware? •Two

RTL Hardware Design

by P. Chu

Chapter 11 47

• Best-case scenario:

– Control signals needed at late stage

– Status signal available at early stage

Page 48: Register Transfer Methodology I · Sequential add-and-shift multiplier. RTL Hardware Design by P. Chu Chapter 11 3 1. Introduction •How to realize an algorithm in hardware? •Two

RTL Hardware Design

by P. Chu

Chapter 11 48

Page 49: Register Transfer Methodology I · Sequential add-and-shift multiplier. RTL Hardware Design by P. Chu Chapter 11 3 1. Introduction •How to realize an algorithm in hardware? •Two

RTL Hardware Design

by P. Chu

Chapter 11 49

• Worst-case scenario:

– Control signals needed at early stage

– Status signal available at late stage

Page 50: Register Transfer Methodology I · Sequential add-and-shift multiplier. RTL Hardware Design by P. Chu Chapter 11 3 1. Introduction •How to realize an algorithm in hardware? •Two

RTL Hardware Design

by P. Chu

Chapter 11 50

Page 51: Register Transfer Methodology I · Sequential add-and-shift multiplier. RTL Hardware Design by P. Chu Chapter 11 3 1. Introduction •How to realize an algorithm in hardware? •Two

RTL Hardware Design

by P. Chu

Chapter 11 51

Page 52: Register Transfer Methodology I · Sequential add-and-shift multiplier. RTL Hardware Design by P. Chu Chapter 11 3 1. Introduction •How to realize an algorithm in hardware? •Two

RTL Hardware Design

by P. Chu

Chapter 11 52

• Performance of FSMD

– Tc: Clock period

– K: # clock cycles to compete the computation

– Total time = K * Tc

• K determined by algorithm, input patterns

etc.

Page 53: Register Transfer Methodology I · Sequential add-and-shift multiplier. RTL Hardware Design by P. Chu Chapter 11 3 1. Introduction •How to realize an algorithm in hardware? •Two

RTL Hardware Design

by P. Chu

Chapter 11 53

• 8-bit input

– Best: b=0, K=2

– Worst: b=255, K=257

• N-bit input:

– Worst:

K = 2+(2N-1)

Page 54: Register Transfer Methodology I · Sequential add-and-shift multiplier. RTL Hardware Design by P. Chu Chapter 11 3 1. Introduction •How to realize an algorithm in hardware? •Two

RTL Hardware Design

by P. Chu

Chapter 11 54

• 8-bit input

– Best: b=0, K=2

– Worst: b=255,

K=2 + 255*2

• N-bit input:

– Worst:

K=2+2*(2N-1)

Page 55: Register Transfer Methodology I · Sequential add-and-shift multiplier. RTL Hardware Design by P. Chu Chapter 11 3 1. Introduction •How to realize an algorithm in hardware? •Two

RTL Hardware Design

by P. Chu

Chapter 11 55

6. Sequential add-and-shift

multiplier

Page 56: Register Transfer Methodology I · Sequential add-and-shift multiplier. RTL Hardware Design by P. Chu Chapter 11 3 1. Introduction •How to realize an algorithm in hardware? •Two

RTL Hardware Design

by P. Chu

Chapter 11 56

Page 57: Register Transfer Methodology I · Sequential add-and-shift multiplier. RTL Hardware Design by P. Chu Chapter 11 3 1. Introduction •How to realize an algorithm in hardware? •Two

RTL Hardware Design

by P. Chu

Chapter 11 57

Page 58: Register Transfer Methodology I · Sequential add-and-shift multiplier. RTL Hardware Design by P. Chu Chapter 11 3 1. Introduction •How to realize an algorithm in hardware? •Two

RTL Hardware Design

by P. Chu

Chapter 11 58

• Note the use of

b_next and n_next

• a<<1 and b>>1

require no logic

• 8-bit input

– Best: b=0,

K = 1 + 8

– Worst: b=255,

K = 1 + 8*2

• N-bit input:

– Worst:

K=2+2*n

Page 59: Register Transfer Methodology I · Sequential add-and-shift multiplier. RTL Hardware Design by P. Chu Chapter 11 3 1. Introduction •How to realize an algorithm in hardware? •Two

RTL Hardware Design

by P. Chu

Chapter 11 59

Page 60: Register Transfer Methodology I · Sequential add-and-shift multiplier. RTL Hardware Design by P. Chu Chapter 11 3 1. Introduction •How to realize an algorithm in hardware? •Two

RTL Hardware Design

by P. Chu

Chapter 11 60

Page 61: Register Transfer Methodology I · Sequential add-and-shift multiplier. RTL Hardware Design by P. Chu Chapter 11 3 1. Introduction •How to realize an algorithm in hardware? •Two

RTL Hardware Design

by P. Chu

Chapter 11 61

Page 62: Register Transfer Methodology I · Sequential add-and-shift multiplier. RTL Hardware Design by P. Chu Chapter 11 3 1. Introduction •How to realize an algorithm in hardware? •Two

RTL Hardware Design

by P. Chu

Chapter 11 62

• Refinement

– No major computation done in the shift state:

the add and shift states can be merged

– Data path can be simplified:

• Replace 2n-bit adder with (n+1)-bit adder

• Reduce the a register from 2n bits to n bits

• Use the lower part of the p register to store B and

eliminate the b register

Page 63: Register Transfer Methodology I · Sequential add-and-shift multiplier. RTL Hardware Design by P. Chu Chapter 11 3 1. Introduction •How to realize an algorithm in hardware? •Two

RTL Hardware Design

by P. Chu

Chapter 11 63

Page 64: Register Transfer Methodology I · Sequential add-and-shift multiplier. RTL Hardware Design by P. Chu Chapter 11 3 1. Introduction •How to realize an algorithm in hardware? •Two

RTL Hardware Design

by P. Chu

Chapter 11 64

Page 65: Register Transfer Methodology I · Sequential add-and-shift multiplier. RTL Hardware Design by P. Chu Chapter 11 3 1. Introduction •How to realize an algorithm in hardware? •Two

RTL Hardware Design

by P. Chu

Chapter 11 65

Page 66: Register Transfer Methodology I · Sequential add-and-shift multiplier. RTL Hardware Design by P. Chu Chapter 11 3 1. Introduction •How to realize an algorithm in hardware? •Two

RTL Hardware Design

by P. Chu

Chapter 11 66

Page 67: Register Transfer Methodology I · Sequential add-and-shift multiplier. RTL Hardware Design by P. Chu Chapter 11 3 1. Introduction •How to realize an algorithm in hardware? •Two

RTL Hardware Design

by P. Chu

Chapter 11 67

• FSMD (Circuit for general seq. algorithms)

– Regular seq. cir. (datapath) and FSM (control)

– Design procedure: ASMD (RT operations)

– RT operations: take place on state trans.

• Timing

– Two coupled loops – bounds

• Examples

– Repetitive adder multiplier

– Shift multiplier

– Refinements

Summary

Page 68: Register Transfer Methodology I · Sequential add-and-shift multiplier. RTL Hardware Design by P. Chu Chapter 11 3 1. Introduction •How to realize an algorithm in hardware? •Two

RTL Hardware Design

by P. Chu

Chapter 11 68

• Separate registers from comb. circuits

– Multi-segment/two-segment style

• RT operation is delayed store

– RT assignment is next value

– Careful about use of register in a decision box

• Functional units

– Dominant components

– For more control, isolate from rest of code

• Separate out control path

– Useful for optimizing FSM

Guidelines