OpenCores
URL https://opencores.org/ocsvn/Aquarius/Aquarius/trunk

Subversion Repositories Aquarius

[/] [Aquarius/] [trunk/] [verilog/] [cpu.v] - Blame information for rev 12

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 thorn_aitc
//======================================================
2
// Aquarius Project
3
//    SuperH-2 ISA Compatible RISC CPU
4
//------------------------------------------------------
5
// Module      : CPU
6
//------------------------------------------------------
7
// File        : cpu.v
8
// Library     : none
9
// Description : Top Layer of CPU.
10
// Simulator   : Icarus Verilog (Cygwin)
11
// Synthesizer : Xilinx XST (Windows XP)
12
// Author      : Thorn Aitch
13
//------------------------------------------------------
14
// Revision Number : 1
15
// Date of Change  : 11th April 2002
16
// Creator         : Thorn Aitch
17
// Description     : Initial Design                               
18
//------------------------------------------------------
19
// Revision Number : 2
20
// Date of Change  : 30th April 2003
21
// Modifier        : Thorn Aitch
22
// Description     : Release Version 1.0
23
//======================================================
24
// Copyright (C) 2002-2003, Thorn Aitch
25
//
26
// Designs can be altered while keeping list of
27
// modifications "the same as in GNU" No money can
28
// be earned by selling the designs themselves, but
29
// anyone can get money by selling the implementation
30
// of the design, such as ICs based on some cores, 
31
// boards based on some schematics or Layouts, and
32
// even GUI interfaces to text mode drivers.
33
// "The same as GPL SW" Any update to the design
34
// should be documented and returned to the design. 
35
// Any derivative work based on the IP should be free
36
// under OpenIP License. Derivative work means any
37
// update, change or improvement on the design. 
38
// Any work based on the design can be either made
39
// free under OpenIP license or protected by any other
40
// license. Work based on the design means any work uses
41
// the OpenIP Licensed core as a building black without
42
// changing anything on it with any other blocks to
43
// produce larger design.  There is NO WARRANTY on the
44
// functionality or performance of the design on the
45
// real hardware implementation.
46
// On the other hand, the SuperH-2 ISA (Instruction Set
47
// Architecture) executed by Aquarius is rigidly
48
// the property of Renesas Corp. Then you have all 
49
// responsibility to judge if there are not any 
50
// infringements to Renesas's rights regarding your 
51
// Aquarius adoption into your design. 
52
// By adopting Aquarius, the user assumes all 
53
// responsibility for its use.
54
// This project may cause any damages around you, for 
55
// example, loss of properties, data, money, profits,
56
// life, or business etc. By adopting this source, 
57
// the user assumes all responsibility for its use.
58
//======================================================
59
 
60
`include "timescale.v"
61
`include "defines.v"
62
 
63
//*************************************************
64
// Module Definition
65
//*************************************************
66
module cpu(
67
// system signal
68
    CLK, RST,
69
// WISHBONE external bus signal
70
    CYC_O, STB_O, ACK_I,
71
    ADR_O, DAT_I, DAT_O,
72
    WE_O, SEL_O,
73
    TAG0_I,
74
// Exception
75
    EVENT_REQ_I,
76
    EVENT_ACK_O,
77
    EVENT_INFO_I,
78
// SLEPP
79
    SLP_O
80
    );
81
 
82
//-------------------
83
// Module I/O Signals
84
//-------------------
85
    // (WISHBONE)
86
    input  CLK;           // clock
87
    input  RST;           // reset
88
    output CYC_O;         // cycle output
89
    output STB_O;         // strobe
90
    input  ACK_I;         // external memory ready
91
    output [31:0] ADR_O;  // external address
92
    input  [31:0] DAT_I;  // external data read bus
93
    output [31:0] DAT_O;  // external data write bus
94
    output WE_O;          // external write/read
95
    output [3:0] SEL_O;   // external valid data position
96
    input  TAG0_I;        // external fetch space width (IF_WIDTH)
97
    // Hardware Exception Event
98
    input  [2:0] EVENT_REQ_I;   // Hardware Exception Event Request
99
    output EVENT_ACK_O;         // Hardware Exception Event Acknowledge
100
    input  [11:0] EVENT_INFO_I; // Hardware Exception Event Information
101
    // SLEEP
102
    output SLP_O;         // SLEEP output
103
 
104
//-----------------------
105
// External Signal Buffer
106
//-----------------------
107
    // CLK   ----------------------------------
108
    //   should be distributed by CTS or CT-GEN
109
    // RST   ----------------------------------
110
    //   should be distributed by CTS or CT-GEN
111
    // CYC_O ------------------------------
112
    wire   CYC;         //use it internally
113
    assign CYC_O = CYC;
114
    // STB_O ------------------------------
115
    wire   STB;         //use it internally
116
    assign STB_O = STB;
117
    // ACK_I ------------------------------
118
    wire   ACK;         //use it internally
119
    assign ACK = ACK_I;
120
    // ADR_O ------------------------------
121
    wire   [31:0] ADR;  //use it internally
122
    assign ADR_O = ADR;
123
    // DAT_I ------------------------------
124
    wire   [31:0] DATI; //use it internally
125
    assign DATI = DAT_I;
126
    // DAT_O ------------------------------
127
    wire   [31:0] DATO; //use it internally
128
    assign DAT_O = DATO;
129
    // WE_O -------------------------------
130
    wire   WE;          //use it internally
131
    assign WE_O = WE;
132
    // SEL_O ------------------------------
133
    wire   [3:0] SEL;   //use it internally
134
    assign SEL_O = SEL;
135
    // TAG0_I -----------------------------
136
    wire   IF_WIDTH;    //use it internally
137
    assign IF_WIDTH = TAG0_I;
138
    // EVENT_REQ_I-------------------------
139
    wire   [2:0] EVENT_REQ;    // use it internally
140
    assign EVENT_REQ = EVENT_REQ_I;
141
    // EVENT_ACK_O-------------------------
142
    wire   EVENT_ACK;          // use it internally
143
    assign EVENT_ACK_O = EVENT_ACK;
144
    // EVENT_INFO_I------------------------
145
    wire   [11:0] EVENT_INFO;  // use it internally
146
    assign EVENT_INFO = EVENT_INFO_I;
147
    // SLP_O-------------------------------
148
    wire   SLP; // use it internally
149
    assign SLP_O = SLP;
150
    // ------------------------------------        
151
 
152
//-----------------
153
// Internal Signals
154
//-----------------
155
    wire   SLOT;          // pipeline slot edge
156
    wire   IF_ISSUE;      // fetch request
157
    wire   IF_JP;         // fetch caused by jump
158
    wire   [31:0] IF_AD;  // fetch address
159
    wire   [15:0] IF_DR;  // fetched instruction
160
    wire   IF_BUS;        // fetch access done to extenal bus
161
    wire   IF_STALL;      // fetch and memory access contention
162
    wire   MA_ISSUE;      // memory access request
163
    wire   KEEP_CYC;      // request read-modify-write (To be issued on READ-CYC to keep CYC_O on)
164
    wire   MA_WR;         // memory access kind :Write(1)/ Read(0)
165
    wire   [1:0] MA_SZ;   // memory access size : 00 byte, 01 word, 10 long, 11 inhibitted
166
    wire   [31:0] MA_AD;  // memory access address
167
    wire   [31:0] MA_DW;  // memory write data
168
    wire   [31:0] MA_DR;  // memory read data
169
 
170
    wire MULCOM1;
171
    wire [7:0] MULCOM2;
172
    wire WRMACH, WRMACL;
173
    wire [31:0] MACIN1;
174
    wire [31:0] MACIN2;
175
    wire [31:0] MACH;
176
    wire [31:0] MACL;
177
    wire MAC_BUSY;
178
 
179
    wire RDREG_X, RDREG_Y, WRREG_Z, WRREG_W;
180
    wire [3:0] REGNUM_X, REGNUM_Y, REGNUM_Z, REGNUM_W;
181
 
182
    wire [4:0] ALUFUNC;
183
 
184
    wire WRMAAD_Z, WRMADW_X, WRMADW_Y, RDMADR_W;
185
 
186
    wire [1:0] MACSEL1, MACSEL2;
187
    wire RDMACH_X, RDMACL_X;
188
    wire RDMACH_Y, RDMACL_Y;
189
 
190
    wire RDSR_X, RDSR_Y;
191
    wire WRSR_Z, WRSR_W;
192
 
193
    wire MAC_S;
194
    wire MAC_S_LATCH;
195
 
196
    wire RDGBR_X, RDGBR_Y;
197
    wire WRGBR_Z, WRGBR_W;
198
 
199
    wire RDVBR_X, RDVBR_Y;
200
    wire WRVBR_Z, WRVBR_W;
201
 
202
    wire RDPR_X, RDPR_Y;
203
    wire WRPR_Z, WRPR_W, WRPR_PC;
204
 
205
    wire RDPC_X, RDPC_Y, WRPC_Z;
206
    wire INCPC, IFADSEL;
207
 
208
    wire [15:0] CONST_IFDR;
209
    wire CONST_ZERO4, CONST_ZERO42, CONST_ZERO44;
210
    wire CONST_ZERO8, CONST_ZERO82, CONST_ZERO84;
211
    wire CONST_SIGN8, CONST_SIGN82, CONST_SIGN122;
212
    wire RDCONST_X, RDCONST_Y;
213
    wire REG_FWD_X, REG_FWD_Y;
214
 
215
    wire [2:0] CMPCOM;
216
    wire [4:0] SFTFUNC;
217
 
218
    wire RDSFT_Z;
219
 
220
    wire T_BCC;
221
    wire T_CMPSET;
222
    wire T_CRYSET;
223
    wire T_TSTSET;
224
    wire T_SFTSET;
225
    wire QT_DV1SET;
226
    wire MQT_DV0SET;
227
    wire T_CLR;
228
    wire T_SET;
229
    wire MQ_CLR;
230
 
231
    wire RDTEMP_X;
232
    wire WRTEMP_Z;
233
    wire WRMAAD_TEMP;
234
 
235
    wire RST_SR;
236
    wire [3:0] IBIT;
237
    wire [3:0] ILEVEL;
238
    wire WR_IBIT;
239
 
240
//*************************
241
// Memory Access Controller
242
//*************************
243
mem MEM (
244
    // system signal
245
    .CLK(CLK), .RST(RST),
246
    // WISHBONE external bus signal
247
    .CYC(CYC), .STB(STB), .ACK(ACK),
248
    .ADR(ADR), .DATI(DATI), .DATO(DATO),
249
    .WE(WE), .SEL(SEL),
250
    .IF_WIDTH(IF_WIDTH),
251
    // internal block control
252
    .SLOT(SLOT),
253
    // instruction fetch control
254
    .IF_ISSUE(IF_ISSUE), .IF_JP(IF_JP), .IF_AD(IF_AD),
255
    .IF_DR(IF_DR), .IF_BUS(IF_BUS), .IF_STALL(IF_STALL),
256
    // data access control
257
    .MA_ISSUE(MA_ISSUE), .KEEP_CYC(KEEP_CYC),
258
    .MA_WR(MA_WR), .MA_SZ(MA_SZ),
259
    .MA_AD(MA_AD), .MA_DW(MA_DW), .MA_DR(MA_DR)
260
    );
261
 
262
decode DECODE (
263
    // system signal
264
    .CLK(CLK), .RST(RST),
265
    // internal block control
266
    .SLOT(SLOT),
267
    // instruction fetch control
268
    .IF_ISSUE(IF_ISSUE), .IF_JP(IF_JP),
269
    .IF_DR(IF_DR), .IF_BUS(IF_BUS), .IF_STALL(IF_STALL),
270
    // data access control
271
    .MA_ISSUE(MA_ISSUE), .KEEP_CYC(KEEP_CYC),
272
    .MA_WR(MA_WR), .MA_SZ(MA_SZ),
273
    // mult command
274
    .MULCOM1(MULCOM1), .MULCOM2(MULCOM2),
275
    .WRMACH(WRMACH), .WRMACL(WRMACL),
276
    // mult finish signal
277
    .MAC_BUSY(MAC_BUSY),
278
    // general register
279
    .RDREG_X(RDREG_X), .RDREG_Y(RDREG_Y),
280
    .WRREG_Z(WRREG_Z), .WRREG_W(WRREG_W),
281
    .REGNUM_X(REGNUM_X), .REGNUM_Y(REGNUM_Y),
282
    .REGNUM_Z(REGNUM_Z), .REGNUM_W(REGNUM_W),
283
    // ALU function
284
    .ALUFUNC(ALUFUNC),
285
    // memory access
286
    .WRMAAD_Z(WRMAAD_Z),
287
    .WRMADW_X(WRMADW_X), .WRMADW_Y(WRMADW_Y), .RDMADR_W(RDMADR_W),
288
    // mult
289
    .MACSEL1(MACSEL1), .MACSEL2(MACSEL2),
290
    .RDMACH_X(RDMACH_X), .RDMACL_X(RDMACL_X),
291
    .RDMACH_Y(RDMACH_Y), .RDMACL_Y(RDMACL_Y),
292
    // status register
293
    .RDSR_X(RDSR_X), .RDSR_Y(RDSR_Y),
294
    .WRSR_Z(WRSR_Z), .WRSR_W(WRSR_W),
295
    // S bit for MAC
296
    .MAC_S_LATCH(MAC_S_LATCH),
297
    // global base register
298
    .RDGBR_X(RDGBR_X), .RDGBR_Y(RDGBR_Y),
299
    .WRGBR_Z(WRGBR_Z), .WRGBR_W(WRGBR_W),
300
    // vector base register
301
    .RDVBR_X(RDVBR_X), .RDVBR_Y(RDVBR_Y),
302
    .WRVBR_Z(WRVBR_Z), .WRVBR_W(WRVBR_W),
303
    // procedure register
304
    .RDPR_X(RDPR_X), .RDPR_Y(RDPR_Y),
305
    .WRPR_Z(WRPR_Z), .WRPR_W(WRPR_W), .WRPR_PC(WRPR_PC),
306
    // program counter
307
    .RDPC_X(RDPC_X), .RDPC_Y(RDPC_Y), .WRPC_Z(WRPC_Z),
308
    .INCPC(INCPC), .IFADSEL(IFADSEL),
309
    // make constant
310
    .CONST_IFDR(CONST_IFDR),
311
    .CONST_ZERO4(CONST_ZERO4), .CONST_ZERO42(CONST_ZERO42), .CONST_ZERO44(CONST_ZERO44),
312
    .CONST_ZERO8(CONST_ZERO8), .CONST_ZERO82(CONST_ZERO82), .CONST_ZERO84(CONST_ZERO84),
313
    .CONST_SIGN8(CONST_SIGN8), .CONST_SIGN82(CONST_SIGN82),
314
    .CONST_SIGN122(CONST_SIGN122),
315
    .RDCONST_X(RDCONST_X), .RDCONST_Y(RDCONST_Y),
316
    // register forward
317
    .REG_FWD_X(REG_FWD_X), .REG_FWD_Y(REG_FWD_Y),
318
    // commands for comparator and shifter
319
    .CMPCOM(CMPCOM), .SFTFUNC(SFTFUNC),
320
    // read controls to Z-BUS
321
    .RDSFT_Z(RDSFT_Z),
322
    // T value for Bcc judgement
323
    .T_BCC(T_BCC),
324
    // SR control
325
    .T_CMPSET(T_CMPSET), .T_CRYSET(T_CRYSET),
326
    .T_TSTSET(T_TSTSET), .T_SFTSET(T_SFTSET),
327
    .QT_DV1SET(QT_DV1SET), .MQT_DV0SET(MQT_DV0SET),
328
    .T_CLR(T_CLR), .T_SET(T_SET), .MQ_CLR(MQ_CLR),
329
    // Temporary Register
330
    .RDTEMP_X(RDTEMP_X),
331
    .WRTEMP_Z(WRTEMP_Z), .WRMAAD_TEMP(WRMAAD_TEMP),
332
    // Hardware Exception Event
333
    .EVENT_REQ(EVENT_REQ),
334
    .EVENT_ACK(EVENT_ACK),
335
    .EVENT_INFO(EVENT_INFO),
336
    // I bit in Status Register
337
    .RST_SR(RST_SR), .IBIT(IBIT), .ILEVEL(ILEVEL), .WR_IBIT(WR_IBIT),
338
    // SLEEP
339
    .SLP(SLP)
340
    );
341
 
342
mult MULT(
343
    // system signal
344
    .CLK(CLK), .RST(RST),
345
    // command
346
    .SLOT(SLOT), .MULCOM1(MULCOM1), .MULCOM2(MULCOM2), .MAC_S(MAC_S),
347
    .WRMACH(WRMACH), .WRMACL(WRMACL),
348
    // input data
349
    .MACIN1(MACIN1), .MACIN2(MACIN2),
350
    // output data
351
    .MACH(MACH), .MACL(MACL),
352
    // finish signal
353
    .MAC_BUSY(MAC_BUSY)
354
    );
355
 
356
datapath DATAPATH(
357
    // system signal
358
    .CLK(CLK), .RST(RST), .SLOT(SLOT),
359
    // general register
360
    .RDREG_X(RDREG_X), .RDREG_Y(RDREG_Y),
361
    .WRREG_Z(WRREG_Z), .WRREG_W(WRREG_W),
362
    .REGNUM_X(REGNUM_X), .REGNUM_Y(REGNUM_Y),
363
    .REGNUM_Z(REGNUM_Z), .REGNUM_W(REGNUM_W),
364
    // ALU function
365
    .ALUFUNC(ALUFUNC),
366
    // memory access
367
    .MA_AD(MA_AD),    .MA_DW(MA_DW),    .MA_DR(MA_DR),
368
    .WRMAAD_Z(WRMAAD_Z),
369
    .WRMADW_X(WRMADW_X), .WRMADW_Y(WRMADW_Y), .RDMADR_W(RDMADR_W),
370
    // multiplier
371
    .MACIN1(MACIN1), .MACIN2(MACIN2),
372
    .MACSEL1(MACSEL1), .MACSEL2(MACSEL2),
373
    .MACH(MACH), .MACL(MACL),
374
    .RDMACH_X(RDMACH_X), .RDMACL_X(RDMACL_X),
375
    .RDMACH_Y(RDMACH_Y), .RDMACL_Y(RDMACL_Y),
376
    // status register
377
    .RDSR_X(RDSR_X), .RDSR_Y(RDSR_Y),
378
    .WRSR_Z(WRSR_Z), .WRSR_W(WRSR_W),
379
    // S bit for MAC
380
    .MAC_S(MAC_S), .MAC_S_LATCH(MAC_S_LATCH),
381
    // global base register
382
    .RDGBR_X(RDGBR_X), .RDGBR_Y(RDGBR_Y),
383
    .WRGBR_Z(WRGBR_Z), .WRGBR_W(WRGBR_W),
384
    // vector base register
385
    .RDVBR_X(RDVBR_X), .RDVBR_Y(RDVBR_Y),
386
    .WRVBR_Z(WRVBR_Z), .WRVBR_W(WRVBR_W),
387
    // procedure register
388
    .RDPR_X(RDPR_X), .RDPR_Y(RDPR_Y),
389
    .WRPR_Z(WRPR_Z), .WRPR_W(WRPR_W), .WRPR_PC(WRPR_PC),
390
    // program counter
391
    .RDPC_X(RDPC_X), .RDPC_Y(RDPC_Y), .WRPC_Z(WRPC_Z),
392
    .INCPC(INCPC), .IFADSEL(IFADSEL), .IF_AD(IF_AD),
393
    // make constant
394
    .CONST_IFDR(CONST_IFDR),
395
    .CONST_ZERO4(CONST_ZERO4), .CONST_ZERO42(CONST_ZERO42), .CONST_ZERO44(CONST_ZERO44),
396
    .CONST_ZERO8(CONST_ZERO8), .CONST_ZERO82(CONST_ZERO82), .CONST_ZERO84(CONST_ZERO84),
397
    .CONST_SIGN8(CONST_SIGN8), .CONST_SIGN82(CONST_SIGN82),
398
    .CONST_SIGN122(CONST_SIGN122),
399
    .RDCONST_X(RDCONST_X), .RDCONST_Y(RDCONST_Y),
400
    // register forward
401
    .REG_FWD_X(REG_FWD_X), .REG_FWD_Y(REG_FWD_Y),
402
    // commands for comparator and shifter
403
    .CMPCOM(CMPCOM), .SFTFUNC(SFTFUNC),
404
    // read controls to Z-BUS
405
    .RDSFT_Z(RDSFT_Z),
406
    // T value for Bcc judgement
407
    .T_BCC(T_BCC),
408
    // SR control
409
    .T_CMPSET(T_CMPSET), .T_CRYSET(T_CRYSET),
410
    .T_TSTSET(T_TSTSET), .T_SFTSET(T_SFTSET),
411
    .QT_DV1SET(QT_DV1SET), .MQT_DV0SET(MQT_DV0SET),
412
    .T_CLR(T_CLR), .T_SET(T_SET), .MQ_CLR(MQ_CLR),
413
    // Temporary Register
414
    .RDTEMP_X(RDTEMP_X),
415
    .WRTEMP_Z(WRTEMP_Z), .WRMAAD_TEMP(WRMAAD_TEMP),
416
    // I bit in Status Register
417
    .RST_SR(RST_SR), .IBIT(IBIT), .ILEVEL(ILEVEL), .WR_IBIT(WR_IBIT)
418
    );
419
 
420
//======================================================
421
  endmodule
422
//======================================================

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.