-
Notifications
You must be signed in to change notification settings - Fork 0
/
control_unit.vhd
101 lines (90 loc) · 2.96 KB
/
control_unit.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
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity ctrl_unit is
port( clock_cu: in std_logic;
rst_cu: in std_logic;
PCld_cu: in std_logic;
mdata_out: in std_logic_vector(15 downto 0);
dpdata_out: in std_logic_vector(15 downto 0);
maddr_in: out std_logic_vector(15 downto 0);
immdata: out std_logic_vector(15 downto 0);
RFs_cu: out std_logic_vector(1 downto 0);
RFwa_cu: out std_logic_vector(3 downto 0);
RFr1a_cu: out std_logic_vector(3 downto 0);
RFr2a_cu: out std_logic_vector(3 downto 0);
RFwe_cu: out std_logic;
RFr1e_cu: out std_logic;
RFr2e_cu: out std_logic;
jpen_cu: out std_logic;
ALUs_cu: out std_logic_vector(1 downto 0);
Mre_cu: out std_logic;
Mwe_cu: out std_logic;
oe_cu: out std_logic
);
end ctrl_unit;
architecture struct of ctrl_unit is
component controller is
port( clock: in std_logic;
rst: in std_logic;
IR_word: in std_logic_vector(15 downto 0);
RFs_ctrl: out std_logic_vector(1 downto 0);
RFwa_ctrl: out std_logic_vector(3 downto 0);
RFr1a_ctrl: out std_logic_vector(3 downto 0);
RFr2a_ctrl: out std_logic_vector(3 downto 0);
RFwe_ctrl: out std_logic;
RFr1e_ctrl: out std_logic;
RFr2e_ctrl: out std_logic;
ALUs_ctrl: out std_logic_vector(1 downto 0);
jmpen_ctrl: out std_logic;
PCinc_ctrl: out std_logic;
PCclr_ctrl: out std_logic;
IRld_ctrl: out std_logic;
Ms_ctrl: out std_logic_vector(1 downto 0);
Mre_ctrl: out std_logic;
Mwe_ctrl: out std_logic;
oe_ctrl: out std_logic
);
end component;
component IR is
port( IRin: in std_logic_vector(15 downto 0);
IRld: in std_logic;
dir_addr: out std_logic_vector(15 downto 0);
IRout: out std_logic_vector(15 downto 0)
);
end component;
component PC is
port( PCld: in std_logic;
PCinc: in std_logic;
PCclr: in std_logic;
PCin: in std_logic_vector(15 downto 0);
PCout: out std_logic_vector(15 downto 0)
);
end component;
component bigmux is
port( Ia: in std_logic_vector(15 downto 0);
Ib: in std_logic_vector(15 downto 0);
Ic: in std_logic_vector(15 downto 0);
Id: in std_logic_vector(15 downto 0);
Option: in std_logic_vector(1 downto 0);
Muxout: out std_logic_vector(15 downto 0)
);
end component;
signal IR_sig: std_logic_vector(15 downto 0);
signal PCinc_sig, PCclr_sig, IRld_sig: std_logic;
signal Ms_sig: std_logic_vector(1 downto 0);
signal PC2mux: std_logic_vector(15 downto 0);
signal IR2mux_a, IR2mux_b: std_logic_vector(15 downto 0);
begin
IR2mux_a <= "00000000" & IR_sig(7 downto 0);
IR2mux_b <= "000000000000" & IR_sig(11 downto 8);
immdata <= IR2mux_a;
U0: controller port map( clock_cu,rst_cu,IR_sig,RFs_cu,RFwa_cu,
RFr1a_cu,RFr2a_cu,RFwe_cu,RFr1e_cu,
RFr2e_cu,ALUs_cu,jpen_cu,PCinc_sig,
PCclr_sig,IRld_sig,Ms_sig,Mre_cu,Mwe_cu,oe_cu);
U1: PC port map(PCld_cu, PCinc_sig, PCclr_sig, IR2mux_a, PC2mux);
U2: IR port map(mdata_out, IRld_sig, IR2mux_a, IR_sig);
U3: bigmux port map(dpdata_out,IR2mux_a,PC2mux,IR2mux_b,Ms_sig,maddr_in);
end struct;