-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathControlunit.vhd
163 lines (155 loc) · 4.23 KB
/
Controlunit.vhd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
----------------------------------------------------------------------------------
-- Company:
-- Engineer:
--
-- Create Date: 15:21:08 05/03/2016
-- Design Name:
-- Module Name: Controlunit - Behavioral
-- Project Name:
-- Target Devices:
-- Tool versions:
-- Description:
--
-- Dependencies:
--
-- Revision:
-- Revision 0.01 - File Created
-- Additional Comments:
--
----------------------------------------------------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
--use IEEE.NUMERIC_STD.ALL;
-- Uncomment the following library declaration if instantiating
-- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;
entity Controlunit is
Port (
op : in STD_LOGIC_VECTOR(5 downto 0);
funct : in STD_LOGIC_VECTOR(5 downto 0);
ALUControl : out STD_LOGIC_VECTOR(2 downto 0);
ALUSource : out STD_LOGIC;
RegDestination : out STD_LOGIC;
WE : out STD_LOGIC;
MemToReg : out STD_LOGIC;
MemWE : out STD_LOGIC;
Branch1 : out STD_LOGIC;
Jump : out STD_LOGIC
);
end Controlunit;
architecture Behavioral of Controlunit is
signal nonsense :STD_LOGIC;
begin
process(op,funct)
begin
if (op="000000")then
case funct is
when "100000" => --add
MemToReg <='0';
MemWE <='0';
ALUControl <="010";
ALUSource <='0';
Jump <='0';
RegDestination <='1';
WE <='1';
Branch1 <='0';
when "100010" => --sub
MemToReg <='0';
MemWE <='0';
ALUControl <="110";
ALUSource <='0';
RegDestination <='1';
Jump <='0';
Branch1 <='0';
WE <='1';
when "101010" => --slt
MemToReg <='0';
MemWE <='0';
ALUControl <="111";
ALUSource <='0';
RegDestination <='1';
Jump <='0';
Branch1 <='0';
WE <='1';
when "100101" => --or
MemToReg <='0';
MemWE <='0';
ALUControl <="001";
ALUSource <='0';
Jump <='0';
Branch1 <='0';
RegDestination <='1';
WE <='1';
when "100100" => --and
MemToReg <='0';
MemWE <='0';
ALUControl <="000";
ALUSource <='0';
Jump <='0';
RegDestination <='1';
Branch1 <='0';
WE <='1';
when others =>
nonsense <='1';
end case;
Else
case op is
when "001000" => --addi
MemToReg <='0';
MemWE <='0';
ALUControl <="010";
ALUSource <='1';
RegDestination <='0';
Jump <='0';
Branch1 <='0';
WE <='1';
when "001010" => --slti
MemToReg <='0';
MemWE <='0';
ALUControl <="111";
ALUSource <='1';
RegDestination <='0';
Jump <='0';
Branch1 <='0';
WE <='1';
when "100011" => --lw
MemToReg <='1';
MemWE <='0';
ALUControl <="010";
WE <='1';
RegDestination <='0';
Jump <='0';
Branch1 <='0';
ALUSource <='1';
when "101011" => --sw
MemWE <='1';
ALUControl <="010";
WE <='0';
Jump <='0';
Branch1 <='0';
ALUSource <='1';
when "000100" => --beq
MemWE <='0';
ALUControl <="110";
WE <='0';
ALUSource <='0';
Jump <='0';
Branch1 <='1';
when "000010" => --J
MemToReg <='0';
MemWE <='0';
ALUControl <="110";
WE <='0';
RegDestination <='0';
ALUSource <='0';
Jump <='1';
Branch1 <='0';
when others =>
nonsense <='1';
end case;
end if;
end process;
end Behavioral;