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.

Etage3_Calcul.vhd 4.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. ----------------------------------------------------------------------------------
  2. -- Company:
  3. -- Engineer:
  4. --
  5. -- Create Date: 18.04.2021 21:19:41
  6. -- Design Name:
  7. -- Module Name: Etage3_Calcul - 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. -- Uncomment the following library declaration if using
  23. -- arithmetic functions with Signed or Unsigned values
  24. --use IEEE.NUMERIC_STD.ALL;
  25. -- Uncomment the following library declaration if instantiating
  26. -- any Xilinx leaf cells in this code.
  27. --library UNISIM;
  28. --use UNISIM.VComponents.all;
  29. entity Etage3_Calcul is
  30. Generic ( Nb_bits : Natural;
  31. Instruction_bus_size : Natural;
  32. Bits_Controle_LC : STD_LOGIC_VECTOR;
  33. Bits_Controle_MUX : STD_LOGIC_VECTOR);
  34. Port ( RST : in STD_LOGIC;
  35. IN_A : in STD_LOGIC_VECTOR (Nb_bits - 1 downto 0);
  36. IN_B : in STD_LOGIC_VECTOR (Nb_bits - 1 downto 0);
  37. IN_C : in STD_LOGIC_VECTOR (Nb_bits - 1 downto 0);
  38. IN_Instruction : in STD_LOGIC_VECTOR (Instruction_bus_size - 1 downto 0);
  39. OUT_A : out STD_LOGIC_VECTOR (Nb_bits - 1 downto 0);
  40. OUT_B : out STD_LOGIC_VECTOR (Nb_bits - 1 downto 0);
  41. OUT_Instruction : out STD_LOGIC_VECTOR (Instruction_bus_size - 1 downto 0);
  42. N : out STD_LOGIC;
  43. O : out STD_LOGIC;
  44. Z : out STD_LOGIC;
  45. C : out STD_LOGIC);
  46. end Etage3_Calcul;
  47. architecture Structural of Etage3_Calcul is
  48. component ALU is
  49. Generic (Nb_bits : Natural);
  50. Port ( A : in STD_LOGIC_VECTOR (Nb_bits-1 downto 0);
  51. B : in STD_LOGIC_VECTOR (Nb_bits-1 downto 0);
  52. OP : in STD_LOGIC_VECTOR (2 downto 0);
  53. S : out STD_LOGIC_VECTOR (Nb_bits-1 downto 0);
  54. N : out STD_LOGIC;
  55. O : out STD_LOGIC;
  56. Z : out STD_LOGIC;
  57. C : out STD_LOGIC);
  58. end component;
  59. component LC is
  60. Generic (Instruction_Vector_Size : Natural;
  61. Command_size : Natural;
  62. Bits_Controle : STD_LOGIC_VECTOR);
  63. Port ( Instruction : in STD_LOGIC_VECTOR (Instruction_Vector_Size - 1 downto 0);
  64. Commande : out STD_LOGIC_VECTOR (Command_size - 1 downto 0));
  65. end component;
  66. component MUX is
  67. Generic (Nb_bits : Natural;
  68. Instruction_Vector_Size : Natural;
  69. Bits_Controle : STD_LOGIC_VECTOR);
  70. Port ( Instruction : in STD_LOGIC_VECTOR (Instruction_Vector_Size - 1 downto 0);
  71. IN1 : in STD_LOGIC_VECTOR (Nb_bits - 1 downto 0);
  72. IN2 : in STD_LOGIC_VECTOR (Nb_bits - 1 downto 0);
  73. OUTPUT : out STD_LOGIC_VECTOR (Nb_bits - 1 downto 0));
  74. end component;
  75. signal OP_ALU : STD_LOGIC_VECTOR (2 downto 0) := (others => '0');
  76. signal Sortie_ALU : STD_LOGIC_VECTOR (Nb_bits - 1 downto 0) := (others => '0');
  77. signal intern_OUT_B : STD_LOGIC_VECTOR (Nb_bits - 1 downto 0) := (others => '0');
  78. signal intern_N : STD_LOGIC := '0';
  79. signal intern_O : STD_LOGIC := '0';
  80. signal intern_Z : STD_LOGIC := '0';
  81. signal intern_C : STD_LOGIC := '0';
  82. begin
  83. instance_LC : LC
  84. generic map (Instruction_Vector_Size => Instruction_bus_size,
  85. Command_size => 3,
  86. Bits_Controle => Bits_Controle_LC)
  87. port map ( Instruction => IN_Instruction,
  88. Commande => OP_ALU);
  89. instance_MUX : MUX
  90. generic map (Nb_bits => Nb_bits,
  91. Instruction_Vector_Size => Instruction_bus_size,
  92. Bits_Controle => Bits_Controle_MUX)
  93. port map ( Instruction => IN_Instruction,
  94. IN1 => IN_B,
  95. IN2 => Sortie_ALU,
  96. OUTPUT => intern_OUT_B);
  97. instance_ALU : ALU
  98. generic map (Nb_bits => Nb_bits)
  99. port map (A => IN_B,
  100. B => IN_C,
  101. OP => OP_ALU,
  102. S => Sortie_ALU,
  103. N => intern_N,
  104. O => intern_O,
  105. Z => intern_Z,
  106. C => intern_C);
  107. OUT_A <= (others => '0') when RST = '0' else
  108. IN_A;
  109. OUT_B <= (others => '0') when RST = '0' else
  110. intern_OUT_B;
  111. OUT_Instruction <= (others => '0') when RST = '0' else
  112. IN_Instruction;
  113. N <= '0' when RST = '0' else
  114. intern_N;
  115. O <= '0' when RST = '0' else
  116. intern_O;
  117. Z <= '0' when RST = '0' else
  118. intern_Z;
  119. C <= '0' when RST = '0' else
  120. intern_C;
  121. end Structural;