Академический Документы
Профессиональный Документы
Культура Документы
Informe Final # 5
Tema: Implementacion de un
Procesador monociclo en FPGA
Alumno: Jhonatan Alexander Juño Garcia
Código: 12190016
Profesor: Ing. Alfredo Granados Ly
2016
UNIVERSIDAD NACIONAL MAYOR DE SAN MARCOS
(Universidad del Perú, DECANA DE AMÉRICA)
FACULTAD DE INGENIERIA ELECTRÓNICA Y
ELÉCTRICA
E.A.P DE INGENIERÍA ELECTRÓNICA
INFORME FINA # 4
SECUENCIA DE PALABRAS
I. OBJETIVO
Describir e identificar una ruta de datos para la implementación de un
microprocesador.
II. MATERIALES Y EQUIPOS
Placa modulo con FPGA Altera Cyclone I
PC con la herramienta de síntesis MAX Plus II y el entorno de desarrollo Quartus II
de Altera
III. PROCEDIMIENTO DE DISEÑO.
1. Diagrama de bloques del circuito
Se propone el siguiente diagrama de bloques del circuito a implementar:
2. Implementación del Circuito en VHDL
COMPONENTE PRINCIPAL
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
Entity procesador is
port( CLK:in std_logic;
DISPLAY:out std_logic_vector(7 downto 0);
T:out std_logic_vector(3 downto 0));
end procesador;
Architecture Behavioral of procesador is
component PC
port( CLK:in std_logic;
ADDRESS: buffer std_logic_vector(2 downto 0));
end component;
component ROM_PROGRAMA
port( ADDRESS: in std_logic_vector(2 downto 0);
DATA: out std_logic_vector(16 downto 0));
end component;
component BANC_REG
port(DATO:in std_logic_vector(7 downto 0);
SEL_D:in std_logic_vector(2 downto 0);
SEL_B:in std_logic_vector(2 downto 0);
W:in std_logic;
clk: in std_logic;
A:out std_logic_vector(7 downto 0);
B:out std_logic_vector(7 downto 0);
PARA EL VISOR
******************************
SAL_R1: out std_logic_vector(7 downto 0);
SAL_R0: out std_logic_vector(7 downto 0));
end component;
component ALU
port(A: in std_logic_vector(7 downto 0);
B: in std_logic_vector(7 downto 0);
FUNC:in std_logic_vector(3 downto 0);
F: out std_logic_vector(7 downto 0));
end component;
component VISOR
port(A:in std_logic_vector(3 downto 0);
B:in std_logic_vector(3 downto 0);
C:in std_logic_vector(3 downto 0);
D:in std_logic_vector(3 downto 0);
CLK:in std_logic;
DISPLAY:out std_logic_vector(7 downto 0);
T:out std_logic_vector(3 downto 0));
end component;
component DIV_1HZ
port(CLK_IN: in std_logic;
CLK_OUT:out std_logic);
end component;
signal CLK_1HZ,N_CLK_1HZ:std_logic;
signal ADDRESS: std_logic_vector(2 downto 0);
signal INSTRUCCION: std_logic_vector(16 downto 0);
signal DATO,A,B,C,R1,R2: std_logic_vector(7 downto 0);
begin
N_CLK_1HZ<=CLK_1HZ;
C<=B when INSTRUCCION(12)='0' else INSTRUCCION(7 downto 0);
U0: PC port map(CLK_1HZ,ADDRESS);
U1: ROM_PROGRAMA port map(ADDRESS,INSTRUCCION);
U2: BANC_REG port map(DATO,
INSTRUCCION(10 downto 8),
INSTRUCCION(7 downto 5),
INSTRUCCION(11),
N_CLK_1HZ,
A,B,R1,R2);
U3: ALU port map(A,C,INSTRUCCION(16 downto 13),DATO);
U4: VISOR port map(R1(3 downto 0),R1(7 downto 4),R2(3 downto 0),
R2(7 downto 4),CLK,DISPLAY,T);
U5: DIV_1HZ port map(CLK,CLK_1HZ);
end Behavioral;
COMPONENTE PC:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
Entity PC is
port( CLK:in std_logic;
ADDRESS: buffer std_logic_vector(2 downto 0):="000");
end PC;
Architecture Behavioral of PC is
begin
process(clk)
begin
if clk='1' and clk'event then
ADDRESS<=ADDRESS+1;
end if;
end process;
end Behavioral;
Componente ROM_PROGRAMA
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
Entity ROM_PROGRAMA is
port( ADDRESS: in std_logic_vector(2 downto 0);
DATA: out std_logic_vector(16 downto 0));
end ROM_PROGRAMA;
Architecture Behavioral of ROM_PROGRAMA is
begin
process(ADDRESS)
begin
case ADDRESS is
when "000"=>DATA<="01011100100000100"; MOV R1,4
when "001"=>DATA<="01011101000000011"; MOV R2,3
when "010"=>DATA<="00000100101000000"; ADD R1,R2
when "011"=>DATA<="00100100100000000"; INC R1
when "100"=>DATA<="00110101000000000"; DEC R2
when "101"=>DATA<="00010100101000000"; SUB R1,R2
when "110"=>DATA<="01110100100000000"; CLR R1
when others=>DATA<="01100101000000000"; NOT R2
end case;
end process;
end Behavioral;
Componente BANC_REG
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity BANC_REG is
port(DATO:in std_logic_vector(7 downto 0);
SEL_D:in std_logic_vector(2 downto 0);
SEL_B:in std_logic_vector(2 downto 0);
W:in std_logic;
clk: in std_logic;
A:out std_logic_vector(7 downto 0);
B:out std_logic_vector(7 downto 0);
PARA EL VISOR
******************************
SAL_R1: out std_logic_vector(7 downto 0);
SAL_R0: out std_logic_vector(7 downto 0));
end BANC_REG;
architecture Behavioral of BANC_REG is
signal R0,R1,R2,R3,R4,R5,R6,R7:std_logic_vector(7 downto 0);
begin
SAL_R0<=R1;
SAL_R1<=R2;
with SEL_D select A <= R0 when "000",
R1 when "001",
R2 when "010",
R3 when "011",
R4 when "100",
R5 when "101",
R6 when "110",
R7 when others;
with SEL_B select B <= R0 when "000",
R1 when "001",
R2 when "010",
R3 when "011",
R4 when "100",
R5 when "101",
R6 when "110",
R7 when others;
process(clk)
begin
if clk='1' and clk'event then
if W='1' then
case SEL_D is
when "000" =>R0<=DATO;
when "001" =>R1<=DATO;
when "010" =>R2<=DATO;
when "011" =>R3<=DATO;
when "100" =>R4<=DATO;
when "101" =>R5<=DATO;
when "110" =>R6<=DATO;
when others=>R7<=DATO;
end case;
end if;
end if;
end process;
end Behavioral;
Componente ALU
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity ALU is
port(A: in std_logic_vector(7 downto 0);
B: in std_logic_vector(7 downto 0);
FUNC:in std_logic_vector(3 downto 0);
F: out std_logic_vector(7 downto 0));
end ALU;
architecture Behavioral of ALU is
begin
with FUNC select F <= A + B when "0000", ADD
A B when "0001", SUB
A + 1 when "0010", INC
A 1 when "0011", DEC
A or B when "0100", OR
B when "0101", MOV
not A when "0110", NOT
"00000000" when "0111", CLR
A and B when "1000", AND
A xor B when others; XOR
end Behavioral;
Componente Visor
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity VISOR is
port(A:in std_logic_vector(3 downto 0);
B:in std_logic_vector(3 downto 0);
C:in std_logic_vector(3 downto 0);
D:in std_logic_vector(3 downto 0);
CLK:in std_logic;
DISPLAY:out std_logic_vector(7 downto 0);
T:out std_logic_vector(3 downto 0));
end VISOR;
architecture Behavioral of VISOR is
signal SEL: std_logic_vector(1 downto 0);
signal Z: std_logic_vector(3 downto 0);
begin
DISEÑO MUX DE 4 A 1
=======================
process(A,B,C,D,SEL)
begin
case SEL is
when "00" => Z <= A;
when "01" => Z <= B;
when "10" => Z <= C;
when others => Z <= D;
end case;
end process;
DISEÑO DEL DECODIFICADOR A 7 SEGMENTOS
=======================================
process(Z)
begin
case Z is
when "0000" => DISPLAY <= "00000011"; 0
when "0001" => DISPLAY <= "10011111"; 1
when "0010" => DISPLAY <= "00100101"; 2
when "0011" => DISPLAY <= "00001101"; 3
when "0100" => DISPLAY <= "10011001"; 4
when "0101" => DISPLAY <= "01001001"; 5
when "0110" => DISPLAY <= "11000001"; 6
when "0111" => DISPLAY <= "00011111"; 7
when "1000" => DISPLAY <= "00000001"; 8
when "1001" => DISPLAY <= "00011001"; 9
when "1010" => DISPLAY <= "00010001"; A
when "1011" => DISPLAY <= "11000001"; B
when "1100" => DISPLAY <= "01100011"; C
when "1101" => DISPLAY <= "10000101"; D
when "1110" => DISPLAY <= "01100001"; E
when others => DISPLAY <= "01110001"; F
end case;
end process;
DISEÑO DEL DECODIFICADOR DE 2 A 4
========================================
process(SEL)
begin
case SEL is
when "00" =>T<="1110";
when "01" =>T<="1101";
when "10" =>T<="1011";
when others =>T<="0111";
end case;
end process;
DISEÑO DEL DIVISOR DE 50MHZ A 200MHZ
=====================================
process(clk)
variable contador: std_logic_vector(15 downto 0);
begin
if clk='1' and clk'event then
contador:=contador+1;
if contador=24000 then
contador:=(others=>'0');
SEL<=SEL+1;
end if;
end if;
end process;
end Behavioral;
Componente Divisor de 1hz
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity DIV_1HZ is
port(CLK_IN: in std_logic;
CLK_OUT:buffer std_logic);
end DIV_1HZ;
architecture Behavioral of DIV_1HZ is
begin
process(CLK_IN)
variable temporal:std_logic_vector(24 downto 0);
begin
if Clk_IN='1' and CLK_IN'event then
temporal:=temporal+1;
if temporal = 24000000 then
temporal:=(others=>'0');
CLK_OUT <= not CLk_OUT;
end if;
end if;
end process;
end Behavioral;
3. Prueba del circuito en módulo FPGA Altera Cyclone I
.