No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Etage2-5_Registres.vhd 9.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. ----------------------------------------------------------------------------------
  2. -- Company: INSA-Toulouse
  3. -- Engineer: Paul Faure
  4. --
  5. -- Create Date: 18.04.2021 21:19:41
  6. -- Module Name: Etage2_5_Registres - Behavioral
  7. -- Project Name: Processeur sécurisé
  8. -- Target Devices: Basys 3 ARTIX7
  9. -- Tool Versions: Vivado 2016.4
  10. -- Description: Etage 2 et 5 du processeur
  11. -- - Gestion des registres, lecture étage 2 et écriture étage 5
  12. -- - Lecture et Ecriture dans les entrées sorties du processeur
  13. --
  14. -- Dependencies:
  15. -- - BancRegistres
  16. -- - LC
  17. -- - MUX
  18. ----------------------------------------------------------------------------------
  19. library IEEE;
  20. use IEEE.STD_LOGIC_1164.ALL;
  21. entity Etage2_5_Registres is
  22. Generic ( Nb_bits : Natural; -- Taille d'un mot binaire
  23. Nb_registres : Natural; -- Nombre de registres du processeurs
  24. Addr_registres_size : Natural; -- Nombre de bits pour adresser les registres
  25. Instruction_bus_size : Natural; -- Nombre de bits du bus d'instruction (Taille d'un code instruction)
  26. Bits_Controle_LC_5 : STD_LOGIC_VECTOR; -- Vecteur de bit controlant le Link Controler de l'étage 5 (cf LC.vhd)
  27. Bits_Controle_MUX_2_A : STD_LOGIC_VECTOR; -- Vecteur de bit controlant le multiplexeur de l'étage 2 sur A (cf MUX.vhd)
  28. Bits_Controle_MUX_2_B : STD_LOGIC_VECTOR; -- Vecteur de bit controlant le multiplexeur de l'étage 2 sur B (cf MUX.vhd)
  29. Code_Instruction_PRI : STD_LOGIC_VECTOR; -- Numéro de l'instruction PRI
  30. Code_Instruction_PRIC : STD_LOGIC_VECTOR; -- Numéro de l'instruction PRIC
  31. Code_Instruction_GET : STD_LOGIC_VECTOR); -- Numéro de l'instruction GET
  32. Port ( CLK : in STD_LOGIC; -- Clock
  33. RST : in STD_LOGIC; -- Reset
  34. STD_IN : in STD_LOGIC_VECTOR (Nb_bits - 1 downto 0); -- Entrée de données depuis l'exterieur du processeur
  35. STD_IN_Av : in STD_LOGIC;
  36. STD_IN_Request : out STD_LOGIC;
  37. STD_OUT : out STD_LOGIC_VECTOR (Nb_bits - 1 downto 0); -- Sortie de données vers l'exterieur du processeur
  38. STD_OUT_Av : out STD_LOGIC;
  39. STD_OUT_Int : out STD_LOGIC;
  40. IN_2_A : in STD_LOGIC_VECTOR (Nb_bits - 1 downto 0); -- Entrée de l'opérande A de l'étage 2
  41. IN_2_B : in STD_LOGIC_VECTOR (Nb_bits - 1 downto 0); -- Entrée de l'opérande B de l'étage 2
  42. IN_2_C : in STD_LOGIC_VECTOR (Nb_bits - 1 downto 0); -- Entrée de l'opérande C de l'étage 2
  43. IN_2_Instruction : in STD_LOGIC_VECTOR (Instruction_bus_size - 1 downto 0); -- Entrée de l'instruction de l'étage 2
  44. OUT_2_A : out STD_LOGIC_VECTOR (Nb_bits - 1 downto 0); -- Sortie de l'opérande A de l'étage 2
  45. OUT_2_B : out STD_LOGIC_VECTOR (Nb_bits - 1 downto 0); -- Sortie de l'opérande B de l'étage 2
  46. OUT_2_C : out STD_LOGIC_VECTOR (Nb_bits - 1 downto 0); -- Sortie de l'opérande C de l'étage 2
  47. OUT_2_Instruction : out STD_LOGIC_VECTOR (Instruction_bus_size - 1 downto 0); -- Sortie de l'instruction de l'étage 2
  48. IN_5_A : in STD_LOGIC_VECTOR (Nb_bits - 1 downto 0); -- Entrée de l'opérande A de l'étage 5
  49. IN_5_B : in STD_LOGIC_VECTOR (Nb_bits - 1 downto 0); -- Entrée de l'opérande B de l'étage 5
  50. IN_5_Instruction : in STD_LOGIC_VECTOR (Instruction_bus_size - 1 downto 0)); -- Entrée de l'instruction de l'étage 5
  51. end Etage2_5_Registres;
  52. architecture Behavioral of Etage2_5_Registres is
  53. component BancRegistres is
  54. Generic (Nb_bits : Natural;
  55. Addr_size : Natural;
  56. Nb_regs : Natural);
  57. Port ( AddrA : in STD_LOGIC_VECTOR (Addr_size-1 downto 0);
  58. AddrB : in STD_LOGIC_VECTOR (Addr_size-1 downto 0);
  59. AddrC : in STD_LOGIC_VECTOR (Addr_size-1 downto 0);
  60. AddrW : in STD_LOGIC_VECTOR (Addr_size-1 downto 0);
  61. W : in STD_LOGIC;
  62. DATA : in STD_LOGIC_VECTOR (Nb_bits-1 downto 0);
  63. RST : in STD_LOGIC;
  64. CLK : in STD_LOGIC;
  65. QA : out STD_LOGIC_VECTOR (Nb_bits-1 downto 0);
  66. QB : out STD_LOGIC_VECTOR (Nb_bits-1 downto 0);
  67. QC : out STD_LOGIC_VECTOR (Nb_bits-1 downto 0));
  68. end component;
  69. component LC is
  70. Generic (Instruction_Vector_Size : Natural;
  71. Command_size : Natural;
  72. Bits_Controle : STD_LOGIC_VECTOR);
  73. Port ( Instruction : in STD_LOGIC_VECTOR (Instruction_Vector_Size - 1 downto 0);
  74. Commande : out STD_LOGIC_VECTOR (Command_size - 1 downto 0));
  75. end component;
  76. component MUX is
  77. Generic (Nb_bits : Natural;
  78. Instruction_Vector_Size : Natural;
  79. Bits_Controle : STD_LOGIC_VECTOR);
  80. Port ( Instruction : in STD_LOGIC_VECTOR (Instruction_Vector_Size - 1 downto 0);
  81. IN1 : in STD_LOGIC_VECTOR (Nb_bits - 1 downto 0);
  82. IN2 : in STD_LOGIC_VECTOR (Nb_bits - 1 downto 0);
  83. OUTPUT : out STD_LOGIC_VECTOR (Nb_bits - 1 downto 0));
  84. end component;
  85. signal Commande_BancRegistres : STD_LOGIC_VECTOR (0 downto 0) := "0"; -- Signal de sortie du LC
  86. 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)
  87. 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
  88. 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
  89. -- Signaux internes
  90. signal intern_OUT_2_A : STD_LOGIC_VECTOR (Nb_bits - 1 downto 0) := (others => '0');
  91. signal intern_OUT_2_B : STD_LOGIC_VECTOR (Nb_bits - 1 downto 0) := (others => '0');
  92. signal intern_OUT_2_C : STD_LOGIC_VECTOR (Nb_bits - 1 downto 0) := (others => '0');
  93. signal Request_Stopped : BOOLEAN := false;
  94. begin
  95. instance_LC : LC
  96. generic map (Instruction_Vector_Size => Instruction_bus_size,
  97. Command_size => 1,
  98. Bits_Controle => Bits_Controle_LC_5)
  99. port map ( Instruction => IN_5_Instruction,
  100. Commande => Commande_BancRegistres);
  101. instance_MUX_A : MUX
  102. generic map (Nb_bits => Nb_bits,
  103. Instruction_Vector_Size => Instruction_bus_size,
  104. Bits_Controle => Bits_Controle_MUX_2_A)
  105. port map ( Instruction => IN_2_Instruction,
  106. IN1 => IN_2_A,
  107. IN2 => Sortie_BancRegistres_A,
  108. OUTPUT => intern_OUT_2_A);
  109. instance_MUX_B : MUX
  110. generic map (Nb_bits => Nb_bits,
  111. Instruction_Vector_Size => Instruction_bus_size,
  112. Bits_Controle => Bits_Controle_MUX_2_B)
  113. port map ( Instruction => IN_2_Instruction,
  114. IN1 => IN_2_B,
  115. IN2 => Sortie_BancRegistres_B,
  116. OUTPUT => intern_OUT_2_B);
  117. instance_BancRegistres : BancRegistres
  118. generic map (Nb_bits => Nb_bits,
  119. Addr_size => Addr_registres_size,
  120. Nb_regs => Nb_registres)
  121. port map ( AddrA => IN_2_A(Addr_registres_size - 1 downto 0),
  122. AddrB => IN_2_B(Addr_registres_size - 1 downto 0),
  123. AddrC => IN_2_C(Addr_registres_size - 1 downto 0),
  124. AddrW => IN_5_A(Addr_registres_size - 1 downto 0),
  125. W => Commande_BancRegistres(0),
  126. DATA => Entree_BancRegistre_DATA,
  127. RST => RST,
  128. CLK => CLK,
  129. QA => Sortie_BancRegistres_A,
  130. QB => Sortie_BancRegistres_B,
  131. QC => intern_OUT_2_C);
  132. OUT_2_A <= (others => '0') when RST = '0' else
  133. intern_OUT_2_A;
  134. OUT_2_B <= (others => '0') when RST = '0' else
  135. intern_OUT_2_B;
  136. OUT_2_C <= (others => '0') when RST = '0' else
  137. intern_OUT_2_C;
  138. OUT_2_Instruction <= (others => '0') when RST = '0' else
  139. IN_2_Instruction;
  140. STD_OUT <= (others => '0') when RST = '0' else
  141. intern_OUT_2_A;
  142. STD_OUT_Av <= '0' when RST = '0' else
  143. '1' when IN_2_Instruction = Code_Instruction_PRI or IN_2_Instruction = Code_Instruction_PRIC else
  144. '0';
  145. STD_OUT_Int <= '0' when RST = '0' else
  146. '1' when IN_2_Instruction = Code_Instruction_PRI else
  147. '0';
  148. process
  149. begin
  150. wait until CLK'event and CLK='1';
  151. if (RST='0') then
  152. Request_Stopped <= false;
  153. elsif (STD_IN_Av = '1') then
  154. Request_Stopped <= true;
  155. else
  156. Request_Stopped <= false;
  157. end if;
  158. end process;
  159. STD_IN_Request <= '1' when not(Request_Stopped) and IN_5_Instruction = Code_Instruction_GET and not(RST='0') else '0';
  160. -- Un multiplexeur pourrait être utilisé ici, mais cela n'a pas été jugé pertinent
  161. Entree_BancRegistre_DATA <= (others => '0') when RST = '0' else
  162. STD_IN when IN_5_Instruction = Code_Instruction_GET else
  163. IN_5_B;
  164. end Behavioral;