-
Notifications
You must be signed in to change notification settings - Fork 0
/
control.vhd
103 lines (99 loc) · 2.87 KB
/
control.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
----------------------------------------------------------
-- Control --
-- Max Santana --
-- Antonio Filho (2023) --
-- CEComp/Univasf --
----------------------------------------------------------
library ieee;
use ieee.std_logic_1164.all;
entity control is
port(
funct : in std_logic_vector(5 downto 0); -- funct
op : in std_logic_vector(5 downto 0);
regDst : out std_logic_vector(1 downto 0);
jump : out std_logic_vector(1 downto 0);
branch : out std_logic;
bne : out std_logic;
memWR : out std_logic; -- when 0 (write), 1 (read)
memToReg : out std_logic_vector(1 downto 0);
aluOp : out std_logic_vector(1 downto 0); -- when 10 (R-type),
jr : out std_logic;
aluSrc : out std_logic;
regWrite : out std_logic
);
end control;
architecture behavior of control is
begin
process(op)
begin
case (op) is
when "000000" => -- R type
regDst <= "01";
jump <= "10" when funct = "001000" else "00";
branch <= '0';
memWR <= 'X';
bne <= '0';
jr <= '1' when funct = "001000" else '0';
memToReg <= "00";
aluOp <= "10";
aluSrc <= '0';
regWrite <= '1';
when "100011" => -- lw
bne <= '0';
when "101011" =>
bne <= '0'; -- sw
when "000100" =>
bne <= '0'; -- beq
when "000101" => -- bne
regDst <= "XX";
jump <= "00";
branch <= '0';
bne <= '1';
memWR <= 'X';
memToReg <= "XX";
aluOp <= "01";
aluSrc <= 'X';
regWrite <= 'X';
when "001000" => -- addi
bne <= '0';
regDst <= "00";
jump <= "00";
branch <= '0';
memWR <= 'X';
memToReg <= "00";
aluOp <= "00";
aluSrc <= '1';
regWrite <= '1';
when "000010" => -- j
regDst <= "XX";
jump <= "01";
branch <= 'X';
bne <= 'X';
memWR <= 'X';
memToReg <= "XX";
aluOp <= "XX";
aluSrc <= 'X';
regWrite <= 'X';
when "000011" => -- jal
regDst <= "10";
jump <= "01";
branch <= 'X';
bne <= 'X';
memWR <= '0';
memToReg <= "10";
aluOp <= "XX";
aluSrc <= 'X';
regWrite <= '1';
when others =>
bne <= 'X';
regDst <= "XX";
jump <= "XX";
branch <= 'X';
memWR <= 'X';
memToReg <= "XX";
aluOp <= "XX";
aluSrc <= 'X';
regWrite <= '0';
end case;
end process;
end behavior;