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

Subversion Repositories amber

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

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

powered by: WebSVN 2.1.0

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