Вы находитесь на странице: 1из 56

Secuenciales III

(Metodología de Diseño)
Diseño de Sistemas con FPGA
Patricia Borensztejn
Revisado 05/2013
Modelado de Sistemas
Secuenciales
• Según la función del siguiente estado se dividen
en:
– Circuitos secuenciales regulares: el estado siguiente
se construye con un incrementador o un shifter
– FSM (Finite State Machines): el estado siguiente no
exhibe un pattern repetitivo, sino mas bien random.
– FSMD (FSM with Data Path): combina los dos tipos
anteriores de sistemas secuenciales, es decir, está
compuesto por dos partes:
• FSM: llamado “control path” es el encargado de examinar las
entradas externas y de generar las señales para el
funcionamiento de los
• Circuitos secuenciales regulares: llamado “data path”.
Algoritmos
• 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)

RTL Hardware Design Chapter 11 3


by P. Chu
• E.g., an algorithm:
– Summate 4 number
– Divide the result by 8
– Round the result
• Pseudocode

RTL Hardware Design Chapter 11 4


by P. Chu
• “Dataflow” implementation in VHDL
– Convert the algorithm in to combinational
circuit
– No memory elements
– The sequence is embedded into the “flow of
data”

RTL Hardware Design Chapter 11 5


by P. Chu
• VHDL code

RTL Hardware Design Chapter 11 6


by P. Chu
• Block diagram

RTL Hardware Design Chapter 11 7


by P. Chu
• 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)

RTL Hardware Design Chapter 11 8


by P. Chu
Algoritmos en Hardware
• Necesitamos construcciones hardware
que se parezcan a las variables y al
modelo secuencial de ejecución.
• La Metodología de transferencia de
registros (RT methodology) sirve a este
propósito.
Register Transfer Methodology
• Realizan los algoritmos en hardware
• Usan registros para almacenar datos
intermedios imitando a las variables
• Usan un camino de datos (Data Path)
para realizar todas las operaciones entre
registros
• Usan un camino de control (control path)
para especificar el “orden” en que estas
operaciones deben realizarse
RTL Hardware Design Chapter 11 10
by P. Chu
Register Transfer Methodology
• The system is specified as sequence of
data manipulation/transfer among
registers
• Realized by FSM with a datapath (FSMD)

RTL Hardware Design Chapter 11 11


by P. Chu
FSMD

RTL Hardware Design Chapter 11 12


by P. Chu
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

RTL Hardware Design Chapter 11 13


by P. Chu
Los Registros
• A diferencia de los registros dedicados que
hemos utilizado para los circuitos secuenciales
regulares, como por ejemplo un contador, en
esta metodología los registros se usan como
almacenamiento de propósito general y
almacenan valores temporales, justamente
como las variables de un algoritmo.
• La mas importante diferencia entre una variable
y un registro es que en una operación RT está
implícito el reloj del sistema
En nuestra notación seria…
La función f()

• La funcion f() puede ser cualquier


expresión que pueda ser realizada por un
circuito combinacional.
Ejempos

• E.g.,

RTL Hardware Design Chapter 11 17


by P. Chu
• Implementation example

RTL Hardware Design Chapter 11 18


by P. Chu
Múltiples valores para un
registro
• A lo largo de un algoritmo, un mismo
registro puede tomar distintos valores en
distintos momentos
• Multiple RT operations

RTL Hardware Design Chapter 11 20


by P. Chu
FSM as control path
• FSM is a good 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

RTL Hardware Design Chapter 11 21


by P. Chu
RTL, FSM y ASM
• Como cada operación RT se realiza en cada
flanco de reloj, su temporización es similar a la
de un FSM y por lo tanto en cada estado
podemos representar las operaciones RT.
• Recordemos que:
– Las máquinas de estado finito (FSM) se pueden
representar de dos maneras:
• Mediante Diagramas de Estado (lo que venimos usando
hasta ahora) (FSM)
• Mediante Diagramas Algoritmicos de Estado (ASM)
ASM
• Un diagrama ASM (Algorithmic State Machine)
está formado por una red de bloques.
• Cada bloque contiene:
– State Box: en cuyo interior pondremos el valor las
salidas de Moore. Corresponde a los estados de la
representación FSM, pero a diferencia de estos, los
State Box tienen una única salida
– Decision Box: Testea la entrada y determina el
camino a tomar. Tiene dos caminos de salida: el
camino T(rue) y el camino F(alse)
– Conditional Output Box: corresponde a las salidas de
Mealy, que se activaran unicamente cuando se de la
condición
FSM y ASM
Ejemplo: FSM y ASM
ASMD
• Usaremos ASM para especificar
estos sistemas mas complejos
descritos con RTL, y los
llamaremos ASMD (ASM con
DataPath)
• Las operaciones RT se ubican en
el mismo lugar que ubicábamos las
salidas (Moore y Mealy)
• Veamos un nodo ASMD y el
circuito combinacional que lo
implementa.
• Algunas observaciones
importantes:
– Estamos mezclando salidas de
Moore con salidas de Mealy. Esto
también se puede hacer con los
FSM
– Los registros se actualizan cuando
el FSMD sale del bloque!
Delayed Store

• Debido a que los registros se


actualizan al salir del bloque, hay
que tener mucho cuidado cuando
especificamos condiciones que
dependen de los valores
almacenados.

• La inscripción rr-1 significa:


r_next=r_reg-1
r_reg r_next cuando se de el flanco
del reloj
FSMD: Finite State Machine con
Data Path
• Control Path, FSM
conteniendo:
– Registro de estado
– Salida
– Siguiente Estado
• Data Path, realiza las
operaciones RT y contiene:
– Registros para los datos
– Unidades funcionales donde
se computan las
operaciones
– Ruteo entre los datos y las
unidades funcionales
• Son dos tipos de sistemas
secuenciales pero ambos
están controlados por el
mismo reloj.
Basic Block Diagram of FSMD

RTL Hardware Design Chapter 11 29


by P. Chu
3. FSMD design example:
Repetitive addition multiplier
• Basic algorithm: 7*5 = 7+7+7+7+7
• Pseudo code

RTL Hardware Design Chapter 11 30


by P. Chu
• ASMD-friendly code

RTL Hardware Design Chapter 11 31


by P. Chu
• 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
RTL Hardware Design Chapter 11 32
by P. Chu
Comentarios
• Observar que dentro de las cajitas de
decisión están las entradas , que pueden
ser externas o bien generadas en el
camino de datos
• Observar también que no se han utilizado
registros en las cajitas de decisión, esto
es posible, pero hay que tener cuidado
con los valores retardados (delay)
Construcción del FSMD
1. Construcción del grafico ASMD
2. Del ASMD, derivar el Camino de Control
y el de Datos:
 Camino de Control:
 Entradas: start, a_is_0, b_is_0, count_0
 Salidas: ready, señales de operación para los
registros (se usa el mismo estado)
 Código para cambio de estado directamente sale
del gráfico
Camino de Datos
 List all RT operations
 Group RT operation according to the destination register
 Add combinational circuit/mux
 Add status circuits

RTL Hardware Design Chapter 11 35


by P. Chu
• E.g., Circuit associated with r register

RTL Hardware Design Chapter 11 36


by P. Chu
RTL Hardware Design Chapter 11 37
by P. Chu
• VHDL code: follow the block diagram

RTL Hardware Design Chapter 11 38


by P. Chu
RTL Hardware Design Chapter 11 39
by P. Chu
RTL Hardware Design Chapter 11 40
by P. Chu
RTL Hardware Design Chapter 11 41
by P. Chu
RTL Hardware Design Chapter 11 42
by P. Chu
RTL Hardware Design Chapter 11 43
by P. Chu
• 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

RTL Hardware Design Chapter 11 44


by P. Chu
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

RTL Hardware Design Chapter 11 45


by P. Chu
RTL Hardware Design Chapter 11 46
by P. Chu
RTL Hardware Design Chapter 11 47
by P. Chu
RTL Hardware Design Chapter 11 48
by P. Chu
RTL Hardware Design Chapter 11 49
by P. Chu
• Mealy-controlled operation
– Control signals is edge-sensitive
– Mealy output is faster and requires fewer states
– E.g.,

RTL Hardware Design Chapter 11 50


by P. Chu
• Mealy control signal
for multiplier
– load and ab0 states
perform no
computation
– Mealy control can
be used to
eliminate ab0 and
load states

RTL Hardware Design Chapter 11 51


by P. Chu
• r, n, b register
loaded using Mealy
signal

RTL Hardware Design Chapter 11 52


by P. Chu
RTL Hardware Design Chapter 11 53
by P. Chu
Fibonacci
Int fibonacci (int i) {
int t0 =0;
int t1 =1;
int tmp =0;
int n =i;
while (n>2) {
tmp=t1;
t1=t1 + t0;
t0=tmp;
n=n-1;
}
If (n==0) t1=0;
}
Fibonacci
Fibonacci

• Se utilizan tres registros. Dos temporales para


almacenar fib (i-1) y fib(i-2) y un índice (n)
• La entrada es i
• La salida es f
• Se incluyen otras señales:
– Start
– Ready
– Done_tick

Вам также может понравиться