Advertisement
Guest User

Untitled

a guest
Mar 21st, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 2.84 KB | None | 0 0
  1. -- Unite de controle processeur pipeline
  2. -- Version à compléter
  3. -- Auteur :
  4. library ieee;
  5. use ieee.std_logic_1164.all;
  6. use ieee.std_logic_arith.all;
  7.  
  8. -- unité entité qui differencie les types de ports
  9. entity control_unit is
  10. port (  Clk : in std_logic;
  11.     inst : in std_logic_vector(31 downto 0);
  12.     Src_PC : out std_logic;
  13.  
  14.     Src1, Src2, Dest : out std_logic_vector(3 downto 0);
  15.     Banc_ecr : out std_logic;
  16.     Banc_src : out std_logic_vector(1 downto 0);
  17.  
  18.     cmd_ual : out std_logic_vector(1 downto 0);
  19.     imm     : out std_logic_vector(15 downto 0);
  20.     Z,N : in std_logic;
  21.    
  22.     Src_Op_B, Src_adr_branch : out std_logic;  
  23.    
  24.     rw, bus_val : out std_logic
  25. );
  26. end control_unit;
  27.  
  28. -- architecture : mode de fonctionnnement (comportement)
  29. architecture beh of control_unit is
  30.  
  31. signal di_ri :  std_logic_vector(31 downto 0) := "00000000000000000000000000000000";
  32. ...
  33.    
  34. begin
  35.  
  36.     -- registre RI
  37.     ri : process(clk)
  38.     begin
  39.         if clk'event and clk='0' then
  40.             di_ri <= inst;
  41.         end if;
  42.     end process;
  43.     di_codeop <= di_ri(31 downto 28);
  44.     di_Dst : std_logic_vector(19 downto 16);
  45.     di_Src1 : std_logic_vector(27 downto 24);
  46.     di_Src2 : std_logic_vector(23 downto 20);
  47.     di_imm : std_logic_vector(27 downto 24);
  48.     -- decodeur
  49.     ---------------------
  50.     -- a vous
  51.     process (di_codeOp)
  52.         begin
  53.             case di_codeop is
  54.             -- ADD
  55.                 when "0001" =>
  56.                 di_cmd_ual => '1';
  57.                 di_Src_Op_B  = '1';
  58.                 di_Imm = std_logic_vector(15 downto 0);
  59.                 di_Src1 = Src1((31 downto 28));
  60.                
  61.                 -- SUB
  62.                 when "0010" is
  63.                 --      "0010"&"0000"&"0010"&"0100"&"0000000000000000", -- 10 SUB R0, R2, R4
  64.                 di_cmd_ual => '1';
  65.                 di_Src_Op_B  = '1';
  66.                 di_Imm = '0000000000000000';
  67.                 di_Src1 = '0000';
  68.                 di_Src2 = '0010';
  69.                 di_Dst : '0100';
  70.                
  71.                 -- SW
  72.                     --"0011"&"0010"&"0100"&"0000"&"0000000000010000", -- 20 SW R4, 10(R2)
  73.                 when "00011" =>
  74.                 di_cmd_ual => '0';
  75.                 di_Src_Op_B  = '0';
  76.                 di_Imm = '0000000000010000';
  77.                 di_Src1 = '0010';
  78.                 di_Src2 = '0100';
  79.                 di_Dst : '0100';
  80.         end c
  81.     ---------------------
  82.    
  83.  
  84.     -- registres pipeline
  85.     -------EX
  86.     ex : process(clk)
  87.     begin
  88.         if clk'event and clk='0' then
  89.             ex_Bus_Donnees_out <= di_Bus_Donnees_out;
  90.             ex_Dst <= di_Dst;
  91.             ex_Src_Adr_Branch <= di_Src_Adr_Branch
  92.             ex_Bus_Donnees_in <= di_Bus_Donnees_in
  93.             ex_Banc8src <= di_Banc_Src;
  94.             Src_PC = '1';
  95.            
  96.         end if;
  97.     end process;   
  98.     ------MEM
  99.     ex : process(clk)
  100.     begin
  101.         if clk'event and clk='0' then
  102.             Src_Op_B
  103.             Src_PC = '1';          
  104.         end if;
  105.     end process;   
  106.     ------ER
  107.     ex : process(clk)
  108.     begin
  109.         if clk'event and clk='0' then
  110.             Src_PC = '1';          
  111.         end if;
  112.     end process;
  113.     -- a vous
  114.     ---------------------
  115.     ex : process(clk)
  116.     begin
  117.         if clk'event and clk='0' then
  118.             ex_CmdUal <= CmdUal;
  119.             ex_Src_Pc <= di_Src_Pc;
  120.             ex_Imm <= di_Imm;
  121.         end if;
  122.     end process;
  123.     CmdUal <= ex_cmdUal; --
  124.  
  125. end beh;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement