-
Notifications
You must be signed in to change notification settings - Fork 0
/
Sparcv8Monocicle.vhd
374 lines (311 loc) · 7.79 KB
/
Sparcv8Monocicle.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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity Sparcv8Monocicle is
Port ( CLK : in STD_LOGIC;
RST: in STD_LOGIC;
R : out STD_LOGIC_VECTOR(31 downto 0)
);
end Sparcv8Monocicle;
architecture Behavioral of Sparcv8Monocicle is
---Componentes
COMPONENT windows_manager
PORT(
cwp : IN std_logic;
rs1 : IN std_logic_vector(4 downto 0);
rs2 : IN std_logic_vector(4 downto 0);
rd : IN std_logic_vector(4 downto 0);
op : IN std_logic_vector(1 downto 0);
op3 : IN std_logic_vector(5 downto 0);
nrs1 : OUT std_logic_vector(5 downto 0);
nrs2 : OUT std_logic_vector(5 downto 0);
nrd : OUT std_logic_vector(5 downto 0);
ncwp : OUT std_logic
);
END COMPONENT;
COMPONENT psr
PORT(
clk : IN std_logic;
reset : IN std_logic;
nzvc : IN std_logic_vector(3 downto 0);
ncwp : IN std_logic;
carry : OUT std_logic;
cwp : OUT std_logic
);
END COMPONENT;
COMPONENT psr_modifier
PORT(
crs1 : IN std_logic;
ope2 : IN std_logic;
alur : IN std_logic_vector(31 downto 0);
aluop : IN std_logic_vector(5 downto 0);
nzvc : OUT std_logic_vector(3 downto 0)
);
END COMPONENT;
COMPONENT sum32b
PORT(
Op1 : IN std_logic_vector(31 downto 0);
Op2 : IN std_logic_vector(31 downto 0);
R : OUT std_logic_vector(31 downto 0)
);
END COMPONENT;
COMPONENT alu
PORT(
carry : IN std_logic;
aluop : IN std_logic_vector(5 downto 0);
crs1 : IN std_logic_vector(31 downto 0);
crs2 : IN std_logic_vector(31 downto 0);
r : OUT std_logic_vector(31 downto 0)
);
END COMPONENT;
COMPONENT control_unit
PORT(
op : IN std_logic_vector(1 downto 0);
op2 : IN std_logic_vector(2 downto 0);
op3 : IN std_logic_vector(5 downto 0);
icc : IN std_logic_vector(3 downto 0);
cond : IN std_logic_vector(3 downto 0);
Aluop : OUT std_logic_vector(5 downto 0);
wrenDM : OUT std_logic;
RFSource : OUT std_logic_vector(1 downto 0);
PCSource : OUT std_logic_vector(1 downto 0);
RFdest : OUT std_logic;
write_enable : OUT std_logic
);
END COMPONENT;
COMPONENT instructionMemory
PORT(
address : IN std_logic_vector(31 downto 0);
reset : IN std_logic;
outInstruction : OUT std_logic_vector(31 downto 0)
);
END COMPONENT;
COMPONENT mux32b
PORT(
A : IN std_logic_vector(31 downto 0);
B : IN std_logic_vector(31 downto 0);
Sel : IN std_logic;
O : OUT std_logic_vector(31 downto 0)
);
END COMPONENT;
COMPONENT pc
PORT(
clk : IN std_logic;
rst : IN std_logic;
address : IN std_logic_vector(31 downto 0);
sig : OUT std_logic_vector(31 downto 0)
);
END COMPONENT;
COMPONENT register_file
PORT(
Wren : IN std_logic;
rst : IN std_logic;
rs1 : IN std_logic_vector(5 downto 0);
rs2 : IN std_logic_vector(5 downto 0);
rd : IN std_logic_vector(5 downto 0);
data : IN std_logic_vector(31 downto 0);
crs1 : OUT std_logic_vector(31 downto 0);
crs2 : OUT std_logic_vector(31 downto 0);
crd : OUT std_logic_vector(31 downto 0)
);
END COMPONENT;
COMPONENT sign_ext_unit
PORT(
entrada : IN std_logic_vector(12 downto 0);
salida : OUT std_logic_vector(31 downto 0)
);
END COMPONENT;
COMPONENT SEUDisp30
PORT(
Disp30 : IN std_logic_vector(29 downto 0);
S : OUT std_logic_vector(31 downto 0)
);
END COMPONENT;
COMPONENT SEUDisp22
PORT(
Disp22 : IN std_logic_vector(21 downto 0);
S : OUT std_logic_vector(31 downto 0)
);
END COMPONENT;
COMPONENT MuxPC
PORT(
PCdisp30 : IN std_logic_vector(31 downto 0);
PCdisp22 : IN std_logic_vector(31 downto 0);
PC : IN std_logic_vector(31 downto 0);
PCplus1 : IN std_logic_vector(31 downto 0);
PCSource : IN std_logic_vector(1 downto 0);
nPC : OUT std_logic_vector(31 downto 0)
);
END COMPONENT;
COMPONENT MuxNextRD
PORT(
RD : IN std_logic_vector(5 downto 0);
O7 : IN std_logic_vector(5 downto 0);
RfDest : IN std_logic;
NRd : OUT std_logic_vector(5 downto 0)
);
END COMPONENT;
COMPONENT MuxDWR
PORT(
DM : IN std_logic_vector(31 downto 0);
AluR : IN std_logic_vector(31 downto 0);
PC : IN std_logic_vector(31 downto 0);
RFSource : IN std_logic_vector(1 downto 0);
DTRF : OUT std_logic_vector(31 downto 0)
);
END COMPONENT;
COMPONENT DataMemory
PORT(
enableMem : IN std_logic;
reset : IN std_logic;
cRD : IN std_logic_vector(31 downto 0);
address : IN std_logic_vector(31 downto 0);
wrEnMem : IN std_logic;
datoToWr : OUT std_logic_vector(31 downto 0)
);
END COMPONENT;
signal aux1,aux2,aux3,aux4,aux6,aux7,aux9,aux10,aux11,aux20,aux21,aux22,aux23,aux25,aux29,aux30,aux32:std_logic_vector(31 downto 0);
signal aux5,aux14,aux15,aux16,aux27:std_logic_vector(5 downto 0);
signal aux12,aux17,aux18,aux26,aux28,aux31: std_logic;
signal aux24,aux34,aux33: std_logic_vector(1 downto 0);
signal aux13:std_logic_vector(3 downto 0);
begin
---Instancia de los componentes
Inst_SEUDisp30: SEUDisp30 PORT MAP(
Disp30 => aux4(29 downto 0),
S => aux20
);
Inst_SEUDisp22: SEUDisp22 PORT MAP(
Disp22 => aux4(21 downto 0),
S => aux21
);
Inst_MuxPC: MuxPC PORT MAP(
PCdisp30 => aux23,
PCdisp22 => aux22,
PC => aux3,
PCplus1 => aux2,
PCSource => aux24,
nPC => aux25
);
Inst_MuxNextRD: MuxNextRD PORT MAP(
RD => aux16,
O7 => "001111",
RfDest => aux26,
NRd => aux27
);
Inst_MuxDWR: MuxDWR PORT MAP(
DM => aux32,
AluR => aux30,
PC => aux3,
RFSource => aux33,
DTRF => aux10
);
Inst_DataMemory: DataMemory PORT MAP(
enableMem => '1',
reset => RST,
cRD => aux29,
address => aux30,
wrEnMem => aux31,
datoToWr => aux32
);
Inst_windows_manager: windows_manager PORT MAP(
cwp => aux18,
rs1 => aux4(18 downto 14),
rs2 => aux4(4 downto 0),
rd => aux4(29 downto 25),
op => aux4(31 downto 30),
op3 => aux4(24 downto 19),
nrs1 => aux14,
nrs2 => aux15,
nrd => aux16,
ncwp => aux17
);
Inst_psr: psr PORT MAP(
clk => CLK,
reset => RST,
nzvc => aux13,
ncwp => aux17,
carry => aux12,
cwp => aux18
);
Inst_psr_modifier: psr_modifier PORT MAP(
crs1 => aux6(31),
ope2 => aux9(31),
alur => aux30,
aluop => aux5,
nzvc => aux13
);
Inst_sumPC: sum32b PORT MAP(
Op1 => x"00000001",
Op2 => aux1,
R => aux2
);
Inst_sumDisp22: sum32b PORT MAP(
Op1 => aux21,
Op2 => aux3,
R => aux22
);
Inst_sumDisp30: sum32b PORT MAP(
Op1 => aux20,
Op2 => aux3,
R => aux23
);
Inst_alu: alu PORT MAP(
carry => aux12,
aluop => aux5,
crs1 => aux6,
crs2 => aux9,
r => aux30
);
Inst_control_unit: control_unit PORT MAP(
op => aux4(31 downto 30),
op2 => aux4(24 downto 22),
op3 => aux4(24 downto 19),
icc => aux13,
cond => aux4(28 downto 25),
Aluop => aux5,
wrenDM => aux31,
RFSource => aux33,
PCSource => aux24,
RFdest => aux26,
write_enable => aux28
);
Inst_instructionMemory: instructionMemory PORT MAP(
address => aux3,
reset => RST,
outInstruction => aux4
);
Inst_mux32b: mux32b PORT MAP(
A => aux7,
B => aux11,
Sel => aux4(13),
O => aux9
);
Inst_pc: pc PORT MAP(
clk => CLK,
rst => RST,
address => aux1,
sig => aux3
);
Inst_npc: pc PORT MAP(
clk => CLK,
rst => RST,
address => aux25,
sig => aux1
);
Inst_register_file: register_file PORT MAP(
Wren => aux28,
rst => RST,
rs1 => aux14,
rs2 => aux15,
rd => aux27,
data => aux10,
crs1 => aux6,
crs2 => aux7,
crd => aux29
);
Inst_sign_ext_unit: sign_ext_unit PORT MAP(
entrada => aux4(12 downto 0),
salida => aux11
);
R<=aux30;
end Behavioral;