-
Notifications
You must be signed in to change notification settings - Fork 0
/
CPU.vhd
112 lines (108 loc) · 3.91 KB
/
CPU.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
-- VHDL project: VHDL code for 8-bit Microcontroller
-- VHDL code for the CPU of the microcontroller
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
-- CPU in VHDL
entity cpu is
port(
clock, reset: in std_logic;
address: out std_logic_vector(7 downto 0);
from_memory: in std_logic_vector(7 downto 0);
write: out std_logic;
to_memory: out std_logic_vector(7 downto 0)
);
end cpu;
architecture Behavioral of cpu is
component control_unit
port (
clock,reset: in std_logic;
IR_Load: out std_logic;
IR: in std_logic_vector(7 downto 0);
MAR_Load: out std_logic;
PC_Load: out std_logic;
PC_Inc: out std_logic;
A_Load: out std_logic;
B_Load:out std_logic;
ALU_Sel:out std_logic_vector(2 downto 0);
CCR_Result: in std_logic_vector(3 downto 0);
CCR_Load: out std_logic;
Bus2_Sel: out std_logic_vector(1 downto 0);
Bus1_Sel: out std_logic_vector(1 downto 0);
write: out std_logic
);
end component control_unit;
component data_path
port (
clock,reset: in std_logic;
IR_Load: in std_logic;
IR: out std_logic_vector(7 downto 0);
MAR_Load: in std_logic;
address: out std_logic_vector(7 downto 0);
PC_Load: in std_logic;
PC_Inc: in std_logic;
A_Load: in std_logic;
B_Load: in std_logic;
ALU_Sel: in std_logic_vector(2 downto 0);
CCR_Result: out std_logic_vector(3 downto 0);
CCR_Load: in std_logic;
Bus2_Sel: in std_logic_vector(1 downto 0);
Bus1_Sel: in std_logic_vector(1 downto 0);
from_memory: in std_logic_vector(7 downto 0);
to_memory: out std_logic_vector(7 downto 0)
);
end component data_path;
signal IR_Load: std_logic;
signal IR: std_logic_vector(7 downto 0);
signal MAR_Load: std_logic;
signal PC_Load: std_logic;
signal PC_Inc: std_logic;
signal A_Load: std_logic;
signal B_Load: std_logic;
signal ALU_Sel: std_logic_vector(2 downto 0);
signal CCR_Result: std_logic_vector(3 downto 0);
signal CCR_Load: std_logic;
signal Bus2_Sel: std_logic_vector(1 downto 0);
signal Bus1_Sel: std_logic_vector(1 downto 0);
begin
-----------------------
-- control_unit
control_unit_module: control_unit port map
(
clock => clock,
reset => reset,
IR_Load => IR_Load,
IR => IR,
MAR_Load => MAR_Load,
PC_Load => PC_Load,
PC_Inc => PC_Inc,
A_Load => A_Load,
B_Load => B_Load,
ALU_Sel => ALU_Sel,
CCR_Result => CCR_Result,
CCR_Load => CCR_Load,
Bus2_Sel => Bus2_Sel,
Bus1_Sel => Bus1_Sel,
write => write
);
-- data_path
data_path_u: data_path port map
(
clock => clock,
reset => reset,
IR_Load => IR_Load,
IR => IR,
MAR_Load => MAR_Load,
address => address,
PC_Load => PC_Load,
PC_Inc => PC_Inc,
A_Load => A_Load,
B_Load => B_Load,
ALU_Sel => ALU_Sel,
CCR_Result => CCR_Result,
CCR_Load => CCR_Load,
Bus2_Sel => Bus2_Sel,
Bus1_Sel => Bus1_Sel,
from_memory => from_memory,
to_memory => to_memory
);
end Behavioral;