Advertisement
Guest User

Untitled

a guest
May 13th, 2019
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 4.48 KB | None | 0 0
  1. ----------------------------------------------------------------------------------
  2. -- Company:
  3. -- Engineer:
  4. --
  5. -- Create Date:    00:05:07 04/12/2019
  6. -- Design Name:
  7. -- Module Name:    DATAPATH - 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_ARITH.ALL;
  23. use IEEE.STD_LOGIC_UNSIGNED.ALL;
  24.  
  25. ---- Uncomment the following library declaration if instantiating
  26. ---- any Xilinx primitives in this code.
  27. --library UNISIM;
  28. --use UNISIM.VComponents.all;
  29.  
  30. entity DATAPATH is
  31.     Port ( Clk         : in  STD_LOGIC;
  32.            address     : out  STD_LOGIC_VECTOR (31 downto 0);
  33.            instr       : out  STD_LOGIC_VECTOR (31 downto 0);
  34.               result      : out STD_LOGIC_VECTOR (31 downto 0));
  35. end DATAPATH;
  36.  
  37.  
  38.  
  39.  
  40. architecture Behavioral of DATAPATH is
  41.  
  42. signal program_counter: STD_LOGIC_VECTOR(31 downto 0 );
  43. signal nxt_pr_counter: STD_LOGIC_VECTOR(31 downto 0 );
  44. signal const_f        : STD_LOGIC_VECTOR(31 downto 0);
  45. signal op             : STD_LOGIC_VECTOR(5 downto 0);
  46. signal rs           : STD_LOGIC_VECTOR (4 downto 0);
  47. signal rd           : STD_LOGIC_VECTOR (4 downto 0);
  48. signal instrukcija  :  STD_LOGIC_VECTOR (31 downto 0);
  49. signal regiDst      :  std_logic;
  50. signal brranch      :  std_logic;
  51. signal memoRead     :  std_logic;
  52. signal memoToReg    :  std_logic;
  53. signal ALUope       :  std_logic_vector(1 DOWNTO 0);
  54. signal memoWrite    :  std_logic;
  55. signal ALUsorc      :  std_logic;
  56. signal regiWrite    :  std_logic;
  57. signal destReg      :  STD_LOGIC_VECTOR (4 downto 0);
  58. signal readRegi     :  STD_LOGIC_VECTOR (4 downto 0);
  59. signal operation      :  STD_LOGIC;
  60. signal procit2      :  STD_LOGIC_VECTOR(31 downto 0);
  61. signal prosirenaVr  :  STD_LOGIC_VECTOR(31 downto 0);
  62. signal readDat1     :  STD_LOGIC_VECTOR (31 downto 0);
  63. signal readDat2     :  STD_LOGIC_VECTOR (31 downto 0);
  64. signal extended     :  STD_LOGIC_VECTOR(31 downto 0);
  65.  
  66. begin
  67.  
  68.    
  69.     Brojac: entity work.PC(Behavioral)
  70.             PORT MAP(
  71.                 clk => Clk,
  72.                 pc_in => nxt_pr_counter,
  73.                 pc_out => program_counter
  74.             );
  75.    
  76.     MemorijaInstrukcija: entity work.MEMORYINSTRUCTION(Behavioral)
  77.             PORT MAP(
  78.                 PC => program_counter,
  79.                 instruction => instrukcija
  80.             );
  81.    
  82.     instr <= instrukcija;
  83.     op <= instrukcija(31 downto 26);
  84.    
  85.            
  86.     Kontrola: entity work.CONTROL(Behavioral)
  87.             PORT MAP(
  88.                 opcode        => op,
  89.                 regDst        => regiDst,
  90.                 branch        => brranch,
  91.                 memRead       => memoRead,
  92.                 memToReg      => memoToReg,
  93.                 ALUop         => ALUope,
  94.                 memWrite      => memoWrite,
  95.                 ALUsrc        => ALUsorc,
  96.                 regWrite      => regiWrite
  97.             );
  98.    
  99.      
  100.      Mux: entity work.MUX2_1(Behavioral)
  101.               PORT MAP(
  102.                  mux_in1 => instrukcija(20 downto 16),
  103.              mux_in2 => instrukcija(15 downto 11),
  104.              mux_ct1 => regiDst,
  105.              mux_out => destReg
  106.               );
  107.    
  108.     process(Clk)
  109.      begin
  110.          IF regiDst = '1' then
  111.              readRegi <= instrukcija(20 downto 16);
  112.          else
  113.             readRegi <= instrukcija(15 downto 11);
  114.          end if;
  115.      end process;
  116.      
  117.      Registri: entity work.REGFILE(Behavioral)
  118.                 PORT MAP(
  119.                     readRegister1 => instrukcija(25 downto 21),
  120.                     readRegister2 => readRegi,
  121.                     writeRegister => destReg,
  122.                     writeData     => x"12345678",
  123.                     registerWrite => regiWrite,
  124.                     clock             => Clk,
  125.                     readData1     => readDat1,
  126.                     readData2     => procit2
  127.                 );
  128.  
  129.    
  130.     Prosirenje: entity work.SIGNEXTEND(Behavioral)
  131.                 PORT MAP(
  132.                     se_in       =>  instrukcija(15 downto 0),
  133.                     se_out   => prosirenaVr
  134.                 );
  135.                
  136.     AluKontrola: entity work.ALUControl(Behavioral)
  137.                 PORT MAP(
  138.                     ALUOp   => ALUope,
  139.                     funct   => instrukcija(5 downto 0),
  140.                     oper    => operation
  141.                 );
  142.                
  143.        
  144.                
  145.    
  146.     Mux2: entity work.MUX2_1_imm(Behavioral)
  147.                 PORT MAP(
  148.                     mux_in1  => procit2,
  149.                     mux_in2  => prosirenaVr,
  150.                     mux_ct1  => ALUsorc,
  151.                     mux_out  => readDat2
  152.                 );
  153.    
  154.     ALU: entity work.ALU(Behavioral)
  155.             PORT MAP(
  156.                     a1              => readDat1,
  157.                     a2                  => readDat2,
  158.                  alu_control    => operation,
  159.                  alu_result     => result
  160.             );
  161.    
  162.    
  163.     BrojacAdder: entity work.PCADDER(Behavioral)
  164.             PORT MAP(
  165.                 cur_address => program_counter,
  166.                 const_four => const_f,
  167.                 next_address => nxt_pr_counter
  168.             );
  169.                        
  170.             address <= nxt_pr_counter;
  171.          
  172. end Behavioral;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement