OpenCores
URL https://opencores.org/ocsvn/mipsr2000/mipsr2000/trunk

Subversion Repositories mipsr2000

[/] [mipsr2000/] [trunk/] [ALu_control.vhd] - Blame information for rev 5

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 5 jimi39
----------------------------------------------------------------------------------
2
-- Company: 
3
-- Engineer:        Lazaridis Dimitris
4
-- 
5
-- Create Date:    03:17:24 07/23/2012 
6
-- Design Name: 
7
-- Module Name:    ALu_control - 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
 
23
-- Uncomment the following library declaration if using
24
-- arithmetic functions with Signed or Unsigned values
25
--use IEEE.NUMERIC_STD.ALL;
26
 
27
-- Uncomment the following library declaration if instantiating
28
-- any Xilinx primitives in this code.
29
--library UNISIM;
30
--use UNISIM.VComponents.all;
31
 
32
entity ALu_control is
33
 
34
PORT
35
(         --clk : IN std_logic;
36
          instr_15_0 : IN std_logic_vector(15 downto 0);
37
          ALUOp : IN std_logic_vector(2 downto 0);
38
                         ALUmux : IN std_logic_vector(1 downto 0);
39
                         From_i_op : IN std_logic_vector(1 downto 0);
40
                         From_i_mux : IN std_logic_vector(1 downto 0);
41
                         sv : out  STD_LOGIC := '0';
42
                         Mul_out_c : out  STD_LOGIC_VECTOR(1 downto 0);
43
                         ALUmux_c : OUT std_logic_vector(1 downto 0);
44
          ALUopcode : OUT std_logic_vector(1 downto 0)
45
);
46
 
47
 
48
end ALu_control;
49
 
50
architecture Behavioral of ALu_control is
51
 
52
begin
53
Alu_Control : PROCESS(instr_15_0, ALUOp,ALUmux,From_i_op,From_i_mux)
54
CONSTANT ADDr : std_logic_vector(5 downto 0) := "100000";
55
CONSTANT ADDr_u : std_logic_vector(5 downto 0) := "100001";
56
CONSTANT SUBr : std_logic_vector(5 downto 0) := "100010";
57
CONSTANT SUBr_u : std_logic_vector(5 downto 0) := "100011";
58
CONSTANT ANDr : std_logic_vector(5 downto 0) := "100100";
59
CONSTANT ORr : std_logic_vector(5 downto 0) := "100101";
60
CONSTANT XORr : std_logic_vector(5 downto 0) := "100110";
61
CONSTANT NORr : std_logic_vector(5 downto 0) := "100111";
62
CONSTANT SLTr : std_logic_vector(5 downto 0) := "101010";
63
CONSTANT SLTUr : std_logic_vector(5 downto 0) := "101011";
64
CONSTANT MULTr : std_logic_vector(5 downto 0) := "011000";
65
CONSTANT Mtlor : std_logic_vector(5 downto 0) := "010011";
66
CONSTANT Mthir : std_logic_vector(5 downto 0) := "010001";
67
CONSTANT Mflor : std_logic_vector(5 downto 0) := "010010";
68
CONSTANT Mfhir : std_logic_vector(5 downto 0) := "010000";
69
CONSTANT Sllr : std_logic_vector(5 downto 0)  := "000000";
70
CONSTANT SLLVr : std_logic_vector(5 downto 0) := "000100";
71
CONSTANT SRLr : std_logic_vector(5 downto 0)  := "000010";
72
CONSTANT SRÁr : std_logic_vector(5 downto 0)  := "000011";
73
CONSTANT SRLVr : std_logic_vector(5 downto 0) := "000110";
74
CONSTANT SRAVr : std_logic_vector(5 downto 0) := "000111";
75
CONSTANT JRr  : std_logic_vector(5 downto 0)  := "001000";
76
 
77
BEGIN
78
  --if FALLING_EDGE(clk) then      
79
  case ALUOp is
80
      when "000" =>
81
                              ALUopcode <= "00";  -- add  I types
82
                                                  ALUmux_c <= ALUmux;
83
      when "001" => ALUopcode <= "01";  -- add unsigned
84
                              ALUmux_c <= ALUmux;
85
                when "010" => ALUopcode <= "01";  -- subtract signed
86
                              ALUmux_c <= ALUmux;
87
                when "011" => ALUopcode <= "11";  -- subtract unsigned
88
                              ALUmux_c <= ALUmux;
89
      when "110" => -- operation depends on function field  r types
90
                case instr_15_0(5 downto 0) is   -- r types
91
                when ADDr => ALUopcode <= "00"; -- add signed
92
                                                      ALUmux_c <= "10";
93
                                         when ADDr_u => ALUopcode <= "01";  -- add unsigned
94
                                                      ALUmux_c <= "10";
95
                when SUBr => ALUopcode <= "10"; -- subtract
96
                                                       ALUmux_c <= "10";
97
                                         when SUBr_u => ALUopcode <= "11"; --subtract unsigned
98
                                                        ALUmux_c <= "10";
99
                when ANDr => ALUopcode <= "00"; -- AND
100
                                                        ALUmux_c <= "11";
101
                when ORr => ALUopcode <= "01"; -- OR
102
                                                        ALUmux_c <= "11";
103
                                         when XORr => ALUopcode <= "10"; -- XOR
104
                                                        ALUmux_c <= "11";
105
                when NORr => ALUopcode <=  "11"; -- NOR
106
                                ALUmux_c <= "11";
107
                when SLTr => ALUopcode  <=  "10";   -- SLT
108
                                ALUmux_c <= "01";
109
                when SLTUr      => ALUopcode  <=  "11";   -- SLTU
110
                                ALUmux_c <= "01";
111
                when MULTr => ALUopcode <=  "00"; -- MULT
112
                                ALUmux_c <= "00";
113
                                  Mul_out_c <= "00";
114
                when Mtlor      => ALUopcode <=  "00"; -- Mtlo
115
                                ALUmux_c <= "00";
116
                                Mul_out_c <= "01";
117
                when Mthir      => ALUopcode <=  "00"; -- Mthi
118
                                ALUmux_c <= "00";
119
                                Mul_out_c <= "10";
120
                when Mflor      => ALUopcode <=  "00"; -- Mflo
121
                                ALUmux_c <= "00";
122
                            --  Mul_out_c <= "00";
123
                when Mfhir => ALUopcode <=  "00"; -- Mfhi
124
                                ALUmux_c <= "00";
125
                            --  Mul_out_c <= "00";
126
                when Sllr =>   ALUopcode <= "00";  --sll
127
                                 ALUmux_c <= "00";
128
                               sv <= '0';
129
                when    SRLr =>   ALUopcode <= "10";  --srl
130
                                 ALUmux_c <= "00";
131
                                                                                 sv <= '0';
132
                                         when SRÁr =>   ALUopcode <= "11";  --sra
133
                                 ALUmux_c <= "00";
134
                                                                                 sv <= '0';
135
                                         when   SLLVr =>  ALUopcode <= "00";  -- sllv
136
                                                        ALUmux_c <= "00";
137
                                                                                 sv <= '1';
138
                                         when   SRLVr =>  ALUopcode <= "10";  --srlv
139
                                 ALUmux_c <= "00";
140
                                                                                 sv <= '1';
141
                                         when SRAVr =>  ALUopcode <= "11";      --srav
142
                                 ALUmux_c <= "00";
143
                                                                                 sv <= '1';
144
                when others => ALUopcode <= "00";
145
                                                        ALUmux_c <= "00";
146
                                                                                 Mul_out_c <= "00";
147
                                                                            sv <= '0';
148
                end case;
149
         when "111" =>   -- I types Aluop from ir
150
                        ALUopcode <= From_i_op;
151
                  ALUmux_c       <= From_i_mux;
152
     when others => ALUopcode <= "00";
153
  end case;
154
 -- end if;
155
END PROCESS;
156
 
157
 
158
 
159
 
160
end Behavioral;
161
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.