Processeur/Processeur.srcs/sources_1/new/MUX.vhd
2021-06-10 18:36:04 +02:00

40 lines
1.6 KiB
VHDL

----------------------------------------------------------------------------------
-- Company: INSA-Toulouse
-- Engineer: Paul Faure
--
-- Create Date: 17.04.2021 21:49:57
-- Module Name: MUX - Behavioral
-- Project Name: Processeur sécurisé
-- Target Devices: Basys 3 ARTIX7
-- Tool Versions: Vivado 2016.4
-- Description: Multiplexeur
--
-- Dependencies: None
--
-- Comments :
-- - Le multiplexeur selectionne une des deux entrées qu'il repercute en sortie en fonction de l'instruction
-- - Les Bits_Controle definissent cette sélection :
-- Si Bits_Controle(Instruction) = '1' alors la première entrée est selectionnée
-- Sinon, la seconde
----------------------------------------------------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.ALL;
entity MUX is
Generic (Nb_bits : Natural; -- Taille d'un mot en entrée
Instruction_Vector_Size : Natural; -- Nombres de bits nécessaires pour coder les instructions
Bits_Controle : STD_LOGIC_VECTOR); -- Vecteur de bit controlant le multiplexeur
Port ( Instruction : in STD_LOGIC_VECTOR (Instruction_Vector_Size - 1 downto 0); -- Instrcution courante
IN1 : in STD_LOGIC_VECTOR (Nb_bits - 1 downto 0); -- Entrée 1
IN2 : in STD_LOGIC_VECTOR (Nb_bits - 1 downto 0); -- Entrée 2
OUTPUT : out STD_LOGIC_VECTOR (Nb_bits - 1 downto 0)); -- Sortie
end MUX;
architecture Behavioral of MUX is
begin
OUTPUT <= IN1 when (Bits_Controle(to_integer(unsigned(Instruction))) = '1') else
IN2;
end Behavioral;