Professional Documents
Culture Documents
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
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
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
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
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
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
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
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
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') );
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;
21
Diagrama de Tempo
22
23