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.

Etage4_Memoire.vhd 7.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. ----------------------------------------------------------------------------------
  2. -- Company:
  3. -- Engineer:
  4. --
  5. -- Create Date: 18.04.2021 21:19:41
  6. -- Design Name:
  7. -- Module Name: Etage4_Memoire - Behavioral
  8. -- Project Name:
  9. -- Target Devices:
  10. -- Tool Versions:
  11. -- Description:
  12. --
  13. -- Dependencies:
  14. --
  15. -- Revision:
  16. -- Revision 0.01 - File Created
  17. -- Additional Comments:
  18. --
  19. ----------------------------------------------------------------------------------
  20. library IEEE;
  21. use IEEE.STD_LOGIC_1164.ALL;
  22. use IEEE.STD_LOGIC_UNSIGNED.ALL;
  23. -- Uncomment the following library declaration if using
  24. -- arithmetic functions with Signed or Unsigned values
  25. -- use IEEE.NUMERIC_STD.ALL;
  26. -- Uncomment the following library declaration if instantiating
  27. -- any Xilinx leaf cells in this code.
  28. --library UNISIM;
  29. --use UNISIM.VComponents.all;
  30. entity Etage4_Memoire is
  31. Generic ( Nb_bits : Natural;
  32. Mem_size : Natural;
  33. Instruction_bus_size : Natural;
  34. Mem_EBP_size : Natural;
  35. Adresse_size_mem_EBP : Natural;
  36. Bits_Controle_LC : STD_LOGIC_VECTOR;
  37. Bits_Controle_MUX_IN : STD_LOGIC_VECTOR;
  38. Bits_Controle_MUX_IN_EBP : STD_LOGIC_VECTOR;
  39. Bits_Controle_MUX_OUT : STD_LOGIC_VECTOR;
  40. Code_Instruction_CALL : STD_LOGIC_VECTOR;
  41. Code_Instruction_RET : STD_LOGIC_VECTOR);
  42. Port ( CLK : in STD_LOGIC;
  43. RST : in STD_LOGIC;
  44. IN_A : in STD_LOGIC_VECTOR (Nb_bits - 1 downto 0);
  45. IN_B : in STD_LOGIC_VECTOR (Nb_bits - 1 downto 0);
  46. IN_Instruction : in STD_LOGIC_VECTOR (Instruction_bus_size - 1 downto 0);
  47. OUT_A : out STD_LOGIC_VECTOR (Nb_bits - 1 downto 0);
  48. OUT_B : out STD_LOGIC_VECTOR (Nb_bits - 1 downto 0);
  49. OUT_Instruction : out STD_LOGIC_VECTOR (Instruction_bus_size - 1 downto 0));
  50. end Etage4_Memoire;
  51. architecture Structural of Etage4_Memoire is
  52. component MemoireDonnees is
  53. Generic (Nb_bits : Natural;
  54. Addr_size : Natural;
  55. Mem_size : Natural);
  56. Port ( Addr : in STD_LOGIC_VECTOR (Addr_size-1 downto 0);
  57. RW : in STD_LOGIC;
  58. D_IN : in STD_LOGIC_VECTOR (Nb_bits-1 downto 0);
  59. RST : in STD_LOGIC;
  60. CLK : in STD_LOGIC;
  61. D_OUT : out STD_LOGIC_VECTOR (Nb_bits-1 downto 0) := (others => '0'));
  62. end component;
  63. component MemoireAdressesRetour is
  64. Generic (Nb_bits : Natural;
  65. Addr_size : Natural;
  66. Mem_size : Natural);
  67. Port ( R : in STD_LOGIC;
  68. W : in STD_LOGIC;
  69. D_IN : in STD_LOGIC_VECTOR (Nb_bits-1 downto 0);
  70. RST : in STD_LOGIC;
  71. CLK : in STD_LOGIC;
  72. D_OUT : out STD_LOGIC_VECTOR (Nb_bits-1 downto 0) := (others => '0');
  73. E : out STD_LOGIC;
  74. F : out STD_LOGIC);
  75. end component;
  76. component LC is
  77. Generic (Instruction_Vector_Size : Natural;
  78. Command_size : Natural;
  79. Bits_Controle : STD_LOGIC_VECTOR);
  80. Port ( Instruction : in STD_LOGIC_VECTOR (Instruction_Vector_Size - 1 downto 0);
  81. Commande : out STD_LOGIC_VECTOR (Command_size - 1 downto 0));
  82. end component;
  83. component MUX is
  84. Generic (Nb_bits : Natural;
  85. Instruction_Vector_Size : Natural;
  86. Bits_Controle : STD_LOGIC_VECTOR);
  87. Port ( Instruction : in STD_LOGIC_VECTOR (Instruction_Vector_Size - 1 downto 0);
  88. IN1 : in STD_LOGIC_VECTOR (Nb_bits - 1 downto 0);
  89. IN2 : in STD_LOGIC_VECTOR (Nb_bits - 1 downto 0);
  90. OUTPUT : out STD_LOGIC_VECTOR (Nb_bits - 1 downto 0));
  91. end component;
  92. signal Addr_MemoireDonnees : STD_LOGIC_VECTOR (Nb_bits - 1 downto 0) := (others => '0');
  93. signal IN_Addr_MemoireDonnees : STD_LOGIC_VECTOR (Nb_bits - 1 downto 0) := (others => '0');
  94. signal Addr_MemoireDonnees_EBP : STD_LOGIC_VECTOR (Nb_bits - 1 downto 0) := (others => '0');
  95. signal Commande_MemoireDonnees : STD_LOGIC_VECTOR (0 downto 0) := "0";
  96. signal Sortie_MemoireDonnees : STD_LOGIC_VECTOR (Nb_bits - 1 downto 0) := (others => '0');
  97. signal intern_OUT_B : STD_LOGIC_VECTOR (Nb_bits - 1 downto 0) := (others => '0');
  98. signal EBP : STD_LOGIC_VECTOR (Nb_bits - 1 downto 0) := (others => '0');
  99. signal R_Aux : STD_LOGIC := '0';
  100. signal W_Aux : STD_LOGIC := '0';
  101. signal E : STD_LOGIC;
  102. signal F : STD_LOGIC;
  103. begin
  104. instance_LC : LC
  105. generic map (Instruction_Vector_Size => Instruction_bus_size,
  106. Command_size => 1,
  107. Bits_Controle => Bits_Controle_LC)
  108. port map ( Instruction => IN_Instruction,
  109. Commande => Commande_MemoireDonnees);
  110. instance_MUX_IN : MUX
  111. generic map (Nb_bits => Nb_bits,
  112. Instruction_Vector_Size => Instruction_bus_size,
  113. Bits_Controle => Bits_Controle_MUX_IN)
  114. port map ( Instruction => IN_Instruction,
  115. IN1 => IN_A,
  116. IN2 => IN_B,
  117. OUTPUT => IN_Addr_MemoireDonnees);
  118. instance_MUX_IN_EBP : MUX
  119. generic map (Nb_bits => Nb_bits,
  120. Instruction_Vector_Size => Instruction_bus_size,
  121. Bits_Controle => Bits_Controle_MUX_IN_EBP)
  122. port map ( Instruction => IN_Instruction,
  123. IN1 => IN_Addr_MemoireDonnees,
  124. IN2 => Addr_MemoireDonnees_EBP,
  125. OUTPUT => Addr_MemoireDonnees);
  126. instance_MUX_OUT : MUX
  127. generic map (Nb_bits => Nb_bits,
  128. Instruction_Vector_Size => Instruction_bus_size,
  129. Bits_Controle => Bits_Controle_MUX_OUT)
  130. port map ( Instruction => IN_Instruction,
  131. IN1 => Sortie_MemoireDonnees,
  132. IN2 => IN_B,
  133. OUTPUT => intern_OUT_B);
  134. instance_MemoireDonnees : MemoireDonnees
  135. generic map (Nb_bits => Nb_bits,
  136. Addr_size => Nb_bits,
  137. Mem_size => Mem_size)
  138. port map ( Addr => Addr_MemoireDonnees,
  139. RW => Commande_MemoireDonnees(0),
  140. D_IN => IN_B,
  141. RST => RST,
  142. CLK => CLK,
  143. D_OUT => Sortie_MemoireDonnees);
  144. instance_MemoireEBP : MemoireAdressesRetour
  145. generic map (Nb_bits => Nb_bits,
  146. Addr_size => Adresse_size_mem_EBP,
  147. Mem_size => Mem_EBP_size
  148. )
  149. port map ( R => R_Aux,
  150. W => W_Aux,
  151. D_IN => IN_B,
  152. RST => RST,
  153. CLK => CLK,
  154. D_OUT => EBP,
  155. E => E,
  156. F => F
  157. );
  158. OUT_A <= (others => '0') when RST = '0' else
  159. IN_A;
  160. OUT_B <= (others => '0') when RST = '0' else
  161. intern_OUT_B;
  162. OUT_Instruction <= (others => '0') when RST = '0' else
  163. IN_Instruction;
  164. R_Aux <= '1' when IN_Instruction = Code_Instruction_RET else
  165. '0';
  166. W_Aux <= '1' when IN_Instruction = Code_Instruction_CALL else
  167. '0';
  168. Addr_MemoireDonnees_EBP <= IN_Addr_MemoireDonnees + EBP;
  169. end Structural;