Documente Academic
Documente Profesional
Documente Cultură
entradas salida
seleccin
D0
Multiplexor Q
Dn
seleccin
MULTIPLEXORES
Para n=1
A B sel Q
A 0 0 0 0
0 0 1 0
Mux Q 0 1 0 0
0 1 1 1
2a1
1 0 0 1
B
1 0 1 0
1 1 0 1
1 1 1 1
sel
sel out
0 A
1 B
A B sel Q
0 0 0 0 AB
0 0 1 0 00 01 11 10
sel
0 1 0 0
0 0 0 1 1
0 1 1 1
1 0 0 1 1 0 1 1 0
1 0 1 0
1 1 0 1
1 1 1 1 Q = A.sel + B.sel
En vhdl
74xx151
MULTIPLEXORES
F(x,y,z)=(0,1,5,6)
I0
I1
I2 F(x,y,z)
I3
I4
I5
I6
I7
ABC
"0"
x y z
MULTIPLEXORES
Ej F(x,y,z)= (0,1,5,6)
x y z F(x,y,z)
0 0 0 1
0 0 1 1
0 1 0 0
0 1 1 0
1 0 0 0
1 0 1 1
1 1 0 1
1 1 1 0
y z F(x,y,z)
0 0 F1(x)= x
0 1 F2(x)= 1
1 0 F3(x)= x
1 1 F4(x)= 0
DEMULTIPLEXORES
dato A B Y0 Y1 Y2 Y3
0 0 0 0 0 0 0
dato
Y0 0 0 1 0 0 0 0
Y1 0 1 0 0 0 0 0
Y2 0 1 1 0 0 0 0
1 0 0 1 0 0 0
A Y3
B 1 0 1 0 1 0 0
1 1 0 0 0 1 0
1 1 1 0 0 0 1
DEMULTIPLEXORES
dato
Y0
Y1 library IEEE;
Y2 use IEEE.STD_LOGIC_1164.ALL;
A Y3
B
entity demux is
Port ( dato : in STD_LOGIC;
a : in STD_LOGIC;
b : in STD_LOGIC;
Y : out STD_LOGIC_VECTOR(3 downto 0));
dato A B Y0 Y1 Y2 Y3 end demux;
0 0 0 0 0 0 0
architecture Behavioral of demux is
0 0 1 0 0 0 0
begin
0 1 0 0 0 0 0 Y(0) <= dato when (b='0' and a='0') else '0';
0 1 1 0 0 0 0 Y(1) <= dato when (b='0' and a='1') else '0';
1 0 0 1 0 0 0 Y(2) <= dato when (b='1' and a='0') else '0';
Y(3) <= dato when (b='1' and a='1') else '0';
1 0 1 0 1 0 0
1 1 0 0 0 1 0 end Behavioral;
1 1 1 0 0 0 1
EJEMPLO DE APLICACIN MULTIPLEXOR Y DEMULTIPLEXORES
D0 D0
Mux DeMux
D7 D7
sel 3 3
COMPUERTAS OR EXCLUSIVAS
COMPUERTAS OR EXCLUSIVAS
Comparador de 1 bit
4-bit comparator
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
DIFF
entity comp_4bit is
Port ( a,b : in STD_LOGIC_vector(3 downto 0);
diff : out STD_LOGIC);
end comp_4bit;
Comparadores de magnitud:
A
A B a>b a=b a<b
a <b
a=b
a>b
A > B 1 0 0
B
A = B 0 1 0
A < B 0 0 1
COMPARADORES
0 0 0 0 0 1 0
0 0 0 1 0 0 1
0 0 1 0 0 0 1
0 0 1 1 0 0 1
0 1 0 0 1 0 0
0 1 0 1 0 1 0
0 1 1 0 0 0 1
A B a>b a=b a<b
0 1 1 1 0 0 1
A > B 1 0 0 1 0 0 0 1 0 0
A = B 0 1 0 1 0 0 1 1 0 0
A < B 0 0 1 1 0 1 0 0 1 0
1 0 1 1 0 0 1
1 1 0 0 1 0 0
1 1 0 1 1 0 0
1 1 1 0 1 0 0
1 1 1 1 0 1 0
COMPARADORES
Entradas Salidas
a1 a0 b1 b0 a>b a=b a<b
0 0 0 0 0 1 0
0 0 0 1 0 0 1
0 0 1 0 0 0 1
0 0 1 1 0 0 1
0 1 0 0 1 0 0
0 1 0 1 0 1 0
0 1 1 0 0 0 1
0 1 1 1 0 0 1
1 0 0 0 1 0 0
1 0 0 1 1 0 0
1 0 1 0 0 1 0
1 0 1 1 0 0 1
1 1 0 0 1 0 0
1 1 0 1 1 0 0
1 1 1 0 1 0 0
1 1 1 1 0 1 0
COMPARADORES
library IEEE;
Comparador use IEEE.STD_LOGIC_1164.ALL;
de magnitud
entity comparador is
A 8
a>b
may Port ( a : in STD_LOGIC_VECTOR (7 downto 0);
b : in STD_LOGIC_VECTOR (7 downto 0);
a=b igu may : out STD_LOGIC;
a<b men igu : out STD_LOGIC;
B 8 men : out STD_LOGIC);
end comparador;
a0 a3
a1 a>b a4 a>b
a2 a=b a5 a=b
a<b a<b
b0 b3
b1 b4
b2 b5
COMPARADORES
P > Q x x x 0 0 1
P < Q x x x 1 0 0
P = Q 0 1 0 0 1 0
P = Q 1 0 0 1 0 0
P = Q 0 0 1 0 0 1
COMPARADORES
P0 P4
P1 P5
P2 P6
P3 P7
P<Q
< <
in < in <
= = P=Q
V in = in =
in >
>
in > >
P>Q
Q0 Q4
Q1 Q5
Q3 Q6
Q3 Q7
SUMADORES
Suma de 2 bits
x y Cout Suma
0 0 0 0 x S
0 1 0 1 y Cout
1 0 0 1
1 1 1 0
Cout = x y
Suma = x y + x y = x y
SUMADORES
Ci x y Ci+1 Suma
0 0 0 0 0
0 0 1 0 1
0 1 0 0 1
0 1 1 1 0
1 0 0 0 1
1 0 1 1 0
1 1 0 1 0
1 1 1 1 1
SUMADORES
Cin x y Cout S
0 0 0 0 0
0 0 1 0 1
0 1 0 0 1
0 1 1 1 0
1 0 0 0 1
1 0 1 1 0
1 1 0 1 0
1 1 1 1 1
SUMADORES
X = x 3 x2 x1 x0
Y = y3 y2 y1 y0
S = s 3 s2 s1 s0
En general:
si = xi yi ci
ci+1 = xi.yi +xi.ci + yi.ci = xi.yi +(xi.+ yi).ci
ci+1 = gi + pi.ci
Donde
gi = xi.yi generador
pi = xi+yi propagador
c1 = g0 + p0.c0
c2 = g1 + p1.c1 = g1 + p1.(g0 + p0.c0)
c2 = x1.y1 + (x1 + y1).c1 = x1.y1 + (x1 + y1)(x0.y0 + (x0+ y0).c0
y3 x3 y2 x2 y1 x1 y0 x0
c3 c2 c1 c1
s3 s2 s1 s0
y3 y2 y1 y0 x3 x2 x1 x0
SUMADORES
Sumadores MSI
SUMADORES
A-B = A +(-B)
Trabajando en complemento a dos, la resta es la suma de A mas el
complemento a 2 de B
El complemento a dos de un nmero, se obtiene cambiando los ceros
por unos, los unos por ceros y luego sumando uno.
A
A-B
-B +
B Comp a 2
Debe verificarse que no se produzca un overflow para que el resultado sea vlido.
Debe cumplirse que :
Si se operan nmeros de distinto signo nunca hay overflow
Si se operan nmeros de igual signo el resultado debe tener el mismo signo
SUMADORES
A7 B7 S7 OVF
0 0 0 0
0 0 1 1
0 1 0 0
0 1 1 0
1 0 0 0
1 0 1 0
1 1 0 1
1 1 1 0
OVF = A7. B7 . S7 + A7 . B7 . S7
A7
B7
S7
OPERACIONES ARITMETICAS EN VHDL
La operacin suma, resta no estn definidas en el estndar VHDL, para los tipos
std_logic_vector . Por ejemplo, ejecutamos check syntx del siguiente cdigo
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity suma_mal is
Port ( a : in STD_LOGIC_VECTOR (7 downto 0);
b : in STD_LOGIC_VECTOR (7 downto 0);
suma : out STD_LOGIC_VECTOR (7 downto 0));
end suma_mal;
architecture Behavioral of suma_mal is
begin
suma <= a + b;
end Behavioral;
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
USE ieee.numeric_std.ALL;
Este paquete introduce dos tipos importantes que van a permitir representar
nmeros para realizar operaciones aritmticas.
Los tipo unsigned y signed. A estos, hay que agregarle otro tipo ya definido
en el estndar, el tipo entero.
A los tipos unsigned y signed hay que declararlos e indicar la cantidad de bits
con que va a trabajar, o bien como puerto de la entity, o si es una seal interna
del siguiente modo:
Para usarlo tambin hay que declararlo, com puerto de la entity o de manera similar
al tipo unsigned:
Indica que oper2 representar un nmero binario de 8 bits con signo( complemento
a 2) es decir:
VHDL es un lenguaje que permite operaciones entre objetos del mismo tipo
(salvo excepciones)
Si se utiliza el paquete ieee.numeric_std.all, se pueden hacer operaciones
de suma resta, comparacin, etc. entre objetos del mismo tipo, tales como
signed o unsigned.
Por ejemplo
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.ALL;
entity suma_unsigned is
Port ( a : in unsigned(7 downto 0);
b : in unsigned(7 downto 0);
suma : out unsigned(7 downto 0));
end suma_unsigned;
architecture Behavioral of suma_unsigned is
begin
suma <= a + b;
end Behavioral;
begin
aux <= unsigned(a) + unsigned(b);
suma <= std_logic_vector(aux);
end Behavioral;
OPERACIONES ARITMETICAS EN VHDL
VHDL tiene definido en el estndar el tipo entero ( integer) este tipo permite
Trabajar con nmeros enteros de 32 bits, representados en complemento a 2
Por lo tanto permite trabajar en el rango -2147483648 to +2147483647
Ejemplo:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity suma_enteros is
Port ( a : in integer;
b : in integer;
suma : out integer);
end suma_enteros;
begin
suma <= a - b +5;
end Behavioral;
OPERACIONES ARITMETICAS EN VHDL
Conversores de tipo:
El paquete numeric_std incorpora estas funciones que permiten la
conversin de tipos
Para convertir una seal (A) de tipo signed de 16 bit en entero (NUM)
NUM <= to_integer(A);
El caso inverso de entero a signed de 16 bits
A <= to_signed(NUM,16);
OPERACIONES ARITMETICAS EN VHDL