Está en la página 1de 127

INTRODUCCIN AL

LENGUAJE VHDL

eman ta zabal zazu

LDD 2007-08 1
NDICE.
Introduccin.
1. Conceptos bsicos del lenguaje y
Aplicaciones.
2. Tipos de datos y Seales.
3. Sentencias concurrentes y secuenciales.
4. Registros y mquinas de estados finitos.

eman ta zabal zazu

LDD 2007-08 2
Bibliografa:
- VHDL Lenguaje estndar de diseo electrnico.
Llus Ters, Yago Torroja, Serafn Olcoz, Eugenio Villar.
Ed, Mc Graw-Hill, 1998

- VHDL Modeling for Digital Design Synthesis


Yu-Chin Hsu, Kevin F. Tsai, Jessie T. Liu, Eric S.Lin.
Ed, Kluwer Academic Publishers, 1995

- Hardware Design and Simulation in VAL / VHDL.


Larry M. Augustin, David C. Luckham, beniot A. Gennart,
Youmth Huh, Alec G. Stanculescu.
Ed, Kluwer Academic Publishers, 1991.

- VHDL Designers Reference.


Jean Michel Berg, Alain Fonkova, Serge Maginot,
Jacques Rovillard.
Kluwer Academic Publishers, 1992

eman ta zabal zazu

LDD 2007-08 3
PROCESO BSICO DE DISEO
Requisitos y Altera
especificaciones
Diseo modelo VHDL

Diseo Funcional
Compilacin

Diseo
Modelado Arquitectural (RTL)
Simulacin
y
Sntesis Diseo Lgico
(puertas) Anlisis de Timing

Diseo Fsico
(transistores-layout) Configuracin del PLD

eman ta zabal zazu


Fabricacin Programacin del PLD
y Test LDD 2007-08 y Test 4
Estas etapas son funcin de las distintas
alternativas de diseo.
Por analoga PROGRAMACIN se busca
SNTESIS DE ALTO NIVEL
Chip desde una descripcin de alto nivel

Imprescindible los lenguajes HDL-- VHDL

eman ta zabal zazu

LDD 2007-08 5
BREVE HISTORIA: EL LENGUAJE
VHDL

VHDL:
(Very HIGH Speed Integrated Circuit Hardware Description
Language)
proyecto del departamento de defensa de los E.E.U.U. para
desarrollar C.I. de 0,5m de muy altas prestaciones.

Objetivo: disponer de una herramienta estndar e independiente


para la especificacin y documentacin de sistemas electrnicos.

eman ta zabal zazu

LDD 2007-08 6
PROPIEDADES
BSICAS.

Permite modelar, y simular sistemas desde un alto nivel de


abstraccin hasta el nivel ms bajo (puertas, biestables).

Bsicamente permite 3 niveles de descripcin:


Comportamental o algortmico
Flujo de datos o RTL
Estructural

Inicialmente desarrollado para modelado y simulacin lgica de


sistemas digitales. Actualmente se usa tambin para sntesis.

eman ta zabal zazu

LDD 2007-08 7
Ventajas del uso de VHDL
Es un lenguaje normalizado compatible con la mayora de las
herramientas de diseo (Std IEEE 1076-1987)

Permite la comunicacin entre distintos diseadores minimizando


errores y problemas de compatibilidad.

Admite diseo jerrquico.

Los sistemas de prueba (test) pueden escribirse en el mismo


lenguaje y usarse para comprobar distintos modelos.

Permite al diseador concentrase en la funcionalidad del diseo


sin tener que preocuparse en otros factores como: retardos,
rea,...

eman ta zabal zazu

LDD 2007-08 8
Otras Ventajas

Reduccin del Tiempo de Diseo.


Mejora de la Calidad del Diseo.
Posibilidad de Explorar el Espacio de Diseo.
Tecnologa VLSI/diseo electrnico abierta a un
mayor nmero de usuarios con poca experiencia.

eman ta zabal zazu

LDD 2007-08 9
Sntesis de hardware
descripcin funcional
process descripcin estructural
begin
for I in 0 to 10 loop
:::
end loop; Sntesis
end process;

Proceso de Transformacin de una descripcin


funcional de un circuito en una descripcin
estructural:
Nivel de Transferencias entre registros.
eman ta zabal zazu
Layout (Caso Ideal)
LDD 2007-08 10
Proceso de Sntesis
Ejemplo de Descripcin:

function Paridad (Inp:std_logic_vector(2 downto 0))


return bit is
variable Par:bit;
begin Inp
Par := 1; 3
for I in 1 to 3 loop
if Inp(I) = 1 then Par := not Par;
Paridad
endif;
end loop;
return Par;
end Paridad;

eman ta zabal zazu


Par
LDD 2007-08 11
Sintesis de Alto Nivel
process Funcin
begin
for I in 0 to 10 Objetivo
loop
:::
end loop;
end process;

Sntesis
Restricciones

Funcin Objetivo: Una funcin de :


Estimacin del rea.
Retardos del Circuito
Restricciones: Condiciones que debe cumplir el
circuito. (p.e. Area estimada < X. Retardo < Y...)
eman ta zabal zazu

LDD 2007-08 12
1.Aplication and language Introduction
- What is VHDL ?
- Aplication areas
- Limitations of VHDL
- VHDL styles
- Main laguages concepts
- Entity
- Architecture
- Hierarchy
- Declaration
- Processes and types
- Packages

eman ta zabal zazu

LDD 2007-08 13
What is VHDL?

eman ta zabal zazu

LDD 2007-08 14
Limitations

eman ta zabal zazu

LDD 2007-08 15
eman ta zabal zazu

LDD 2007-08 16
VHDL Styles

eman ta zabal zazu

LDD 2007-08 17
eman ta zabal zazu

LDD 2007-08 18
eman ta zabal zazu

LDD 2007-08 19
eman ta zabal zazu

LDD 2007-08 20
eman ta zabal zazu

LDD 2007-08 21
Entity

eman ta zabal zazu

LDD 2007-08 22
Architecture

eman ta zabal zazu

LDD 2007-08 23
eman ta zabal zazu

LDD 2007-08 24
eman ta zabal zazu

LDD 2007-08 25
eman ta zabal zazu

LDD 2007-08 26
eman ta zabal zazu

LDD 2007-08 27
eman ta zabal zazu

LDD 2007-08 28
eman ta zabal zazu

LDD 2007-08 29
eman ta zabal zazu

LDD 2007-08 30
Processes

eman ta zabal zazu

LDD 2007-08 31
eman ta zabal zazu

LDD 2007-08 32
Types

eman ta zabal zazu

LDD 2007-08 33
The package

eman ta zabal zazu

LDD 2007-08 34
eman ta zabal zazu

LDD 2007-08 35
2. Signals and Data Types
- The concept of a type
- Standard data types
- Assignments to signals
- Type definition
- Multi valued logic
- Standard Logic
- Using Standard Logic
VHDL Operators
- Logical Operators
- Relational Operators
- Arithmetic Operators
eman ta zabal zazu

LDD 2007-08 36
Type definition

eman ta zabal zazu

LDD 2007-08 37
Type definition

eman ta zabal zazu

LDD 2007-08 38
Type concept and specification

eman ta zabal zazu

LDD 2007-08 39
eman ta zabal zazu

LDD 2007-08 40
eman ta zabal zazu

LDD 2007-08 41
eman ta zabal zazu

LDD 2007-08 42
eman ta zabal zazu

LDD 2007-08 43
Type std_logic is (
U, Uninitiliced
X Unknown
0 Logic 0 Strong drive
1 logic 1
Z high
impedance
W Unknown Weak drive
L logic 0
H logic 1
_ Dont care

eman ta zabal zazu

LDD 2007-08 44
eman ta zabal zazu

LDD 2007-08 45
eman ta zabal zazu

LDD 2007-08 46
Using Standard Logic

library IEEE;
use IEEE.Std_logic_1164.all;

entity MULS is
port ( A, B, : in std_logic ;
Z : out std_logic );
end MULS;

eman ta zabal zazu

LDD 2007-08 47
OPERADORES EN VHDL

Existen 3 tipos predefinidos:


Operadores lgicos
Operadores matemticos
Operadores relacionales
Por defecto, cada operador puede usarse con cierto tipo
de datos.
El usuario puede definir funciones si precisa usar otros
tipos.

eman ta zabal zazu

LDD 2007-08 48
OPERADORES LGICOS
Son los siguientes:
AND, NAND, OR, NOR
XOR, XNOR
NOT
Adems de desplazamientos lgicos/aritmticos
izda/dcha y rotaciones: SLL, SRL, SLA, SRA, ROL,
ROR.
Todos misma prioridad (de izda a dcha) salvo NOT que
es siempre prioritaria.
eman ta zabal zazu

LDD 2007-08 49
OPERADORES LGICOS
Tipos para los que estn definidos:

eman ta zabal zazu

LDD 2007-08 50
library IEEE;
use IEEE.Std_logic_1164.all;
entity MULS is
port ( A, B, : in std_logic ;
Z : out std_logic );
end MULS;

architecture EX of MULS is
begin
z <= A and not (B or C );
end EX;
eman ta zabal zazu

LDD 2007-08 51
Signal A_BUS, B_BUS, Z_BUS:
std_logic_vector ( 3 downto 0 );

Z_BUS <= A_BUS and B_BUS;

Equivalente a

ZBUS(3) <= A_BUS(3) and B_BUS(3);


ZBUS(2) <= A_BUS(2) and B_BUS(2);
ZBUS(1) <= A_BUS(1) and B_BUS(1);
ZBUS(0) <= A_BUS(0) and B_BUS(0);
eman ta zabal zazu

LDD 2007-08 52
OPERADORES RELACIONALES

Son los siguientes:


igual (=) , distinto (/=)
mayor(>), mayor o igual (>=)
menor(>), menor o igual (>=)
Los operandos pueden ser de cualquier tipo.
El resultado es de tipo boolean.

eman ta zabal zazu

LDD 2007-08 53
eman ta zabal zazu

LDD 2007-08 54
eman ta zabal zazu

LDD 2007-08 55
OPERADORES ARITMTICOS

Son los siguientes y para los tipos de datos indicados:


suma (+), resta (-) --- cualquier tipo numrico
producto (*), divisin (/) --- entero/real
potencias (**) --- entero/real (exponente entero)
mdulo (mod), resto (rem) --- enteros
valor absoluto (abs) --- entero/real

eman ta zabal zazu

LDD 2007-08 56
CONSTANTES

Es un objeto que almacena un nico valor durante toda


la simulacin
Ejemplos:
constant E:real:=2.7172;
constant V37:bit_vector (7 downto 0):= 0100110;
constant delay:time:=2ns;

eman ta zabal zazu

LDD 2007-08 57
Arrays...

eman ta zabal zazu

LDD 2007-08 58
eman ta zabal zazu

LDD 2007-08 59
eman ta zabal zazu

LDD 2007-08 60
c 1 2 3 4

z 3 2 1 0

eman ta zabal zazu

LDD 2007-08 61
eman ta zabal zazu

LDD 2007-08 62
Concatenation
and aggregates
eman ta zabal zazu

LDD 2007-08 63
eman ta zabal zazu

LDD 2007-08 64
eman ta zabal zazu

LDD 2007-08 65
eman ta zabal zazu

LDD 2007-08 66
eman ta zabal zazu

LDD 2007-08 67
eman ta zabal zazu

LDD 2007-08 68
eman ta zabal zazu

LDD 2007-08 69
3. Concurrent and secuential Statements
- Concurrent Assignment Statements
- The Process
- Process execution
- Sensitivity lists
- The if statement
- The case statement
-The for loop
-Variables

eman ta zabal zazu

LDD 2007-08 70
eman ta zabal zazu

LDD 2007-08 71
eman ta zabal zazu

LDD 2007-08 72
eman ta zabal zazu

LDD 2007-08 73
eman ta zabal zazu

LDD 2007-08 74
SENTENCIA WHEN ... SELECT
Es una sentencia concurrente que permite
realizar asignaciones condicionales de valores,
expresiones u objetos a seales.
Sintxis :
[etiqueta:]seal<= valor1 when condicin1 else
valor2 when condicin2 else

valorn when condicinn else
unaffected;
eman ta zabal zazu

LDD 2007-08 75
SENTENCIA WITH... SELECT
Es una sentencia concurrente que permite
realizar asignaciones condicionales de valores,
expresiones u objetos a seales (anloga a
WHEN..SELECT).
Sintxis :
[etiqueta:]with expresin select
seal<= valor1 when resultado1 else
valor2 when resultado2 else

valorn when resultadon else
eman ta zabal zazu
unaffected when others;
LDD 2007-08 76
eman ta zabal zazu

LDD 2007-08 77
eman ta zabal zazu

LDD 2007-08 78
eman ta zabal zazu

LDD 2007-08 79
eman ta zabal zazu

LDD 2007-08 80
eman ta zabal zazu

LDD 2007-08 81
eman ta zabal zazu

LDD 2007-08 82
eman ta zabal zazu

LDD 2007-08 83
Process execution

eman ta zabal zazu

LDD 2007-08 84
eman ta zabal zazu

LDD 2007-08 85
Sensitivity Lists

eman ta zabal zazu

LDD 2007-08 86
eman ta zabal zazu

LDD 2007-08 87
eman ta zabal zazu

LDD 2007-08 88
eman ta zabal zazu

LDD 2007-08 89
The If Statement

eman ta zabal zazu

LDD 2007-08 90
Executes first true branch
eman ta zabal zazu

LDD 2007-08 91
The Case Statement

eman ta zabal zazu

LDD 2007-08 92
eman ta zabal zazu

LDD 2007-08 93
The For Loop

eman ta zabal zazu

LDD 2007-08 94
eman ta zabal zazu

LDD 2007-08 95
Variable usage

eman ta zabal zazu

LDD 2007-08 96
4 ODD
A ( 3 downto 0 )

Process (A)
variable TMP : std_logic;
begin
TMP:= 0;
for I in Alow to Ahigh loop
TMP := TMP xor A(I);
end loop;
ODD <= TMP;
end process;
eman ta zabal zazu

LDD 2007-08 97
eman ta zabal zazu

LDD 2007-08 98
eman ta zabal zazu

LDD 2007-08 99
eman ta zabal zazu

LDD 2007-08 100


ARQUITECTURA
ESTILOS DE DESCRIPCIN
La arquitectura define la funcionalidad de la
entidad.
Estilos de descripcin:
Algortmico: mediante un conjunto de
instrucciones que se ejecutan secuencialmente
(proceso)
Flujo de datos: mediante funciones u operadores.
Estructural: conjunto de componentes
interconectados
eman ta zabal zazu

LDD 2007-08 101


Tema 4: Synthesis Issues

- Specifying registers in VHDL


- Detecting a rising clock
- Controling transparent latches
- Finite State Machines

eman ta zabal zazu

LDD 2007-08 102


Specifying registers in
VHDL

eman ta zabal zazu

LDD 2007-08 103


Entiti Flop is
port (D, Clk : in std_logic;
Q : out st_logic);
end Flop;
architecture A of Flop is
begin
process
begin
wait until Clkevent and Clk = 1;
Q <= D;
end process;
eman ta zabal zazu
end A;
LDD 2007-08 104
eman ta zabal zazu

LDD 2007-08 105


eman ta zabal zazu

LDD 2007-08 106


eman ta zabal zazu

LDD 2007-08 107


entity incomp_if is
port (EN, D : in std_logic;
Q : out st_logic);
end incomp_if;
architecture A of incomp_if is
begin
process (EN, D )
begin
if ( EN = 1 ) then ;
Q <= D;
end if ;
end process;

eman ta zabal zazu


end A;
LDD 2007-08 108
Controling Transparent
Latches

eman ta zabal zazu

LDD 2007-08 109


eman ta zabal zazu

LDD 2007-08 110


eman ta zabal zazu

LDD 2007-08 111


eman ta zabal zazu

LDD 2007-08 112


FINITE
STATE
MACHINES
eman ta zabal zazu

LDD 2007-08 113


EJEMPLO
Reset*
E0

E2 E1
1 0
S2 X S1

E3
0
Y

1
0
X
S1,S0
1
eman ta zabal zazu

LDD 2007-08 114


eman ta zabal zazu

LDD 2007-08 115


Architecture una of UC is
signal EST_PRES,EST_SIG: integer range 0 to 3;
begin...........
EST_PRE
EST_SIG
S

eman ta zabal zazu

LDD 2007-08 116


SEC: process (EST_PRES, X,Y)
--- inicializacin
case EST_PRES is
when 0 =>
if X= 0 then EST_SIG<=1;
else EST_SIG <=2;
end if;
when 1 => EST_SIG<=3;
when 2 =>
if Y= 1 then EST_SIG<=3;
else EST_SIG <=2;
end if;
when 3 =>
if X= 0 then EST_SIG<=1;
else EST_SIG <=0;
end if;
end case;
end process SEC;

eman ta zabal zazu

LDD 2007-08 117


REG: process (clk, Reset)
begin
if Reset=0 then EST_PRES <= 0;
if clk event and clk=1 then
EST_PRES <= EST_SIG;
end if;
eman ta zabal zazu
end process REG;
LDD 2007-08 118
outputs

S2 <=1 when EST_PRES=2 else 0;


S1 <=1 when (EST_PRES=1 or (EST_PRES=2 AND Y=1)) else 0;
S0 <=1 when (EST_PRES=2 AND Y=1) else 0;
ESTADO <= EST_PRES;

eman ta zabal zazu

LDD 2007-08 119


DESCRIPCIN COMPLETA:
architecture una of UC is
signal EST_PRES,EST_SIG: integer range 0 to 3;
begin
SEC: process (EST_PRES, X,Y)
--- inicializacin
case EST_PRES is
when 0 =>
if X= 0 then EST_SIG<=1;
else EST_SIG <=2;
end if;
when 1 => EST_SIG<=3;
when 2 =>
if Y= 1 then EST_SIG<=3;
else EST_SIG <=2;
end if;
when 3 =>
if X= 0 then EST_SIG<=1;
else EST_SIG <=0;
end if;
end case;
end process SEC;
REG: process (clk, Reset)
begin
if Reset=0 then EST_PRES <= 0;
if clk event and clk=1 then
EST_PRES <= EST_SIG;
end if;
end process REG;
S2 <=1 when EST_PRE else 0;
S1 <=1 when (EST_PRES=1 or (EST_PRES=2 AND Y=1)) else 0;
S0 <=1 when (EST_PRES=2 AND Y=1) else 0;
ESTADO <= EST_PRES;
eman ta zabal zazu

end una;
LDD 2007-08 120
Lgica combinacional

Seale
Generar s
Entradas estado salida
siguiente Estado Registro Estado
siguiente presente
Generar
seales de
Clk
salida

eman ta zabal zazu

LDD 2007-08 121


EJEMPLO:
E0 (00) RESET*

0
(borrar registro y
overflow) borrar sumar
OVF<--0 1 0
INIC SUM
CLR
E3(11) 1
E1(01)
LDR
(cargar el
registro)
1 0
SUM + Cout
INIC
1
(activar
0 OVF<--1 overflow)

E2(10)

(borrar registro y
overflow)
OVF<--0 1 0
CLR INIC

eman ta zabal zazu

LDD 2007-08 122


Descripcin en
VHDL:

library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_arith.all;

entity p1_ucV is
port( CLK ,RESETL : in std_logic;
INIC, SUM, COUT : in std_logic;
CLRL, LDRL, OVF1, OVF0L: out std_logic;
ESTADO : out integer range 0 to 3);
end p1_ucV;

eman ta zabal zazu

LDD 2007-08 123


Descripcin en
VHDL:

architecture UC of p1_ucV is
signal EST_PRES, EST_SIG_EST integer range 0 to 3;

begin
ES: process (EST_PRES, INIC,SUM,COUT)
begin
EST_SIG <= EST_PRES;
case EST_PRES is

eman ta zabal zazu

LDD 2007-08 124


Descripcin en
VHDL:
case EST_PRES is
when E0 => if INIC='1' then EST_SIG <= E3;
elsif SUM='1' then EST_SIG <= E1;
else EST_SIG <= E0;
end if;
when E1 => if COUT='1' then EST_SIG <= E2;
else EST_SIG <= E3;
end if;
when E2 => if INIC='0' then EST_SIG <= E2;
else EST_SIG <= E3;
end if;
when E3 => if (INIC or SUM) = '1' then EST_SIG <= E3;
else EST_SIG <= E0;
end if;
end case;
end process ES;

eman ta zabal zazu

LDD 2007-08 125


Descripcin en
VHDL:
REG: process (clk, resetL)
begin
if (resetL='0') then EST_PRES<=E0;
elsif (clk'event) and (clk='1') then
EST_PRES<=EST_SIG;
end if;
end process REG;

eman ta zabal zazu

LDD 2007-08 126


Descripcin en
VHDL:
LDRL <= '0' when EST_PRES=E1 else '1';
CLRL <= '0' when (EST_PRES=E1 OR EST_PRES =E0) AND INIC='1' else '1';
OVF1 <= '1' when EST_PRES=E1 AND COUT='1' else '0';
OVF0L <= 0' when (EST_PRES=E2 OR EST_PRES =E0) AND INIC='1' else 1';

ESTADO <= EST_PRES;

end UC;

eman ta zabal zazu

LDD 2007-08 127

También podría gustarte