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.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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. begin
  94. instance_LC : LC
  95. generic map (Instruction_Vector_Size => Instruction_bus_size,
  96. Command_size => 1,
  97. Bits_Controle => Bits_Controle_LC_5)
  98. port map ( Instruction => IN_5_Instruction,
  99. Commande => Commande_BancRegistres);
  100. instance_MUX_A : MUX
  101. generic map (Nb_bits => Nb_bits,
  102. Instruction_Vector_Size => Instruction_bus_size,
  103. Bits_Controle => Bits_Controle_MUX_2_A)
  104. port map ( Instruction => IN_2_Instruction,
  105. IN1 => IN_2_A,
  106. IN2 => Sortie_BancRegistres_A,
  107. OUTPUT => intern_OUT_2_A);
  108. instance_MUX_B : MUX
  109. generic map (Nb_bits => Nb_bits,
  110. Instruction_Vector_Size => Instruction_bus_size,
  111. Bits_Controle => Bits_Controle_MUX_2_B)
  112. port map ( Instruction => IN_2_Instruction,
  113. IN1 => IN_2_B,
  114. IN2 => Sortie_BancRegistres_B,
  115. OUTPUT => intern_OUT_2_B);
  116. instance_BancRegistres : BancRegistres
  117. generic map (Nb_bits => Nb_bits,
  118. Addr_size => Addr_registres_size,
  119. Nb_regs => Nb_registres)
  120. port map ( AddrA => IN_2_A(Addr_registres_size - 1 downto 0),
  121. AddrB => IN_2_B(Addr_registres_size - 1 downto 0),
  122. AddrC => IN_2_C(Addr_registres_size - 1 downto 0),
  123. AddrW => IN_5_A(Addr_registres_size - 1 downto 0),
  124. W => Commande_BancRegistres(0),
  125. DATA => Entree_BancRegistre_DATA,
  126. RST => RST,
  127. CLK => CLK,
  128. QA => Sortie_BancRegistres_A,
  129. QB => Sortie_BancRegistres_B,
  130. QC => intern_OUT_2_C);
  131. OUT_2_A <= (others => '0') when RST = '0' else
  132. intern_OUT_2_A;
  133. OUT_2_B <= (others => '0') when RST = '0' else
  134. intern_OUT_2_B;
  135. OUT_2_C <= (others => '0') when RST = '0' else
  136. intern_OUT_2_C;
  137. OUT_2_Instruction <= (others => '0') when RST = '0' else
  138. IN_2_Instruction;
  139. STD_OUT <= (others => '0') when RST = '0' else
  140. intern_OUT_2_A;
  141. STD_OUT_Av <= '0' when RST = '0' else
  142. '1' when IN_2_Instruction = Code_Instruction_PRI or IN_2_Instruction = Code_Instruction_PRIC else
  143. '0';
  144. STD_OUT_Int <= '0' when RST = '0' else
  145. '1' when IN_2_Instruction = Code_Instruction_PRI else
  146. '0';
  147. STD_IN_Request <= '0' when RST = '0' else
  148. '1' when IN_5_Instruction = Code_Instruction_GET and STD_IN_Av = '0' else
  149. '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;