vhdl(iniciar)
Post on 30-Oct-2014
20 Views
Preview:
TRANSCRIPT
LDD 2004-05 1
eman ta zabal zazu
INTRODUCCIÓN AL
LENGUAJE VHDL
eman ta zabal zazu
LDD 2004-05 2
eman ta zabal zazu
ÍNDICE.
1. Introducción.
2. Conceptos básicos del lenguaje y Aplicaciones.
3. Tipos de datos y Señales.4. Sentencias concurrentes y secuenciales. 5. Registros y máquinas de estados finitos.
LDD 2004-05 3
eman ta zabal zazu
Bibliografía:
- VHDL Lenguaje estándar de diseño electrónico. Lluís Terés, Yago Torroja, Serafín 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
LDD 2004-05 4
eman ta zabal zazu
INTRODUCCIÓN.
• Circuitos integrados. • Evolución del diseño electrónico• El lenguaje VHDL
LDD 2004-05 5
eman ta zabal zazu
CIRCUITOS INTEGRADOS
• Un Circuito Integrado (C.I.) es un circuito electrónico donde tanto los componentes como su conexionado se construyen en un mismo dado de material semiconductor (Si)
chip
• 1958 J. Kilby (Texas Instr.) primer C.I.
LDD 2004-05 6
eman ta zabal zazu
• Rápida evolución:Componentes SSI → Procesador VLSI
• Circuitos más complejos • Metodologías nuevas de diseño• Herramientas nuevas de diseño• Desarrollo paralelo
Microelectrónica ↔ Informática
LDD 2004-05 7
eman ta zabal zazu
PROCESO BÁSICO DE DISEÑO
Requisitos y especificaciones
DiseñoArquitectural (RTL )
Diseño Lógico(puer tas)
Diseño Físico(transistores-layout)
Diseño Funcional
Fabr icacióny Test
Modeladoy
Síntesis
Configuración del PLD
Programación del PLDy Test
Altera
Diseño modelo VHDL
Simulación
Compilación
Análisis de Timing
LDD 2004-05 8
eman ta zabal zazu
• Estas etapas son función de las distintas alternativas de diseño.
• Por analogía PROGRAMACIÓN se busca
SÍNTESIS DE ALTO NIVELChip desde una descripción de alto nivel
• Imprescindible los lenguajes HDL-- VHDL
LDD 2004-05 9
eman ta zabal zazu
Síntesis de hardware
Proceso de Transformación de una descripción funcional de un circuito en una descripción estructural:
–Nivel de Transferencias entre registros.–Layout (Caso Ideal)
Síntesis
processbegin
for I in 0 to 10 loop:::
end loop;end process;
descripción funcionaldescripción funcional
descripción estructuraldescripción estructural
LDD 2004-05 10
eman ta zabal zazu
Sintesis de Alto Nivel
• Func ión Objetivo : Una función de :– Estimación del área.– Retardos del Circuito
• Restricc iones : Condiciones que debe cumplir el circuito. (p.e. Area estimada < X. Retardo < Y...)
Síntesis
processbegin
for I in 0 to 10 loop
:::end loop;
end process;
Restricciones
FunciónObjetivo
LDD 2004-05 11
eman ta zabal zazu
1.Aplication and laguage Introduction
- What is VHDL ?- Aplication areas- Limitations of VHDL- VHDL styles- Main laguages concepts- Entity- Architecture- Hierarchy- Declaration- Processes and types- Packages
LDD 2004-05 12
eman ta zabal zazu
What is VHDL?
LDD 2004-05 13
eman ta zabal zazu
Limitations
LDD 2004-05 14
eman ta zabal zazu
LDD 2004-05 15
eman ta zabal zazu
VHDL Styles
LDD 2004-05 16
eman ta zabal zazu
LDD 2004-05 17
eman ta zabal zazu
LDD 2004-05 18
eman ta zabal zazu
LDD 2004-05 19
eman ta zabal zazu
LDD 2004-05 20
eman ta zabal zazu
Entity
LDD 2004-05 21
eman ta zabal zazu
Architecture
LDD 2004-05 22
eman ta zabal zazu
LDD 2004-05 23
eman ta zabal zazu
LDD 2004-05 24
eman ta zabal zazu
LDD 2004-05 25
eman ta zabal zazu
LDD 2004-05 26
eman ta zabal zazu
LDD 2004-05 27
eman ta zabal zazu
LDD 2004-05 28
eman ta zabal zazu
LDD 2004-05 29
eman ta zabal zazu
Processes
LDD 2004-05 30
eman ta zabal zazu
LDD 2004-05 31
eman ta zabal zazu
Types
LDD 2004-05 32
eman ta zabal zazu
The package
LDD 2004-05 33
eman ta zabal zazu
LDD 2004-05 34
eman ta zabal zazu
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
LDD 2004-05 35
eman ta zabal zazu
Type definition
LDD 2004-05 36
eman ta zabal zazu
Type definition
LDD 2004-05 37
eman ta zabal zazu
Type concept and specification
LDD 2004-05 38
eman ta zabal zazu
LDD 2004-05 39
eman ta zabal zazu
LDD 2004-05 40
eman ta zabal zazu
LDD 2004-05 41
eman ta zabal zazu
LDD 2004-05 42
eman ta zabal zazu
Type std_logic is (
‘ U’, Uninitiliced
‘ X’ Unknown
‘ 0’ Logic 0
‘ 1’ logic 1
‘ Z’ high impedance
‘W’ Unknown
‘ L’ logic 0
‘ H’ logic 1
‘ _ ‘ Don´t care
Strong drive
Weak drive
LDD 2004-05 43
eman ta zabal zazu
LDD 2004-05 44
eman ta zabal zazu
LDD 2004-05 45
eman ta zabal zazu
library IEEE;
use IEEE.Std_logic_1164.all;
entity MULS is
port ( A, B, : in std_logic ;
Z : out std_logic );
end MULS;
Using Standard Logic
LDD 2004-05 46
eman ta zabal zazu
OPERADORES EN VHDL
Existen 3 tipos predefinidos:
• Operadores lógicos
• Operadores matemáticos
• Operadores relacionales
Por defecto, cada operador puede usarse con cierto tipo de datos.
El usuario puede definir funciones si precisa usar otros tipos.
LDD 2004-05 47
eman ta zabal zazu
OPERADORES LÓGICOS
Son los siguientes:
• AND, NAND, OR, NOR
• XOR, XNOR
• NOT
• Además de desplazamientos lógicos/aritméticos izda/dcha y rotaciones: SLL, SRL, SLA, SRA, ROL, ROR.
Todos misma prioridad (de izda a dcha) salvo NOT que es siempre prioritaria.
LDD 2004-05 48
eman ta zabal zazu
OPERADORES LÓGICOSTipos para los que están definidos:
LDD 2004-05 49
eman ta zabal zazu
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 isbegin
z <= A and not (B or C );end EX;
LDD 2004-05 50
eman ta zabal zazu
Signal A_BUS, B_BUS, Z_BUS:
std_logic_vector ( 3 downto 0 );
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);
Z_BUS <= A_BUS and B_BUS;
LDD 2004-05 51
eman ta zabal zazu
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.
LDD 2004-05 52
eman ta zabal zazu
LDD 2004-05 53
eman ta zabal zazu
LDD 2004-05 54
eman ta zabal zazu
OPERADORES ARITMÉTICOS
Son los siguientes y para los tipos de datos indicados:
• suma (+), resta (-) --- cualquier tipo numérico
• producto (*), división (/) --- entero/real
• potencias (**) --- entero/real (exponente entero)
• módulo (mod), resto (rem) --- enteros
• valor absoluto (abs) --- entero/real
LDD 2004-05 55
eman ta zabal zazu
CONSTANTES
Es un objeto que almacena un único valor durante toda la simulación
Ejemplos:
• constant E:real:=2.7172;
• constant V37:bit_vector (7 downto 0):= “0100110”;
• constant delay:time:=2ns;
LDD 2004-05 56
eman ta zabal zazu
Arrays...
LDD 2004-05 57
eman ta zabal zazu
LDD 2004-05 58
eman ta zabal zazu
LDD 2004-05 59
eman ta zabal zazu
3 2 1 0
1 2 3 4
z
c
LDD 2004-05 60
eman ta zabal zazu
LDD 2004-05 61
eman ta zabal zazu
Concatenation and aggregates
LDD 2004-05 62
eman ta zabal zazu
LDD 2004-05 63
eman ta zabal zazu
LDD 2004-05 64
eman ta zabal zazu
LDD 2004-05 65
eman ta zabal zazu
LDD 2004-05 66
eman ta zabal zazu
LDD 2004-05 67
eman ta zabal zazu
LDD 2004-05 68
eman ta zabal zazu
3. Concurrent and secuential Statements
- Concurrent Assignment Statements- The Process- Process execution- Sensitivity lists- The if statement- The case statement-The for loop-Variables
LDD 2004-05 69
eman ta zabal zazu
LDD 2004-05 70
eman ta zabal zazu
LDD 2004-05 71
eman ta zabal zazu
LDD 2004-05 72
eman ta zabal zazu
LDD 2004-05 73
eman ta zabal zazu
• Es una sentencia concurrente que permite realizar asignaciones condicionales de valores, expresiones u objetos a señales.
• Sintáxis :[etiqueta:]señal<= valor1 when condición1 else
valor2 when condición2 else…………valorn when condiciónn elseunaffected;
SENTENCIA WHEN ... SELECT
LDD 2004-05 74
eman ta zabal zazu
• Es una sentencia concurrente que permite realizar asignaciones condicionales de valores, expresiones u objetos a señales (análoga a WHEN..SELECT).
• Sintáxis :[etiqueta:]with expresión select
señal<= valor1 when resultado1 elsevalor2 when resultado2 else
…………valorn when resultadon elseunaffected when others;
SENTENCIA WITH... SELECT
LDD 2004-05 75
eman ta zabal zazu
LDD 2004-05 76
eman ta zabal zazu
LDD 2004-05 77
eman ta zabal zazu
LDD 2004-05 78
eman ta zabal zazu
LDD 2004-05 79
eman ta zabal zazu
LDD 2004-05 80
eman ta zabal zazu
LDD 2004-05 81
eman ta zabal zazu
LDD 2004-05 82
eman ta zabal zazu
Process execution
LDD 2004-05 83
eman ta zabal zazu
LDD 2004-05 84
eman ta zabal zazu
Sensitivity Lists
LDD 2004-05 85
eman ta zabal zazu
LDD 2004-05 86
eman ta zabal zazu
LDD 2004-05 87
eman ta zabal zazu
LDD 2004-05 88
eman ta zabal zazu
The If Statement
LDD 2004-05 89
eman ta zabal zazu
'ZGEWVGU HKTUV�VTWG�DTCPEJ
LDD 2004-05 90
eman ta zabal zazu
The Case Statement
LDD 2004-05 91
eman ta zabal zazu
LDD 2004-05 92
eman ta zabal zazu
The For Loop
LDD 2004-05 93
eman ta zabal zazu
LDD 2004-05 94
eman ta zabal zazu
Variable usage
LDD 2004-05 95
eman ta zabal zazu
4 ODDA ( 3 downto 0 )
Process (A)
variable TMP : std_logic;
begin
TMP:= ‘0’;
for I in A’low to A’high loop
TMP := TMP xor A(I);
end loop;
ODD <= TMP;
end p rocess ;
LDD 2004-05 96
eman ta zabal zazu
LDD 2004-05 97
eman ta zabal zazu
LDD 2004-05 98
eman ta zabal zazu
LDD 2004-05 99
eman ta zabal zazu
ARQUITECTURA ESTILOS DE DESCRIPCIÓN
• La arquitectura define la funcionalidad de la entidad.
• Estilos de descripción:– Algorítmico: mediante un conjunto de
instrucciones que se ejecutan secuencialmente (proceso)
– Flujo de datos: mediante funciones u operadores.– Estructural: conjunto de componentes
interconectados
LDD 2004-05 100
eman ta zabal zazu
Tema 4: Synthesis Issues
- Specifying registers in VHDL- Detecting a rising clock- Controling transparent latches- Finite State Machines
LDD 2004-05 101
eman ta zabal zazu
Specifying registers inVHDL
LDD 2004-05 102
eman ta zabal zazu
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 Clk’event and Clk = ‘1’;
Q <= D;
end process;
end A;
LDD 2004-05 103
eman ta zabal zazu
LDD 2004-05 104
eman ta zabal zazu
LDD 2004-05 105
eman ta zabal zazu
LDD 2004-05 106
eman ta zabal zazu
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;
end A;
LDD 2004-05 107
eman ta zabal zazu
Controling Transparent Latches
LDD 2004-05 108
eman ta zabal zazu
LDD 2004-05 109
eman ta zabal zazu
LDD 2004-05 110
eman ta zabal zazu
LDD 2004-05 111
eman ta zabal zazu
FINITE
STATE
MACHINES
LDD 2004-05 112
eman ta zabal zazu
Reset*
E2
E0
E1
E3
S2 S1
S1,S0
X
X
Y
1 0
01
0
1
EJEMPLO
LDD 2004-05 113
eman ta zabal zazu
LDD 2004-05 114
eman ta zabal zazu
Architecture una of UC is
signal EST_PRES,EST_SIG: integer range 0 to 3;
begin...........
EST_SIGEST_PRES
LDD 2004-05 115
eman ta zabal zazu
SEC: process (EST_PRES, X,Y)--- inicialización
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;
LDD 2004-05 116
eman ta zabal zazu
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;
LDD 2004-05 117
eman ta zabal zazu
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;
outputs
LDD 2004-05 118
eman ta zabal zazu
DESCRIPCIÓN COMPLETA:architecture una of UC is
signal EST_PRES,EST_SIG: integer range 0 to 3;begin
SEC: process (EST_PRES, X,Y)--- inicializacióncase 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;
end una;
LDD 2004-05 119
eman ta zabal zazu
Lógica combinacional
Registro
Generar estado
siguienteEntradas
Señales salida
Estado siguiente
Clk
Estado presente
Generar señales de
salida
LDD 2004-05 120
eman ta zabal zazu
(activar overflow)
INIC SUM
LDR
OVF<--0CLR
SUM +INIC
OVF<--0CLR
OVF<--1
Cout
E0 (00)
E3(11) E1(01)
E2(10)
RESET*
01
0
1
0
1
01
0
1
INIC
(cargar elregistro)
(borrar registro yoverflow)
(borrar registro yoverflow) borrar sumar
EJEMPLO:
LDD 2004-05 121
eman ta zabal zazu
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;
Descripc ión en VHDL:
LDD 2004-05 122
eman ta zabal zazu
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
Descripc ión en VHDL:
LDD 2004-05 123
eman ta zabal zazu
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;
Descripc ión en VHDL:
LDD 2004-05 124
eman ta zabal zazu
Descripc ión en VHDL:
REG: process (clk, resetL)
begin
if (resetL=' 0' ) thenEST_PRES<=E0;
elsif (clk' event) and (clk=' 1' ) then
EST_PRES<=EST_SIG;
end if;
end process REG;
LDD 2004-05 125
eman ta zabal zazu
Descripc ión 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;
top related