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

Subversion Repositories amber

[/] [amber/] [trunk/] [hw/] [vlog/] [amber25/] [a25_core.v] - Blame information for rev 16

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 16 csantifort
//////////////////////////////////////////////////////////////////
2
//                                                              //
3
//  Amber 25 Core top-Level module                              //
4
//                                                              //
5
//  This file is part of the Amber project                      //
6
//  http://www.opencores.org/project,amber                      //
7
//                                                              //
8
//  Description                                                 //
9
//  Instantiates the core consisting of fetch, instruction      //
10
//  decode, execute, and co-processor.                          //
11
//                                                              //
12
//  Author(s):                                                  //
13
//      - Conor Santifort, csantifort.amber@gmail.com           //
14
//                                                              //
15
//////////////////////////////////////////////////////////////////
16
//                                                              //
17
// Copyright (C) 2011 Authors and OPENCORES.ORG                 //
18
//                                                              //
19
// This source file may be used and distributed without         //
20
// restriction provided that this copyright statement is not    //
21
// removed from the file and that any derivative work contains  //
22
// the original copyright notice and the associated disclaimer. //
23
//                                                              //
24
// This source file is free software; you can redistribute it   //
25
// and/or modify it under the terms of the GNU Lesser General   //
26
// Public License as published by the Free Software Foundation; //
27
// either version 2.1 of the License, or (at your option) any   //
28
// later version.                                               //
29
//                                                              //
30
// This source is distributed in the hope that it will be       //
31
// useful, but WITHOUT ANY WARRANTY; without even the implied   //
32
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      //
33
// PURPOSE.  See the GNU Lesser General Public License for more //
34
// details.                                                     //
35
//                                                              //
36
// You should have received a copy of the GNU Lesser General    //
37
// Public License along with this source; if not, download it   //
38
// from http://www.opencores.org/lgpl.shtml                     //
39
//                                                              //
40
//////////////////////////////////////////////////////////////////
41
 
42
 
43
module a25_core
44
(
45
input                       i_clk,
46
 
47
input                       i_irq,              // Interrupt request, active high
48
input                       i_firq,             // Fast Interrupt request, active high
49
 
50
input                       i_system_rdy,       // Amber is stalled when this is low
51
 
52
// Wishbone Master I/F
53
output      [31:0]          o_wb_adr,
54
output      [3:0]           o_wb_sel,
55
output                      o_wb_we,
56
input       [31:0]          i_wb_dat,
57
output      [31:0]          o_wb_dat,
58
output                      o_wb_cyc,
59
output                      o_wb_stb,
60
input                       i_wb_ack,
61
input                       i_wb_err
62
 
63
);
64
 
65
wire      [31:0]          execute_iaddress;
66
wire                      execute_iaddress_valid;
67
wire      [31:0]          execute_iaddress_nxt;  // un-registered version of execute_address
68
                                                 // to the instruction cache rams
69
wire      [31:0]          execute_daddress;
70
wire                      execute_daddress_valid;
71
wire      [31:0]          execute_daddress_nxt; // un-registered version of execute_daddress
72
                                                // to the data cache rams
73
wire      [31:0]          write_data;
74
wire                      write_enable;
75
wire      [31:0]          fetch_instruction;
76
// wire                      priviledged;
77
wire                      decode_exclusive;
78
wire                      decode_iaccess;
79
wire                      decode_daccess;
80
wire      [3:0]           byte_enable;
81
wire                      exclusive;            // swap access
82
wire                      cache_enable;         // Enabel the cache
83
wire                      cache_flush;          // Flush the cache
84
wire      [31:0]          cacheable_area;
85
 
86
wire                      fetch_stall;
87
wire                      mem_stall;
88
wire                      access_stall;
89
 
90
wire     [1:0]            status_bits_mode;
91
wire                      status_bits_irq_mask;
92
wire                      status_bits_firq_mask;
93
wire                      status_bits_flags_wen;
94
wire                      status_bits_mode_wen;
95
wire                      status_bits_irq_mask_wen;
96
wire                      status_bits_firq_mask_wen;
97
wire     [31:0]           execute_status_bits;
98
 
99
wire     [31:0]           imm32;
100
wire     [4:0]            imm_shift_amount;
101
wire                      shift_imm_zero;
102
wire     [3:0]            condition;
103
 
104
wire     [3:0]            rm_sel;
105
wire     [3:0]            rs_sel;
106
wire     [7:0]            decode_load_rd;
107
wire     [7:0]            exec_load_rd;
108
wire     [3:0]            rn_sel;
109
wire     [1:0]            barrel_shift_amount_sel;
110
wire     [1:0]            barrel_shift_data_sel;
111
wire     [1:0]            barrel_shift_function;
112
wire     [8:0]            alu_function;
113
wire     [1:0]            multiply_function;
114
wire     [2:0]            interrupt_vector_sel;
115
wire     [3:0]            iaddress_sel;
116
wire     [3:0]            daddress_sel;
117
wire     [2:0]            pc_sel;
118
wire     [1:0]            byte_enable_sel;
119
wire     [2:0]            status_bits_sel;
120
wire     [2:0]            reg_write_sel;
121
// wire                      user_mode_regs_load;     
122
wire                      user_mode_regs_store_nxt;
123
wire                      firq_not_user_mode;
124
 
125
wire                      write_data_wen;
126
wire                      copro_write_data_wen;
127
wire                      base_address_wen;
128
wire                      pc_wen;
129
wire     [14:0]           reg_bank_wen;
130
 
131
wire     [2:0]            copro_opcode1;
132
wire     [2:0]            copro_opcode2;
133
wire     [3:0]            copro_crn;
134
wire     [3:0]            copro_crm;
135
wire     [3:0]            copro_num;
136
wire     [1:0]            copro_operation;
137
wire     [31:0]           copro_read_data;
138
wire     [31:0]           copro_write_data;
139
wire                      multiply_done;
140
 
141
wire                      decode_fault;
142
wire                      iabt_trigger;
143
wire                      dabt_trigger;
144
 
145
wire     [7:0]            decode_fault_status;
146
wire     [7:0]            iabt_fault_status;
147
wire     [7:0]            dabt_fault_status;
148
 
149
wire     [31:0]           decode_fault_address;
150
wire     [31:0]           iabt_fault_address;
151
wire     [31:0]           dabt_fault_address;
152
 
153
wire                      adex;
154
 
155
wire     [31:0]           mem_read_data;
156
wire                      mem_read_data_valid;
157
wire     [9:0]            mem_load_rd;
158
 
159
wire     [31:0]           wb_read_data;
160
wire                      wb_read_data_valid;
161
wire     [9:0]            wb_load_rd;
162
 
163
wire                      dcache_wb_cached_req;
164
wire                      dcache_wb_uncached_req;
165
wire                      dcache_wb_qword;
166
wire                      dcache_wb_write;
167
wire     [3:0]            dcache_wb_byte_enable;
168
wire     [31:0]           dcache_wb_address;
169
wire     [31:0]           dcache_wb_read_data;
170
wire     [31:0]           dcache_wb_write_data;
171
wire                      dcache_wb_cached_ready;
172
wire                      dcache_wb_uncached_ready;
173
wire     [31:0]           icache_wb_address;
174
wire                      icache_wb_req;
175
wire                      icache_wb_qword;
176
wire     [31:0]           icache_wb_adr;
177
wire     [31:0]           icache_wb_read_data;
178
wire                      icache_wb_ready;
179
 
180
wire                      conflict;
181
 
182
 
183
// data abort has priority
184
assign decode_fault_status  = dabt_trigger ? dabt_fault_status  : iabt_fault_status;
185
assign decode_fault_address = dabt_trigger ? dabt_fault_address : iabt_fault_address;
186
assign decode_fault         = dabt_trigger | iabt_trigger;
187
 
188
assign access_stall         = fetch_stall || mem_stall;
189
 
190
// ======================================
191
//  Fetch Stage
192
// ======================================
193
a25_fetch u_fetch (
194
    .i_clk                              ( i_clk                             ),
195
    .i_mem_stall                        ( mem_stall                         ),
196
    .i_conflict                         ( conflict                          ),
197
    .i_system_rdy                       ( i_system_rdy                      ),
198
    .o_fetch_stall                      ( fetch_stall                       ),
199
 
200
    .i_iaddress                         ( {execute_iaddress[31:2], 2'd0}    ),
201
    .i_iaddress_valid                   ( execute_iaddress_valid            ),
202
    .i_iaddress_nxt                     ( execute_iaddress_nxt              ),
203
    .o_fetch_instruction                ( fetch_instruction                 ),
204
    .i_cache_enable                     ( cache_enable                      ),
205
    .i_cache_flush                      ( cache_flush                       ),
206
    .i_cacheable_area                   ( cacheable_area                    ),
207
 
208
 
209
    .o_wb_req                           ( icache_wb_req                     ),
210
    .o_wb_qword                         ( icache_wb_qword                   ),
211
    .o_wb_address                       ( icache_wb_address                 ),
212
    .i_wb_read_data                     ( icache_wb_read_data               ),
213
    .i_wb_ready                         ( icache_wb_ready                   )
214
);
215
 
216
 
217
// ======================================
218
//  Decode Stage
219
// ======================================
220
a25_decode u_decode (
221
    .i_clk                              ( i_clk                             ),
222
    .i_access_stall                     ( access_stall                      ),
223
 
224
    // Instruction fetch or data read signals
225
    .i_fetch_instruction                ( fetch_instruction                 ),
226
    .i_execute_iaddress                 ( execute_iaddress                  ),
227
    .i_execute_daddress                 ( execute_daddress                  ),
228
    .i_adex                             ( adex                              ),
229
    .i_iabt                             ( 1'd0                              ),
230
    .i_dabt                             ( 1'd0                              ),
231
    .i_abt_status                       ( 8'd0                              ),
232
 
233
    .i_irq                              ( i_irq                             ),
234
    .i_firq                             ( i_firq                            ),
235
    .i_execute_status_bits              ( execute_status_bits               ),
236
    .i_multiply_done                    ( multiply_done                     ),
237
 
238
    .o_status_bits_mode                 ( status_bits_mode                  ),
239
    .o_status_bits_irq_mask             ( status_bits_irq_mask              ),
240
    .o_status_bits_firq_mask            ( status_bits_firq_mask             ),
241
    .o_imm32                            ( imm32                             ),
242
    .o_imm_shift_amount                 ( imm_shift_amount                  ),
243
    .o_shift_imm_zero                   ( shift_imm_zero                    ),
244
    .o_condition                        ( condition                         ),
245
    .o_decode_exclusive                 ( decode_exclusive                  ),
246
    .o_decode_iaccess                   ( decode_iaccess                    ),
247
    .o_decode_daccess                   ( decode_daccess                    ),
248
    .o_rm_sel                           ( rm_sel                            ),
249
    .o_rs_sel                           ( rs_sel                            ),
250
    .o_load_rd                          ( decode_load_rd                    ),
251
    .o_rn_sel                           ( rn_sel                            ),
252
    .o_barrel_shift_amount_sel          ( barrel_shift_amount_sel           ),
253
    .o_barrel_shift_data_sel            ( barrel_shift_data_sel             ),
254
    .o_barrel_shift_function            ( barrel_shift_function             ),
255
    .o_alu_function                     ( alu_function                      ),
256
    .o_multiply_function                ( multiply_function                 ),
257
    .o_interrupt_vector_sel             ( interrupt_vector_sel              ),
258
    .o_iaddress_sel                     ( iaddress_sel                      ),
259
    .o_daddress_sel                     ( daddress_sel                      ),
260
    .o_pc_sel                           ( pc_sel                            ),
261
    .o_byte_enable_sel                  ( byte_enable_sel                   ),
262
    .o_status_bits_sel                  ( status_bits_sel                   ),
263
    .o_reg_write_sel                    ( reg_write_sel                     ),
264
//     .o_user_mode_regs_load              ( user_mode_regs_load               ),
265
    .o_user_mode_regs_store_nxt         ( user_mode_regs_store_nxt          ),
266
    .o_firq_not_user_mode               ( firq_not_user_mode                ),
267
    .o_write_data_wen                   ( write_data_wen                    ),
268
    .o_base_address_wen                 ( base_address_wen                  ),
269
    .o_pc_wen                           ( pc_wen                            ),
270
    .o_reg_bank_wen                     ( reg_bank_wen                      ),
271
    .o_status_bits_flags_wen            ( status_bits_flags_wen             ),
272
    .o_status_bits_mode_wen             ( status_bits_mode_wen              ),
273
    .o_status_bits_irq_mask_wen         ( status_bits_irq_mask_wen          ),
274
    .o_status_bits_firq_mask_wen        ( status_bits_firq_mask_wen         ),
275
 
276
    .o_copro_opcode1                    ( copro_opcode1                     ),
277
    .o_copro_opcode2                    ( copro_opcode2                     ),
278
    .o_copro_crn                        ( copro_crn                         ),
279
    .o_copro_crm                        ( copro_crm                         ),
280
    .o_copro_num                        ( copro_num                         ),
281
    .o_copro_operation                  ( copro_operation                   ),
282
    .o_copro_write_data_wen             ( copro_write_data_wen              ),
283
 
284
    .o_iabt_trigger                     ( iabt_trigger                      ),
285
    .o_iabt_address                     ( iabt_fault_address                ),
286
    .o_iabt_status                      ( iabt_fault_status                 ),
287
    .o_dabt_trigger                     ( dabt_trigger                      ),
288
    .o_dabt_address                     ( dabt_fault_address                ),
289
    .o_dabt_status                      ( dabt_fault_status                 ),
290
 
291
    .o_conflict                         ( conflict                          )
292
);
293
 
294
 
295
// ======================================
296
//  Execute Stage
297
// ======================================
298
a25_execute u_execute (
299
    .i_clk                              ( i_clk                             ),
300
    .i_access_stall                     ( access_stall                      ),
301
    .i_mem_stall                        ( mem_stall                         ),
302
 
303
    .i_wb_read_data                     ( wb_read_data                      ),
304
    .i_wb_read_data_valid               ( wb_read_data_valid                ),
305
    .i_wb_load_rd                       ( wb_load_rd                        ),
306
 
307
    .i_copro_read_data                  ( copro_read_data                   ),
308
 
309
    .o_write_data                       ( write_data                        ),
310
    .o_copro_write_data                 ( copro_write_data                  ),
311
    .o_iaddress                         ( execute_iaddress                  ),
312
    .o_iaddress_valid                   ( execute_iaddress_valid            ),
313
    .o_iaddress_nxt                     ( execute_iaddress_nxt              ),
314
    .o_daddress                         ( execute_daddress                  ),
315
    .o_daddress_nxt                     ( execute_daddress_nxt              ),
316
    .o_daddress_valid                   ( execute_daddress_valid            ),
317
    .o_byte_enable                      ( byte_enable                       ),
318
    .o_write_enable                     ( write_enable                      ),
319
    .o_exclusive                        ( exclusive                         ),
320
    .o_priviledged                      (                                   ),
321
    .o_exec_load_rd                     ( exec_load_rd                      ),
322
 
323
    .o_adex                             ( adex                              ),
324
    .o_status_bits                      ( execute_status_bits               ),
325
    .o_multiply_done                    ( multiply_done                     ),
326
 
327
    .i_status_bits_mode                 ( status_bits_mode                  ),
328
    .i_status_bits_irq_mask             ( status_bits_irq_mask              ),
329
    .i_status_bits_firq_mask            ( status_bits_firq_mask             ),
330
    .i_imm32                            ( imm32                             ),
331
    .i_imm_shift_amount                 ( imm_shift_amount                  ),
332
    .i_shift_imm_zero                   ( shift_imm_zero                    ),
333
    .i_condition                        ( condition                         ),
334
    .i_decode_exclusive                 ( decode_exclusive                  ),
335
    .i_decode_iaccess                   ( decode_iaccess                    ),
336
    .i_decode_daccess                   ( decode_daccess                    ),
337
    .i_rm_sel                           ( rm_sel                            ),
338
    .i_rs_sel                           ( rs_sel                            ),
339
    .i_decode_load_rd                   ( decode_load_rd                    ),
340
    .i_rn_sel                           ( rn_sel                            ),
341
    .i_barrel_shift_amount_sel          ( barrel_shift_amount_sel           ),
342
    .i_barrel_shift_data_sel            ( barrel_shift_data_sel             ),
343
    .i_barrel_shift_function            ( barrel_shift_function             ),
344
    .i_alu_function                     ( alu_function                      ),
345
    .i_multiply_function                ( multiply_function                 ),
346
    .i_interrupt_vector_sel             ( interrupt_vector_sel              ),
347
    .i_iaddress_sel                     ( iaddress_sel                      ),
348
    .i_daddress_sel                     ( daddress_sel                      ),
349
    .i_pc_sel                           ( pc_sel                            ),
350
    .i_byte_enable_sel                  ( byte_enable_sel                   ),
351
    .i_status_bits_sel                  ( status_bits_sel                   ),
352
    .i_reg_write_sel                    ( reg_write_sel                     ),
353
//     .i_user_mode_regs_load              ( user_mode_regs_load               ),   
354
    .i_user_mode_regs_store_nxt         ( user_mode_regs_store_nxt          ),
355
    .i_firq_not_user_mode               ( firq_not_user_mode                ),
356
    .i_write_data_wen                   ( write_data_wen                    ),
357
    .i_base_address_wen                 ( base_address_wen                  ),
358
    .i_pc_wen                           ( pc_wen                            ),
359
    .i_reg_bank_wen                     ( reg_bank_wen                      ),
360
    .i_status_bits_flags_wen            ( status_bits_flags_wen             ),
361
    .i_status_bits_mode_wen             ( status_bits_mode_wen              ),
362
    .i_status_bits_irq_mask_wen         ( status_bits_irq_mask_wen          ),
363
    .i_status_bits_firq_mask_wen        ( status_bits_firq_mask_wen         ),
364
    .i_copro_write_data_wen             ( copro_write_data_wen              ),
365
    .i_conflict                         ( conflict                          )
366
);
367
 
368
 
369
// ======================================
370
//  Memory access stage with data cache
371
// ======================================
372
a25_mem u_mem (
373
    .i_clk                              ( i_clk                             ),
374
    .i_fetch_stall                      ( fetch_stall                       ),
375
    .o_mem_stall                        ( mem_stall                         ),
376
 
377
    .i_daddress                         ( execute_daddress                  ),
378
    .i_daddress_valid                   ( execute_daddress_valid            ),
379
    .i_daddress_nxt                     ( execute_daddress_nxt              ),
380
    .i_write_data                       ( write_data                        ),
381
    .i_write_enable                     ( write_enable                      ),
382
    .i_byte_enable                      ( byte_enable                       ),
383
    .i_exclusive                        ( exclusive                         ),
384
    .i_exec_load_rd                     ( exec_load_rd                      ),
385
 
386
    .o_mem_read_data                    ( mem_read_data                     ),
387
    .o_mem_read_data_valid              ( mem_read_data_valid               ),
388
    .o_mem_load_rd                      ( mem_load_rd                       ),
389
 
390
    .i_cache_enable                     ( cache_enable                      ),
391
    .i_cache_flush                      ( cache_flush                       ),
392
    .i_cacheable_area                   ( cacheable_area                    ),
393
 
394
    .o_wb_cached_req                    ( dcache_wb_cached_req              ),
395
    .o_wb_uncached_req                  ( dcache_wb_uncached_req            ),
396
    .o_wb_qword                         ( dcache_wb_qword                   ),
397
    .o_wb_write                         ( dcache_wb_write                   ),
398
    .o_wb_write_data                    ( dcache_wb_write_data              ),
399
    .o_wb_byte_enable                   ( dcache_wb_byte_enable             ),
400
    .o_wb_address                       ( dcache_wb_address                 ),
401
    .i_wb_read_data                     ( dcache_wb_read_data               ),
402
    .i_wb_cached_ready                  ( dcache_wb_cached_ready            ),
403
    .i_wb_uncached_ready                ( dcache_wb_uncached_ready          )
404
);
405
 
406
 
407
// ======================================
408
//  Write back stage with data cache
409
// ======================================
410
a25_write_back u_write_back (
411
    .i_clk                              ( i_clk                             ),
412
    .i_mem_stall                        ( mem_stall                         ),
413
 
414
    .i_daddress                         ( execute_daddress                  ),
415
    .i_daddress_valid                   ( execute_daddress_valid            ),
416
 
417
    .i_mem_read_data                    ( mem_read_data                     ),
418
    .i_mem_read_data_valid              ( mem_read_data_valid               ),
419
    .i_mem_load_rd                      ( mem_load_rd                       ),
420
 
421
    .o_wb_read_data                     ( wb_read_data                      ),
422
    .o_wb_read_data_valid               ( wb_read_data_valid                ),
423
    .o_wb_load_rd                       ( wb_load_rd                        )
424
);
425
 
426
 
427
 
428
// ======================================
429
//  Wishbone Master I/F
430
// ======================================
431
a25_wishbone u_wishbone (
432
    // CPU Side
433
    .i_clk                              ( i_clk                             ),
434
 
435
    // Instruction Cache Accesses
436
    .i_icache_req                       ( icache_wb_req                     ),
437
    .i_icache_qword                     ( icache_wb_qword                   ),
438
    .i_icache_address                   ( icache_wb_address                 ),
439
    .o_icache_read_data                 ( icache_wb_read_data               ),
440
    .o_icache_ready                     ( icache_wb_ready                   ),
441
 
442
    // Data Cache Accesses 
443
    .i_exclusive                        ( exclusive                         ),
444
    .i_dcache_cached_req                ( dcache_wb_cached_req              ),
445
    .i_dcache_uncached_req              ( dcache_wb_uncached_req            ),
446
    .i_dcache_qword                     ( dcache_wb_qword                   ),
447
    .i_dcache_write                     ( dcache_wb_write                   ),
448
    .i_dcache_write_data                ( dcache_wb_write_data              ),
449
    .i_dcache_byte_enable               ( dcache_wb_byte_enable             ),
450
    .i_dcache_address                   ( dcache_wb_address                 ),
451
    .o_dcache_read_data                 ( dcache_wb_read_data               ),
452
    .o_dcache_cached_ready              ( dcache_wb_cached_ready            ),
453
    .o_dcache_uncached_ready            ( dcache_wb_uncached_ready          ),
454
 
455
    .o_wb_adr                           ( o_wb_adr                          ),
456
    .o_wb_sel                           ( o_wb_sel                          ),
457
    .o_wb_we                            ( o_wb_we                           ),
458
    .i_wb_dat                           ( i_wb_dat                          ),
459
    .o_wb_dat                           ( o_wb_dat                          ),
460
    .o_wb_cyc                           ( o_wb_cyc                          ),
461
    .o_wb_stb                           ( o_wb_stb                          ),
462
    .i_wb_ack                           ( i_wb_ack                          ),
463
    .i_wb_err                           ( i_wb_err                          )
464
);
465
 
466
 
467
 
468
// ======================================
469
//  Co-Processor #15
470
// ======================================
471
a25_coprocessor u_coprocessor (
472
    .i_clk                              ( i_clk                             ),
473
    .i_access_stall                     ( access_stall                      ),
474
 
475
    .i_copro_opcode1                    ( copro_opcode1                     ),
476
    .i_copro_opcode2                    ( copro_opcode2                     ),
477
    .i_copro_crn                        ( copro_crn                         ),
478
    .i_copro_crm                        ( copro_crm                         ),
479
    .i_copro_num                        ( copro_num                         ),
480
    .i_copro_operation                  ( copro_operation                   ),
481
    .i_copro_write_data                 ( copro_write_data                  ),
482
 
483
    .i_fault                            ( decode_fault                      ),
484
    .i_fault_status                     ( decode_fault_status               ),
485
    .i_fault_address                    ( decode_fault_address              ),
486
 
487
    .o_copro_read_data                  ( copro_read_data                   ),
488
    .o_cache_enable                     ( cache_enable                      ),
489
    .o_cache_flush                      ( cache_flush                       ),
490
    .o_cacheable_area                   ( cacheable_area                    )
491
);
492
 
493
 
494
endmodule
495
 

powered by: WebSVN 2.1.0

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