Escolar Documentos
Profissional Documentos
Cultura Documentos
VHDL
VHDL
1 – Introdução
2 - Programações de portas
2.1 – Porta NOT
Exemplo - Porta NOT com variável entrada A e variável saída B.
entity nome is
port (A: in bit;
B: out bit);
end nome;
architecture lógica of nome is
begin
B<= not A;
end lógica;
entity nome_1 is
port (a,b: in bit;
X: out bit);
end nome_1;
architecture lógica of nome_1 is
begin
X<= a and b;
end lógica;
entity nome_2 is
port (a,b,c: in bit;
y: out bit);
end nome_2;
architecture lógica of nome_2 is
begin
y<= a and b and c;
end lógica;
entity nome_3 is
port (A,B,C,D: in bit;
g: out bit);
end nome_3;
architecture lógica of nome_3 is
begin
g<= A and B and C and D;
end lógica;
2.3 – Porta OR
Exemplo 1 - Uma porta OR com duas entradas ( a , b ) e saída X.
entity nome_1 is
port (a,b: in bit;
X: out bit);
end nome_1;
architecture lógica of nome_1 is
begin
X<= a or b;
end lógica;
entity nome_2 is
port (a,b,c: in bit;
y: out bit);
end nome_2;
architecture lógica of nome_2 is
begin
y<= a or b or c;
end lógica;
entity nome_1 is
port (a,b: in bit;
X: out bit);
end nome_1;
architecture lógica of nome_1 is
begin
X<= a nand b;
end lógica;
entity nome_2 is
port (a,b,c: in bit;
y: out bit);
end nome_2;
architecture lógica of nome_2 is
begin
y<= a nand b nand c;
end lógica;
2.5 – Porta NOR
Exemplo 1 - Uma porta NOR com duas entradas ( a , b ) e saída X.
entity nome_1 is
port (a,b: in bit;
X: out bit);
end nome_1;
architecture lógica of nome_1 is
begin
X<= a nor b;
end lógica;
entity nome_2 is
port (a,b,c: in bit;
y: out bit);
end nome_2;
architecture lógica of nome_2 is
begin
X<= a nor b nor c;
end lógica;
2.6 – Porta XOR
Exemplo 1 - Uma porta XOR com duas entradas ( a , b ) e saída X.
entity nome_1 is
port (a,b: in bit;
X: out bit);
end nome_1;
architecture lógica of nome_1 is
begin
X<= a xor b;
end lógica;
entity nome_1 is
port (a,b: in bit;
X: out bit);
end nome_1;
architecture lógica of nome_1 is
begin
X<= a xnor b;
end lógica;
3 – Programação de circuitos lógicos através das operações concorrentes e
dos modelos estruturais
3.1 – Comparação entre as operações concorrente e os modelos estruturais
Exemplo 3.1 – Construa a listagem em VHDL que descreve o circuito lógico
mostrado abaixo, usando operações concorrentes.
entity nome_3 is
port (a,b,c: in bit;
f: out bit);
end nome_3;
architecture concorrente of nome_3 is
begin
f<= not a xnor ( b nand c ) ;
end concorrente;
entity nome_3 is
port (a,b,c: in bit;
f: out bit);
end nome_3;
architecture estrutural of nome_3 is
--Define a porta NAND de duas entradas como um componente
component ni_2
port (a,b: in bit;
X: out bit);
end component;
--Define a porta XNOR
component xnou_2
port (a,b: in bit;
X: out bit);
end component;
--Define a porta INVERSORA
component não
port (a: in bit;
X: out bit);
end component;
--Declara os sinais internos ao módulo
signal X1,X2:bit;
--O mapeamento das portas especifica a conexão interna
Begin
G1: não port map(a,X1);
G2: ni_2 port map(b,c,X2);
G3: xnou_2 port map(X1,X2,f);
End estrutural
--Os componentes têm que ser declarados como entity e sua architecture
--Define a porta NAND de duas entradas
entity ni_2 is
port (a,b: in bit;
X: out bit);
End ni_2;
entity Mux_4_1 is
port (P0,P1,P2,P3: in bit;
S: in bit_vector (1 downto 0);
F: out bit);
end Mux_4_1;
-- A arquitetura pode ser feita com comandos concorrentes
entity Mux_4_1 is
port (P0,P1,P2,P3: in bit;
S: in bit_vector (1 downto 0);
F: out bit);
end Mux_4_1;
architecture básica of Mux_4_1 is
begin
if S = “00” then
F<=P0
F<=P1
F<=P2
F<=P3
endif
end básica;
4.2 – Programações de demultiplexadores em VHDL
Exemplo 1 – Na figura abaixo se tem um demultiplexador (DeMux_1_4) com 1
entradas de dados (D), 2 entradas de seleção (S0 e S1) e 4 saídas de dados (O0, O1, O2
e O3).
entity DeMux_1_4 is
port (D: in bit;
S: in bit_vector (1 downto 0);
P0,P1,P2,P3: out bit);
end Mux_4_1;
architecture operação of DeMux_1_4 is
begin
if S=”00” then
P0 <= D
P1 <=’0’
P2 <=’0’
P3 <=’0’;
Elseif S=”01” then
P0 <=’0’
P1 <= D
P2 <=’0’
P3 <=’0’;
Elseif S=”10” then
P0 <=’0’
P1 <=‘0’
P2 <= D
P3 <=’0’;
Elseif S=”11” then
P0 <=’0’
P1 <=’0’
P2 <=’0’
P3 <= D;
End if
End operação;
End estrutural
entity não is
port (A: in bit;
B: out bit);
end não;
architecture lógica of não is
begin
B<= not A;
end lógica;
entity i_2 is
port (a,b: in bit;
X: out bit);
end i_2;
architecture lógica of i_2 is
begin
X<= a and b;
end lógica;
entity ou_5 is
port (a,b,c,d,e: in bit;
y: out bit);
end ou_5;
architecture lógica of ou_5 is
begin
y<= a or b or c or d or e;
end lógica;