Robin2706

Exercice 2 - Examen 2010 VHDL - Sanchez

May 25th, 2013
619
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. library ieee;
  2.     use ieee.std_logic_1164.all;
  3.     use ieee.std_logic_unsigned.all;
  4.  
  5. entity reg_ex2 is
  6.     port(
  7.         D : std_logic_vector(3 downto 0);
  8.         op: std_logic_vector(1 downto 0);
  9.         clk: std_logic;
  10.         left_in: std_logic;
  11.         right_in: std_logic;
  12.         Q: out std_logic_vector(3 downto 0)
  13.     );
  14. end entity;
  15.  
  16. architecture toto of reg_ex2 is
  17.     signal inside, nextone : std_logic_vector(3 downto 0);
  18.    
  19. begin
  20.     inside <= inside; -- si rien ne se passe, garder la valeur
  21.    
  22.     process (clk, D, op, left_in, right_in)
  23.     begin
  24.         if rising_edge(clk) then
  25.             case op is
  26.                 when "00" =>
  27.                     null; -- si opcode="00", garder la valeur
  28.                 when "01" =>
  29.                     inside <= inside(3 downto 1) & right_in; -- left shift
  30.                 when "10" =>
  31.                     inside <= left_in & inside(2 downto 0); -- right shift
  32.                 when "11" =>
  33.                     inside <= D; -- stocker la valeur d'entrĂ©e
  34.                 when others =>
  35.                     null; -- ne rien faire (pour terminer le case uniquement)
  36.             end case;
  37.         end if;
  38.     end process;
  39.    
  40.     Q <= inside;
  41. end toto;
Advertisement