Fusion des deux versions en cours
This commit is contained in:
parent
961344803c
commit
1c8364b30d
5 changed files with 871 additions and 9 deletions
289
Processeur.srcs/sources_1/new/Etage1_LectureInstruction.vhd
Normal file
289
Processeur.srcs/sources_1/new/Etage1_LectureInstruction.vhd
Normal file
|
@ -0,0 +1,289 @@
|
|||
----------------------------------------------------------------------------------
|
||||
-- Company: INSA-Toulouse
|
||||
-- Engineer: Paul Faure
|
||||
--
|
||||
-- Create Date: 18.04.2021 21:19:41
|
||||
-- Module Name: Etage1_LectureInstruction - Behavioral
|
||||
-- Project Name: Processeur sécurisé
|
||||
-- Target Devices: Basys 3 ARTIX7
|
||||
-- Tool Versions: Vivado 2016.4
|
||||
-- Description: Etage 1 du processeur
|
||||
-- - Gestion des instructions, lecture en mémoire
|
||||
-- - Gestion des aléas sur les registres
|
||||
-- - Gestion des sauts et appels de fonction
|
||||
--
|
||||
-- Dependencies:
|
||||
-- - MemoireInstruction
|
||||
-- - MemoireAdressesRetour
|
||||
----------------------------------------------------------------------------------
|
||||
|
||||
|
||||
library IEEE;
|
||||
use IEEE.STD_LOGIC_1164.ALL;
|
||||
use IEEE.STD_LOGIC_UNSIGNED.ALL;
|
||||
use IEEE.NUMERIC_STD.ALL;
|
||||
|
||||
|
||||
entity Etage1_LectureInstruction is
|
||||
Generic (Instruction_size_in_memory : Natural; -- Taille d'une instruction en mémoire (Taille d'un code instruction + 3*Taille d'un mot binaire)
|
||||
Addr_size_mem_instruction : Natural; -- Nombre de bits pour adresser la mémoire d'instruction
|
||||
Mem_instruction_size : Natural; -- Taille de la mémoire d'instruction (nombre d'instructions stockées)
|
||||
Nb_bits : Natural; -- Taille d'un mot binaire
|
||||
Instruction_bus_size : Natural; -- Nombre de bits du bus d'instruction (Taille d'un code instruction)
|
||||
Nb_registres : Natural; -- Nombre de registres du processeurs
|
||||
Mem_adresse_retour_size : Natural; -- Taille de la mémoire des adresses de retour (nombre d'adresse maximum) (profondeur d'appel maximale)
|
||||
Adresse_size_mem_adresse_retour : Natural; -- Nombre de bits pour adresser la mémoire des adresses de retour
|
||||
Instructions_critiques_lecture_A : STD_LOGIC_VECTOR; -- Vecteur de bit représentant les instruction critiques sur l'opérande A (si le bit i est a un, l'instruction i lit une valeur dans le registre n°opérandeA)
|
||||
Instructions_critiques_lecture_B : STD_LOGIC_VECTOR; -- Vecteur de bit représentant les instruction critiques sur l'opérande B (si le bit i est a un, l'instruction i lit une valeur dans le registre n°opérandeB)
|
||||
Instructions_critiques_lecture_C : STD_LOGIC_VECTOR; -- Vecteur de bit représentant les instruction critiques sur l'opérande C (si le bit i est a un, l'instruction i lit une valeur dans le registre n°opérandeC)
|
||||
Instructions_critiques_ecriture : STD_LOGIC_VECTOR; -- Vecteur de bit représentant les instruction critiques en écriture (toujours sur l'opérande A) (si le bit i est a un, l'instruction i ecrit une valeur dans le registre n°opérandeA)
|
||||
|
||||
-- Exemple 1 : Soit MUL i j k avec pour numéro d'instruction 7 avec le comportement Ri <- Rj*Rk
|
||||
-- Instructions_critiques_lecture_A(7) = '0' --> MUL ne lit pas dans le registre de l'opérande A
|
||||
-- Instructions_critiques_lecture_B(7) = '1' --> MUL lit dans le registre de l'opérande B
|
||||
-- Instructions_critiques_lecture_C(7) = '1' --> MUL lit dans le registre de l'opérande C
|
||||
-- Instructions_critiques_ecriture(7) = '1' --> MUL ecrit dans le registre de l'opérande A
|
||||
|
||||
-- Exemple 2 : Soit AFC i val avec pour numéro d'instruction 5 avec le comportement Ri <- val
|
||||
-- Instructions_critiques_lecture_A(5) = '0' --> AFC ne lit pas dans le registre de l'opérande A
|
||||
-- Instructions_critiques_lecture_B(5) = '0' --> AFC ne lit pas dans le registre de l'opérande B (pour AFC, B est directement la valeur, pas un numero de registre, il n'y a donc pas de lecture)
|
||||
-- Instructions_critiques_lecture_C(5) = '0' --> AFC ne lit pas dans le registre de l'opérande C
|
||||
-- Instructions_critiques_ecriture(5) = '1' --> AFC ecrit dans le registre de l'opérande A
|
||||
|
||||
Code_Instruction_JMP : STD_LOGIC_VECTOR; -- Numéro de l'instruction JMP
|
||||
Code_Instruction_JMZ : STD_LOGIC_VECTOR; -- Numéro de l'instruction JMZ
|
||||
Code_Instruction_CALL : STD_LOGIC_VECTOR; -- Numéro de l'instruction CALL
|
||||
Code_Instruction_RET : STD_LOGIC_VECTOR; -- Numéro de l'instruction RET
|
||||
Code_Instruction_STOP : STD_LOGIC_VECTOR); -- Numéro de l'instruction STOP
|
||||
Port ( CLK : in STD_LOGIC; -- Clock
|
||||
RST : in STD_LOGIC; -- Reset
|
||||
Z : in STD_LOGIC; -- Flag Zero de l'ALU (utile pour le JMZ)
|
||||
A : out STD_LOGIC_VECTOR (Nb_bits - 1 downto 0); -- Sortie de l'opérande A
|
||||
B : out STD_LOGIC_VECTOR (Nb_bits - 1 downto 0); -- Sortie de l'opérande B
|
||||
C : out STD_LOGIC_VECTOR (Nb_bits - 1 downto 0); -- Sortie de l'opérande C
|
||||
Instruction : out STD_LOGIC_VECTOR (Instruction_bus_size - 1 downto 0)); -- Sortie du code de l'instruction
|
||||
end Etage1_LectureInstruction;
|
||||
|
||||
|
||||
|
||||
architecture Behavioral of Etage1_LectureInstruction is
|
||||
component MemoireInstructions is
|
||||
Generic (Nb_bits : Natural;
|
||||
Addr_size : Natural;
|
||||
Mem_size : Natural);
|
||||
Port ( Addr : in STD_LOGIC_VECTOR (Addr_size-1 downto 0);
|
||||
D_OUT : out STD_LOGIC_VECTOR (Nb_bits-1 downto 0) := (others => '0'));
|
||||
end component;
|
||||
|
||||
component MemoireAdressesRetour is
|
||||
Generic (Nb_bits : Natural;
|
||||
Addr_size : Natural;
|
||||
Mem_size : Natural);
|
||||
Port ( R : in STD_LOGIC;
|
||||
W : in STD_LOGIC;
|
||||
D_IN : in STD_LOGIC_VECTOR (Nb_bits-1 downto 0);
|
||||
RST : in STD_LOGIC;
|
||||
CLK : in STD_LOGIC;
|
||||
D_OUT : out STD_LOGIC_VECTOR (Nb_bits-1 downto 0) := (others => '0');
|
||||
E : out STD_LOGIC;
|
||||
F : out STD_LOGIC);
|
||||
end component;
|
||||
|
||||
-- Signaux pour récuperer l'instruction de la mémoire
|
||||
signal Pointeur_instruction : STD_LOGIC_VECTOR (Addr_size_mem_instruction - 1 downto 0) := (others => '0');
|
||||
signal Pointeur_instruction_next : STD_LOGIC_VECTOR (Addr_size_mem_instruction - 1 downto 0) := (0 => '1', others => '0');
|
||||
signal Instruction_courante : STD_LOGIC_VECTOR (Instruction_size_in_memory - 1 downto 0) := (others => '0');
|
||||
|
||||
|
||||
-- Tableau pour gérer les aléas des registres (lecture en étage 2 avant écriture en étage 5)
|
||||
subtype Registre is integer range -1 to Nb_registres - 1;
|
||||
type Tab_registres is array (1 to 3) of Registre;
|
||||
signal Tableau : Tab_registres := (others => - 1);
|
||||
|
||||
-- Signaux de gestion pour la mémoire des adresses de retour
|
||||
signal Adresse_Retour : STD_LOGIC_VECTOR (Addr_size_mem_instruction - 1 downto 0) := (others => '0');
|
||||
signal E : STD_LOGIC;
|
||||
signal F : STD_LOGIC;
|
||||
signal R_Aux : STD_LOGIC := '0';
|
||||
signal W_Aux : STD_LOGIC := '0';
|
||||
|
||||
-- constantes pour injecter des bulles dans le pipeline
|
||||
constant Instruction_nulle : STD_LOGIC_VECTOR (Instruction_bus_size - 1 downto 0) := (others => '0');
|
||||
constant Argument_nul : STD_LOGIC_VECTOR (Nb_bits - 1 downto 0) := (others => '0');
|
||||
|
||||
-- condition pour detecter si une bulle doit être injectée
|
||||
signal bulles : boolean := false;
|
||||
|
||||
-- Compteur pour attendre lors d'un JMZ que l'instruction d'avant soit a l'ALU, ou lors d'un STOP k
|
||||
signal compteur : integer := 0;
|
||||
|
||||
-- Signal d'arret (STOP 0)
|
||||
signal locked : boolean := false;
|
||||
|
||||
begin
|
||||
instance : MemoireInstructions
|
||||
generic map (Nb_bits => Instruction_size_in_memory,
|
||||
Addr_size => Addr_size_mem_instruction,
|
||||
Mem_size => Mem_instruction_size)
|
||||
port map (Addr => Pointeur_Instruction,
|
||||
D_OUT => Instruction_courante);
|
||||
|
||||
instance_MemoireAdressesRetour : MemoireAdressesRetour
|
||||
generic map (Nb_bits => Addr_size_mem_instruction,
|
||||
Addr_size => Adresse_size_mem_adresse_retour,
|
||||
Mem_size => Mem_adresse_retour_size
|
||||
)
|
||||
port map ( R => R_Aux,
|
||||
W => W_Aux,
|
||||
D_IN => Pointeur_instruction_next,
|
||||
RST => RST,
|
||||
CLK => CLK,
|
||||
D_OUT => Adresse_Retour,
|
||||
E => E,
|
||||
F => F
|
||||
);
|
||||
|
||||
|
||||
process
|
||||
begin
|
||||
-- Synchronisation
|
||||
wait until CLK'event and CLK = '1';
|
||||
if (RST = '0') then
|
||||
-- Reset de l'étage
|
||||
Tableau <= (others => -1);
|
||||
Pointeur_Instruction <= (others => '0');
|
||||
compteur <= 0;
|
||||
locked <= false;
|
||||
C <= Argument_nul;
|
||||
B <= Argument_nul;
|
||||
A <= Argument_nul;
|
||||
Instruction <= Instruction_nulle;
|
||||
else
|
||||
-- Avancement des instructions en écritures dans le pipeline
|
||||
Tableau(3) <= Tableau(2);
|
||||
Tableau(2) <= Tableau(1);
|
||||
Tableau(1) <= -1;
|
||||
if (not bulles) then
|
||||
-- S'il ne faut pas injecter de bulles ont traite l'instruction (Possible code factorisable sur ce if)
|
||||
if ((Instruction_courante (Instruction_bus_size + 3 * Nb_bits - 1 downto 3 * Nb_bits) = Code_Instruction_CALL) or (Instruction_courante (Instruction_bus_size + 3 * Nb_bits - 1 downto 3 * Nb_bits) = Code_Instruction_JMP)) then
|
||||
-- CAS PARTICULIER : CALL ou JMP, on transmet et on saute
|
||||
C <= Instruction_courante (1 * Nb_bits - 1 downto 0 * Nb_bits);
|
||||
B <= Instruction_courante (2 * Nb_bits - 1 downto 1 * Nb_bits);
|
||||
A <= Instruction_courante (3 * Nb_bits - 1 downto 2 * Nb_bits);
|
||||
Instruction <= Instruction_courante (Instruction_bus_size + 3 * Nb_bits - 1 downto 3 * Nb_bits);
|
||||
Pointeur_Instruction <= Instruction_courante (2 * Nb_bits + Addr_size_mem_instruction - 1 downto 2 * Nb_bits);
|
||||
elsif (Instruction_courante (Instruction_bus_size + 3 * Nb_bits - 1 downto 3 * Nb_bits) = Code_Instruction_RET) then
|
||||
-- CAS PARTICULIER : RET, on transmet et on revient
|
||||
C <= Instruction_courante (1 * Nb_bits - 1 downto 0 * Nb_bits);
|
||||
B <= Instruction_courante (2 * Nb_bits - 1 downto 1 * Nb_bits);
|
||||
A <= Instruction_courante (3 * Nb_bits - 1 downto 2 * Nb_bits);
|
||||
Instruction <= Instruction_courante (Instruction_bus_size + 3 * Nb_bits - 1 downto 3 * Nb_bits);
|
||||
Pointeur_Instruction <= Adresse_Retour;
|
||||
elsif (Instruction_courante (Instruction_bus_size + 3 * Nb_bits - 1 downto 3 * Nb_bits) = Code_Instruction_JMZ) then
|
||||
-- CAS PARTICULIER : JMZ, on attends que l'instruction précedente arrive sur l'ALU, si le flag Zero est a un on saute, sinon on continue normalement
|
||||
compteur <= compteur + 1;
|
||||
C <= Instruction_courante (1 * Nb_bits - 1 downto 0 * Nb_bits);
|
||||
B <= Instruction_courante (2 * Nb_bits - 1 downto 1 * Nb_bits);
|
||||
A <= Instruction_courante (3 * Nb_bits - 1 downto 2 * Nb_bits);
|
||||
Instruction <= Instruction_courante (Instruction_bus_size + 3 * Nb_bits - 1 downto 3 * Nb_bits);
|
||||
if (compteur = 2) then
|
||||
if (Z = '1') then
|
||||
Pointeur_Instruction <= Instruction_courante (2 * Nb_bits + Addr_size_mem_instruction - 1 downto 2 * Nb_bits);
|
||||
else
|
||||
Pointeur_Instruction <= Pointeur_Instruction + 1;
|
||||
end if;
|
||||
compteur <= 0;
|
||||
end if;
|
||||
elsif (Instruction_courante (Instruction_bus_size + 3 * Nb_bits - 1 downto 3 * Nb_bits) = Code_Instruction_STOP) then
|
||||
-- CAS PARTICULIER : STOP, si on est bloqué, on ne fait rien, programme arrété
|
||||
-- sinon, on regarde si l'on doit se bloquer
|
||||
-- sinon, on incremente le compteur et on attends
|
||||
if (not locked) then
|
||||
if (Instruction_courante (3 * Nb_bits - 1 downto 2 * Nb_bits) = Argument_nul) then
|
||||
locked <= true;
|
||||
end if;
|
||||
compteur <= compteur + 1;
|
||||
if (compteur + 1 = to_integer(unsigned(Instruction_courante (3 * Nb_bits - 1 downto 2 * Nb_bits))) * 1000) then
|
||||
Pointeur_Instruction <= Pointeur_Instruction + 1;
|
||||
compteur <= 0;
|
||||
end if;
|
||||
end if;
|
||||
C <= Instruction_courante (1 * Nb_bits - 1 downto 0 * Nb_bits);
|
||||
B <= Instruction_courante (2 * Nb_bits - 1 downto 1 * Nb_bits);
|
||||
A <= Instruction_courante (3 * Nb_bits - 1 downto 2 * Nb_bits);
|
||||
Instruction <= Instruction_courante (Instruction_bus_size + 3 * Nb_bits - 1 downto 3 * Nb_bits);
|
||||
else
|
||||
-- CAS GENERAL : On transmet l'instruction et les opérandes, si elle est critique en ecriture, on enregistre le registre associé dans le tableau
|
||||
C <= Instruction_courante (1 * Nb_bits - 1 downto 0 * Nb_bits);
|
||||
B <= Instruction_courante (2 * Nb_bits - 1 downto 1 * Nb_bits);
|
||||
A <= Instruction_courante (3 * Nb_bits - 1 downto 2 * Nb_bits);
|
||||
Instruction <= Instruction_courante (Instruction_bus_size + 3 * Nb_bits - 1 downto 3 * Nb_bits);
|
||||
if (Instructions_critiques_ecriture(to_integer(unsigned(Instruction_courante (Instruction_bus_size + 3 * Nb_bits - 1 downto 3 * Nb_bits)))) = '1') then
|
||||
Tableau(1) <= to_integer(unsigned(Instruction_courante (3 * Nb_bits - 1 downto 2 * Nb_bits)));
|
||||
end if;
|
||||
Pointeur_Instruction <= Pointeur_Instruction + 1;
|
||||
end if;
|
||||
else
|
||||
-- Si besoin de bulle, on l'injecte
|
||||
C <= Argument_nul;
|
||||
B <= Argument_nul;
|
||||
A <= Argument_nul;
|
||||
Instruction <= Instruction_nulle;
|
||||
end if;
|
||||
end if;
|
||||
end process;
|
||||
|
||||
|
||||
-- Condition horrible -> Instruction critique en lecture sur A qui lit dans A=i et Ri dans tableau ou instruction critique en lecture sur B qui lit dans B=j et Rj dans tableau ou instruction critique en lecture sur C qui lit dans C=k et Rk dans tableau
|
||||
bulles <=
|
||||
(
|
||||
(
|
||||
Instructions_critiques_lecture_A(to_integer(unsigned(Instruction_courante (Instruction_bus_size + 3 * Nb_bits - 1 downto 3 * Nb_bits)))) = '1' -- Intruction critique sur A
|
||||
)
|
||||
and
|
||||
(
|
||||
(to_integer(unsigned(Instruction_courante (3 * Nb_bits - 1 downto 2 * Nb_bits))) = Tableau(1)) -- A est
|
||||
or
|
||||
(to_integer(unsigned(Instruction_courante (3 * Nb_bits - 1 downto 2 * Nb_bits))) = Tableau(2)) -- dans le
|
||||
or
|
||||
(to_integer(unsigned(Instruction_courante (3 * Nb_bits - 1 downto 2 * Nb_bits))) = Tableau(3)) -- tableau
|
||||
)
|
||||
)
|
||||
or
|
||||
(
|
||||
(
|
||||
Instructions_critiques_lecture_B(to_integer(unsigned(Instruction_courante (Instruction_bus_size + 3 * Nb_bits - 1 downto 3 * Nb_bits)))) = '1'
|
||||
)
|
||||
and
|
||||
(
|
||||
(to_integer(unsigned(Instruction_courante (2 * Nb_bits - 1 downto 1 * Nb_bits))) = Tableau(1))
|
||||
or
|
||||
(to_integer(unsigned(Instruction_courante (2 * Nb_bits - 1 downto 1 * Nb_bits))) = Tableau(2))
|
||||
or
|
||||
(to_integer(unsigned(Instruction_courante (2 * Nb_bits - 1 downto 1 * Nb_bits))) = Tableau(3))
|
||||
)
|
||||
)
|
||||
or
|
||||
(
|
||||
(
|
||||
Instructions_critiques_lecture_C(to_integer(unsigned(Instruction_courante (Instruction_bus_size + 3 * Nb_bits - 1 downto 3 * Nb_bits)))) = '1'
|
||||
)
|
||||
and
|
||||
(
|
||||
(to_integer(unsigned(Instruction_courante (1 * Nb_bits - 1 downto 0 * Nb_bits))) = Tableau(1))
|
||||
or
|
||||
(to_integer(unsigned(Instruction_courante (1 * Nb_bits - 1 downto 0 * Nb_bits))) = Tableau(2))
|
||||
or
|
||||
(to_integer(unsigned(Instruction_courante (1 * Nb_bits - 1 downto 0 * Nb_bits))) = Tableau(3))
|
||||
)
|
||||
);
|
||||
|
||||
-- Gestion de l'écriture/lecture dans la mémoire des adresses de retour
|
||||
R_Aux <= '1' when Instruction_courante (Instruction_bus_size + 3 * Nb_bits - 1 downto 3 * Nb_bits) = Code_Instruction_RET else
|
||||
'0';
|
||||
W_Aux <= '1' when Instruction_courante (Instruction_bus_size + 3 * Nb_bits - 1 downto 3 * Nb_bits) = Code_instruction_CALL else
|
||||
'0';
|
||||
|
||||
|
||||
Pointeur_instruction_next <= Pointeur_instruction + 1;
|
||||
end Behavioral;
|
192
Processeur.srcs/sources_1/new/Etage4_Memoire.vhd
Normal file
192
Processeur.srcs/sources_1/new/Etage4_Memoire.vhd
Normal file
|
@ -0,0 +1,192 @@
|
|||
----------------------------------------------------------------------------------
|
||||
-- Company: INSA-Toulouse
|
||||
-- Engineer: Paul Faure
|
||||
--
|
||||
-- Create Date: 18.04.2021 21:19:41
|
||||
-- Module Name: Etage4_Memoire - Structural
|
||||
-- Project Name: Processeur sécurisé
|
||||
-- Target Devices: Basys 3 ARTIX7
|
||||
-- Tool Versions: Vivado 2016.4
|
||||
--
|
||||
-- Description: Etage 4 du processeur
|
||||
-- - Gestion de la mémoire
|
||||
-- - Gestion de la sauvegarde du contexte lors des appels de fonction
|
||||
--
|
||||
-- Dependencies:
|
||||
-- - MemoireDonnees
|
||||
-- - MemoireAdressesRetour
|
||||
-- - LC
|
||||
-- - MUX
|
||||
----------------------------------------------------------------------------------
|
||||
|
||||
|
||||
library IEEE;
|
||||
use IEEE.STD_LOGIC_1164.ALL;
|
||||
use IEEE.STD_LOGIC_UNSIGNED.ALL;
|
||||
|
||||
entity Etage4_Memoire is
|
||||
Generic ( Nb_bits : Natural; -- Taille d'un mot binaire
|
||||
Mem_size : Natural; -- Taille de la mémoire de donnees (nombre de mots binaires stockables)
|
||||
Adresse_mem_size : Natural; -- Nombre de bits pour adresser la mémoire de donnees
|
||||
Instruction_bus_size : Natural; -- Nombre de bits du bus d'instruction (Taille d'un code instruction)
|
||||
Mem_EBP_size : Natural; -- Taille de la mémoire du contexte (profondeur d'appel maximale)
|
||||
Adresse_size_mem_EBP : Natural; -- Nombre de bits pour adresser la mémoire de contexte
|
||||
Bits_Controle_LC : STD_LOGIC_VECTOR; -- Vecteur de bit controlant le Link Controler (cf LC.vhd)
|
||||
Bits_Controle_MUX_IN : STD_LOGIC_VECTOR; -- Vecteur de bit controlant le multiplexer selectionnant A ou B comme adresse (cf MUX.vhd)
|
||||
Bits_Controle_MUX_IN_EBP : STD_LOGIC_VECTOR; -- Vecteur de bit controlant le multiplexer selectionnant si on doit ajouter ou non EBP à l'adresse (cf MUX.vhd)
|
||||
Bits_Controle_MUX_OUT : STD_LOGIC_VECTOR; -- Vecteur de bit controlant le multiplexer de sortie (cf MUX.vhd)
|
||||
Code_Instruction_CALL : STD_LOGIC_VECTOR; -- Numéro de l'instruction CALL
|
||||
Code_Instruction_RET : STD_LOGIC_VECTOR); -- Numéro de l'instruction RET
|
||||
Port ( CLK : in STD_LOGIC; -- Clock
|
||||
RST : in STD_LOGIC; -- Reset
|
||||
IN_A : in STD_LOGIC_VECTOR (Nb_bits - 1 downto 0); -- Entrée de l'opérande A
|
||||
IN_B : in STD_LOGIC_VECTOR (Nb_bits - 1 downto 0); -- Entrée de l'opérande B
|
||||
IN_Instruction : in STD_LOGIC_VECTOR (Instruction_bus_size - 1 downto 0); -- Entrée de l'instruction
|
||||
OUT_A : out STD_LOGIC_VECTOR (Nb_bits - 1 downto 0); -- Sortie de l'opérande A
|
||||
OUT_B : out STD_LOGIC_VECTOR (Nb_bits - 1 downto 0); -- Sortie de l'opérande B
|
||||
OUT_Instruction : out STD_LOGIC_VECTOR (Instruction_bus_size - 1 downto 0)); -- Sortie de l'instruction
|
||||
end Etage4_Memoire;
|
||||
|
||||
architecture Structural of Etage4_Memoire is
|
||||
component MemoireDonnees is
|
||||
Generic (Nb_bits : Natural;
|
||||
Addr_size : Natural;
|
||||
Mem_size : Natural);
|
||||
Port ( Addr : in STD_LOGIC_VECTOR (Addr_size-1 downto 0);
|
||||
RW : in STD_LOGIC;
|
||||
D_IN : in STD_LOGIC_VECTOR (Nb_bits-1 downto 0);
|
||||
RST : in STD_LOGIC;
|
||||
CLK : in STD_LOGIC;
|
||||
D_OUT : out STD_LOGIC_VECTOR (Nb_bits-1 downto 0) := (others => '0'));
|
||||
end component;
|
||||
|
||||
component MemoireAdressesRetour is
|
||||
Generic (Nb_bits : Natural;
|
||||
Addr_size : Natural;
|
||||
Mem_size : Natural);
|
||||
Port ( R : in STD_LOGIC;
|
||||
W : in STD_LOGIC;
|
||||
D_IN : in STD_LOGIC_VECTOR (Nb_bits-1 downto 0);
|
||||
RST : in STD_LOGIC;
|
||||
CLK : in STD_LOGIC;
|
||||
D_OUT : out STD_LOGIC_VECTOR (Nb_bits-1 downto 0) := (others => '0');
|
||||
E : out STD_LOGIC;
|
||||
F : out STD_LOGIC);
|
||||
end component;
|
||||
|
||||
component LC is
|
||||
Generic (Instruction_Vector_Size : Natural;
|
||||
Command_size : Natural;
|
||||
Bits_Controle : STD_LOGIC_VECTOR);
|
||||
Port ( Instruction : in STD_LOGIC_VECTOR (Instruction_Vector_Size - 1 downto 0);
|
||||
Commande : out STD_LOGIC_VECTOR (Command_size - 1 downto 0));
|
||||
end component;
|
||||
|
||||
component MUX is
|
||||
Generic (Nb_bits : Natural;
|
||||
Instruction_Vector_Size : Natural;
|
||||
Bits_Controle : STD_LOGIC_VECTOR);
|
||||
Port ( Instruction : in STD_LOGIC_VECTOR (Instruction_Vector_Size - 1 downto 0);
|
||||
IN1 : in STD_LOGIC_VECTOR (Nb_bits - 1 downto 0);
|
||||
IN2 : in STD_LOGIC_VECTOR (Nb_bits - 1 downto 0);
|
||||
OUTPUT : out STD_LOGIC_VECTOR (Nb_bits - 1 downto 0));
|
||||
end component;
|
||||
|
||||
|
||||
signal EBP : STD_LOGIC_VECTOR (Adresse_mem_size - 1 downto 0) := (others => '0'); -- EBP (offset à ajouter à l'adresse)
|
||||
signal New_EBP : STD_LOGIC_VECTOR (Adresse_mem_size - 1 downto 0) := (others => '0'); -- Nouvelle valeur d'EBP, a stocker lors d'un CALL (Cf fonctionnement MemoireAdressesRetour.vhd)
|
||||
|
||||
signal Addr_MemoireDonnees : STD_LOGIC_VECTOR (Adresse_mem_size - 1 downto 0) := (others => '0'); -- Adresse entrante dans le composant de mémoire de donnees
|
||||
signal IN_Addr_MemoireDonnees : STD_LOGIC_VECTOR (Adresse_mem_size - 1 downto 0) := (others => '0'); -- Sortie du mux de choix d'adresse entre A et B
|
||||
signal Addr_MemoireDonnees_EBP : STD_LOGIC_VECTOR (Adresse_mem_size - 1 downto 0) := (others => '0'); -- Adresse avec EBP ajouté (IN_Addr_MemoireDonnees + BP)
|
||||
|
||||
signal Commande_MemoireDonnees : STD_LOGIC_VECTOR (0 downto 0) := "0"; -- Sortie du Link Controler, signal de commande de la mémoire
|
||||
|
||||
signal Sortie_MemoireDonnees : STD_LOGIC_VECTOR (Nb_bits - 1 downto 0) := (others => '0'); -- Sortie de la mémoire (a multiplexer)
|
||||
|
||||
signal intern_OUT_B : STD_LOGIC_VECTOR (Nb_bits - 1 downto 0) := (others => '0'); -- Signal interne
|
||||
|
||||
-- Signaux de la memoire de contexte
|
||||
signal R_Aux : STD_LOGIC := '0';
|
||||
signal W_Aux : STD_LOGIC := '0';
|
||||
signal E : STD_LOGIC;
|
||||
signal F : STD_LOGIC;
|
||||
|
||||
|
||||
begin
|
||||
instance_LC : LC -- Link controleur sur la mémoire de donnees
|
||||
generic map (Instruction_Vector_Size => Instruction_bus_size,
|
||||
Command_size => 1,
|
||||
Bits_Controle => Bits_Controle_LC)
|
||||
port map ( Instruction => IN_Instruction,
|
||||
Commande => Commande_MemoireDonnees);
|
||||
|
||||
instance_MUX_IN : MUX -- Multiplexeur selectionnant A ou B pour adresse
|
||||
generic map (Nb_bits => Adresse_mem_size,
|
||||
Instruction_Vector_Size => Instruction_bus_size,
|
||||
Bits_Controle => Bits_Controle_MUX_IN)
|
||||
port map ( Instruction => IN_Instruction,
|
||||
IN1 => IN_A (Adresse_mem_size - 1 downto 0),
|
||||
IN2 => IN_B (Adresse_mem_size - 1 downto 0),
|
||||
OUTPUT => IN_Addr_MemoireDonnees);
|
||||
|
||||
instance_MUX_IN_EBP : MUX -- Multiplexeur selectionnant l'adresse plus EBP ou l'adresse de base
|
||||
generic map (Nb_bits => Adresse_mem_size,
|
||||
Instruction_Vector_Size => Instruction_bus_size,
|
||||
Bits_Controle => Bits_Controle_MUX_IN_EBP)
|
||||
port map ( Instruction => IN_Instruction,
|
||||
IN1 => IN_Addr_MemoireDonnees,
|
||||
IN2 => Addr_MemoireDonnees_EBP,
|
||||
OUTPUT => Addr_MemoireDonnees);
|
||||
|
||||
instance_MUX_OUT : MUX -- Multiplexeur selectionnant la sortie de l'étage (sur B)
|
||||
generic map (Nb_bits => Nb_bits,
|
||||
Instruction_Vector_Size => Instruction_bus_size,
|
||||
Bits_Controle => Bits_Controle_MUX_OUT)
|
||||
port map ( Instruction => IN_Instruction,
|
||||
IN1 => Sortie_MemoireDonnees,
|
||||
IN2 => IN_B,
|
||||
OUTPUT => intern_OUT_B);
|
||||
|
||||
instance_MemoireDonnees : MemoireDonnees
|
||||
generic map (Nb_bits => Nb_bits,
|
||||
Addr_size => Adresse_mem_size,
|
||||
Mem_size => Mem_size)
|
||||
port map ( Addr => Addr_MemoireDonnees,
|
||||
RW => Commande_MemoireDonnees(0),
|
||||
D_IN => IN_B,
|
||||
RST => RST,
|
||||
CLK => CLK,
|
||||
D_OUT => Sortie_MemoireDonnees);
|
||||
|
||||
instance_MemoireEBP : MemoireAdressesRetour
|
||||
generic map (Nb_bits => Adresse_mem_size,
|
||||
Addr_size => Adresse_size_mem_EBP,
|
||||
Mem_size => Mem_EBP_size
|
||||
)
|
||||
port map ( R => R_Aux,
|
||||
W => W_Aux,
|
||||
D_IN => New_EBP,
|
||||
RST => RST,
|
||||
CLK => CLK,
|
||||
D_OUT => EBP,
|
||||
E => E,
|
||||
F => F
|
||||
);
|
||||
|
||||
OUT_A <= (others => '0') when RST = '0' else
|
||||
IN_A;
|
||||
OUT_B <= (others => '0') when RST = '0' else
|
||||
intern_OUT_B;
|
||||
OUT_Instruction <= (others => '0') when RST = '0' else
|
||||
IN_Instruction;
|
||||
|
||||
-- Controle de la mémoire de contexte (ici aussi un LC aurait été disproportionné)
|
||||
R_Aux <= '1' when IN_Instruction = Code_Instruction_RET else
|
||||
'0';
|
||||
W_Aux <= '1' when IN_Instruction = Code_Instruction_CALL else
|
||||
'0';
|
||||
|
||||
Addr_MemoireDonnees_EBP <= IN_Addr_MemoireDonnees + EBP;
|
||||
New_EBP <= EBP + IN_B (Adresse_mem_size - 1 downto 0);
|
||||
end Structural;
|
328
Processeur.srcs/sources_1/new/Pipeline.vhd
Normal file
328
Processeur.srcs/sources_1/new/Pipeline.vhd
Normal file
|
@ -0,0 +1,328 @@
|
|||
----------------------------------------------------------------------------------
|
||||
-- Company:
|
||||
-- Engineer:
|
||||
--
|
||||
-- Create Date: 19.04.2021 16:57:41
|
||||
-- Design Name:
|
||||
-- Module Name: Pipeline - Behavioral
|
||||
-- Project Name:
|
||||
-- Target Devices:
|
||||
-- Tool Versions:
|
||||
-- Description:
|
||||
--
|
||||
-- Dependencies:
|
||||
--
|
||||
-- Revision:
|
||||
-- Revision 0.01 - File Created
|
||||
-- Additional Comments:
|
||||
--
|
||||
----------------------------------------------------------------------------------
|
||||
|
||||
|
||||
library IEEE;
|
||||
use IEEE.STD_LOGIC_1164.ALL;
|
||||
|
||||
-- Uncomment the following library declaration if using
|
||||
-- arithmetic functions with Signed or Unsigned values
|
||||
--use IEEE.NUMERIC_STD.ALL;
|
||||
|
||||
-- Uncomment the following library declaration if instantiating
|
||||
-- any Xilinx leaf cells in this code.
|
||||
--library UNISIM;
|
||||
--use UNISIM.VComponents.all;
|
||||
|
||||
entity Pipeline is
|
||||
Generic (Nb_bits : Natural := 8;
|
||||
Instruction_En_Memoire_Size : Natural := 29;
|
||||
Addr_Memoire_Instruction_Size : Natural := 3;
|
||||
Memoire_Instruction_Size : Natural := 8;
|
||||
Instruction_Bus_Size : Natural := 5;
|
||||
Nb_Instructions : Natural := 32;
|
||||
Nb_Registres : Natural := 16;
|
||||
Addr_registres_size : Natural := 4;
|
||||
Memoire_Size : Natural := 32;
|
||||
Adresse_mem_size : Natural := 5;
|
||||
Memoire_Adresses_Retour_Size : Natural := 16;
|
||||
Adresse_Memoire_Adresses_Retour_Size : Natural := 4);
|
||||
Port (CLK : STD_LOGIC;
|
||||
RST : STD_LOGIC;
|
||||
STD_IN : in STD_LOGIC_VECTOR (Nb_bits - 1 downto 0);
|
||||
STD_OUT : out STD_LOGIC_VECTOR (Nb_bits - 1 downto 0));
|
||||
end Pipeline;
|
||||
|
||||
architecture Behavioral of Pipeline is
|
||||
|
||||
component Etage1_LectureInstruction is
|
||||
Generic (Instruction_size_in_memory : Natural;
|
||||
Addr_size_mem_instruction : Natural;
|
||||
Mem_instruction_size : Natural;
|
||||
Nb_bits : Natural;
|
||||
Instruction_bus_size : Natural;
|
||||
Nb_registres : Natural;
|
||||
Mem_adresse_retour_size : Natural;
|
||||
Adresse_size_mem_adresse_retour : Natural;
|
||||
Instructions_critiques_lecture_A : STD_LOGIC_VECTOR;
|
||||
Instructions_critiques_lecture_B : STD_LOGIC_VECTOR;
|
||||
Instructions_critiques_lecture_C : STD_LOGIC_VECTOR;
|
||||
Instructions_critiques_ecriture : STD_LOGIC_VECTOR;
|
||||
Code_Instruction_JMP : STD_LOGIC_VECTOR;
|
||||
Code_Instruction_JMZ : STD_LOGIC_VECTOR;
|
||||
Code_Instruction_CALL : STD_LOGIC_VECTOR;
|
||||
Code_Instruction_RET : STD_LOGIC_VECTOR;
|
||||
Code_Instruction_STOP : STD_LOGIC_VECTOR);
|
||||
Port ( CLK : in STD_LOGIC;
|
||||
RST : in STD_LOGIC;
|
||||
Z : in STD_LOGIC;
|
||||
A : out STD_LOGIC_VECTOR (Nb_bits - 1 downto 0);
|
||||
B : out STD_LOGIC_VECTOR (Nb_bits - 1 downto 0);
|
||||
C : out STD_LOGIC_VECTOR (Nb_bits - 1 downto 0);
|
||||
Instruction : out STD_LOGIC_VECTOR (Instruction_bus_size - 1 downto 0));
|
||||
end component;
|
||||
|
||||
component Etage2_5_Registres is
|
||||
Generic ( Nb_bits : Natural;
|
||||
Nb_registres : Natural;
|
||||
Addr_registres_size : Natural;
|
||||
Instruction_bus_size : Natural;
|
||||
Bits_Controle_LC_5 : STD_LOGIC_VECTOR;
|
||||
Bits_Controle_MUX_2_A : STD_LOGIC_VECTOR;
|
||||
Bits_Controle_MUX_2_B : STD_LOGIC_VECTOR;
|
||||
Code_Instruction_PRI : STD_LOGIC_VECTOR;
|
||||
Code_Instruction_GET : STD_LOGIC_VECTOR);
|
||||
Port ( CLK : in STD_LOGIC;
|
||||
RST : in STD_LOGIC;
|
||||
STD_IN : in STD_LOGIC_VECTOR (Nb_bits - 1 downto 0);
|
||||
STD_OUT : out STD_LOGIC_VECTOR (Nb_bits - 1 downto 0);
|
||||
IN_2_A : in STD_LOGIC_VECTOR (Nb_bits - 1 downto 0);
|
||||
IN_2_B : in STD_LOGIC_VECTOR (Nb_bits - 1 downto 0);
|
||||
IN_2_C : in STD_LOGIC_VECTOR (Nb_bits - 1 downto 0);
|
||||
IN_2_Instruction : in STD_LOGIC_VECTOR (Instruction_bus_size - 1 downto 0);
|
||||
OUT_2_A : out STD_LOGIC_VECTOR (Nb_bits - 1 downto 0);
|
||||
OUT_2_B : out STD_LOGIC_VECTOR (Nb_bits - 1 downto 0);
|
||||
OUT_2_C : out STD_LOGIC_VECTOR (Nb_bits - 1 downto 0);
|
||||
OUT_2_Instruction : out STD_LOGIC_VECTOR (Instruction_bus_size - 1 downto 0);
|
||||
IN_5_A : in STD_LOGIC_VECTOR (Nb_bits - 1 downto 0);
|
||||
IN_5_B : in STD_LOGIC_VECTOR (Nb_bits - 1 downto 0);
|
||||
IN_5_Instruction : in STD_LOGIC_VECTOR (Instruction_bus_size - 1 downto 0));
|
||||
end component;
|
||||
|
||||
component Etage3_Calcul is
|
||||
Generic ( Nb_bits : Natural;
|
||||
Instruction_bus_size : Natural;
|
||||
Bits_Controle_LC : STD_LOGIC_VECTOR;
|
||||
Bits_Controle_MUX : STD_LOGIC_VECTOR);
|
||||
Port ( RST : in STD_LOGIC;
|
||||
IN_A : in STD_LOGIC_VECTOR (Nb_bits - 1 downto 0);
|
||||
IN_B : in STD_LOGIC_VECTOR (Nb_bits - 1 downto 0);
|
||||
IN_C : in STD_LOGIC_VECTOR (Nb_bits - 1 downto 0);
|
||||
IN_Instruction : in STD_LOGIC_VECTOR (Instruction_bus_size - 1 downto 0);
|
||||
OUT_A : out STD_LOGIC_VECTOR (Nb_bits - 1 downto 0);
|
||||
OUT_B : out STD_LOGIC_VECTOR (Nb_bits - 1 downto 0);
|
||||
OUT_Instruction : out STD_LOGIC_VECTOR (Instruction_bus_size - 1 downto 0);
|
||||
N : out STD_LOGIC;
|
||||
O : out STD_LOGIC;
|
||||
Z : out STD_LOGIC;
|
||||
C : out STD_LOGIC);
|
||||
end component;
|
||||
|
||||
component Etage4_Memoire is
|
||||
Generic ( Nb_bits : Natural;
|
||||
Mem_size : Natural;
|
||||
Adresse_mem_size : Natural;
|
||||
Instruction_bus_size : Natural;
|
||||
Mem_EBP_size : Natural;
|
||||
Adresse_size_mem_EBP : Natural;
|
||||
Bits_Controle_LC : STD_LOGIC_VECTOR;
|
||||
Bits_Controle_MUX_IN : STD_LOGIC_VECTOR;
|
||||
Bits_Controle_MUX_IN_EBP : STD_LOGIC_VECTOR;
|
||||
Bits_Controle_MUX_OUT : STD_LOGIC_VECTOR;
|
||||
Code_Instruction_CALL : STD_LOGIC_VECTOR;
|
||||
Code_Instruction_RET : STD_LOGIC_VECTOR);
|
||||
Port ( CLK : in STD_LOGIC;
|
||||
RST : in STD_LOGIC;
|
||||
IN_A : in STD_LOGIC_VECTOR (Nb_bits - 1 downto 0);
|
||||
IN_B : in STD_LOGIC_VECTOR (Nb_bits - 1 downto 0);
|
||||
IN_Instruction : in STD_LOGIC_VECTOR (Instruction_bus_size - 1 downto 0);
|
||||
OUT_A : out STD_LOGIC_VECTOR (Nb_bits - 1 downto 0);
|
||||
OUT_B : out STD_LOGIC_VECTOR (Nb_bits - 1 downto 0);
|
||||
OUT_Instruction : out STD_LOGIC_VECTOR (Instruction_bus_size - 1 downto 0));
|
||||
end component;
|
||||
|
||||
signal A_from_1 : STD_LOGIC_VECTOR (Nb_bits - 1 downto 0) := (others => '0');
|
||||
signal A_from_2 : STD_LOGIC_VECTOR (Nb_bits - 1 downto 0) := (others => '0');
|
||||
signal A_from_3 : STD_LOGIC_VECTOR (Nb_bits - 1 downto 0) := (others => '0');
|
||||
signal A_from_4 : STD_LOGIC_VECTOR (Nb_bits - 1 downto 0) := (others => '0');
|
||||
signal A_to_2 : STD_LOGIC_VECTOR (Nb_bits - 1 downto 0) := (others => '0');
|
||||
signal A_to_3 : STD_LOGIC_VECTOR (Nb_bits - 1 downto 0) := (others => '0');
|
||||
signal A_to_4 : STD_LOGIC_VECTOR (Nb_bits - 1 downto 0) := (others => '0');
|
||||
signal A_to_5 : STD_LOGIC_VECTOR (Nb_bits - 1 downto 0) := (others => '0');
|
||||
signal B_from_1 : STD_LOGIC_VECTOR (Nb_bits - 1 downto 0) := (others => '0');
|
||||
signal B_from_2 : STD_LOGIC_VECTOR (Nb_bits - 1 downto 0) := (others => '0');
|
||||
signal B_from_3 : STD_LOGIC_VECTOR (Nb_bits - 1 downto 0) := (others => '0');
|
||||
signal B_from_4 : STD_LOGIC_VECTOR (Nb_bits - 1 downto 0) := (others => '0');
|
||||
signal B_to_2 : STD_LOGIC_VECTOR (Nb_bits - 1 downto 0) := (others => '0');
|
||||
signal B_to_3 : STD_LOGIC_VECTOR (Nb_bits - 1 downto 0) := (others => '0');
|
||||
signal B_to_4 : STD_LOGIC_VECTOR (Nb_bits - 1 downto 0) := (others => '0');
|
||||
signal B_to_5 : STD_LOGIC_VECTOR (Nb_bits - 1 downto 0) := (others => '0');
|
||||
signal C_from_1 : STD_LOGIC_VECTOR (Nb_bits - 1 downto 0) := (others => '0');
|
||||
signal C_from_2 : STD_LOGIC_VECTOR (Nb_bits - 1 downto 0) := (others => '0');
|
||||
signal C_to_2 : STD_LOGIC_VECTOR (Nb_bits - 1 downto 0) := (others => '0');
|
||||
signal C_to_3 : STD_LOGIC_VECTOR (Nb_bits - 1 downto 0) := (others => '0');
|
||||
signal Instruction_from_1 : STD_LOGIC_VECTOR (Instruction_Bus_Size - 1 downto 0) := (others => '0');
|
||||
signal Instruction_from_2 : STD_LOGIC_VECTOR (Instruction_Bus_Size - 1 downto 0) := (others => '0');
|
||||
signal Instruction_from_3 : STD_LOGIC_VECTOR (Instruction_Bus_Size - 1 downto 0) := (others => '0');
|
||||
signal Instruction_from_4 : STD_LOGIC_VECTOR (Instruction_Bus_Size - 1 downto 0) := (others => '0');
|
||||
signal Instruction_to_2 : STD_LOGIC_VECTOR (Instruction_Bus_Size - 1 downto 0) := (others => '0');
|
||||
signal Instruction_to_3 : STD_LOGIC_VECTOR (Instruction_Bus_Size - 1 downto 0) := (others => '0');
|
||||
signal Instruction_to_4 : STD_LOGIC_VECTOR (Instruction_Bus_Size - 1 downto 0) := (others => '0');
|
||||
signal Instruction_to_5 : STD_LOGIC_VECTOR (Instruction_Bus_Size - 1 downto 0) := (others => '0');
|
||||
signal N : STD_LOGIC := '0';
|
||||
signal Z : STD_LOGIC := '0';
|
||||
signal O : STD_LOGIC := '0';
|
||||
signal C : STD_LOGIC := '0';
|
||||
|
||||
constant Bits_Controle_MUX_2_A : STD_LOGIC_VECTOR (Nb_Instructions - 1 downto 0) := "1111111111" & "1111011101111111111111";
|
||||
constant Bits_Controle_MUX_2_B : STD_LOGIC_VECTOR (Nb_Instructions - 1 downto 0) := "1111111111" & "1111111000011000000001";
|
||||
constant Bits_Controle_LC_3 : STD_LOGIC_VECTOR (Nb_Instructions * 3 - 1 downto 0) := "000" & "000" & "000" & "000" & "000" & "000" & "000" & "000" & "000" & "000" & "000" & "000" & "000" & "000" & "000" & "000" & "000" & "000" & "000" & "000" & "000" & "000" & "000" & "000" & "111" & "110" & "101" & "100" & "010" & "011" & "001" & "000";
|
||||
constant Bits_Controle_MUX_3 : STD_LOGIC_VECTOR (Nb_Instructions - 1 downto 0) := "1111111111" & "1111111111111100000001";
|
||||
constant Bits_Controle_LC_4 : STD_LOGIC_VECTOR (Nb_Instructions - 1 downto 0) := "1111111111" & "1111111001011111111111";
|
||||
constant Bits_Controle_MUX_4_IN : STD_LOGIC_VECTOR (Nb_Instructions - 1 downto 0) := "1111111111" & "1111111110101111111111";
|
||||
constant Bits_Controle_MUX_4_IN_EBP : STD_LOGIC_VECTOR (Nb_Instructions - 1 downto 0) := "1111111111" & "1111111011001111111111";
|
||||
constant Bits_Controle_MUX_4_OUT : STD_LOGIC_VECTOR (Nb_Instructions - 1 downto 0) := "1111111111" & "0000000001010000000000";
|
||||
constant Bits_Controle_LC_5 : STD_LOGIC_VECTOR (Nb_Instructions - 1 downto 0) := "1111111111" & "0001000001011111111110";
|
||||
constant Code_Instruction_JMP : STD_LOGIC_VECTOR (Instruction_Bus_Size - 1 downto 0) := "01111";
|
||||
constant Code_Instruction_JMZ : STD_LOGIC_VECTOR (Instruction_Bus_Size - 1 downto 0) := "10000";
|
||||
constant Code_Instruction_PRI : STD_LOGIC_VECTOR (Instruction_Bus_Size - 1 downto 0) := "10001";
|
||||
constant Code_Instruction_GET : STD_LOGIC_VECTOR (Instruction_Bus_Size - 1 downto 0) := "10010";
|
||||
constant Code_Instruction_CALL : STD_LOGIC_VECTOR (Instruction_Bus_Size - 1 downto 0) := "10011";
|
||||
constant Code_Instruction_RET : STD_LOGIC_VECTOR (Instruction_Bus_Size - 1 downto 0) := "10100";
|
||||
constant Code_Instruction_STOP : STD_LOGIC_VECTOR (Instruction_Bus_Size - 1 downto 0) := "10101";
|
||||
|
||||
constant Instructions_critiques_lecture_A : STD_LOGIC_VECTOR (Nb_Instructions - 1 downto 0) := "1111111111" & "0000100010000000000000";
|
||||
constant Instructions_critiques_lecture_B : STD_LOGIC_VECTOR (Nb_Instructions - 1 downto 0) := "1111111111" & "0000000111100111111110";
|
||||
constant Instructions_critiques_lecture_C : STD_LOGIC_VECTOR (Nb_Instructions - 1 downto 0) := "1111111111" & "0000000000000011111110";
|
||||
constant Instructions_critiques_ecriture : STD_LOGIC_VECTOR (Nb_Instructions - 1 downto 0) := "1111111111" & "0001000001011111111110";
|
||||
begin
|
||||
instance_Etage1 : Etage1_LectureInstruction
|
||||
generic map (Instruction_size_in_memory => Instruction_En_Memoire_Size,
|
||||
Addr_size_mem_instruction => Addr_Memoire_Instruction_Size,
|
||||
Mem_instruction_size => Memoire_Instruction_Size,
|
||||
Nb_bits => Nb_bits,
|
||||
Instruction_bus_size => Instruction_Bus_Size,
|
||||
Nb_registres => Nb_Registres,
|
||||
Mem_adresse_retour_size => Memoire_Adresses_Retour_Size,
|
||||
Adresse_size_mem_adresse_retour => Adresse_Memoire_Adresses_Retour_Size,
|
||||
Instructions_critiques_lecture_A => Instructions_critiques_lecture_A,
|
||||
Instructions_critiques_lecture_B => Instructions_critiques_lecture_B,
|
||||
Instructions_critiques_lecture_C => Instructions_critiques_lecture_C,
|
||||
Instructions_critiques_ecriture => Instructions_critiques_ecriture,
|
||||
Code_Instruction_JMP => Code_Instruction_JMP,
|
||||
Code_Instruction_JMZ => Code_Instruction_JMZ,
|
||||
Code_Instruction_CALL => Code_Instruction_CALL,
|
||||
Code_Instruction_RET => Code_Instruction_RET,
|
||||
Code_Instruction_STOP => Code_Instruction_STOP
|
||||
)
|
||||
port map (
|
||||
CLK => CLK,
|
||||
RST => RST,
|
||||
Z => Z,
|
||||
A => A_from_1,
|
||||
B => B_from_1,
|
||||
C => C_from_1,
|
||||
Instruction => Instruction_from_1
|
||||
);
|
||||
|
||||
instance_Etage2_5 : Etage2_5_Registres
|
||||
generic map( Nb_bits => Nb_bits,
|
||||
Nb_Registres => Nb_Registres,
|
||||
Addr_registres_size => Addr_registres_size,
|
||||
Instruction_bus_size => Instruction_Bus_Size,
|
||||
Bits_Controle_LC_5 => Bits_Controle_LC_5,
|
||||
Bits_Controle_MUX_2_A => Bits_Controle_MUX_2_A,
|
||||
Bits_Controle_MUX_2_B => Bits_Controle_MUX_2_B,
|
||||
Code_Instruction_PRI => Code_Instruction_PRI,
|
||||
Code_Instruction_GET => Code_Instruction_GET
|
||||
)
|
||||
port map( CLK => CLK,
|
||||
RST => RST,
|
||||
STD_IN => STD_IN,
|
||||
STD_OUT => STD_OUT,
|
||||
IN_2_A => A_to_2,
|
||||
IN_2_B => B_to_2,
|
||||
IN_2_C => C_to_2,
|
||||
IN_2_Instruction => Instruction_to_2,
|
||||
OUT_2_A => A_from_2,
|
||||
OUT_2_B => B_from_2,
|
||||
OUT_2_C => C_from_2,
|
||||
OUT_2_Instruction => Instruction_from_2,
|
||||
IN_5_A => A_to_5,
|
||||
IN_5_B => B_to_5,
|
||||
IN_5_Instruction => Instruction_to_5
|
||||
);
|
||||
|
||||
instance_Etage3 : Etage3_Calcul
|
||||
generic map( Nb_bits => Nb_bits,
|
||||
Instruction_bus_size => Instruction_Bus_Size,
|
||||
Bits_Controle_LC => Bits_Controle_LC_3,
|
||||
Bits_Controle_MUX => Bits_Controle_MUX_3
|
||||
)
|
||||
port map( RST => RST,
|
||||
IN_A => A_to_3,
|
||||
IN_B => B_to_3,
|
||||
IN_C => C_to_3,
|
||||
IN_Instruction => Instruction_to_3,
|
||||
OUT_A => A_from_3,
|
||||
OUT_B => B_from_3,
|
||||
OUT_Instruction => Instruction_from_3,
|
||||
N => N,
|
||||
O => O,
|
||||
Z => Z,
|
||||
C => C
|
||||
);
|
||||
|
||||
instance_Etage4 : Etage4_Memoire
|
||||
generic map( Nb_bits => Nb_bits,
|
||||
Mem_size => Memoire_Size,
|
||||
Adresse_mem_size => Adresse_mem_size,
|
||||
Instruction_bus_size => Instruction_Bus_Size,
|
||||
Mem_EBP_size => Memoire_Adresses_Retour_Size,
|
||||
Adresse_size_mem_EBP => Adresse_Memoire_Adresses_Retour_Size,
|
||||
Bits_Controle_LC => Bits_Controle_LC_4,
|
||||
Bits_Controle_MUX_IN => Bits_Controle_MUX_4_IN,
|
||||
Bits_Controle_MUX_IN_EBP => Bits_Controle_MUX_4_IN_EBP,
|
||||
Bits_Controle_MUX_OUT => Bits_Controle_MUX_4_OUT,
|
||||
Code_Instruction_CALL => Code_Instruction_CALL,
|
||||
Code_Instruction_RET => Code_Instruction_RET
|
||||
)
|
||||
port map( CLK => CLK,
|
||||
RST => RST,
|
||||
IN_A => A_to_4,
|
||||
IN_B => B_to_4,
|
||||
IN_Instruction => Instruction_to_4,
|
||||
OUT_A => A_from_4,
|
||||
OUT_B => B_from_4,
|
||||
OUT_Instruction => Instruction_from_4
|
||||
);
|
||||
|
||||
process
|
||||
begin
|
||||
wait until CLK'event and CLK = '1';
|
||||
A_to_2 <= A_from_1;
|
||||
B_to_2 <= B_from_1;
|
||||
C_to_2 <= C_from_1;
|
||||
Instruction_to_2 <= Instruction_from_1;
|
||||
|
||||
A_to_3 <= A_from_2;
|
||||
B_to_3 <= B_from_2;
|
||||
C_to_3 <= C_from_2;
|
||||
Instruction_to_3 <= Instruction_from_2;
|
||||
|
||||
A_to_4 <= A_from_3;
|
||||
B_to_4 <= B_from_3;
|
||||
Instruction_to_4 <= Instruction_from_3;
|
||||
|
||||
A_to_5 <= A_from_4;
|
||||
B_to_5 <= B_from_4;
|
||||
Instruction_to_5 <= Instruction_from_4;
|
||||
end process;
|
||||
end Behavioral;
|
|
@ -31,6 +31,26 @@ entity System is
|
|||
end System;
|
||||
|
||||
architecture Structural of System is
|
||||
|
||||
component Pipeline is
|
||||
Generic (Nb_bits : Natural := 8;
|
||||
Instruction_En_Memoire_Size : Natural := 29;
|
||||
Addr_Memoire_Instruction_Size : Natural := 3;
|
||||
Memoire_Instruction_Size : Natural := 8;
|
||||
Instruction_Bus_Size : Natural := 5;
|
||||
Nb_Instructions : Natural := 32;
|
||||
Nb_Registres : Natural := 16;
|
||||
Addr_registres_size : Natural := 4;
|
||||
Memoire_Size : Natural := 32;
|
||||
Adresse_mem_size : Natural := 5;
|
||||
Memoire_Adresses_Retour_Size : Natural := 16;
|
||||
Adresse_Memoire_Adresses_Retour_Size : Natural := 4);
|
||||
Port (CLK : STD_LOGIC;
|
||||
RST : STD_LOGIC;
|
||||
STD_IN : in STD_LOGIC_VECTOR (Nb_bits - 1 downto 0);
|
||||
STD_OUT : out STD_LOGIC_VECTOR (Nb_bits - 1 downto 0));
|
||||
end component;
|
||||
|
||||
component Pipeline_NS is
|
||||
Generic (Nb_bits : Natural := 8;
|
||||
Instruction_En_Memoire_Size : Natural := 29;
|
||||
|
@ -55,20 +75,35 @@ architecture Structural of System is
|
|||
signal my_RST : STD_LOGIC;
|
||||
signal my_CLK : STD_LOGIC;
|
||||
|
||||
constant SECURISED : boolean := true;
|
||||
|
||||
begin
|
||||
|
||||
-- Diviseur de clock
|
||||
clk_div : Clock_Divider
|
||||
port map (CLK_IN => CLK,
|
||||
CLK_OUT => my_CLK);
|
||||
|
||||
-- Le processeur, augmentation de la taille de la mémoire d'instruction
|
||||
instance : Pipeline_NS
|
||||
|
||||
-- Generation du processeur en fonction de la condition sécurisé ou non
|
||||
instance: if (SECURISED) generate
|
||||
instance_securisee : entity work.Pipeline
|
||||
generic map (Addr_Memoire_Instruction_Size => 8,
|
||||
Memoire_Instruction_Size => 256)
|
||||
port map (CLK => my_CLK,
|
||||
RST => my_RST,
|
||||
STD_IN => sw,
|
||||
STD_OUT => led);
|
||||
else generate
|
||||
instance_non_securisee : entity work.Pipeline_NS
|
||||
generic map (Addr_Memoire_Instruction_Size => 8,
|
||||
Memoire_Instruction_Size => 256)
|
||||
port map (CLK => my_CLK,
|
||||
RST => my_RST,
|
||||
STD_IN => sw,
|
||||
STD_OUT => led);
|
||||
end generate;
|
||||
|
||||
|
||||
-- Gestion du RST (inversion d'état)
|
||||
my_RST <= '1' when btnC = '0' else
|
||||
|
|
|
@ -62,7 +62,7 @@
|
|||
</FileInfo>
|
||||
</File>
|
||||
<File Path="$PSRCDIR/sources_1/new/System.vhd">
|
||||
<FileInfo>
|
||||
<FileInfo SFType="VHDL2008">
|
||||
<Attr Name="UsedIn" Val="synthesis"/>
|
||||
<Attr Name="UsedIn" Val="simulation"/>
|
||||
</FileInfo>
|
||||
|
@ -139,6 +139,24 @@
|
|||
<Attr Name="UsedIn" Val="simulation"/>
|
||||
</FileInfo>
|
||||
</File>
|
||||
<File Path="$PSRCDIR/sources_1/new/Pipeline.vhd">
|
||||
<FileInfo>
|
||||
<Attr Name="UsedIn" Val="synthesis"/>
|
||||
<Attr Name="UsedIn" Val="simulation"/>
|
||||
</FileInfo>
|
||||
</File>
|
||||
<File Path="$PSRCDIR/sources_1/new/Etage4_Memoire.vhd">
|
||||
<FileInfo>
|
||||
<Attr Name="UsedIn" Val="synthesis"/>
|
||||
<Attr Name="UsedIn" Val="simulation"/>
|
||||
</FileInfo>
|
||||
</File>
|
||||
<File Path="$PSRCDIR/sources_1/new/Etage1_LectureInstruction.vhd">
|
||||
<FileInfo>
|
||||
<Attr Name="UsedIn" Val="synthesis"/>
|
||||
<Attr Name="UsedIn" Val="simulation"/>
|
||||
</FileInfo>
|
||||
</File>
|
||||
<Config>
|
||||
<Option Name="DesignMode" Val="RTL"/>
|
||||
<Option Name="TopModule" Val="System"/>
|
||||
|
|
Loading…
Reference in a new issue