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

Subversion Repositories amber

[/] [amber/] [trunk/] [hw/] [vlog/] [amber25/] [a25_execute.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
//  Execute stage of Amber 25 Core                              //
4
//                                                              //
5
//  This file is part of the Amber project                      //
6
//  http://www.opencores.org/project,amber                      //
7
//                                                              //
8
//  Description                                                 //
9
//  Executes instructions. Instantiates the register file, ALU  //
10
//  multiplication unit and barrel shifter. This stage is       //
11
//  relitively simple. All the complex stuff is done in the     //
12
//  decode stage.                                               //
13
//                                                              //
14
//  Author(s):                                                  //
15
//      - Conor Santifort, csantifort.amber@gmail.com           //
16
//                                                              //
17
//////////////////////////////////////////////////////////////////
18
//                                                              //
19
// Copyright (C) 2011 Authors and OPENCORES.ORG                 //
20
//                                                              //
21
// This source file may be used and distributed without         //
22
// restriction provided that this copyright statement is not    //
23
// removed from the file and that any derivative work contains  //
24
// the original copyright notice and the associated disclaimer. //
25
//                                                              //
26
// This source file is free software; you can redistribute it   //
27
// and/or modify it under the terms of the GNU Lesser General   //
28
// Public License as published by the Free Software Foundation; //
29
// either version 2.1 of the License, or (at your option) any   //
30
// later version.                                               //
31
//                                                              //
32
// This source is distributed in the hope that it will be       //
33
// useful, but WITHOUT ANY WARRANTY; without even the implied   //
34
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      //
35
// PURPOSE.  See the GNU Lesser General Public License for more //
36
// details.                                                     //
37
//                                                              //
38
// You should have received a copy of the GNU Lesser General    //
39
// Public License along with this source; if not, download it   //
40
// from http://www.opencores.org/lgpl.shtml                     //
41
//                                                              //
42
//////////////////////////////////////////////////////////////////
43
 
44
 
45
module a25_execute (
46
 
47
input                       i_clk,
48
input                       i_access_stall,             // stall all stages of the cpu at the same time
49
input                       i_mem_stall,                // data memory access stalls
50
 
51
input       [31:0]          i_wb_read_data,             // data reads
52
input                       i_wb_read_data_valid,       // read data is valid
53
input       [9:0]           i_wb_load_rd,               // Rd for data reads
54
 
55
input       [31:0]          i_copro_read_data,          // From Co-Processor, to either Register 
56
                                                        // or Memory
57
input                       i_decode_iaccess,           // Indicates an instruction access
58
input                       i_decode_daccess,           // Indicates a data access
59
input       [7:0]           i_decode_load_rd,           // The destination register for a load instruction
60
 
61
output reg  [31:0]          o_copro_write_data = 'd0,
62
output reg  [31:0]          o_write_data = 'd0,
63
output reg  [31:0]          o_iaddress = 32'hdead_dead,
64
output      [31:0]          o_iaddress_nxt,             // un-registered version of address to the 
65
                                                        // cache rams address ports
66
output reg                  o_iaddress_valid = 'd0,     // High when instruction address is valid
67
output reg  [31:0]          o_daddress = 32'h0,         // Address to data cache
68
output      [31:0]          o_daddress_nxt,             // un-registered version of address to the 
69
                                                        // cache rams address ports
70
output reg                  o_daddress_valid = 'd0,     // High when data address is valid
71
output reg                  o_adex = 'd0,               // Address Exception
72
output reg                  o_priviledged = 'd0,        // Priviledged access
73
output reg                  o_exclusive = 'd0,          // swap access
74
output reg                  o_write_enable = 'd0,
75
output reg  [3:0]           o_byte_enable = 'd0,
76
output reg  [7:0]           o_exec_load_rd = 'd0,       // The destination register for a load instruction
77
output      [31:0]          o_status_bits,              // Full PC will all status bits, but PC part zero'ed out
78
output                      o_multiply_done,
79
 
80
 
81
// --------------------------------------------------
82
// Control signals from Instruction Decode stage
83
// --------------------------------------------------
84
input      [1:0]            i_status_bits_mode,
85
input                       i_status_bits_irq_mask,
86
input                       i_status_bits_firq_mask,
87
input      [31:0]           i_imm32,
88
input      [4:0]            i_imm_shift_amount,
89
input                       i_shift_imm_zero,
90
input      [3:0]            i_condition,
91
input                       i_decode_exclusive,       // swap access
92
 
93
input      [3:0]            i_rm_sel,
94
input      [3:0]            i_rs_sel,
95
input      [3:0]            i_rn_sel,
96
input      [1:0]            i_barrel_shift_amount_sel,
97
input      [1:0]            i_barrel_shift_data_sel,
98
input      [1:0]            i_barrel_shift_function,
99
input      [8:0]            i_alu_function,
100
input      [1:0]            i_multiply_function,
101
input      [2:0]            i_interrupt_vector_sel,
102
input      [3:0]            i_iaddress_sel,
103
input      [3:0]            i_daddress_sel,
104
input      [2:0]            i_pc_sel,
105
input      [1:0]            i_byte_enable_sel,
106
input      [2:0]            i_status_bits_sel,
107
input      [2:0]            i_reg_write_sel,
108
// input                       i_user_mode_regs_load,
109
input                       i_user_mode_regs_store_nxt,
110
input                       i_firq_not_user_mode,
111
 
112
input                       i_write_data_wen,
113
input                       i_base_address_wen,     // save LDM base address register, 
114
                                                    // in case of data abort
115
input                       i_pc_wen,
116
input      [14:0]           i_reg_bank_wen,
117
input                       i_status_bits_flags_wen,
118
input                       i_status_bits_mode_wen,
119
input                       i_status_bits_irq_mask_wen,
120
input                       i_status_bits_firq_mask_wen,
121
input                       i_copro_write_data_wen,
122
input                       i_conflict
123
 
124
);
125
 
126
`include "a25_localparams.v"
127
`include "a25_functions.v"
128
 
129
// ========================================================
130
// Internal signals
131
// ========================================================
132
wire [31:0]         write_data_nxt;
133
wire [3:0]          byte_enable_nxt;
134
wire [31:0]         pc_plus4;
135
wire [31:0]         pc_minus4;
136
wire [31:0]         daddress_plus4;
137
wire [31:0]         alu_plus4;
138
wire [31:0]         rn_plus4;
139
wire [31:0]         alu_out;
140
wire [3:0]          alu_flags;
141
wire [31:0]         rm;
142
wire [31:0]         rs;
143
wire [31:0]         rd;
144
wire [31:0]         rn;
145
wire [31:0]         pc;
146
wire [31:0]         pc_nxt;
147
wire [31:0]         interrupt_vector;
148
wire [7:0]          shift_amount;
149
wire [31:0]         barrel_shift_in;
150
wire [31:0]         barrel_shift_out;
151
wire                barrel_shift_carry;
152
 
153
wire [3:0]          status_bits_flags_nxt;
154
reg  [3:0]          status_bits_flags = 'd0;
155
wire [1:0]          status_bits_mode_nxt;
156
reg  [1:0]          status_bits_mode = SVC;
157
                    // one-hot encoded rs select
158
wire [3:0]          status_bits_mode_rds_oh_nxt;
159
reg  [3:0]          status_bits_mode_rds_oh = 1'd1 << OH_SVC;
160
wire                status_bits_mode_rds_oh_update;
161
wire                status_bits_irq_mask_nxt;
162
reg                 status_bits_irq_mask = 1'd1;
163
wire                status_bits_firq_mask_nxt;
164
reg                 status_bits_firq_mask = 1'd1;
165
 
166
wire                execute;                    // high when condition execution is true
167
wire [31:0]         reg_write_nxt;
168
wire                pc_wen;
169
wire [14:0]         reg_bank_wen;
170
wire [31:0]         multiply_out;
171
wire [1:0]          multiply_flags;
172
reg  [31:0]         base_address = 'd0;             // Saves base address during LDM instruction in 
173
                                                    // case of data abort
174
wire [31:0]         read_data_filtered1;
175
wire [31:0]         read_data_filtered;
176
 
177
wire                write_enable_nxt;
178
wire                daddress_valid_nxt;
179
wire                iaddress_valid_nxt;
180
wire                priviledged_nxt;
181
wire                priviledged_update;
182
wire                iaddress_update;
183
wire                daddress_update;
184
wire                base_address_update;
185
wire                write_data_update;
186
wire                copro_write_data_update;
187
wire                byte_enable_update;
188
wire                exec_load_rd_update;
189
wire                write_enable_update;
190
wire                exclusive_update;
191
wire                status_bits_flags_update;
192
wire                status_bits_mode_update;
193
wire                status_bits_irq_mask_update;
194
wire                status_bits_firq_mask_update;
195
 
196
wire [31:0]         alu_out_pc_filtered;
197
wire                adex_nxt;
198
wire [31:0]         save_int_pc;
199
wire [31:0]         save_int_pc_m4;
200
wire                ldm_flags;
201
wire                ldm_status_bits;
202
 
203
// ========================================================
204
// Status Bits in PC register
205
// ========================================================
206
assign o_status_bits = {   status_bits_flags,           // 31:28
207
                           status_bits_irq_mask,        // 7
208
                           status_bits_firq_mask,       // 6
209
                           24'd0,
210
                           status_bits_mode };          // 1:0 = mode
211
 
212
 
213
// ========================================================
214
// Status Bits Select
215
// ========================================================
216
assign ldm_flags                 = i_wb_read_data_valid & ~i_mem_stall & i_wb_load_rd[7];
217
assign ldm_status_bits           = i_wb_read_data_valid & ~i_mem_stall & i_wb_load_rd[6];
218
 
219
 
220
assign status_bits_flags_nxt     = ldm_flags                 ? read_data_filtered[31:28]           :
221
                                   i_status_bits_sel == 3'd0 ? alu_flags                           :
222
                                   i_status_bits_sel == 3'd1 ? alu_out          [31:28]            :
223
                                   i_status_bits_sel == 3'd3 ? i_copro_read_data[31:28]            :
224
                                   // 4 = update flags after a multiply operation
225
                                                        { multiply_flags, status_bits_flags[1:0] } ;
226
 
227
assign status_bits_mode_nxt      = ldm_status_bits           ? read_data_filtered [1:0] :
228
                                   i_status_bits_sel == 3'd0 ? i_status_bits_mode       :
229
                                   i_status_bits_sel == 3'd1 ? alu_out            [1:0] :
230
                                                               i_copro_read_data  [1:0] ;
231
 
232
 
233
// Used for the Rds output of register_bank - this special version of
234
// status_bits_mode speeds up the critical path from status_bits_mode through the
235
// register_bank, barrel_shifter and alu. It moves a mux needed for the
236
// i_user_mode_regs_store_nxt signal back into the previous stage -
237
// so its really part of the decode stage even though the logic is right here
238
// In addition the signal is one-hot encoded to further speed up the logic
239
 
240
assign status_bits_mode_rds_oh_nxt    = i_user_mode_regs_store_nxt ? 1'd1 << OH_USR                            :
241
                                        status_bits_mode_update    ? oh_status_bits_mode(status_bits_mode_nxt) :
242
                                                                     oh_status_bits_mode(status_bits_mode)     ;
243
 
244
 
245
assign status_bits_irq_mask_nxt  = ldm_status_bits           ? read_data_filtered     [27] :
246
                                   i_status_bits_sel == 3'd0 ? i_status_bits_irq_mask      :
247
                                   i_status_bits_sel == 3'd1 ? alu_out                [27] :
248
                                                               i_copro_read_data      [27] ;
249
 
250
assign status_bits_firq_mask_nxt = ldm_status_bits           ? read_data_filtered     [26] :
251
                                   i_status_bits_sel == 3'd0 ? i_status_bits_firq_mask     :
252
                                   i_status_bits_sel == 3'd1 ? alu_out                [26] :
253
                                                               i_copro_read_data      [26] ;
254
 
255
 
256
 
257
// ========================================================
258
// Adders
259
// ========================================================
260
assign pc_plus4       = pc         + 32'd4;
261
assign pc_minus4      = pc         - 32'd4;
262
assign daddress_plus4 = o_daddress + 32'd4;
263
assign alu_plus4      = alu_out    + 32'd4;
264
assign rn_plus4       = rn         + 32'd4;
265
 
266
// ========================================================
267
// Barrel Shift Amount Select
268
// ========================================================
269
// An immediate shift value of 0 is translated into 32
270
assign shift_amount = i_barrel_shift_amount_sel == 2'd0 ? 8'd0                         :
271
                      i_barrel_shift_amount_sel == 2'd1 ? rs[7:0]                      :
272
                                                          {3'd0, i_imm_shift_amount  } ;
273
 
274
 
275
// ========================================================
276
// Barrel Shift Data Select
277
// ========================================================
278
assign barrel_shift_in = i_barrel_shift_data_sel == 2'd0 ? i_imm32 : rm ;
279
 
280
 
281
// ========================================================
282
// Interrupt vector Select
283
// ========================================================
284
 
285
assign interrupt_vector = // Reset vector
286
                          (i_interrupt_vector_sel == 3'd0) ? 32'h00000000 :
287
                          // Data abort interrupt vector                 
288
                          (i_interrupt_vector_sel == 3'd1) ? 32'h00000010 :
289
                          // Fast interrupt vector  
290
                          (i_interrupt_vector_sel == 3'd2) ? 32'h0000001c :
291
                          // Regular interrupt vector
292
                          (i_interrupt_vector_sel == 3'd3) ? 32'h00000018 :
293
                          // Prefetch abort interrupt vector
294
                          (i_interrupt_vector_sel == 3'd5) ? 32'h0000000c :
295
                          // Undefined instruction interrupt vector
296
                          (i_interrupt_vector_sel == 3'd6) ? 32'h00000004 :
297
                          // Software (SWI) interrupt vector
298
                          (i_interrupt_vector_sel == 3'd7) ? 32'h00000008 :
299
                          // Default is the address exception interrupt
300
                                                             32'h00000014 ;
301
 
302
 
303
// ========================================================
304
// Address Select
305
// ========================================================
306
assign pc_dmem_wen    = i_wb_read_data_valid & ~i_mem_stall & i_wb_load_rd[3:0] == 4'd15;
307
 
308
// If rd is the pc, then seperate the address bits from the status bits for
309
// generating the next address to fetch
310
assign alu_out_pc_filtered = pc_wen && i_pc_sel == 3'd1 ? pcf(alu_out) : alu_out;
311
 
312
// if current instruction does not execute because it does not meet the condition
313
// then address advances to next instruction
314
assign o_iaddress_nxt = (pc_dmem_wen)            ? pcf(read_data_filtered) :
315
                        (!execute)               ? pc_plus4                :
316
                        (i_iaddress_sel == 4'd0) ? pc_plus4                :
317
                        (i_iaddress_sel == 4'd1) ? alu_out_pc_filtered     :
318
                        (i_iaddress_sel == 4'd2) ? interrupt_vector        :
319
                                                   pc                      ;
320
 
321
 
322
 
323
// if current instruction does not execute because it does not meet the condition
324
// then address advances to next instruction
325
assign o_daddress_nxt = (i_daddress_sel == 4'd1) ? alu_out_pc_filtered   :
326
                        (i_daddress_sel == 4'd2) ? interrupt_vector      :
327
                        (i_daddress_sel == 4'd4) ? rn                    :
328
                        (i_daddress_sel == 4'd5) ? daddress_plus4        :  // MTRANS address incrementer
329
                        (i_daddress_sel == 4'd6) ? alu_plus4             :  // MTRANS decrement after
330
                                                   rn_plus4              ;  // MTRANS increment before
331
 
332
// Data accesses use 32-bit address space, but instruction
333
// accesses are restricted to 26 bit space
334
assign adex_nxt      = |o_iaddress_nxt[31:26] && i_decode_iaccess;
335
 
336
 
337
// ========================================================
338
// Filter Read Data
339
// ========================================================
340
// mem_load_rd[9:8] -> shift ROR bytes
341
// mem_load_rd[7]   -> load flags with PC
342
// mem_load_rd[6]   -> load status bits with PC
343
// mem_load_rd[5]   -> Write into User Mode register
344
// mem_load_rd[4]   -> zero_extend byte
345
// mem_load_rd[3:0] -> Destination Register 
346
assign read_data_filtered1 = i_wb_load_rd[9:8] === 2'd0 ? i_wb_read_data                                 :
347
                             i_wb_load_rd[9:8] === 2'd1 ? {i_wb_read_data[7:0],  i_wb_read_data[31:8]}  :
348
                             i_wb_load_rd[9:8] === 2'd2 ? {i_wb_read_data[15:0], i_wb_read_data[31:16]} :
349
                                                          {i_wb_read_data[23:0], i_wb_read_data[31:24]} ;
350
 
351
assign read_data_filtered  = i_wb_load_rd[4] ? {24'd0, read_data_filtered1[7:0]} : read_data_filtered1 ;
352
 
353
 
354
// ========================================================
355
// Program Counter Select
356
// ========================================================
357
// If current instruction does not execute because it does not meet the condition
358
// then PC advances to next instruction
359
assign pc_nxt = (!execute)       ? pc_plus4                :
360
                i_pc_sel == 3'd0 ? pc_plus4                :
361
                i_pc_sel == 3'd1 ? alu_out                 :
362
                i_pc_sel == 3'd2 ? interrupt_vector        :
363
                i_pc_sel == 3'd3 ? pcf(read_data_filtered) :
364
                                   pc_minus4               ;
365
 
366
 
367
// ========================================================
368
// Register Write Select
369
// ========================================================
370
 
371
assign save_int_pc    = { status_bits_flags,
372
                          status_bits_irq_mask,
373
                          status_bits_firq_mask,
374
                          pc[25:2],
375
                          status_bits_mode      };
376
 
377
 
378
assign save_int_pc_m4 = { status_bits_flags,
379
                          status_bits_irq_mask,
380
                          status_bits_firq_mask,
381
                          pc_minus4[25:2],
382
                          status_bits_mode      };
383
 
384
 
385
assign reg_write_nxt = i_reg_write_sel == 3'd0 ? alu_out               :
386
                       // save pc to lr on an interrupt                    
387
                       i_reg_write_sel == 3'd1 ? save_int_pc_m4        :
388
                       // to update Rd at the end of Multiplication
389
                       i_reg_write_sel == 3'd2 ? multiply_out          :
390
                       i_reg_write_sel == 3'd3 ? o_status_bits         :
391
                       i_reg_write_sel == 3'd5 ? i_copro_read_data     :  // mrc
392
                       i_reg_write_sel == 3'd6 ? base_address          :
393
                                                 save_int_pc           ;
394
 
395
 
396
// ========================================================
397
// Byte Enable Select
398
// ========================================================
399
assign byte_enable_nxt = i_byte_enable_sel == 2'd0   ? 4'b1111 :  // word write
400
                         i_byte_enable_sel == 2'd2   ?            // halfword write
401
                         ( o_daddress_nxt[1] == 1'd0 ? 4'b0011 :
402
                                                       4'b1100  ) :
403
 
404
                         o_daddress_nxt[1:0] == 2'd0 ? 4'b0001 :  // byte write
405
                         o_daddress_nxt[1:0] == 2'd1 ? 4'b0010 :
406
                         o_daddress_nxt[1:0] == 2'd2 ? 4'b0100 :
407
                                                       4'b1000 ;
408
 
409
 
410
// ========================================================
411
// Write Data Select
412
// ========================================================
413
assign write_data_nxt = i_byte_enable_sel == 2'd0 ? rd            :
414
                                                    {4{rd[ 7:0]}} ;
415
 
416
 
417
// ========================================================
418
// Conditional Execution
419
// ========================================================
420
assign execute = conditional_execute ( i_condition, status_bits_flags );
421
 
422
// allow the PC to increment to the next instruction when current
423
// instruction does not execute
424
assign pc_wen       = (i_pc_wen || !execute) && !i_conflict;
425
 
426
// only update register bank if current instruction executes
427
assign reg_bank_wen = {{15{execute}} & i_reg_bank_wen};
428
 
429
 
430
// ========================================================
431
// Priviledged output flag
432
// ========================================================
433
// Need to look at status_bits_mode_nxt so switch to priviledged mode
434
// at the same time as assert interrupt vector address
435
assign priviledged_nxt  = ( i_status_bits_mode_wen ? status_bits_mode_nxt : status_bits_mode ) != USR ;
436
 
437
 
438
// ========================================================
439
// Write Enable
440
// ========================================================
441
// This must be de-asserted when execute is fault
442
assign write_enable_nxt = execute && i_write_data_wen;
443
 
444
 
445
// ========================================================
446
// Address Valid
447
// ========================================================
448
assign daddress_valid_nxt = execute && i_decode_daccess && !i_access_stall;
449
assign iaddress_valid_nxt = i_decode_iaccess;
450
 
451
 
452
// ========================================================
453
// Register Update
454
// ========================================================
455
 
456
assign daddress_update                 = !i_access_stall;
457
assign exec_load_rd_update             = !i_access_stall && execute;
458
assign priviledged_update              = !i_access_stall;
459
assign exclusive_update                = !i_access_stall && execute;
460
assign write_enable_update             = !i_access_stall;
461
assign write_data_update               = !i_access_stall && execute && i_write_data_wen;
462
assign byte_enable_update              = !i_access_stall && execute && i_write_data_wen;
463
 
464
assign iaddress_update                 = pc_dmem_wen || (!i_access_stall && !i_conflict);
465
assign copro_write_data_update         = !i_access_stall && execute && i_copro_write_data_wen;
466
 
467
assign base_address_update             = !i_access_stall && execute && i_base_address_wen;
468
// assign dcache_read_data_update         = !i_mem_stall;
469
assign status_bits_flags_update        = ldm_flags       || (!i_access_stall && execute && i_status_bits_flags_wen);
470
assign status_bits_mode_update         = ldm_status_bits || (!i_access_stall && execute && i_status_bits_mode_wen);
471
assign status_bits_mode_rds_oh_update  = !i_access_stall;
472
assign status_bits_irq_mask_update     = ldm_status_bits || (!i_access_stall && execute && i_status_bits_irq_mask_wen);
473
assign status_bits_firq_mask_update    = ldm_status_bits || (!i_access_stall && execute && i_status_bits_firq_mask_wen);
474
 
475
 
476
always @( posedge i_clk )
477
    begin
478
    o_daddress              <= daddress_update                ? o_daddress_nxt               : o_daddress;
479
    o_daddress_valid        <= daddress_update                ? daddress_valid_nxt           : o_daddress_valid;
480
    o_exec_load_rd          <= exec_load_rd_update            ? i_decode_load_rd             : o_exec_load_rd;
481
    o_priviledged           <= priviledged_update             ? priviledged_nxt              : o_priviledged;
482
    o_exclusive             <= exclusive_update               ? i_decode_exclusive           : o_exclusive;
483
    o_write_enable          <= write_enable_update            ? write_enable_nxt             : o_write_enable;
484
    o_write_data            <= write_data_update              ? write_data_nxt               : o_write_data;
485
    o_byte_enable           <= byte_enable_update             ? byte_enable_nxt              : o_byte_enable;
486
    o_iaddress              <= iaddress_update                ? o_iaddress_nxt               : o_iaddress;
487
    o_iaddress_valid        <= iaddress_update                ? iaddress_valid_nxt           : o_iaddress_valid;
488
    o_adex                  <= iaddress_update                ? adex_nxt                     : o_adex;
489
    o_copro_write_data      <= copro_write_data_update        ? write_data_nxt               : o_copro_write_data;
490
 
491
    base_address            <= base_address_update            ? rn                           : base_address;
492
 
493
    status_bits_flags       <= status_bits_flags_update       ? status_bits_flags_nxt        : status_bits_flags;
494
    status_bits_mode        <= status_bits_mode_update        ? status_bits_mode_nxt         : status_bits_mode;
495
    status_bits_mode_rds_oh <= status_bits_mode_rds_oh_update ? status_bits_mode_rds_oh_nxt  : status_bits_mode_rds_oh;
496
    status_bits_irq_mask    <= status_bits_irq_mask_update    ? status_bits_irq_mask_nxt     : status_bits_irq_mask;
497
    status_bits_firq_mask   <= status_bits_firq_mask_update   ? status_bits_firq_mask_nxt    : status_bits_firq_mask;
498
    end
499
 
500
 
501
// ========================================================
502
// Instantiate Barrel Shift
503
// ========================================================
504
a25_barrel_shift u_barrel_shift  (
505
    .i_in             ( barrel_shift_in           ),
506
    .i_carry_in       ( status_bits_flags[1]      ),
507
    .i_shift_amount   ( shift_amount              ),
508
    .i_shift_imm_zero ( i_shift_imm_zero          ),
509
    .i_function       ( i_barrel_shift_function   ),
510
 
511
    .o_out            ( barrel_shift_out          ),
512
    .o_carry_out      ( barrel_shift_carry        )
513
);
514
 
515
 
516
// ========================================================
517
// Instantiate ALU
518
// ========================================================
519
a25_alu u_alu (
520
    .i_a_in                 ( rn                    ),
521
    .i_b_in                 ( barrel_shift_out      ),
522
    .i_barrel_shift_carry   ( barrel_shift_carry    ),
523
    .i_status_bits_carry    ( status_bits_flags[1]  ),
524
    .i_function             ( i_alu_function        ),
525
 
526
    .o_out                  ( alu_out               ),
527
    .o_flags                ( alu_flags             )
528
);
529
 
530
 
531
// ========================================================
532
// Instantiate Booth 64-bit Multiplier-Accumulator
533
// ========================================================
534
a25_multiply u_multiply (
535
    .i_clk          ( i_clk                 ),
536
    .i_access_stall ( i_access_stall        ),
537
    .i_a_in         ( rs                    ),
538
    .i_b_in         ( rm                    ),
539
    .i_function     ( i_multiply_function   ),
540
    .i_execute      ( execute               ),
541
    .o_out          ( multiply_out          ),
542
    .o_flags        ( multiply_flags        ),  // [1] = N, [0] = Z
543
    .o_done         ( o_multiply_done       )
544
);
545
 
546
 
547
// ========================================================
548
// Instantiate Register Bank
549
// ========================================================
550
a25_register_bank u_register_bank(
551
    .i_clk                   ( i_clk                     ),
552
    .i_access_stall          ( i_access_stall            ),
553
    .i_mem_stall             ( i_mem_stall               ),
554
    .i_rm_sel                ( i_rm_sel                  ),
555
    .i_rs_sel                ( i_rs_sel                  ),
556
    .i_rn_sel                ( i_rn_sel                  ),
557
    .i_pc_wen                ( pc_wen                    ),
558
    .i_reg_bank_wen          ( reg_bank_wen              ),
559
    .i_pc                    ( pc_nxt[25:2]              ),
560
    .i_reg                   ( reg_write_nxt             ),
561
    .i_mode_idec             ( i_status_bits_mode        ),
562
    .i_mode_exec             ( status_bits_mode          ),
563
 
564
    .i_wb_read_data          ( read_data_filtered        ),
565
    .i_wb_read_data_valid    ( i_wb_read_data_valid      ),
566
    .i_wb_read_data_rd       ( i_wb_load_rd[3:0]         ),
567
    .i_wb_user_mode          ( i_wb_load_rd[5]           ),
568
 
569
    .i_status_bits_flags     ( status_bits_flags         ),
570
    .i_status_bits_irq_mask  ( status_bits_irq_mask      ),
571
    .i_status_bits_firq_mask ( status_bits_firq_mask     ),
572
 
573
    // pre-encoded in decode stage to speed up long path
574
    .i_firq_not_user_mode    ( i_firq_not_user_mode      ),
575
 
576
    // use one-hot version for speed, combine with i_user_mode_regs_store
577
    .i_mode_rds_exec         ( status_bits_mode_rds_oh   ),
578
 
579
    .o_rm                    ( rm                        ),
580
    .o_rs                    ( rs                        ),
581
    .o_rd                    ( rd                        ),
582
    .o_rn                    ( rn                        ),
583
    .o_pc                    ( pc                        )
584
);
585
 
586
 
587
// ========================================================
588
// Debug - non-synthesizable code
589
// ========================================================
590
//synopsys translate_off
591
 
592
wire    [(2*8)-1:0]    xCONDITION;
593
wire    [(4*8)-1:0]    xMODE;
594
 
595
assign  xCONDITION           = i_condition == EQ ? "EQ"  :
596
                               i_condition == NE ? "NE"  :
597
                               i_condition == CS ? "CS"  :
598
                               i_condition == CC ? "CC"  :
599
                               i_condition == MI ? "MI"  :
600
                               i_condition == PL ? "PL"  :
601
                               i_condition == VS ? "VS"  :
602
                               i_condition == VC ? "VC"  :
603
                               i_condition == HI ? "HI"  :
604
                               i_condition == LS ? "LS"  :
605
                               i_condition == GE ? "GE"  :
606
                               i_condition == LT ? "LT"  :
607
                               i_condition == GT ? "GT"  :
608
                               i_condition == LE ? "LE"  :
609
                               i_condition == AL ? "AL"  :
610
                                                   "NV " ;
611
 
612
assign  xMODE  =  status_bits_mode == SVC  ? "SVC"  :
613
                  status_bits_mode == IRQ  ? "IRQ"  :
614
                  status_bits_mode == FIRQ ? "FIRQ" :
615
                  status_bits_mode == USR  ? "USR"  :
616
                                             "XXX"  ;
617
 
618
 
619
//synopsys translate_on
620
 
621
endmodule
622
 
623
 

powered by: WebSVN 2.1.0

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