You are on page 1of 23

Universidade Tecnolgica Federal do Paran UTFPR Curso Superior de Tecnologia em Sistemas para a Internet

LD31A Lgica Digital

Prof. Rogrio Paulo Henrique A. Gonalves Sabo


rogerioag@utfpr.edu.br phsabo@utfpr.edu.br

Aula 011
Instanciando e Testando Entidades VHDL GHDL

HDL
Modelo Estrutural
Sistemas Lgicos Complexos so construdos pela combinao de portas lgicas e outras unidades bsicas. Em VHDL sistemas grandes tambm so criados pela interconexo de mdulos mais simples Isso o modelo estrutural. estrutural
Exemplo de Modelo Estrutural
a b G1 X1 G3 c d G2 X2 f

unidade_a0
3

HDL
Modelo Estrutural
Expresso do Circuito
a b G1 X1 G3 c d G2 X2 f

f = a.b + c.d X1 = a.b X2 = c.d f = X1 + X2

unidade_a0
Em VHDL os modelos estruturais so construdos usandose blocos construtivos chamados de componentes Modelo Estrutural: 1. escolhe os componentes 2. descreve como os componentes so conectados
4

Entidade

a b

G1

X1 G3 f

c d

G2

X2

unidade_a0

Entidade
Descrevemos as entidades componentes

a b

G1

X1 G3 f

c d

G2

X2

unidade_a0

Entidades identificadas:

AN D

OR
6

Descrio de componentes
Descrevemos as entidades componentes
entity and2 is port(x, y: in bit; z: out bit); end and2;
AN D

architecture logica of and2 is begin z <= x and y; end logica; entity or2 is port(x, y: in bit; z: out bit); end or2;

OR

architecture logica of and2 is begin z <= x or y; end logica;


7

Descrio da Entidade
entity unidade_a0 is port(a, b, c, d: in bit; f: out bit); end unidade_a0; architecture estrutural of unidade_a0 is component and2 port(x, y: in bit; z: out bit); end component; component or2 port(x, y: in bit; z: out bit); end component; -- sinais para ligar as signal x1: bit; signal x2: bit; begin g1: and2 port map(x=>a, g2: and2 port map(x=>c, g3: or2 port map(x=>x1, end estrutural; portas e resultados.

Descrio Estrutural

a b

G1

X1 G3 f

c d

G2

X2

unidade_a0

y=>b, z=>x1); y=>d, z=>x2); y=>x2, z=>f);


8

Descrio da Entidade
entity unidade_a0 is port(a, b, c, d: in bit; f: out bit); end unidade_a0; architecture estrutural of unidade_a0 is component and2 port(x, y: in bit; z: out bit); end component; component or2 port(x, y: in bit; z: out bit); end component; -- sinais para ligar as signal x1: bit; signal x2: bit; begin g1: and2 port map(x=>a, g2: and2 port map(x=>c, g3: or2 port map(x=>x1, end estrutural; portas e resultados.

Descrio Estrutural

a b

G1

X1 G3 f

c d

G2

X2

unidade_a0

y=>b, z=>x1); y=>d, z=>x2); y=>x2, z=>f);


9

Descrio da Entidade
entity unidade_a0 is port(a, b, c, d: in bit; f: out bit); end unidade_a0; architecture estrutural of unidade_a0 is component and2 port(x, y: in bit; z: out bit); end component; component or2 port(x, y: in bit; z: out bit); end component; -- sinais para ligar as signal x1: bit; signal x2: bit; begin g1: and2 port map(x=>a, g2: and2 port map(x=>c, g3: or2 port map(x=>x1, end estrutural; portas e resultados.

Descrio Estrutural

a b

G1

X1 G3 f

c d

G2

X2

unidade_a0

y=>b, z=>x1); y=>d, z=>x2); y=>x2, z=>f);


10

Descrio da Entidade
entity unidade_a0 is port(a, b, c, d: in bit; f: out bit); end unidade_a0; architecture estrutural of unidade_a0 is component and2 port(x, y: in bit; z: out bit); end component; component or2 port(x, y: in bit; z: out bit); end component; -- sinais para ligar as signal x1: bit; signal x2: bit; begin g1: and2 port map(x=>a, g2: and2 port map(x=>c, g3: or2 port map(x=>x1, end estrutural; portas e resultados.

Descrio Estrutural

a b

G1

X1 G3 f

c d

G2

X2

unidade_a0

y=>b, z=>x1); y=>d, z=>x2); y=>x2, z=>f);


11

Descrio da Entidade
entity unidade_a0 is port(a, b, c, d: in bit; f: out bit); end unidade_a0; architecture estrutural of unidade_a0 is component and2 port(x, y: in bit; z: out bit); end component; component or2 port(x, y: in bit; z: out bit); end component; -- sinais para ligar as signal x1: bit; signal x2: bit; begin g1: and2 port map(x=>a, g2: and2 port map(x=>c, g3: or2 port map(x=>x1, end estrutural; portas e resultados.
Mapeamento de portas com os sinais

Descrio Estrutural

a b

G1

X1 G3 f

c d

G2

X2

unidade_a0

y=>b, z=>x1); y=>d, z=>x2); y=>x2, z=>f);


12

Temos nossa Entidade

a b

G1

X1 G3 f

c d

G2

X2

unidade_a0

13

Teste da Entidade
Testebench

a b

G1

X1 G3 f

c d

G2

X2

unidade_a0 unidade_a0_tb

14

Teste da Entidade
Testebench

a b

G1

X1 G3 f

c d

G2

X2

unidade_a0 unidade_a0_tb

15

Teste da Entidade
Testebench t_a t_b t_c t_d

a b

G1

X1 G3 f

t_f

c d

G2

X2

unidade_a0 unidade_a0_tb

16

Teste da Entidade
Testebench t_a t_b t_c t_d

a b

G1

X1 G3 f

t_f

c d

G2

X2

unidade_a0 unidade_a0_tb

17

Descrio da Entidade de Teste


entity unidade_a0_tb is end unidade_a0_tb; architecture estrutural of unidade_a0_tb is -- Declarao do componente. component unidade_a0 port(a, b, c, d: in bit; f: out bit); end component; -- Especifica qual entidade est vinculada com o componente. for unidade_a0_0: unidade_a0 use entity work.unidade_a0; signal t_a, t_b, t_c, t_d, t_f: bit; begin -- Instanciao do Componente. unidade_a0_0: unidade_a0 port map (a => t_a, b => t_b, c => t_c, d => t_d, f => t_f);
18

Descrio da Entidade de Teste


process -- Um registro criado com as entradas e sadas da entidade. type pattern_type is record -- entradas. x, y, z, t: bit; -- sadas. f : bit; end record;

19

-- Os padres de entrada so aplicados (injetados) s entradas. type pattern_array is array (natural range <>) of pattern_type; constant patterns : pattern_array := (('0', '0', '0', '0', '0'), ('0', '0', '0', '1', '0'), ('0', '0', '1', '0', '0'), ('0', '0', '1', '1', '1'), ('0', '1', '0', '0', '0'), ('0', '1', '0', '1', '0'), ('0', '1', '1', '0', '0'), ('0', '1', '1', '1', '1'), ('1', '0', '0', '0', '0'), ('1', '0', '0', '1', '0'), ('1', '0', '1', '0', '0'), ('1', '0', '1', '1', '1'), ('1', '1', '0', '0', '1'), ('1', '1', '0', '1', '1'), ('1', '1', '1', '0', '1'), ('1', '1', '1', '1', '1') );

Descrio da Entidade de Teste

20

begin -- Checagem de padres. for i in patterns'range loop -- Injeta as entradas. t_a <= patterns(i).x; t_b <= patterns(i).y; t_c <= patterns(i).z; t_d <= patterns(i).t; -- Aguarda os resultados. wait for 1 ns; -- Checa o resultado com a sada esperada no padro. assert t_f = patterns(i).f report "Valor de t_f no confere com o resultado esperado." severity error; end loop; assert false report "Fim do teste." severity note; -- Wait forever; Isto finaliza a simulao. wait; end process; end estrutural;

Descrio da Entidade de Teste

21

Diagrama de Tempo

22

Resumo da Aula de Hoje


Tpicos mais importantes: Linguagem de Descrio de Hardware (HDL) Entregar folha com:
Nome Registro ou Matrcula Data de Hoje Resumo

23

You might also like