FSM With Datapath

Post on 22-Nov-2014

574 views 0 download

transcript

FINITE STATE MACHINE with DATAPATH

SYNTHESIS

Dr. Le DungHanoi University of Science and Technology

Dr. Le Dung Hanoi University of Science and Technology

FSMD MODELData inputs

Controller Datapath

Data outputsController outputs

Status signals

Control signals

Controller inputs

Datapath performs the computations on data

Controller indicates to the datapath which operations have to be carried out on which data (algorithm)

Dr. Le Dung Hanoi University of Science and Technology

Datapath Design

Temporary storage: registers, (shift registers), counters, register files, FIFOs, LIFOs

Functional units: arithmetic units, logical units and (barrel shifter)

Connections: data busses, multiplexers, tri-state buffers

Shift register (temporary store) Register (temporary store) Barrel shifter (functional unit)

Dr. Le Dung Hanoi University of Science and Technology

Temporary storage

RegisterR

LLoad

Reset

Inputs

Output

C Clock CounterR

LLoad

Reset

Inputs

Output

U/DUp/Down C Clock

RegisterFiles

2n

RE

WE

Read Enable

Inputs

Output

C Clock

Write Enable

RA(n)

WA(n)

Read Address (n bits)

Write Address (n bits)

Dr. Le Dung Hanoi University of Science and Technology

Register Files

Dr. Le Dung Hanoi University of Science and Technology

Functional Units

• Arithmetic units : Adder, Subtractor, Multiplier, Divider

• Logical units : Comparator, AND, OR, XOR …

• Barrel shifter : a digital circuit that can shift a data word by a specified number of bits in one clock cycle.

Dr. Le Dung Hanoi University of Science and Technology

Eight-bit Barrel Shifter

8-bit Barrel shifter

Shift

Number (0-7)

8 bits input

8 bits output

Sh

Nr

Dr. Le Dung Hanoi University of Science and Technology

Generic structure of the Datapath

Temporary storage

External inputs

External outputs

Result switching network

Functional units

Operand switching network

Connections

Connections

Connections

Dr. Le Dung Hanoi University of Science and Technology

Connections in Datapath

OOE

ROE

Outputs

RegisterR

LC Counter

R

LU/D C

RegisterFiles

2n

RE

WE

C

RA(n)

WA(n)

MUX

ComparatorALU Nr

ShF Barrel shifter

Inputs

COE

AOE BOE

< = >

Data busses

Data busses

Tri-buffer

Tri-buffer

k0 k1

S

Dr. Le Dung Hanoi University of Science and Technology

Example 1: Datapath design (1)

Algorithm :

input sum;FOR i = 1 TO 5

input x; sum = sum + x;

ENDFORoutport sum;

Temporary storage:sum Registeri Up counter 5 Registerx Register

Functional units:+ Adder> 5 Comparator

• Each variable and constant corresponds to a register or counter• Each operator corresponds to a functional unit.

Dr. Le Dung Hanoi University of Science and Technology

Example 1: Datapath design (2)

input sum;FOR i = 1 TO 5

input x; sum = sum + x;

ENDFORoutport sum;

• Connect outputs of registers and counter to input of functional units• Connect output of functional units to input of registers and counter

RegisterxL C

Adder

RegistersumL C

Up Counteri

LC

Register= 5L

5

1

1 MUX

Input

Comparator<

Output

6

1

243

C(status)

k0 k1

S

U5

Dr. Le Dung Hanoi University of Science and Technology

Example 1: Controller designInput sum;FOR i = 1 TO 5

input x; sum = sum + x;

ENDFORoutport sum;

State A

1 = 0 k0

State B

1 2=0

State C

1 4=1

3

State D

1 2=1

State E

1 5=1

CState F

1 6=1

01

Start=1

Start=0

1

2

3

4

5

6

Start

C

Clk

Controller

One-hot FSM

D-FF design

Dr. Le Dung Hanoi University of Science and Technology

Example 2: FSMD Design

Dr. Le Dung Hanoi University of Science and Technology

ExerciseThiết kế Datapath cho FSMD thực hiện thuật toán đếm và tính tổng của các số lớn hơn 10 trong các số x đựơc đưa vào như sau:

cnt=0; sum=0;Repeat

input x if (x> 10) then

cnt=cnt + 1; sum=sum + x;end if;

until x =0;output sum; output cnt; Chú ý: 1. 0 ≤ x ≤255, 0≤ sum ≤255.

Các lệnh viết trên cùng 1 hàng được thực hiện song song. 2. Chỉ rõ các thanh ghi trong datapath là bao nhiêu bit.