-
Notifications
You must be signed in to change notification settings - Fork 1
/
mu0.vhd
executable file
·204 lines (180 loc) · 4.44 KB
/
mu0.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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
-------------------------------------------
-- VHDL implementation of mu0 processor --
-- processor level --
-- Ben Howes 2011 --
-------------------------------------------
library ieee;
use ieee.std_logic_1164.all;
entity mu0 is
port (
CLK : in std_logic;
DATA_IN : in std_logic_vector (15 downto 0);
DATA_OUT : out std_logic_vector (15 downto 0);
ADDR : out std_logic_vector (15 downto 0);
RESET : in std_logic;
MEMRQ, RNW : out std_logic -- control lines for the memory
);
end;
-- map the components up!
architecture mu0_arch of mu0 is
component accumulator
port(
CLK, EN : in std_logic;
INPUT : in std_logic_vector (15 downto 0);
Z, NEG : out std_logic;
OUTPUT : out std_logic_vector (15 downto 0)
);
end component;
component instruction_pointer
port(
CLK, EN : in std_logic;
INPUT : in std_logic_vector (15 downto 0);
OUTPUT : out std_logic_vector (15 downto 0)
);
end component;
component instruction_register
port(
CLK, EN : in std_logic;
INPUT : in std_logic_vector (15 downto 0);
OUTPUT : out std_logic_vector (15 downto 0)
);
end component;
component mux
port(
IN_A, IN_B : in std_logic_vector (15 downto 0);
SEL_B : in std_logic;
OUTPUT : out std_logic_vector (15 downto 0)
);
end component;
component buff
port(
IN_A: in std_logic_vector (15 downto 0);
EN: in std_logic;
OUT_A : out std_logic_vector (15 downto 0)
);
end component;
component control is
port(
CLK : in std_logic;
RST, ACC_Z, ACC_15, EX_IN : in std_logic;
OP_CODE : in std_logic_vector (3 downto 0);
IR_CE, ACC_CE, IP_CE, ACC_OE, MEMRQ, RNW, ASEL, BSEL, A_EN, B_INV, C_IN, EX_O : out std_logic
);
end component;
component ALU is
port (IN_A, IN_B: in std_logic_vector (15 downto 0);
B_INV, C_IN, A_EN, RST: in std_logic;
OUTPUT : out std_logic_vector (15 downto 0)
);
end component;
--SIGNALS
--major busses
signal dbus: std_logic_vector (15 downto 0);
signal abus: std_logic_vector (15 downto 0);
signal acc_bus : std_logic_vector (15 downto 0);
signal r_bus : std_logic_vector (15 downto 0);
signal b_bus : std_logic_vector (15 downto 0);
signal pc_bus : std_logic_vector (15 downto 0);
signal ir_bus : std_logic_vector (15 downto 0); --has to be split
-- pc/ir mux special signal
signal pc_ir_mux_bus : std_logic_vector (15 downto 0);
-- control signals
--input to control
signal rst : std_logic;
signal acc_z : std_logic;
signal acc_15 : std_logic;
--output from control
signal ir_ce : std_logic;
signal acc_ce : std_logic;
signal ip_ce : std_logic;
signal acc_oe : std_logic;
signal asel : std_logic;
signal bsel : std_logic;
signal a_en : std_logic;
signal b_inv : std_logic;
signal c_in : std_logic;
signal ex : std_logic;
begin
-- define split up signals
pc_ir_mux_bus <= "0000" & ir_bus (11 downto 0);
rst <= RESET;
dbus <= DATA_IN;
ADDR <= abus;
---------------------------
-- port mappings
---------------------------
ACC : accumulator
port map(
CLK => CLK,
EN => acc_ce,
INPUT => r_bus,
Z => acc_z,
NEG => acc_15,
OUTPUT => acc_bus
);
IP : instruction_pointer
port map(
CLK => CLK,
EN => ip_ce,
INPUT => r_bus,
OUTPUT => pc_bus
);
IR : instruction_register
port map(
CLK => CLK,
EN => ir_ce,
INPUT => DATA_IN,
OUTPUT => ir_bus
);
CNTL : control
port map(
CLK => CLK,
RST => rst,
ACC_Z => acc_z,
ACC_15 => ACC_15,
EX_IN => ex,
OP_CODE => ir_bus (15 downto 12),
IR_CE => ir_ce,
ACC_CE => acc_ce,
IP_CE => ip_ce,
ACC_OE => acc_oe,
MEMRQ => memrq,
RNW => rnw,
ASEL => asel,
BSEL => bsel,
A_EN => a_en,
B_INV => b_inv,
C_IN => c_in,
EX_O => ex
);
ADDER : ALU
port map(
IN_A => acc_bus,
IN_B => b_bus,
B_INV => b_inv,
C_IN => c_in,
A_EN => a_en,
RST => rst,
OUTPUT => r_bus
);
IR_PC_MUX : mux
port map(
IN_A => pc_bus,
IN_B => pc_ir_mux_bus,
SEL_B => asel,
OUTPUT => abus
);
DBUS_ABUS_MUX : mux
port map(
IN_A => abus,
IN_B => DATA_IN,
SEL_B => bsel,
OUTPUT => b_bus
);
ACC_DBUF : buff
port map(
IN_A => acc_bus,
EN => acc_oe,
OUT_A => DATA_OUT
);
end mu0_arch;