Академический Документы
Профессиональный Документы
Культура Документы
Diseo lgico
combinacional mediante
VHDL
Introduccin
a b c f
0 0 0 1
0 0 1 0
0 1 0 0
0 1 1 1
1 0 0 0
1 0 1 0
1 1 0 1
1 1 1 1
Operadores lgicos
Los operadores lgicos ms utilizados en la descripcin de funciones boolea-
nas, y definidos en los diferentes tipos de datos bit, son los operadores
and, or, nand, xor, xnor y not. Las operaciones que se efecten en-
tre ellos (excepto not) deben realizarse con datos que tengan la misma lon-
gitud o palabra de bits.
En el momento de ser compilados los operadores lgicos presentan el si-
guiente orden y prioridad:
Ecuacin En VHDL
q = a + x y q = a or (x and y)
Solucin
D c B A F
0 0 0 0 0
0 0 0 1 0
0 0 1 0 0
0 0 1 1 0
0 1 0 0 1
0 1 0 1 1
0 1 1 0 1
0 1 1 1 1
1 0 0 0 0
1 0 0 1 0
1 0 1 0 0
1 0 1 1 0
1 1 0 0 0
1 1 0 1 0
1 1 1 0 0
1 1 1 1 0
1 library ieee;
2 vise ieee. std_logic_1164. all ;
3 entity funcin is port (
4 D,C,B,A: in std_logic;
5 F: out std_logic);
6 end funcin;
7 architecture a_func of funcin is
8 begin
9 F <= '1' when (A = '0' and B = '0' and C= 1' and D= '0' ) else
10 '1' when (A = '1' and B = '0' and C= 1' and D= '0' ) else
11 '1' when (A = '0' and B = '1' and c= V and D= '0' ) else
12 '1' when (A = V and B = '1' and c= 1' and D= '0') else
13 '0';
14 end a_func;
library ieee;
use ieee.std_logic_1164.all;
entity logic is port (
a,b,c,d,e,f: in std_logic;
xl,x2,x3: out std_logic) ;
end logic;
architecture booleana of logic is
begin
xl <= a xnor b;
x2 <= ( ( (c and d)or(a xnor b) ) nand
( (e xor f)and(c and d) ) ) ;
x3 <= (e xnor f) and (c and d) ;
end booleana;
A B C X Y z
0 0 0 1 0 1
0 0 1 1 1 0
0 1 0 0 0 1
0 1 1 1 0 1
1 0 0 0 0 0
1 0 1 0 1 0
1 1 0 0 1 0
1 1 1 1 0 0
Solucin
1) X = A B C + B C + B C + A B C
2) Y = B C + A B C + A B C
3) Z = B C + A B C + B C
1 library ieee;
2 use ieee.std_logic_1164.all ;
3 entity concurrente is port (
4 A,B,C: in std_logic;
5 X,Y,Z: out std_logic);
6 end concurrente;
7 architecture a_conc of concurrente is
8 begin
9 X <= (not A and not B and not C) or (not A and not B and C)
10 or (not a and B and C ) or (A and B and C) ;
11 Y <= (not A and not B and C) or (A and not B and C)
12 or (A and B and not C) ;
13 Z <= (not A and not B and not C) car (not A and B and not C)
14 or (not A and B and C) ;
15 end a_conc;
Diseo lgico combinacional mediante V H D L 67
a(0) a(l) c
0 0 1
0 1 0
1 0 1
1 1 0
F i g u r a 3 . 3 Tabla de verdad.
library ieee;
use ieee.std_logic_l164.all;
entity circuito is port(
a: in std_logic_vector (1 downto 0) ;
c: out std_logic);
end circuito;
architecture arq_cir of circuito is
begin
with a select
c <= '1' when "00",
'0' when "01",
'1' when "10",
'0' when others1;
end arq_cir;
Ejemplo 3.3 Se requiere disear un circuito combinacional que detecte nmeros primos
de 4 bits. Realice la tabla de verdad v elabore un programa que describa su
funcin. Utilice instrucciones del tipo with - select - when.
1 El uso de la palabra reservada others se explica a detalle en la seccin multiplexores de este captulo.
68 V H D L : El arte de programar sistemas digitales
Solucin
XO XI X2 X3 F
0 0 0 0 0
0 0 0 1 1
0 0 1 0 1
0 0 1 1 1
0 1 0 0 0
0 1 0 1 1
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 0
1 1 0 1 1
1 1 1 0 0
1 1 1 1 0
1 library ieee;
2 use ieee.std_logic_1164.all;
3 entity seleccin is port (
4 X: in std_logic_vector(0 to 3);
5 F: out std_logic) ;
6 end seleccin;
7 architecture a_selec of seleccin is
8 begin
9 with X select
10 F <= '1' when "0001",
11 '1' when "0010",
12 '1' when "0011",
13 '1' when "0101",
14 '1' when "0111",
15 '1' when "1011",
16 '1' when "1101",
17 '0 ' when others;
18 end a_selec;
Diseo lgico combinacional mediante V H D L 69
Notemos cmo en este tipo de ejemplos slo son necesarias dos condi-
ciones por evaluar, pero no en todos los diseos es as. Por tanto, cuando se
requieren ms condiciones de control, se utiliza una nueva estructura llama-
da elsif (si no-si), la cual permite expandir y especificar prioridades dentro
del proceso. La sintaxis para esta operacin es:
3 . 2 . 1 C o m p a r a d o r de magnitud de 4 bits
1 library ieee;
2 use ieee.std_logic_1164.all ;
3 entity comp4 is port (
4 a,b: in std_logic_vector(3 downto 0);
5 x,y,z: out std_logic);
6 end comp4;
7 architecture arq_comp4 of comp4 is
8 begin
9 process (a,b)
10 begin
11 if (a = b) then
12 x <= '1';
13 elsif (a > b) then
14 y <= '1';
15 else
16 z <= '1';
17 end if;
18 end process;
19 end arq_comp4 ;
Ejemplo 3 . 4 Disee un comparador de dos nmeros A y B, cada nmero formado por dos
bits ( Al AO ) y ( Bl BO ) la salida del comparador tambin es de dos bits y
est representada por la variable Z ( Z1 ZO ) de tal forma que si:
A = B entonces Z = 11
A < B entonces Z = 01
A > B entonces Z = 10
Al AO Bl BO Z1 Z O
0 0 0 0 1 1
0 0 0 1 0 1
0 0 1 0 0 1
0 0 1 1 0 1
0 1 0 0 1 0
0 1 0 1 1 1
0 1 1 0 0 1
0 1 1 1 0 1
1 0 0 0 1 0
1 0 0 1 1 0
1 0 1 0 1 1
1 0 1 1 0 1
1 1 0 0 1 0
1 1 0 1 1 0
1 1 1 0 1 0
1 1 1 1 1 1
Z1 = AO A l + BO B l + A l BO + AO BO + AO B 1
ZO = O A l + BO B l + O B 1 + O B 0 + Al BO
library ieee;
use ieee.std_logic_1164.all;
entity comp is port (
A,B: in std_logic_vector(1 downto 0);
Z: out std_logic_vector (1 downto 0));
end comp ;
architecture a_comp of comp is
begin
process (A,B) begin
if A = B then
Z <= "11";
Z <= "01";
else
Z <= "10";
end if;
end process;
end a_comp;
Operador Significado
= Igual
/= Diferente
< Menor
< = Menor o igual
> Mayor
> = Mayor o igual
enable
salida
entrada
library ieee;
use ieee.std_logic_1164.all ;
entity tri_est is port(
enable, entrada: in std_logic;
salida: out std_logic);
end tri_est;
architecture arq_buffer of tri_est is
begin
process (enable, entrada) begin
if enable = '0' then
salida <= 'Z';
else
salida <= entrada;
end if;
end process ;
end arq_buffer;
3.2.3 Multiplexores
a1
b1
c1
d1 z1 a[1:0]
b[1:0]
aO
b[1:0]
bO z[1:0]
d[1:0]
cO
zO
dO
s[1:0]
s1 so
a) b)
library ieee;
use ieee.std_logic_1164.all ;
entity mux is port(
a,b,c,d: in std_logic_vector(1 downto 0);
s: in std_logic_vector (1 downto 0) ;
Z: out std_logic_vector (1 downto 0) ;
end mux;
2 La herramienta de sntesis es el software incluido en VHDL, que genera las ecuaciones de diseo de cualquier
circuito. Esta herramienta permite implementar diseos sin el formato de ecuaciones booleaneas que utilizan
otros programas.
Diseo lgico combinacional mediante V H D L 77
library ieee;
use ieee.std_logic_1164.all;
entity mux is port (
a,b,c,d: in std_logic_vector(1 downto 0);
s: in std_logic_vector(1 downto 0) ;
z: out std_logic_vector(1 downto 0));
end mux;
end arqmux ;
3 Un dato metalgico consiste en los valores definidos para el tipo std_logic. los cuales estn contenidos en el
3 . 2 . 5 Sumadores
0 + 0 =0
0+1 = 1
1 + 0 = 1
1 + 1 = 10
A B Suma Cout
0 0 0 0
0 1 1 0
1 0 1 0
1 1 0 1 ( 1 + 1 = 10 )
library ieee;
use ieee.std_logic_1164.all ;
entity m_sum is port (
A,B: in std_logic;
SUMA, Cout: out std_logic) ;
end m_sum;
architecture am_sum of m_sum is
begin
SUMA <= A XOR B;
Cout <= A AND B;
end am_sum;
Suma = A B C i n
Cout = AB + ( A B ) Cin
AB + (A B) Cin
library ieee;
use ieee.std_logic_1164.all;
entity sum is port (
A,B,Cin: in std_logic;
Suma, Cout: out std_logic);
end sum;
architecture a_sum of sum is
begin
Suma <= A xor B xor Cin;
Cout <= (A and B) or (A xor B) and Cin;
end a_sum;
Figura 3 . 1 1 S u m a d o r de 4 bits.
82 V H D L : El arte de programar sistemas digitales
library ieee;
use ieee.std_logic_1164.all;
entity suma is port(
A,B: in std_logic_vector (0 to 3) ;
S: out std_logic_vector {0 to 3);
Cout: out std_logic);
end suma ;
architecture arqsuma of suma is
signal C: std_logic_vector(0 to 2);
begin
S(0) <= A(0) xor B(0);
C(0) <= A(0) and B(0);
S(l) <= (A(1) xor B(l)) xor C(0);
C(l) <= (A(1) and B(1) ) or (C(0)and(A(l)xor B(l)));
S (2) <= (A (2) xor B (2) ) xor C(l);
C (2) <= (A (2) and B(2)) or (C (1) and (A(2) xor B(2)));
S (3) <= (A(3) xor B(3)) xor C(2);
Cout <= (A(3) and B(3)) or (C(2)and(A(3)xor B(3)));
end arqsuma ;
Operador Descripcin
+ Suma
- Resta
/ Divisin
*
Multiplicacin
* *
Potencia
library ieee;
use ieee.std_logic_l164.all;
use work.std_arith.all;
entity sum is port (
A,B: in std_logic_vector(0 to 3);
Suma: out std_logic_vector(0 to 3));
end sum;
architecture arqsum of sum is
begin
Suma <= A + B;
end arqsum;
3.2.6 Decodificadores
Decodificador B C D a decimal
e < _ t 1' ;
f < = ' 1'
g < _ / 1' t
h <:_ / 1' !
if X - "0000" then
a < = '0';
elsif X = "0001" then
b < = '0';
elsif X = "0010" then
c < = '0';
elsif X = "0011" then
d < = 'C;
elsif X = "0100" then
e <
elsif X = "0101" then
f < = '0';
elsif X = "0110" then
g <
elsif X = "0111" then
h < = '0';
elsif X = "1000" then
i < = '0';
else
j < = '0';
end if;
end process ;
end arqdeco;
Como se puede apreciar, la entidad del decodificador cuenta con una en-
trada llamada A, formada por cuatro bits (AO, A l , A2, A3), y siete salidas
(a, b, c, d, e, f, g) activas en nivel bajo, las cuales corresponden a los segmen-
tos del display. En la tabla 3.5 se indican los valores lgicos de salida corres-
pondientes a cada segmento.
AO A l A 2 A 3 a b c d e f g
0 0 0 0 0 0 0 0 0 0 1
0 0 0 1 1 0 0 1 1 1 1
0 0 1 0 0 0 1 0 0 1 0
0 0 1 1 0 0 0 0 1 1 0
0 1 0 0 1 0 0 1 1 0 0
0 1 0 1 0 1 0 0 1 0 0
0 1 1 0 0 1 0 0 0 0 0
0 1 1 1 0 0 0 1 1 1 0
1 0 0 0 0 0 0 0 0 0 0
1 0 0 1 0 0 0 0 1 0 0
library ieee;
use ieee.std_logic_1164.all ;
entity deco is port (
A: in std_logic_vector(3 downto 0);
d: out std_logic_vector(6 downto 0));
end deco;
architecture arqdeco of deco is
begin
Contina
Diseo lgico combinacional mediante V H D L 87
3.2.7 Codificadores
library ieee;
use ieee.std_logic_1164.all ;
entity codif is port (
a: in integer range 0 to 9;
d: out std_logic_vector(3 downto 0));
end codif;
process (a)
begin
If a = 0 then
d <= "0000";
elsif a = 1 then
d <= "0001";
elsif a = 2 then
d <= "0010";
elsif a = 3 then
d <= "0011";
elsif a = 4 then
d <= "0100";
elsif a = 5 then
d <= "0101";
elsif a = 6 then
d <= "0110";
elsif a = 7 then
d <= "0111";
elsif a = 8 then
d <= "1000";
else
d <= "1001";
end if;
end process;
end arqcodif;
Ejercicios
Declaraciones concurrentes
a) X = (a + b) (c xor d) _ _
b) F = (a + c + d) + (a d c) (a + b)
c) Z = (wxy) + (x xnor y)
Decodificadores
Donde:
EN Entrada de habilitacin del circuito (se activa en baja)
A, B = Entradas del circuito
Y[0:3] = Salidas del circuito
3.13 Con base en el programa del listado 3.6 (Sec. 3.1.2.2) que describe
un buffer triestado, elabore un programa de un circuito triestado oc-
tal como el de las figuras 3.13a) y 3.13b).
G1
G2
A1
A2
A3
A4
A5
A6
A7
A8
a) b)
Multiplexores
3.14 Disee un programa de un multiplexor de 1 bit con ocho entradas
como el que se ilustra en la figura siguiente. Implemente el algoritmo
con base en la tabla de verdad adjunta.
EN c B A Y Y'
1 X X X 0 1
0 0 0 0 E0 E0'
0 0 0 1 El El'
0 0 0 0 E2 E2'
0 0 0 1 E3 E3'
0 1 1 0 E4 E4'
0 1 1 1 E5 E5'
0 1 1 0 E6 E6'
0 1 1 1 E7 E7'
Bibliografa