123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187 |
- ----------------------------------------------------------------------------------
- -- Company: INSA-Toulouse
- -- Engineer: Paul Faure
- --
- -- Create Date: 18.04.2021 21:19:41
- -- Module Name: Etage2_5_Registres - Behavioral
- -- Project Name: Processeur sécurisé
- -- Target Devices: Basys 3 ARTIX7
- -- Tool Versions: Vivado 2016.4
- -- Description: Etage 2 et 5 du processeur
- -- - Gestion des registres, lecture étage 2 et écriture étage 5
- -- - Lecture et Ecriture dans les entrées sorties du processeur
- --
- -- Dependencies:
- -- - BancRegistres
- -- - LC
- -- - MUX
- ----------------------------------------------------------------------------------
-
-
- library IEEE;
- use IEEE.STD_LOGIC_1164.ALL;
-
- entity Etage2_5_Registres is
- Generic ( Nb_bits : Natural; -- Taille d'un mot binaire
- Nb_registres : Natural; -- Nombre de registres du processeurs
- Addr_registres_size : Natural; -- Nombre de bits pour adresser les registres
- Instruction_bus_size : Natural; -- Nombre de bits du bus d'instruction (Taille d'un code instruction)
- Bits_Controle_LC_5 : STD_LOGIC_VECTOR; -- Vecteur de bit controlant le Link Controler de l'étage 5 (cf LC.vhd)
- Bits_Controle_MUX_2_A : STD_LOGIC_VECTOR; -- Vecteur de bit controlant le multiplexeur de l'étage 2 sur A (cf MUX.vhd)
- Bits_Controle_MUX_2_B : STD_LOGIC_VECTOR; -- Vecteur de bit controlant le multiplexeur de l'étage 2 sur B (cf MUX.vhd)
- Code_Instruction_PRI : STD_LOGIC_VECTOR; -- Numéro de l'instruction PRI
- Code_Instruction_PRIC : STD_LOGIC_VECTOR; -- Numéro de l'instruction PRIC
- Code_Instruction_GET : STD_LOGIC_VECTOR); -- Numéro de l'instruction GET
- Port ( CLK : in STD_LOGIC; -- Clock
- RST : in STD_LOGIC; -- Reset
- STD_IN : in STD_LOGIC_VECTOR (Nb_bits - 1 downto 0); -- Entrée de données depuis l'exterieur du processeur
- STD_IN_Av : in STD_LOGIC;
- STD_IN_Request : out STD_LOGIC;
- STD_OUT : out STD_LOGIC_VECTOR (Nb_bits - 1 downto 0); -- Sortie de données vers l'exterieur du processeur
- STD_OUT_Av : out STD_LOGIC;
- STD_OUT_Int : out STD_LOGIC;
- IN_2_A : in STD_LOGIC_VECTOR (Nb_bits - 1 downto 0); -- Entrée de l'opérande A de l'étage 2
- IN_2_B : in STD_LOGIC_VECTOR (Nb_bits - 1 downto 0); -- Entrée de l'opérande B de l'étage 2
- IN_2_C : in STD_LOGIC_VECTOR (Nb_bits - 1 downto 0); -- Entrée de l'opérande C de l'étage 2
- IN_2_Instruction : in STD_LOGIC_VECTOR (Instruction_bus_size - 1 downto 0); -- Entrée de l'instruction de l'étage 2
- OUT_2_A : out STD_LOGIC_VECTOR (Nb_bits - 1 downto 0); -- Sortie de l'opérande A de l'étage 2
- OUT_2_B : out STD_LOGIC_VECTOR (Nb_bits - 1 downto 0); -- Sortie de l'opérande B de l'étage 2
- OUT_2_C : out STD_LOGIC_VECTOR (Nb_bits - 1 downto 0); -- Sortie de l'opérande C de l'étage 2
- OUT_2_Instruction : out STD_LOGIC_VECTOR (Instruction_bus_size - 1 downto 0); -- Sortie de l'instruction de l'étage 2
- IN_5_A : in STD_LOGIC_VECTOR (Nb_bits - 1 downto 0); -- Entrée de l'opérande A de l'étage 5
- IN_5_B : in STD_LOGIC_VECTOR (Nb_bits - 1 downto 0); -- Entrée de l'opérande B de l'étage 5
- IN_5_Instruction : in STD_LOGIC_VECTOR (Instruction_bus_size - 1 downto 0)); -- Entrée de l'instruction de l'étage 5
- end Etage2_5_Registres;
-
- architecture Behavioral of Etage2_5_Registres is
- component BancRegistres is
- Generic (Nb_bits : Natural;
- Addr_size : Natural;
- Nb_regs : Natural);
- Port ( AddrA : in STD_LOGIC_VECTOR (Addr_size-1 downto 0);
- AddrB : in STD_LOGIC_VECTOR (Addr_size-1 downto 0);
- AddrC : in STD_LOGIC_VECTOR (Addr_size-1 downto 0);
- AddrW : in STD_LOGIC_VECTOR (Addr_size-1 downto 0);
- W : in STD_LOGIC;
- DATA : in STD_LOGIC_VECTOR (Nb_bits-1 downto 0);
- RST : in STD_LOGIC;
- CLK : in STD_LOGIC;
- QA : out STD_LOGIC_VECTOR (Nb_bits-1 downto 0);
- QB : out STD_LOGIC_VECTOR (Nb_bits-1 downto 0);
- QC : out STD_LOGIC_VECTOR (Nb_bits-1 downto 0));
- 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 Commande_BancRegistres : STD_LOGIC_VECTOR (0 downto 0) := "0"; -- Signal de sortie du LC
-
- signal Entree_BancRegistre_DATA : STD_LOGIC_VECTOR (Nb_bits - 1 downto 0) := (others => '0'); -- Entrée DATA du banc de registre (B de l'étage 5 ou STD_IN)
-
- signal Sortie_BancRegistres_A : STD_LOGIC_VECTOR (Nb_bits - 1 downto 0) := (others => '0'); -- Sortie du banc de registre a passer par le multiplexeur sur A
- signal Sortie_BancRegistres_B : STD_LOGIC_VECTOR (Nb_bits - 1 downto 0) := (others => '0'); -- Sortie du banc de registre a passer par le multiplexeur sur B
-
- -- Signaux internes
- signal intern_OUT_2_A : STD_LOGIC_VECTOR (Nb_bits - 1 downto 0) := (others => '0');
- signal intern_OUT_2_B : STD_LOGIC_VECTOR (Nb_bits - 1 downto 0) := (others => '0');
- signal intern_OUT_2_C : STD_LOGIC_VECTOR (Nb_bits - 1 downto 0) := (others => '0');
-
- signal Request_Stopped : BOOLEAN := false;
-
-
- begin
- instance_LC : LC
- generic map (Instruction_Vector_Size => Instruction_bus_size,
- Command_size => 1,
- Bits_Controle => Bits_Controle_LC_5)
- port map ( Instruction => IN_5_Instruction,
- Commande => Commande_BancRegistres);
-
- instance_MUX_A : MUX
- generic map (Nb_bits => Nb_bits,
- Instruction_Vector_Size => Instruction_bus_size,
- Bits_Controle => Bits_Controle_MUX_2_A)
- port map ( Instruction => IN_2_Instruction,
- IN1 => IN_2_A,
- IN2 => Sortie_BancRegistres_A,
- OUTPUT => intern_OUT_2_A);
-
- instance_MUX_B : MUX
- generic map (Nb_bits => Nb_bits,
- Instruction_Vector_Size => Instruction_bus_size,
- Bits_Controle => Bits_Controle_MUX_2_B)
- port map ( Instruction => IN_2_Instruction,
- IN1 => IN_2_B,
- IN2 => Sortie_BancRegistres_B,
- OUTPUT => intern_OUT_2_B);
-
- instance_BancRegistres : BancRegistres
- generic map (Nb_bits => Nb_bits,
- Addr_size => Addr_registres_size,
- Nb_regs => Nb_registres)
- port map ( AddrA => IN_2_A(Addr_registres_size - 1 downto 0),
- AddrB => IN_2_B(Addr_registres_size - 1 downto 0),
- AddrC => IN_2_C(Addr_registres_size - 1 downto 0),
- AddrW => IN_5_A(Addr_registres_size - 1 downto 0),
- W => Commande_BancRegistres(0),
- DATA => Entree_BancRegistre_DATA,
- RST => RST,
- CLK => CLK,
- QA => Sortie_BancRegistres_A,
- QB => Sortie_BancRegistres_B,
- QC => intern_OUT_2_C);
-
- OUT_2_A <= (others => '0') when RST = '0' else
- intern_OUT_2_A;
- OUT_2_B <= (others => '0') when RST = '0' else
- intern_OUT_2_B;
- OUT_2_C <= (others => '0') when RST = '0' else
- intern_OUT_2_C;
- OUT_2_Instruction <= (others => '0') when RST = '0' else
- IN_2_Instruction;
-
- STD_OUT <= (others => '0') when RST = '0' else
- intern_OUT_2_A;
- STD_OUT_Av <= '0' when RST = '0' else
- '1' when IN_2_Instruction = Code_Instruction_PRI or IN_2_Instruction = Code_Instruction_PRIC else
- '0';
- STD_OUT_Int <= '0' when RST = '0' else
- '1' when IN_2_Instruction = Code_Instruction_PRI else
- '0';
-
- process
- begin
- wait until CLK'event and CLK='1';
- if (RST='0') then
- Request_Stopped <= false;
- elsif (STD_IN_Av = '1') then
- Request_Stopped <= true;
- else
- Request_Stopped <= false;
- end if;
- end process;
-
- STD_IN_Request <= '1' when not(Request_Stopped) and IN_5_Instruction = Code_Instruction_GET and not(RST='0') else '0';
-
- -- Un multiplexeur pourrait être utilisé ici, mais cela n'a pas été jugé pertinent
- Entree_BancRegistre_DATA <= (others => '0') when RST = '0' else
- STD_IN when IN_5_Instruction = Code_Instruction_GET else
- IN_5_B;
-
-
- end Behavioral;
|