Está en la página 1de 14

MICROPROCESADORES Condori Poma Ivan David

ETN 801 Inquillo Torrez Marco Antonio


Laboratorio Nº 2

UNIVERSIDAD MAYOR DE SAN ANDRÉS


FACULTAD DE INGENIERÍA
INGENIERÍA ELECTRÓNICA

PRE INFORME Nº 2

UNIDAD ARITMETICA LOGICA (ALU)

GRUPO: M2

INTEGRANTES:

Marco Antonio INQUILLO TORREZ


Ivan David CONDORI POMA

MATERIA: MICROPROCESADORES

FECHA: 24/SEPTIEMBRE/2013

LA PAZ – BOLIVIA
2013
MICROPROCESADORES Condori Poma Ivan David
ETN 801 Inquillo Torrez Marco Antonio
Laboratorio Nº 2

UNIDAD ARITMETICA LOGICA

OBJETIVOS

 Estudiar el comportamiento de una ALU de cuatro bits y comprobar su funcionalidad.


 Elaborar secuencias de operaciones combinadas para obtener funciones más complejas.

INTRODUCCIÓN

La ALU es un nuevo sistema que incorpora el sumador-restador como elemento


constitutivo, además de las tres funciones lógicas básicas estudiadas. La ALU básica, al
igual que el sumador-restador, es una estructura digital combinacional multifuncional,
capaz de ejecutar varias operaciones sobre dos valores binarios de entrada, en respuesta
a un arreglo de señales de control.

Las señales de control pueden ser agrupadas en un mismo nivel y sus correspondientes
combinaciones relevantes ser codificadas para conformar un conjunto de operaciones
codificadas.

PREINFORME

1. Diseñe una ALU de 4 bits para su montaje y verificación en


laboratorio.

Para el diseño de la ALU necesitamos implementar a nuestra UBC algunos componentes


que nos permitan realizar operaciones lógicas.

Operación NAND

X3
r3
Y3
Modelo simplificado
X2
r2 4
Y2 X
4
4 R
X1 Y
r1
Y1
X0
r0
Y0
MICROPROCESADORES Condori Poma Ivan David
ETN 801 Inquillo Torrez Marco Antonio
Laboratorio Nº 2

Operación OR y XOR

X 4 X 4
4 4
4 R 4 R
Y Y

El diseño de la UBC es el siguiente.

Diagrama de partes

Operación AND entre x e y, cada uno de cuatro bits:

X
Salida

Control

Tabla funcional AND:

x Y salida
0 0 0
0 1 0
1 0 0
1 1 1

Operación OR entre x e y, cada uno de cuatro bits:


MICROPROCESADORES Condori Poma Ivan David
ETN 801 Inquillo Torrez Marco Antonio
Laboratorio Nº 2

Salida
Control

Tabla funcional OR:

x Y salida
0 0 0
0 1 1
1 0 1
1 1 1

Operación XOR entre x e y, cada uno de cuatro bits:

Salida

Control

Tabla funcional XOR:

x Y salida
0 0 0
0 1 1
1 0 1
1 1 0
MICROPROCESADORES Condori Poma Ivan David
ETN 801 Inquillo Torrez Marco Antonio
Laboratorio Nº 2

El diseño de la ALU, en este diseño implementamos a la UBC las funciones lógicas básicas
que son AND, OR y XOR, de la siguiente manera.

n
X n
Y n
n
n
n MUX
n 4a1 C
n n
R
n
n
n UBC
S6 S5
S4 S3 S 2 S 1 S0

S6 S5 Salida selecta
0 0 AND
0 1 OR
1 0 XOR
1 1 UBC
Selección del MUX
MICROPROCESADORES Condori Poma Ivan David
ETN 801 Inquillo Torrez Marco Antonio
Laboratorio Nº 2

2. Detalle el diagrama lógico y el diagrama circuital, incluyendo


la identificación universal de las partes.
Diagrama cirtuital ALU

3. Elabore la tabla funcional.

Para elaborar la Tabla Funcional de la ALU tomamos solo las funciones básicas simples de
la tabla de 32 funciones y omitimos tanto las funciones complejas como las redundantes.

Tabla funcional de UBC:

S4 S3 S2 S1 S0 C R FUNCION
0 0 0 0 0 0 0 Borrar salida
0 0 0 0 1 0 1 Constante uno positivo
0 0 0 1 0 0 -1 Constante uno negativo
MICROPROCESADORES Condori Poma Ivan David
ETN 801 Inquillo Torrez Marco Antonio
Laboratorio Nº 2

0 0 0 1 1 1 0 Borrar salida
0 0 1 0 0 0 -1 Constante uno negativo
0 0 1 0 1 1 0 Borrar salida
0 0 1 1 0 0 -2 Constante dos negativo
0 0 1 1 1 1 -1 Constante uno negativo
0 1 0 0 0 0 y Leer y
0 1 0 0 1 ↕ y+1 Incrementar y
0 1 0 1 0 0 -y-1 Complemento1 y
0 1 0 1 1 ↕ -y Complemento2 y
0 1 1 0 0 ↕ y-1 Decrementar y
0 1 1 0 1 1 y Leer y
0 1 1 1 0 ↕ -y-2 Función compleja 1
0 1 1 1 1 1 -y-1 Complemento1 y
1 0 0 0 0 0 x Leer x
1 0 0 0 1 ↕ x+1 Incrementar x
1 0 0 1 0 ↕ x-1 Decrementar x
1 0 0 1 1 1 x Leer x
1 0 1 0 0 0 -x-1 Complemento1 x
1 0 1 0 1 ↕ -x Complemento2 x
1 0 1 1 0 ↕ -x-2 Función compleja 2
1 0 1 1 1 1 -x-1 Complemento1 x
1 1 0 0 0 ↕ x+y Sumar
1 1 0 0 1 ↕ x+y+1 Función compleja 3
1 1 0 1 0 ↕ x-y-1 Función compleja 4
1 1 0 1 1 ↕ x-y Restar y de x
1 1 1 0 0 ↕ -x+y-1 Función compleja 5
1 1 1 0 1 ↕ y-x Restar x de y
1 1 1 1 0 ↕ -x-y-2 Función compleja 6
1 1 1 1 1 ↕ -x-y-1 Función compleja 7

Una vez escogidas las 9 funciones más importantes (resaltadas con verde en la tabla de las
32 funciones) y añadiendo la otras 3 funciones básicas de una ALU (AND, OR, XOR)
procedemos a realizar la siguiente tabla:
MICROPROCESADORES Condori Poma Ivan David
ETN 801 Inquillo Torrez Marco Antonio
Laboratorio Nº 2

Tabla de funciones aritméticas y lógicas selectas

S6 S5 S4 S3 S2 S1 S0 C R FUNCION
1 1 0 0 0 0 0 0 0 Constante, borrar la
salida
1 1 1 0 0 0 0 0 x Leer x
1 1 0 1 0 0 0 0 y Leer y
1 1 1 0 1 0 1 ↕ -x Negar x
1 1 1 0 1 0 0 ↕ -x-1 Invertir x
0 0 0 0 0 0 0 0 x^y x and y
0 1 0 0 0 0 0 0 xνy x or y
1 0 0 0 0 0 0 0 xѳy x xor y
1 1 1 1 0 0 0 ↕ x+y Sumar
1 1 1 1 0 1 1 ↕ x-y Restar y de x
1 1 1 0 0 0 1 ↕ x+1 Incrementar x
1 1 1 0 0 1 0 ↕ x-1 Decrementar x

Como podemos ver en la tabla, contamos con una palabra de control demasiado larga, para
soluciona este problema procedemos a codificar la palabra de control mediante la
asignación arbitraria a un código mínimo, para nuestro caso basta con tener 4 bits para
codificar la 12 operaciones o funciones mas importantes. De esta manera al introducir un
código de 4 bits el descodificador generara la palabra de control y se ejecutara la operación.

Tabla de funciones de la ALU codificada

C3 C2 C1 C0 C FUNCION
0 0 0 0 0 borrar
0 0 0 1 0 leer x
0 0 1 0 0 leer y
0 0 1 1 1 negar x
0 1 0 0 ↕ not x
0 1 0 1 0 and
0 1 1 0 0 or
0 1 1 1 0 xor
1 0 0 0 ↕ Sumar
1 0 0 1 ↕ restar
1 0 1 0 ↕ incrementar x
1 0 1 1 ↕ decrementar y

4. Incorpore un control de paso para la señal de acarreo.


Diseñe las palabras de control.
MICROPROCESADORES Condori Poma Ivan David
ETN 801 Inquillo Torrez Marco Antonio
Laboratorio Nº 2

Control de paso para la señal de acarreo:

X
Salida

Control

Tabla funcional:

Control C
0 0
1 C

Tabla de funciones de la ALU codificada

Descodificación Palabra de Control Resultado


HEX C3 C2 C1 C0 ctl S6 S5 S4 S3 S2 S1 S0 C R FUNCION
0 0 0 0 0 1 1 1 0 0 0 0 0 0 0 Borrar
1 0 0 0 1 1 1 1 1 0 0 0 0 0 x Leer x
2 0 0 1 0 1 1 1 0 1 0 0 0 0 y Leer y
3 0 0 1 1 0 1 1 1 1 1 0 1 0* -x Negar x
4 0 1 0 0 0 1 1 1 0 1 0 0 0* -x-1 Invertir x
5 0 1 0 1 1 0 0 0 0 0 0 0 0 x^y x and y
6 0 1 1 0 1 0 1 0 0 0 0 0 0 xνy x or y
7 0 1 1 1 1 1 0 0 0 0 0 0 0 xѳy x xor y
8 1 0 0 0 1 1 1 1 0 0 0 0 ↕ x+y Sumar
9 1 0 0 1 1 1 1 1 0 0 1 1 ↕ x-y Restar y de x
A 1 0 1 0 1 1 1 1 0 0 0 1 ↕ x+1 Incrementar x
B 1 0 1 1 1 1 1 1 0 0 1 0 0 x-1 Decrementar y

5. Incorpore el descodificador de operaciones. Emplee una


ROM reprogramable.

Tabla para la memoria ROM reprogramable

Dirección Datos
Nº HEX C3 C2 C1 C0 ctl S6 S5 S4 S3 S2 S1 S0
0 0 0 0 0 1 1 1 0 0 0 0 0
1 0 0 0 1 1 1 1 1 0 0 0 0
MICROPROCESADORES Condori Poma Ivan David
ETN 801 Inquillo Torrez Marco Antonio
Laboratorio Nº 2

2 0 0 1 0 1 1 1 0 1 0 0 0
3 0 0 1 1 0 1 1 1 1 1 0 1
4 0 1 0 0 0 1 1 1 0 1 0 0
5 0 1 0 1 1 0 0 0 0 0 0 0
6 0 1 1 0 1 0 1 0 0 0 0 0
7 0 1 1 1 1 1 0 0 0 0 0 0
8 1 0 0 0 1 1 1 1 0 0 0 0
9 1 0 0 1 1 1 1 1 0 0 1 1
A 1 0 1 0 1 1 1 1 0 0 0 1
B 1 0 1 1 1 1 1 1 0 0 1 0

ALU+BANDERAS
MICROPROCESADORES Condori Poma Ivan David
ETN 801 Inquillo Torrez Marco Antonio
Laboratorio Nº 2

Finalmente, la tabla funcional de la ALU puede expresarse de la manera que se muestra a


continuación.

COD OPER OPERACION N Z V H P C FUNCION


0 Clr 0 1 0 0 0 * Cero al resultado
1 Nop * * * * * * Ninguna operación
2 In X X * 0 X * Introducir dato externo
3 Neg X X * 1 X * Negativo de a
4 Not * * * * * * Not a
5 And X X * 0 X 0 And
6 Or X X * 0 X 0 Or
7 Xor X X * 0 X 0 Xor
8 Add X X X X X 1 Adicionar dato
9 Sub X X X X X 1 Substraer
A Inc X X X X X * Incrementar a
B Dec X X X X X * Decrementar a
C Lda X X * 0 X * Leer dato de memoria en el
acumulador
D Sta X X * 0 X * Depositar dato del acumulador
en la memoria

EL CODIGO REALIZADO EN VHDL ES EL SIGUIENTE


***************VHDL DE LA UBC********************
library ieee;
use ieee.std_logic_1164.all;

Entity ubc is
Port( x,y : in std_logic_vector(3 downto 0);
S : in std_logic_vector(4 downto 0);
R : out std_logic_vector(3 downto 0);
c : out std_logic);
end ubc;

Architecture Comportamiento of ubc is


signal a,b,acar,pasoX,pasoY : std_logic_vector(3 downto 0);
begin
pasoX(0)<=x(0) and S(4);
pasoX(1)<=x(1) and S(4);
pasoX(2)<=x(2) and S(4);
MICROPROCESADORES Condori Poma Ivan David
ETN 801 Inquillo Torrez Marco Antonio
Laboratorio Nº 2

pasoX(3)<=x(3) and S(4);


pasoY(0)<=y(0) and S(3);
pasoY(1)<=y(1) and S(3);
pasoY(2)<=y(2) and S(3);
pasoY(3)<=y(3) and S(3);

a(0)<=pasoX(0) xor S(2);


a(1)<=pasoX(1) xor S(2);
a(2)<=pasoX(2) xor S(2);
a(3)<=pasoX(3) xor S(2);
b(0)<=pasoY(0) xor S(1);
b(1)<=pasoY(1) xor S(1);
b(2)<=pasoY(2) xor S(1);
b(3)<=pasoY(3) xor S(1);

R(0)<=s(0) xor a(0) xor b(0); acar(0)<=(b(0)and a(0)) or (s(0) and (a(0) xor b(0)));
R(1)<=a(1) xor b(1) xor acar(0); acar(1)<=(a(0) and b(0) and (a(1) xor b(1))) or (s(0) and
(a(0) xor b(0)) and (a(1) xor b(1))) or (a(1) and b(1));
R(2)<=a(2) xor b(2) xor acar(1); acar(2)<=(a(1) and b(1) and (a(2) xor b(2))) or ((a(0) and
b(0)) and (a(1) xor b(1)) and (a(2) xor b(2))) or (s(0) and (a(0) xor b(0)) and (a(1) xor b(1))
and (a(2) xor b(2))) or (a(2) and b(2));
R(3)<=a(3) xor b(3) xor acar(2); acar(3)<=(a(2) and b(2) and (a(3) xor b(3))) or ((a(1) and
b(1)) and (a(2) xor b(2)) and (a(3) xor b(3))) or ((a(0) and b(0)) and (a(1) xor b(1)) and (a(2)
xor b(2)) and (a(3) xor b(3))) or (s(0) and (a(0) xor b(0)) and (a(1) xor b(1)) and (a(2) xor
b(2)) and (a(3) xor b(3))) or (a(3) and b(3)); c<=acar(3);
end Comportamiento;

****************************VHDL DE LA ALU CON BANDERAS******************


library ieee;
use ieee.std_logic_1164.all;

Entity alu is
port(
x, y ,c : in std_logic_vector(3 downto 0);
Ralu : out std_logic_vector(3 downto 0);
Calu, H, Z, N, V, P: out std_logic);
end alu;
MICROPROCESADORES Condori Poma Ivan David
ETN 801 Inquillo Torrez Marco Antonio
Laboratorio Nº 2

Architecture Comportamiento of alu is


signal asd: std_logic_vector(0 to 1);
signal Rcal:std_logic_vector(3 downto 0);
signal carry : std_logic;
signal Subc: std_logic_vector(7 downto 0);
component ubc is
Port( x,y : in std_logic_vector(3 downto 0);
S : in std_logic_vector(4 downto 0);
R : out std_logic_vector(3 downto 0);
c : out std_logic);
end component;

begin
with c select
Subc<= "01100000" when "0000",
"01110000" when "0001",
"01101000" when "0010",
"01110101" when "0011",
"01110100" when "0100",
"00000000" when "0101",
"00100000" when "0110",
"01000000" when "0111",
"11111000" when "1000",
"11111011" when "1001",
"11110001" when "1010",
"11110010" when "1011",
"11100000" when others;
stage0: ubc port map(x,y,Subc(4)&Subc(3)&Subc(2)&Subc(1)&Subc(0),Rcal,carry);
asd<=Subc(6)& Subc(5);
process(asd)
begin
case asd is
when "00" => Ralu<=x and y;
when "01" => Ralu<=x or y;
when "10" => Ralu<=x xor y;
when "11" => Ralu<=Rcal;
end case;
end process;
MICROPROCESADORES Condori Poma Ivan David
ETN 801 Inquillo Torrez Marco Antonio
Laboratorio Nº 2

Calu<=Subc(7) and carry;


H<=carry and c(3) and not c(2) and not c(1) and not c(0);
Z<=not(Rcal(3) or Rcal(2) or Rcal(1) or Rcal(0));
N<=Rcal(3) and (c(3) and not c(2) and not c(1) and not c(0));
V<=(c(3) and not c(2) and not c(1) and not c(0)) and ((not x(3) and not y(3) and
Rcal(3))or((x(3) and y(3) and not Rcal(3))and not(Subc(4) and Subc(3) and Subc(0))) or
(((not x(3) and y(3))or (x(3) and not y(3)))and Rcal(3) and (Subc(4) and Subc(3) and
Subc(0))));
P<=(Rcal(3) xor Rcal(2) xor Rcal(1) xor Rcal(0)) and c(3) and not c(2) and not c(1) and not
c(0);

end comportamiento;

También podría gustarte