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 8.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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_GET : STD_LOGIC_VECTOR); -- Numéro de l'instruction GET
  31. Port ( CLK : in STD_LOGIC; -- Clock
  32. RST : in STD_LOGIC; -- Reset
  33. STD_IN : in STD_LOGIC_VECTOR (Nb_bits - 1 downto 0); -- Entrée de données depuis l'exterieur du processeur
  34. STD_OUT : out STD_LOGIC_VECTOR (Nb_bits - 1 downto 0); -- Sortie de données vers l'exterieur du processeur
  35. IN_2_A : in STD_LOGIC_VECTOR (Nb_bits - 1 downto 0); -- Entrée de l'opérande A de l'étage 2
  36. IN_2_B : in STD_LOGIC_VECTOR (Nb_bits - 1 downto 0); -- Entrée de l'opérande B de l'étage 2
  37. IN_2_C : in STD_LOGIC_VECTOR (Nb_bits - 1 downto 0); -- Entrée de l'opérande C de l'étage 2
  38. IN_2_Instruction : in STD_LOGIC_VECTOR (Instruction_bus_size - 1 downto 0); -- Entrée de l'instruction de l'étage 2
  39. OUT_2_A : out STD_LOGIC_VECTOR (Nb_bits - 1 downto 0); -- Sortie de l'opérande A de l'étage 2
  40. OUT_2_B : out STD_LOGIC_VECTOR (Nb_bits - 1 downto 0); -- Sortie de l'opérande B de l'étage 2
  41. OUT_2_C : out STD_LOGIC_VECTOR (Nb_bits - 1 downto 0); -- Sortie de l'opérande C de l'étage 2
  42. OUT_2_Instruction : out STD_LOGIC_VECTOR (Instruction_bus_size - 1 downto 0); -- Sortie de l'instruction de l'étage 2
  43. IN_5_A : in STD_LOGIC_VECTOR (Nb_bits - 1 downto 0); -- Entrée de l'opérande A de l'étage 5
  44. IN_5_B : in STD_LOGIC_VECTOR (Nb_bits - 1 downto 0); -- Entrée de l'opérande B de l'étage 5
  45. IN_5_Instruction : in STD_LOGIC_VECTOR (Instruction_bus_size - 1 downto 0)); -- Entrée de l'instruction de l'étage 5
  46. end Etage2_5_Registres;
  47. architecture Behavioral of Etage2_5_Registres is
  48. component BancRegistres is
  49. Generic (Nb_bits : Natural;
  50. Addr_size : Natural;
  51. Nb_regs : Natural);
  52. Port ( AddrA : in STD_LOGIC_VECTOR (Addr_size-1 downto 0);
  53. AddrB : in STD_LOGIC_VECTOR (Addr_size-1 downto 0);
  54. AddrC : in STD_LOGIC_VECTOR (Addr_size-1 downto 0);
  55. AddrW : in STD_LOGIC_VECTOR (Addr_size-1 downto 0);
  56. W : in STD_LOGIC;
  57. DATA : in STD_LOGIC_VECTOR (Nb_bits-1 downto 0);
  58. RST : in STD_LOGIC;
  59. CLK : in STD_LOGIC;
  60. QA : out STD_LOGIC_VECTOR (Nb_bits-1 downto 0);
  61. QB : out STD_LOGIC_VECTOR (Nb_bits-1 downto 0);
  62. QC : out STD_LOGIC_VECTOR (Nb_bits-1 downto 0));
  63. end component;
  64. component LC is
  65. Generic (Instruction_Vector_Size : Natural;
  66. Command_size : Natural;
  67. Bits_Controle : STD_LOGIC_VECTOR);
  68. Port ( Instruction : in STD_LOGIC_VECTOR (Instruction_Vector_Size - 1 downto 0);
  69. Commande : out STD_LOGIC_VECTOR (Command_size - 1 downto 0));
  70. end component;
  71. component MUX is
  72. Generic (Nb_bits : Natural;
  73. Instruction_Vector_Size : Natural;
  74. Bits_Controle : STD_LOGIC_VECTOR);
  75. Port ( Instruction : in STD_LOGIC_VECTOR (Instruction_Vector_Size - 1 downto 0);
  76. IN1 : in STD_LOGIC_VECTOR (Nb_bits - 1 downto 0);
  77. IN2 : in STD_LOGIC_VECTOR (Nb_bits - 1 downto 0);
  78. OUTPUT : out STD_LOGIC_VECTOR (Nb_bits - 1 downto 0));
  79. end component;
  80. signal Commande_BancRegistres : STD_LOGIC_VECTOR (0 downto 0) := "0"; -- Signal de sortie du LC
  81. 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)
  82. 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
  83. 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
  84. -- Signaux internes
  85. signal intern_OUT_2_A : STD_LOGIC_VECTOR (Nb_bits - 1 downto 0) := (others => '0');
  86. signal intern_OUT_2_B : STD_LOGIC_VECTOR (Nb_bits - 1 downto 0) := (others => '0');
  87. signal intern_OUT_2_C : STD_LOGIC_VECTOR (Nb_bits - 1 downto 0) := (others => '0');
  88. signal intern_STD_OUT : STD_LOGIC_VECTOR (Nb_bits - 1 downto 0) := (others => '0');
  89. begin
  90. instance_LC : LC
  91. generic map (Instruction_Vector_Size => Instruction_bus_size,
  92. Command_size => 1,
  93. Bits_Controle => Bits_Controle_LC_5)
  94. port map ( Instruction => IN_5_Instruction,
  95. Commande => Commande_BancRegistres);
  96. instance_MUX_A : MUX
  97. generic map (Nb_bits => Nb_bits,
  98. Instruction_Vector_Size => Instruction_bus_size,
  99. Bits_Controle => Bits_Controle_MUX_2_A)
  100. port map ( Instruction => IN_2_Instruction,
  101. IN1 => IN_2_A,
  102. IN2 => Sortie_BancRegistres_A,
  103. OUTPUT => intern_OUT_2_A);
  104. instance_MUX_B : MUX
  105. generic map (Nb_bits => Nb_bits,
  106. Instruction_Vector_Size => Instruction_bus_size,
  107. Bits_Controle => Bits_Controle_MUX_2_B)
  108. port map ( Instruction => IN_2_Instruction,
  109. IN1 => IN_2_B,
  110. IN2 => Sortie_BancRegistres_B,
  111. OUTPUT => intern_OUT_2_B);
  112. instance_BancRegistres : BancRegistres
  113. generic map (Nb_bits => Nb_bits,
  114. Addr_size => Addr_registres_size,
  115. Nb_regs => Nb_registres)
  116. port map ( AddrA => IN_2_A(Addr_registres_size - 1 downto 0),
  117. AddrB => IN_2_B(Addr_registres_size - 1 downto 0),
  118. AddrC => IN_2_C(Addr_registres_size - 1 downto 0),
  119. AddrW => IN_5_A(Addr_registres_size - 1 downto 0),
  120. W => Commande_BancRegistres(0),
  121. DATA => Entree_BancRegistre_DATA,
  122. RST => RST,
  123. CLK => CLK,
  124. QA => Sortie_BancRegistres_A,
  125. QB => Sortie_BancRegistres_B,
  126. QC => intern_OUT_2_C);
  127. OUT_2_A <= (others => '0') when RST = '0' else
  128. intern_OUT_2_A;
  129. OUT_2_B <= (others => '0') when RST = '0' else
  130. intern_OUT_2_B;
  131. OUT_2_C <= (others => '0') when RST = '0' else
  132. intern_OUT_2_C;
  133. OUT_2_Instruction <= (others => '0') when RST = '0' else
  134. IN_2_Instruction;
  135. -- Gestion de STD_OU (peut être améliorée)
  136. process
  137. begin
  138. -- Synchronisation sur la clock
  139. wait until CLK'event and CLK = '1';
  140. if (RST = '0') then
  141. intern_STD_OUT <= (others => '0');
  142. else
  143. if (IN_2_Instruction = Code_Instruction_PRI) then
  144. intern_STD_OUT <= intern_OUT_2_A;
  145. end if;
  146. end if;
  147. end process;
  148. STD_OUT <= intern_STD_OUT when RST = '1' else
  149. (others => '0');
  150. -- Un multiplexeur pourrait être utilisé ici, mais cela n'a pas été jugé pertinent
  151. Entree_BancRegistre_DATA <= (others => '0') when RST = '0' else
  152. STD_IN when IN_5_Instruction = Code_Instruction_GET else
  153. IN_5_B;
  154. end Behavioral;