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

Subversion Repositories amber

[/] [amber/] [trunk/] [hw/] [vlog/] [amber23/] [a23_execute.v] - Blame information for rev 78

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

Line No. Rev Author Line
1 2 csantifort
//////////////////////////////////////////////////////////////////
2
//                                                              //
3
//  Execute stage of Amber 2 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) 2010 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 73 csantifort
`include "a23_config_defines.v"
45 2 csantifort
 
46 15 csantifort
module a23_execute (
47 2 csantifort
 
48
input                       i_clk,
49
input       [31:0]          i_read_data,
50
input       [4:0]           i_read_data_alignment,  // 2 LSBs of address in [4:3], appended 
51
                                                    // with 3 zeros
52
input       [31:0]          i_copro_read_data,      // From Co-Processor, to either Register 
53
                                                    // or Memory
54
input                       i_data_access_exec,     // from Instruction Decode stage
55
                                                    // high means the memory access is a read 
56
                                                    // read or write, low for instruction
57
 
58
output reg  [31:0]          o_copro_write_data = 'd0,
59
output reg  [31:0]          o_write_data = 'd0,
60
output reg  [31:0]          o_address = 32'hdead_dead,
61
output reg                  o_adex = 'd0,           // Address Exception
62
output reg                  o_address_valid = 'd0,  // Prevents the reset address value being a 
63
                                                    // wishbone access
64
output      [31:0]          o_address_nxt,          // un-registered version of address to the 
65
                                                    // cache rams address ports
66
output reg                  o_priviledged = 'd0,    // Priviledged access
67
output reg                  o_exclusive = 'd0,      // swap access
68
output reg                  o_write_enable = 'd0,
69
output reg  [3:0]           o_byte_enable = 'd0,
70
output reg                  o_data_access = 'd0,    // To Fetch stage. high = data fetch, 
71
                                                    // low = instruction fetch
72
output      [31:0]          o_status_bits,          // Full PC will all status bits, but PC part zero'ed out
73
output                      o_multiply_done,
74
 
75
 
76
// --------------------------------------------------
77
// Control signals from Instruction Decode stage
78
// --------------------------------------------------
79
input                       i_fetch_stall,          // stall all stages of the cpu at the same time
80
input      [1:0]            i_status_bits_mode,
81
input                       i_status_bits_irq_mask,
82
input                       i_status_bits_firq_mask,
83
input      [31:0]           i_imm32,
84
input      [4:0]            i_imm_shift_amount,
85
input                       i_shift_imm_zero,
86
input      [3:0]            i_condition,
87
input                       i_exclusive_exec,       // swap access
88
 
89
input      [3:0]            i_rm_sel,
90
input      [3:0]            i_rds_sel,
91
input      [3:0]            i_rn_sel,
92 71 csantifort
input      [3:0]            i_rm_sel_nxt,
93
input      [3:0]            i_rds_sel_nxt,
94
input      [3:0]            i_rn_sel_nxt,
95 2 csantifort
input      [1:0]            i_barrel_shift_amount_sel,
96
input      [1:0]            i_barrel_shift_data_sel,
97
input      [1:0]            i_barrel_shift_function,
98
input      [8:0]            i_alu_function,
99
input      [1:0]            i_multiply_function,
100
input      [2:0]            i_interrupt_vector_sel,
101
input      [3:0]            i_address_sel,
102
input      [1:0]            i_pc_sel,
103
input      [1:0]            i_byte_enable_sel,
104
input      [2:0]            i_status_bits_sel,
105
input      [2:0]            i_reg_write_sel,
106
input                       i_user_mode_regs_load,
107
input                       i_user_mode_regs_store_nxt,
108
input                       i_firq_not_user_mode,
109 71 csantifort
input                       i_firq_not_user_mode_nxt,
110 2 csantifort
 
111
input                       i_write_data_wen,
112
input                       i_base_address_wen,     // save LDM base address register, 
113
                                                    // in case of data abort
114
input                       i_pc_wen,
115
input      [14:0]           i_reg_bank_wen,
116 71 csantifort
input      [3:0]            i_reg_bank_wsel,
117 2 csantifort
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
 
123
);
124
 
125 15 csantifort
`include "a23_localparams.v"
126
`include "a23_functions.v"
127 2 csantifort
 
128
// ========================================================
129
// Internal signals
130
// ========================================================
131
wire [31:0]         write_data_nxt;
132
wire [3:0]          byte_enable_nxt;
133
wire [31:0]         pc_plus4;
134
wire [31:0]         pc_minus4;
135
wire [31:0]         address_plus4;
136
wire [31:0]         alu_plus4;
137
wire [31:0]         rn_plus4;
138
wire [31:0]         alu_out;
139
wire [3:0]          alu_flags;
140
wire [31:0]         rm;
141
wire [31:0]         rs;
142
wire [31:0]         rd;
143
wire [31:0]         rn;
144
wire [31:0]         pc;
145
wire [31:0]         pc_nxt;
146
wire                write_enable_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 71 csantifort
wire [1:0]          status_bits_mode_nr;
157 2 csantifort
reg  [1:0]          status_bits_mode = SVC;
158 71 csantifort
                    // raw rs select
159
wire [1:0]          status_bits_mode_rds_nxt;
160
wire [1:0]          status_bits_mode_rds_nr;
161
reg  [1:0]          status_bits_mode_rds;
162 2 csantifort
                    // one-hot encoded rs select
163
wire [3:0]          status_bits_mode_rds_oh_nxt;
164
reg  [3:0]          status_bits_mode_rds_oh = 1'd1 << OH_SVC;
165
wire                status_bits_mode_rds_oh_update;
166
wire                status_bits_irq_mask_nxt;
167
reg                 status_bits_irq_mask = 1'd1;
168
wire                status_bits_firq_mask_nxt;
169
reg                 status_bits_firq_mask = 1'd1;
170
 
171
wire                execute;           // high when condition execution is true
172
wire [31:0]         reg_write_nxt;
173
wire                pc_wen;
174
wire [14:0]         reg_bank_wen;
175 71 csantifort
wire [3:0]          reg_bank_wsel;
176 2 csantifort
wire [31:0]         multiply_out;
177
wire [1:0]          multiply_flags;
178
reg  [31:0]         base_address = 'd0;    // Saves base address during LDM instruction in 
179
                                           // case of data abort
180
 
181
wire                priviledged_nxt;
182
wire                priviledged_update;
183
wire                address_update;
184
wire                base_address_update;
185
wire                write_data_update;
186
wire                copro_write_data_update;
187
wire                byte_enable_update;
188
wire                data_access_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
 
199
// ========================================================
200
// Status Bits in PC register
201
// ========================================================
202 54 csantifort
wire [1:0] status_bits_out;
203
assign status_bits_out = (i_status_bits_mode_wen && i_status_bits_sel == 3'd1) ?
204
                            alu_out[1:0] : status_bits_mode ;
205
 
206
 
207 2 csantifort
assign o_status_bits = {   status_bits_flags,           // 31:28
208
                           status_bits_irq_mask,        // 7
209
                           status_bits_firq_mask,       // 6
210
                           24'd0,
211 54 csantifort
                           status_bits_out};          // 1:0 = mode
212 2 csantifort
 
213
// ========================================================
214
// Status Bits Select
215
// ========================================================
216
assign status_bits_flags_nxt     = i_status_bits_sel == 3'd0 ? alu_flags                           :
217
                                   i_status_bits_sel == 3'd1 ? alu_out          [31:28]            :
218
                                   i_status_bits_sel == 3'd3 ? i_copro_read_data[31:28]            :
219
                                   // 4 = update flags after a multiply operation
220
                                                        { multiply_flags, status_bits_flags[1:0] } ;
221
 
222
assign status_bits_mode_nxt      = i_status_bits_sel == 3'd0 ? i_status_bits_mode       :
223
                                   i_status_bits_sel == 3'd1 ? alu_out            [1:0] :
224
                                                               i_copro_read_data  [1:0] ;
225
 
226
 
227
// Used for the Rds output of register_bank - this special version of
228
// status_bits_mode speeds up the critical path from status_bits_mode through the
229
// register_bank, barrel_shifter and alu. It moves a mux needed for the
230
// i_user_mode_regs_store_nxt signal back into the previous stage -
231
// so its really part of the decode stage even though the logic is right here
232
// In addition the signal is one-hot encoded to further speed up the logic
233 71 csantifort
// Raw version is also kept for ram-based register bank implementation.
234 2 csantifort
 
235 72 csantifort
assign status_bits_mode_rds_nxt  = i_user_mode_regs_store_nxt ? USR                  :
236 71 csantifort
                                   status_bits_mode_update    ? status_bits_mode_nxt :
237
                                                                status_bits_mode     ;
238 2 csantifort
 
239 71 csantifort
assign status_bits_mode_rds_oh_nxt    = oh_status_bits_mode(status_bits_mode_rds_nxt);
240
 
241
 
242 2 csantifort
assign status_bits_irq_mask_nxt  = i_status_bits_sel == 3'd0 ? i_status_bits_irq_mask      :
243
                                   i_status_bits_sel == 3'd1 ? alu_out                [27] :
244
                                                               i_copro_read_data      [27] ;
245
 
246
assign status_bits_firq_mask_nxt = i_status_bits_sel == 3'd0 ? i_status_bits_firq_mask     :
247
                                   i_status_bits_sel == 3'd1 ? alu_out                [26] :
248
                                                               i_copro_read_data      [26] ;
249
 
250
 
251
 
252
// ========================================================
253
// Adders
254
// ========================================================
255
assign pc_plus4      = pc        + 32'd4;
256
assign pc_minus4     = pc        - 32'd4;
257
assign address_plus4 = o_address + 32'd4;
258
assign alu_plus4     = alu_out   + 32'd4;
259
assign rn_plus4      = rn        + 32'd4;
260
 
261
// ========================================================
262
// Barrel Shift Amount Select
263
// ========================================================
264
// An immediate shift value of 0 is translated into 32
265
assign shift_amount = i_barrel_shift_amount_sel == 2'd0 ? 8'd0                           :
266
                      i_barrel_shift_amount_sel == 2'd1 ? rs[7:0]                       :
267
                      i_barrel_shift_amount_sel == 2'd2 ? {3'd0, i_imm_shift_amount    } :
268
                                                          {3'd0, i_read_data_alignment } ;
269
 
270
// ========================================================
271
// Barrel Shift Data Select
272
// ========================================================
273
assign barrel_shift_in = i_barrel_shift_data_sel == 2'd0 ? i_imm32       :
274
                         i_barrel_shift_data_sel == 2'd1 ? i_read_data   :
275
                                                           rm            ;
276
 
277
// ========================================================
278
// Interrupt vector Select
279
// ========================================================
280
 
281
assign interrupt_vector = // Reset vector
282
                          (i_interrupt_vector_sel == 3'd0) ? 32'h00000000 :
283
                          // Data abort interrupt vector                 
284
                          (i_interrupt_vector_sel == 3'd1) ? 32'h00000010 :
285
                          // Fast interrupt vector  
286
                          (i_interrupt_vector_sel == 3'd2) ? 32'h0000001c :
287
                          // Regular interrupt vector
288
                          (i_interrupt_vector_sel == 3'd3) ? 32'h00000018 :
289
                          // Prefetch abort interrupt vector
290
                          (i_interrupt_vector_sel == 3'd5) ? 32'h0000000c :
291
                          // Undefined instruction interrupt vector
292
                          (i_interrupt_vector_sel == 3'd6) ? 32'h00000004 :
293
                          // Software (SWI) interrupt vector
294
                          (i_interrupt_vector_sel == 3'd7) ? 32'h00000008 :
295
                          // Default is the address exception interrupt
296
                                                             32'h00000014 ;
297
 
298
 
299
// ========================================================
300
// Address Select
301
// ========================================================
302
 
303
// If rd is the pc, then seperate the address bits from the status bits for
304
// generating the next address to fetch
305
assign alu_out_pc_filtered = pc_wen && i_pc_sel == 2'd1 ? pcf(alu_out) : alu_out;
306
 
307
// if current instruction does not execute because it does not meet the condition
308
// then address advances to next instruction
309
assign o_address_nxt = (!execute)              ? pc_plus4              :
310
                       (i_address_sel == 4'd0) ? pc_plus4              :
311
                       (i_address_sel == 4'd1) ? alu_out_pc_filtered   :
312
                       (i_address_sel == 4'd2) ? interrupt_vector      :
313
                       (i_address_sel == 4'd3) ? pc                    :
314
                       (i_address_sel == 4'd4) ? rn                    :
315
                       (i_address_sel == 4'd5) ? address_plus4         :  // MTRANS address incrementer
316
                       (i_address_sel == 4'd6) ? alu_plus4             :  // MTRANS decrement after
317
                                                 rn_plus4              ;  // MTRANS increment before
318
 
319
// Data accesses use 32-bit address space, but instruction
320
// accesses are restricted to 26 bit space
321
assign adex_nxt      = |o_address_nxt[31:26] && !i_data_access_exec;
322
 
323
// ========================================================
324
// Program Counter Select
325
// ========================================================
326
// If current instruction does not execute because it does not meet the condition
327
// then PC advances to next instruction
328
assign pc_nxt = (!execute)       ? pc_plus4              :
329
                i_pc_sel == 2'd0 ? pc_plus4              :
330
                i_pc_sel == 2'd1 ? alu_out               :
331
                                   interrupt_vector      ;
332
 
333
 
334
// ========================================================
335
// Register Write Select
336
// ========================================================
337
wire [31:0] save_int_pc;
338
wire [31:0] save_int_pc_m4;
339
 
340
assign save_int_pc    = { status_bits_flags,
341
                          status_bits_irq_mask,
342
                          status_bits_firq_mask,
343
                          pc[25:2],
344
                          status_bits_mode      };
345
 
346
 
347
assign save_int_pc_m4 = { status_bits_flags,
348
                          status_bits_irq_mask,
349
                          status_bits_firq_mask,
350
                          pc_minus4[25:2],
351
                          status_bits_mode      };
352
 
353
 
354
assign reg_write_nxt = i_reg_write_sel == 3'd0 ? alu_out               :
355
                       // save pc to lr on an interrupt                    
356
                       i_reg_write_sel == 3'd1 ? save_int_pc_m4        :
357
                       // to update Rd at the end of Multiplication
358
                       i_reg_write_sel == 3'd2 ? multiply_out          :
359
                       i_reg_write_sel == 3'd3 ? o_status_bits         :
360
                       i_reg_write_sel == 3'd5 ? i_copro_read_data     :  // mrc
361
                       i_reg_write_sel == 3'd6 ? base_address          :
362
                                                 save_int_pc           ;
363
 
364
 
365
// ========================================================
366
// Byte Enable Select
367
// ========================================================
368
assign byte_enable_nxt = i_byte_enable_sel == 2'd0  ? 4'b1111 :  // word write
369
                         i_byte_enable_sel == 2'd2  ?            // halfword write
370
                         ( o_address_nxt[1] == 1'd0 ? 4'b0011 :
371
                                                      4'b1100  ) :
372
 
373
                         o_address_nxt[1:0] == 2'd0 ? 4'b0001 :  // byte write
374
                         o_address_nxt[1:0] == 2'd1 ? 4'b0010 :
375
                         o_address_nxt[1:0] == 2'd2 ? 4'b0100 :
376
                                                      4'b1000 ;
377
 
378
 
379
// ========================================================
380
// Write Data Select
381
// ========================================================
382
assign write_data_nxt = i_byte_enable_sel == 2'd0 ? rd            :
383
                                                    {4{rd[ 7:0]}} ;
384
 
385
 
386
// ========================================================
387
// Conditional Execution
388
// ========================================================
389
assign execute = conditional_execute ( i_condition, status_bits_flags );
390
 
391
// allow the PC to increment to the next instruction when current
392
// instruction does not execute
393
assign pc_wen       = i_pc_wen || !execute;
394
 
395
// only update register bank if current instruction executes
396
assign reg_bank_wen = {{15{execute}} & i_reg_bank_wen};
397
 
398 71 csantifort
assign reg_bank_wsel = {{4{~execute}} | i_reg_bank_wsel};
399 2 csantifort
 
400 71 csantifort
 
401 2 csantifort
// ========================================================
402
// Priviledged output flag
403
// ========================================================
404
// Need to look at status_bits_mode_nxt so switch to priviledged mode
405
// at the same time as assert interrupt vector address
406
assign priviledged_nxt  = ( i_status_bits_mode_wen ? status_bits_mode_nxt : status_bits_mode ) != USR ;
407
 
408
 
409
// ========================================================
410
// Write Enable
411
// ========================================================
412
// This must be de-asserted when execute is fault
413
assign write_enable_nxt = execute && i_write_data_wen;
414
 
415
 
416
// ========================================================
417
// Register Update
418
// ========================================================
419
 
420
assign priviledged_update              = !i_fetch_stall;
421
assign data_access_update              = !i_fetch_stall && execute;
422
assign write_enable_update             = !i_fetch_stall;
423
assign write_data_update               = !i_fetch_stall && execute && i_write_data_wen;
424
assign exclusive_update                = !i_fetch_stall && execute;
425
assign address_update                  = !i_fetch_stall;
426
assign byte_enable_update              = !i_fetch_stall && execute && i_write_data_wen;
427
assign copro_write_data_update         = !i_fetch_stall && execute && i_copro_write_data_wen;
428
 
429
assign base_address_update             = !i_fetch_stall && execute && i_base_address_wen;
430
assign status_bits_flags_update        = !i_fetch_stall && execute && i_status_bits_flags_wen;
431
assign status_bits_mode_update         = !i_fetch_stall && execute && i_status_bits_mode_wen;
432
assign status_bits_mode_rds_oh_update  = !i_fetch_stall;
433
assign status_bits_irq_mask_update     = !i_fetch_stall && execute && i_status_bits_irq_mask_wen;
434
assign status_bits_firq_mask_update    = !i_fetch_stall && execute && i_status_bits_firq_mask_wen;
435
 
436 71 csantifort
assign status_bits_mode_rds_nr         =  status_bits_mode_rds_oh_update ? status_bits_mode_rds_nxt :
437
                                                                           status_bits_mode_rds     ;
438 2 csantifort
 
439 71 csantifort
assign status_bits_mode_nr             =  status_bits_mode_update        ? status_bits_mode_nxt     :
440
                                                                           status_bits_mode         ;
441
 
442 2 csantifort
always @( posedge i_clk )
443
    begin
444
    o_priviledged           <= priviledged_update             ? priviledged_nxt              : o_priviledged;
445
    o_exclusive             <= exclusive_update               ? i_exclusive_exec             : o_exclusive;
446
    o_data_access           <= data_access_update             ? i_data_access_exec           : o_data_access;
447
    o_write_enable          <= write_enable_update            ? write_enable_nxt             : o_write_enable;
448
    o_write_data            <= write_data_update              ? write_data_nxt               : o_write_data;
449
    o_address               <= address_update                 ? o_address_nxt                : o_address;
450
    o_adex                  <= address_update                 ? adex_nxt                     : o_adex;
451
    o_address_valid         <= address_update                 ? 1'd1                         : o_address_valid;
452
    o_byte_enable           <= byte_enable_update             ? byte_enable_nxt              : o_byte_enable;
453
    o_copro_write_data      <= copro_write_data_update        ? write_data_nxt               : o_copro_write_data;
454
 
455
    base_address            <= base_address_update            ? rn                           : base_address;
456
 
457
    status_bits_flags       <= status_bits_flags_update       ? status_bits_flags_nxt        : status_bits_flags;
458 71 csantifort
    status_bits_mode        <=  status_bits_mode_nr;
459 2 csantifort
    status_bits_mode_rds_oh <= status_bits_mode_rds_oh_update ? status_bits_mode_rds_oh_nxt  : status_bits_mode_rds_oh;
460 71 csantifort
    status_bits_mode_rds    <= status_bits_mode_rds_nr;
461 2 csantifort
    status_bits_irq_mask    <= status_bits_irq_mask_update    ? status_bits_irq_mask_nxt     : status_bits_irq_mask;
462
    status_bits_firq_mask   <= status_bits_firq_mask_update   ? status_bits_firq_mask_nxt    : status_bits_firq_mask;
463
    end
464
 
465
 
466
// ========================================================
467
// Instantiate Barrel Shift
468
// ========================================================
469 74 csantifort
`ifndef ALTERA_FPGA
470 15 csantifort
a23_barrel_shift u_barrel_shift  (
471 74 csantifort
`else
472
a23_barrel_shift_fpga u_barrel_shift  (
473
`endif
474 2 csantifort
    .i_in             ( barrel_shift_in           ),
475
    .i_carry_in       ( status_bits_flags[1]      ),
476
    .i_shift_amount   ( shift_amount              ),
477
    .i_shift_imm_zero ( i_shift_imm_zero          ),
478
    .i_function       ( i_barrel_shift_function   ),
479
 
480
    .o_out            ( barrel_shift_out          ),
481
    .o_carry_out      ( barrel_shift_carry        )
482
);
483
 
484
 
485
// ========================================================
486
// Instantiate ALU
487
// ========================================================
488 15 csantifort
a23_alu u_alu (
489 2 csantifort
    .i_a_in                 ( rn                    ),
490
    .i_b_in                 ( barrel_shift_out      ),
491
    .i_barrel_shift_carry   ( barrel_shift_carry    ),
492
    .i_status_bits_carry    ( status_bits_flags[1]  ),
493
    .i_function             ( i_alu_function        ),
494
 
495
    .o_out                  ( alu_out               ),
496
    .o_flags                ( alu_flags             )
497
);
498
 
499
 
500
// ========================================================
501
// Instantiate Booth 64-bit Multiplier-Accumulator
502
// ========================================================
503 15 csantifort
a23_multiply u_multiply (
504 2 csantifort
    .i_clk          ( i_clk                 ),
505
    .i_fetch_stall  ( i_fetch_stall         ),
506
    .i_a_in         ( rs                    ),
507
    .i_b_in         ( rm                    ),
508
    .i_function     ( i_multiply_function   ),
509
    .i_execute      ( execute               ),
510
    .o_out          ( multiply_out          ),
511
    .o_flags        ( multiply_flags        ),  // [1] = N, [0] = Z
512
    .o_done         ( o_multiply_done       )
513
);
514
 
515
 
516
// ========================================================
517
// Instantiate Register Bank
518
// ========================================================
519 73 csantifort
`ifndef A23_RAM_REGISTER_BANK
520 15 csantifort
a23_register_bank u_register_bank(
521 2 csantifort
    .i_clk                   ( i_clk                     ),
522
    .i_fetch_stall           ( i_fetch_stall             ),
523
    .i_rm_sel                ( i_rm_sel                  ),
524
    .i_rds_sel               ( i_rds_sel                 ),
525
    .i_rn_sel                ( i_rn_sel                  ),
526
    .i_pc_wen                ( pc_wen                    ),
527
    .i_reg_bank_wen          ( reg_bank_wen              ),
528
    .i_pc                    ( pc_nxt[25:2]              ),
529
    .i_reg                   ( reg_write_nxt             ),
530
    .i_mode_idec             ( i_status_bits_mode        ),
531
    .i_mode_exec             ( status_bits_mode          ),
532
 
533
    .i_status_bits_flags     ( status_bits_flags         ),
534
    .i_status_bits_irq_mask  ( status_bits_irq_mask      ),
535
    .i_status_bits_firq_mask ( status_bits_firq_mask     ),
536
 
537
    // pre-encoded in decode stage to speed up long path
538
    .i_firq_not_user_mode    ( i_firq_not_user_mode      ),
539
 
540
    // use one-hot version for speed, combine with i_user_mode_regs_store
541
    .i_mode_rds_exec         ( status_bits_mode_rds_oh   ),
542
 
543
    .i_user_mode_regs_load   ( i_user_mode_regs_load     ),
544
    .o_rm                    ( rm                        ),
545
    .o_rs                    ( rs                        ),
546
    .o_rd                    ( rd                        ),
547
    .o_rn                    ( rn                        ),
548
    .o_pc                    ( pc                        )
549
);
550 73 csantifort
`else
551
a23_ram_register_bank u_register_bank(
552
    .i_clk                   ( i_clk                     ),
553
    .i_fetch_stall           ( i_fetch_stall             ),
554
    .i_rm_sel                ( i_rm_sel_nxt              ),
555
    .i_rds_sel               ( i_rds_sel_nxt             ),
556
    .i_rn_sel                ( i_rn_sel_nxt              ),
557
    .i_pc_wen                ( pc_wen                    ),
558
    .i_reg_bank_wsel         ( reg_bank_wsel             ),
559
    .i_pc                    ( pc_nxt[25:2]              ),
560
    .i_reg                   ( reg_write_nxt             ),
561 2 csantifort
 
562 73 csantifort
    .i_mode_exec_nxt         ( status_bits_mode_nr       ),
563
    .i_mode_exec             ( status_bits_mode          ),
564
    .i_mode_rds_exec         ( status_bits_mode_rds_nr   ),
565
    .i_user_mode_regs_load   ( i_user_mode_regs_load     ),
566 2 csantifort
 
567 73 csantifort
    .i_status_bits_flags     ( status_bits_flags         ),
568
    .i_status_bits_irq_mask  ( status_bits_irq_mask      ),
569
    .i_status_bits_firq_mask ( status_bits_firq_mask     ),
570
 
571
    .o_rm                    ( rm                        ),
572
    .o_rs                    ( rs                        ),
573
    .o_rd                    ( rd                        ),
574
    .o_rn                    ( rn                        ),
575
    .o_pc                    ( pc                        )
576
);
577
`endif
578
 
579 2 csantifort
// ========================================================
580
// Debug - non-synthesizable code
581
// ========================================================
582
//synopsys translate_off
583
 
584
wire    [(2*8)-1:0]    xCONDITION;
585
wire    [(4*8)-1:0]    xMODE;
586
 
587
assign  xCONDITION           = i_condition == EQ ? "EQ"  :
588
                               i_condition == NE ? "NE"  :
589
                               i_condition == CS ? "CS"  :
590
                               i_condition == CC ? "CC"  :
591
                               i_condition == MI ? "MI"  :
592
                               i_condition == PL ? "PL"  :
593
                               i_condition == VS ? "VS"  :
594
                               i_condition == VC ? "VC"  :
595
                               i_condition == HI ? "HI"  :
596
                               i_condition == LS ? "LS"  :
597
                               i_condition == GE ? "GE"  :
598
                               i_condition == LT ? "LT"  :
599
                               i_condition == GT ? "GT"  :
600
                               i_condition == LE ? "LE"  :
601
                               i_condition == AL ? "AL"  :
602
                                                   "NV " ;
603
 
604
assign  xMODE  =  status_bits_mode == SVC  ? "SVC"  :
605
                  status_bits_mode == IRQ  ? "IRQ"  :
606
                  status_bits_mode == FIRQ ? "FIRQ" :
607
                  status_bits_mode == USR  ? "USR"  :
608
                                             "XXX"  ;
609
 
610
 
611
//synopsys translate_on
612
 
613
endmodule
614
 
615
 

powered by: WebSVN 2.1.0

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