You are on page 1of 125

INTRODUCCIN AL LENGUAJE VHDL

eman ta zabal zazu

LDD 2004-05

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

eman ta zabal zazu

LDD 2004-05

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 2004-05

INTRODUCCIN.
Circuitos integrados. Evolucin del diseo electrnico El lenguaje VHDL

eman ta zabal zazu

LDD 2004-05

CIRCUITOS INTEGRADOS
Un Circuito Integrado (C.I.) es un circuito electrnico 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.
eman ta zabal zazu

LDD 2004-05

Rpida evolucin:
Componentes SSI Procesador VLSI

Circuitos ms complejos Metodologas nuevas de diseo Herramientas nuevas de diseo Desarrollo paralelo Microelectrnica Informtica

eman ta zabal zazu

LDD 2004-05

PROCESO BSICO DE DISEO


Requisitos y especificaciones

Altera
Diseo modelo VHDL

Diseo Funcional Compilacin Diseo Arquitectural (RTL)

Modelado y Sntesis

Simulacin

Diseo Lgico
(puertas)

Anlisis de Timing

Diseo Fsico
(transistores-layout)

Configuracin del PLD

eman ta zabal zazu

Fabricacin y Test LDD 2004-05

Programacin del PLD y Test 7

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 2004-05

Sntesis de hardware
descripcin funcional
process begin for I in 0 to 10 loop ::: end loop; end process;

descripcin estructural

Sntesis

Proceso de Transformacin de una descripcin funcional de un circuito en una descripcin estructural:


eman ta zabal zazu

Nivel de Transferencias entre registros. Layout (Caso Ideal)


LDD 2004-05 9

Sintesis de Alto Nivel


process begin for I in 0 to 10 loop ::: end loop; end process;

Funcin Objetivo

Restricciones

Sntesis

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 2004-05

10

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
eman ta zabal zazu

LDD 2004-05

11

What is VHDL?

eman ta zabal zazu

LDD 2004-05

12

Limitations

eman ta zabal zazu

LDD 2004-05

13

eman ta zabal zazu

LDD 2004-05

14

VHDL Styles

eman ta zabal zazu

LDD 2004-05

15

eman ta zabal zazu

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

Entity

eman ta zabal zazu

LDD 2004-05

20

Architecture

eman ta zabal zazu

LDD 2004-05

21

eman ta zabal zazu

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

Processes

eman ta zabal zazu

LDD 2004-05

29

eman ta zabal zazu

LDD 2004-05

30

Types

eman ta zabal zazu

LDD 2004-05

31

The package

eman ta zabal zazu

LDD 2004-05

32

eman ta zabal zazu

LDD 2004-05

33

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 2004-05

34

Type definition
eman ta zabal zazu

LDD 2004-05

35

Type definition

eman ta zabal zazu

LDD 2004-05

36

Type concept and specification

eman ta zabal zazu

LDD 2004-05

37

eman ta zabal zazu

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

Type std_logic is ( U, X 0 1 Z impedance W L H _


eman ta zabal zazu

Uninitiliced Unknown Logic 0 logic 1 high Unknown logic 0 logic 1 Dont care Weak drive Strong drive

LDD 2004-05

42

eman ta zabal zazu

LDD 2004-05

43

eman ta zabal zazu

LDD 2004-05

44

Using Standard Logic


library IEEE; use IEEE.Std_logic_1164.all;

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

eman ta zabal zazu

LDD 2004-05

45

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 2004-05

46

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 2004-05

47

OPERADORES LGICOS
Tipos para los que estn definidos:

eman ta zabal zazu

LDD 2004-05

48

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 2004-05

49

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 2004-05

50

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 2004-05

51

eman ta zabal zazu

LDD 2004-05

52

eman ta zabal zazu

LDD 2004-05

53

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 2004-05

54

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 2004-05

55

Arrays...
eman ta zabal zazu

LDD 2004-05

56

eman ta zabal zazu

LDD 2004-05

57

eman ta zabal zazu

LDD 2004-05

58

c z

1 2 3 4 3 2 1 0

eman ta zabal zazu

LDD 2004-05

59

eman ta zabal zazu

LDD 2004-05

60

Concatenation and aggregates


eman ta zabal zazu

LDD 2004-05

61

eman ta zabal zazu

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

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 2004-05

68

eman ta zabal zazu

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

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 2004-05

73

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 unaffected when others;
eman ta zabal zazu

LDD 2004-05

74

eman ta zabal zazu

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

Process execution

eman ta zabal zazu

LDD 2004-05

82

eman ta zabal zazu

LDD 2004-05

83

Sensitivity Lists

eman ta zabal zazu

LDD 2004-05

84

eman ta zabal zazu

LDD 2004-05

85

eman ta zabal zazu

LDD 2004-05

86

eman ta zabal zazu

LDD 2004-05

87

The If Statement

eman ta zabal zazu

LDD 2004-05

88

'GWG ZE V U
eman ta zabal zazu

H UVWDC E KTV T G T PJ
LDD 2004-05 89

The Case Statement

eman ta zabal zazu

LDD 2004-05

90

eman ta zabal zazu

LDD 2004-05

91

The For Loop

eman ta zabal zazu

LDD 2004-05

92

eman ta zabal zazu

LDD 2004-05

93

Variable usage

eman ta zabal zazu

LDD 2004-05

94

4 A ( 3 downto 0 )

ODD

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 2004-05

95

eman ta zabal zazu

LDD 2004-05

96

eman ta zabal zazu

LDD 2004-05

97

eman ta zabal zazu

LDD 2004-05

98

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 2004-05

99

Tema 4: Synthesis Issues


- Specifying registers in VHDL - Detecting a rising clock - Controling transparent latches - Finite State Machines

eman ta zabal zazu

LDD 2004-05

100

Specifying registers in VHDL

eman ta zabal zazu

LDD 2004-05

101

Entiti Flop is port (D, Clk : in std_logic; Q end Flop; architecture A of Flop is begin process begin wait until Clkevent and Clk = 1; Q <= D; end process;
eman ta zabal zazu

: out st_logic);

end A;
LDD 2004-05 102

eman ta zabal zazu

LDD 2004-05

103

eman ta zabal zazu

LDD 2004-05

104

eman ta zabal zazu

LDD 2004-05

105

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;
eman ta zabal zazu

LDD 2004-05

106

Controling Transparent Latches

eman ta zabal zazu

LDD 2004-05

107

eman ta zabal zazu

LDD 2004-05

108

eman ta zabal zazu

LDD 2004-05

109

eman ta zabal zazu

LDD 2004-05

110

FINITE STATE MACHINES


eman ta zabal zazu

LDD 2004-05

111

EJEMPLO
E0 Reset*

E2 S2 1 X 0 S1

E1

E3 0 Y 1 S1,S0
eman ta zabal zazu

X 1
LDD 2004-05

112

eman ta zabal zazu

LDD 2004-05

113

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


EST_SIG EST_PRE S

eman ta zabal zazu

LDD 2004-05

114

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 2004-05

115

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;
eman ta zabal zazu

LDD 2004-05

116

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 2004-05

117

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 S1 <= 1 when (EST_PRES=1 or (EST_PRES=2 AND Y= 1)) S0 <= 1 when (EST_PRES=2 AND Y= 1) ESTADO <= EST_PRES;
eman ta zabal zazu

else 0; else 0; else 0;

end una;

LDD 2004-05

118

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

Entradas

eman ta zabal zazu

LDD 2004-05

119

EJEMPLO:
E0 (00)
0
(borrar registro y overflow) borrar sumar

RESET*

OVF<--0 CLR

INIC

SUM
1

E3(11)

E1(01)
(cargar el registro)

LDR
1 0

SUM + INIC

Cout
1

OVF<--1

(activar overflow)

E2(10)
(borrar registro y overflow)

OVF<--0 CLR

INIC

eman ta zabal zazu

LDD 2004-05

120

Descripcin en VHDL:
library IEEE; use IEEE.std_logic_1164.all; use IEEE.std_logic_arith.all;

entity p1_ucV is port( CLK ,RESETL INIC, SUM, COUT : in : in std_logic; std_logic; std_logic;

CLRL, LDRL, OVF1, OVF0L: out ESTADO end p1_ucV;

: out integer range 0 to 3);

eman ta zabal zazu

LDD 2004-05

121

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 2004-05

122

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

eman ta zabal zazu

LDD 2004-05

123

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 2004-05

124

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

<= 0' when (EST_PRES=E2 OR EST_PRES =E0) AND INIC=' 1'

ESTADO <= EST_PRES;

end UC;

eman ta zabal zazu

LDD 2004-05

125

You might also like