-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathControlUnit.vhd
More file actions
72 lines (66 loc) · 2.21 KB
/
ControlUnit.vhd
File metadata and controls
72 lines (66 loc) · 2.21 KB
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
----------------------------------------------------------------------------------
-- Company:
-- Engineer:
--
-- Create Date: 27.07.2023 14:40:28
-- 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 leaf cells in this code.
--library UNISIM;
--use UNISIM.VComponents.all;
entity ControlUnit is
Port ( CLK : in STD_LOGIC;
RESET : in STD_LOGIC;
ALU_OP : in STD_LOGIC_VECTOR (4 downto 0);
STAGE : out STD_LOGIC_VECTOR (5 downto 0));
end ControlUnit;
architecture Behavioral of ControlUnit is
begin
process (CLK)
begin
if rising_edge (CLK) then
if RESET = '1' then
STAGE <= "000001";
else
case STAGE is
when "000001" => -- Fetch
STAGE <= "000010";
when "000010" => -- Decode
STAGE <= "000100";
when "000100" => -- Read Register
STAGE <= "001000";
when "001000" => -- Execute
if ALU_OP (3 downto 0) = "1100" or ALU_OP (3 downto 0) = "1101" then -- if LDR, STR
STAGE <= "010000";
else
STAGE <= "100000";
end if;
when "010000" => -- Memory
STAGE <= "100000";
when "100000" => -- Write Memory
STAGE <= "000001";
when others =>
STAGE <= "000001";
end case;
end if;
end if;
end process;
end Behavioral;