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

Subversion Repositories amber

[/] [amber/] [trunk/] [hw/] [vlog/] [amber25/] [a25_register_bank.v] - Diff between revs 16 and 35

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 16 Rev 35
Line 42... Line 42...
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////
 
 
module a25_register_bank (
module a25_register_bank (
 
 
input                       i_clk,
input                       i_clk,
input                       i_access_stall,
input                       i_core_stall,
input                       i_mem_stall,
input                       i_mem_stall,
 
 
input       [1:0]           i_mode_idec,            // user, supervisor, irq_idec, firq_idec etc.
input       [1:0]           i_mode_idec,            // user, supervisor, irq_idec, firq_idec etc.
                                                    // Used for register writes
                                                    // Used for register writes
input       [1:0]           i_mode_exec,            // 1 periods delayed from i_mode_idec
input       [1:0]           i_mode_exec,            // 1 periods delayed from i_mode_idec
Line 65... Line 65...
input       [31:0]          i_reg,
input       [31:0]          i_reg,
 
 
input       [31:0]          i_wb_read_data,
input       [31:0]          i_wb_read_data,
input                       i_wb_read_data_valid,
input                       i_wb_read_data_valid,
input       [3:0]           i_wb_read_data_rd,
input       [3:0]           i_wb_read_data_rd,
input                       i_wb_user_mode,
input       [1:0]           i_wb_mode,
 
 
input       [3:0]           i_status_bits_flags,
input       [3:0]           i_status_bits_flags,
input                       i_status_bits_irq_mask,
input                       i_status_bits_irq_mask,
input                       i_status_bits_firq_mask,
input                       i_status_bits_firq_mask,
 
 
Line 176... Line 176...
assign irq_exec  = i_mode_exec == IRQ;
assign irq_exec  = i_mode_exec == IRQ;
assign firq_exec = i_mode_exec == FIRQ;
assign firq_exec = i_mode_exec == FIRQ;
 
 
assign read_data_wen = {15{i_wb_read_data_valid & ~i_mem_stall}} & decode (i_wb_read_data_rd);
assign read_data_wen = {15{i_wb_read_data_valid & ~i_mem_stall}} & decode (i_wb_read_data_rd);
 
 
assign reg_bank_wen_c = {15{~i_access_stall}} & i_reg_bank_wen;
assign reg_bank_wen_c = {15{~i_core_stall}} & i_reg_bank_wen;
assign pc_wen_c       = ~i_access_stall & i_pc_wen;
assign pc_wen_c       = ~i_core_stall & i_pc_wen;
assign pc_dmem_wen    = i_wb_read_data_valid & ~i_mem_stall & i_wb_read_data_rd == 4'd15;
assign pc_dmem_wen    = i_wb_read_data_valid & ~i_mem_stall & i_wb_read_data_rd == 4'd15;
 
 
 
 
// ========================================================
// ========================================================
// Register Update
// Register Update
// ========================================================
// ========================================================
always @ ( posedge i_clk )
always @ ( posedge i_clk )
    begin
    begin
 
    // these registers are used in all modes
    r0       <= reg_bank_wen_c[0 ]               ? i_reg : read_data_wen[0 ] ? i_wb_read_data : r0;
    r0       <= reg_bank_wen_c[0 ]               ? i_reg : read_data_wen[0 ] ? i_wb_read_data : r0;
    r1       <= reg_bank_wen_c[1 ]               ? i_reg : read_data_wen[1 ] ? i_wb_read_data : r1;
    r1       <= reg_bank_wen_c[1 ]               ? i_reg : read_data_wen[1 ] ? i_wb_read_data : r1;
    r2       <= reg_bank_wen_c[2 ]               ? i_reg : read_data_wen[2 ] ? i_wb_read_data : r2;
    r2       <= reg_bank_wen_c[2 ]               ? i_reg : read_data_wen[2 ] ? i_wb_read_data : r2;
    r3       <= reg_bank_wen_c[3 ]               ? i_reg : read_data_wen[3 ] ? i_wb_read_data : r3;
    r3       <= reg_bank_wen_c[3 ]               ? i_reg : read_data_wen[3 ] ? i_wb_read_data : r3;
    r4       <= reg_bank_wen_c[4 ]               ? i_reg : read_data_wen[4 ] ? i_wb_read_data : r4;
    r4       <= reg_bank_wen_c[4 ]               ? i_reg : read_data_wen[4 ] ? i_wb_read_data : r4;
    r5       <= reg_bank_wen_c[5 ]               ? i_reg : read_data_wen[5 ] ? i_wb_read_data : r5;
    r5       <= reg_bank_wen_c[5 ]               ? i_reg : read_data_wen[5 ] ? i_wb_read_data : r5;
    r6       <= reg_bank_wen_c[6 ]               ? i_reg : read_data_wen[6 ] ? i_wb_read_data : r6;
    r6       <= reg_bank_wen_c[6 ]               ? i_reg : read_data_wen[6 ] ? i_wb_read_data : r6;
    r7       <= reg_bank_wen_c[7 ]               ? i_reg : read_data_wen[7 ] ? i_wb_read_data : r7;
    r7       <= reg_bank_wen_c[7 ]               ? i_reg : read_data_wen[7 ] ? i_wb_read_data : r7;
 
 
    r8       <= reg_bank_wen_c[8 ] && !firq_idec ? i_reg : read_data_wen[8 ] && ( !firq_idec || i_wb_user_mode ) ? i_wb_read_data : r8;
    // these registers are used in all modes, except fast irq
    r9       <= reg_bank_wen_c[9 ] && !firq_idec ? i_reg : read_data_wen[9 ] && ( !firq_idec || i_wb_user_mode ) ? i_wb_read_data : r9;
    r8       <= reg_bank_wen_c[8 ] && !firq_idec ? i_reg : read_data_wen[8 ] && i_wb_mode != FIRQ ? i_wb_read_data       : r8;
    r10      <= reg_bank_wen_c[10] && !firq_idec ? i_reg : read_data_wen[10] && ( !firq_idec || i_wb_user_mode ) ? i_wb_read_data : r10;
    r9       <= reg_bank_wen_c[9 ] && !firq_idec ? i_reg : read_data_wen[9 ] && i_wb_mode != FIRQ ? i_wb_read_data       : r9;
    r11      <= reg_bank_wen_c[11] && !firq_idec ? i_reg : read_data_wen[11] && ( !firq_idec || i_wb_user_mode ) ? i_wb_read_data : r11;
    r10      <= reg_bank_wen_c[10] && !firq_idec ? i_reg : read_data_wen[10] && i_wb_mode != FIRQ ? i_wb_read_data       : r10;
    r12      <= reg_bank_wen_c[12] && !firq_idec ? i_reg : read_data_wen[12] && ( !firq_idec || i_wb_user_mode ) ? i_wb_read_data : r12;
    r11      <= reg_bank_wen_c[11] && !firq_idec ? i_reg : read_data_wen[11] && i_wb_mode != FIRQ ? i_wb_read_data       : r11;
 
    r12      <= reg_bank_wen_c[12] && !firq_idec ? i_reg : read_data_wen[12] && i_wb_mode != FIRQ ? i_wb_read_data       : r12;
    r8_firq  <= reg_bank_wen_c[8 ] &&  firq_idec ? i_reg : read_data_wen[8 ] && ( firq_idec && !i_wb_user_mode ) ? i_wb_read_data : r8_firq;
 
    r9_firq  <= reg_bank_wen_c[9 ] &&  firq_idec ? i_reg : read_data_wen[9 ] && ( firq_idec && !i_wb_user_mode ) ? i_wb_read_data : r9_firq;
    // these registers are used in fast irq mode
    r10_firq <= reg_bank_wen_c[10] &&  firq_idec ? i_reg : read_data_wen[10] && ( firq_idec && !i_wb_user_mode ) ? i_wb_read_data : r10_firq;
    r8_firq  <= reg_bank_wen_c[8 ] &&  firq_idec ? i_reg : read_data_wen[8 ] && i_wb_mode == FIRQ ? i_wb_read_data       : r8_firq;
    r11_firq <= reg_bank_wen_c[11] &&  firq_idec ? i_reg : read_data_wen[11] && ( firq_idec && !i_wb_user_mode ) ? i_wb_read_data : r11_firq;
    r9_firq  <= reg_bank_wen_c[9 ] &&  firq_idec ? i_reg : read_data_wen[9 ] && i_wb_mode == FIRQ ? i_wb_read_data       : r9_firq;
    r12_firq <= reg_bank_wen_c[12] &&  firq_idec ? i_reg : read_data_wen[12] && ( firq_idec && !i_wb_user_mode ) ? i_wb_read_data : r12_firq;
    r10_firq <= reg_bank_wen_c[10] &&  firq_idec ? i_reg : read_data_wen[10] && i_wb_mode == FIRQ ? i_wb_read_data       : r10_firq;
 
    r11_firq <= reg_bank_wen_c[11] &&  firq_idec ? i_reg : read_data_wen[11] && i_wb_mode == FIRQ ? i_wb_read_data       : r11_firq;
    r13      <= reg_bank_wen_c[13] &&  usr_idec  ? i_reg : read_data_wen[13] && ( usr_idec || i_wb_user_mode )   ? i_wb_read_data : r13;
    r12_firq <= reg_bank_wen_c[12] &&  firq_idec ? i_reg : read_data_wen[12] && i_wb_mode == FIRQ ? i_wb_read_data       : r12_firq;
    r14      <= reg_bank_wen_c[14] &&  usr_idec  ? i_reg : read_data_wen[14] && ( usr_idec || i_wb_user_mode )   ? i_wb_read_data : r14;
 
 
    // these registers are used in user mode
    r13_svc  <= reg_bank_wen_c[13] &&  svc_idec  ? i_reg : read_data_wen[13] && ( svc_idec && !i_wb_user_mode )  ? i_wb_read_data : r13_svc;
    r13      <= reg_bank_wen_c[13] &&  usr_idec  ? i_reg : read_data_wen[13] && i_wb_mode == USR ? i_wb_read_data        : r13;
    r14_svc  <= reg_bank_wen_c[14] &&  svc_idec  ? i_reg : read_data_wen[14] && ( svc_idec && !i_wb_user_mode )  ? i_wb_read_data : r14_svc;
    r14      <= reg_bank_wen_c[14] &&  usr_idec  ? i_reg : read_data_wen[14] && i_wb_mode == USR ? i_wb_read_data        : r14;
 
 
    r13_irq  <= reg_bank_wen_c[13] &&  irq_idec  ? i_reg : read_data_wen[13] && ( irq_idec && !i_wb_user_mode )  ? i_wb_read_data : r13_irq;
    // these registers are used in supervisor mode
    r14_irq  <= reg_bank_wen_c[14] &&  irq_idec  ? i_reg : read_data_wen[14] && ( irq_idec && !i_wb_user_mode )  ? i_wb_read_data : r14_irq;
    r13_svc  <= reg_bank_wen_c[13] &&  svc_idec  ? i_reg : read_data_wen[13] && i_wb_mode == SVC  ? i_wb_read_data       : r13_svc;
 
    r14_svc  <= reg_bank_wen_c[14] &&  svc_idec  ? i_reg : read_data_wen[14] && i_wb_mode == SVC  ? i_wb_read_data       : r14_svc;
    r13_firq <= reg_bank_wen_c[13] &&  firq_idec ? i_reg : read_data_wen[13] && ( firq_idec && !i_wb_user_mode ) ? i_wb_read_data : r13_firq;
 
    r14_firq <= reg_bank_wen_c[14] &&  firq_idec ? i_reg : read_data_wen[14] && ( firq_idec && !i_wb_user_mode ) ? i_wb_read_data : r14_firq;
    // these registers are used in irq mode
 
    r13_irq  <= reg_bank_wen_c[13] &&  irq_idec  ? i_reg : read_data_wen[13] && i_wb_mode == IRQ  ? i_wb_read_data       : r13_irq;
 
    r14_irq  <= (reg_bank_wen_c[14] && irq_idec) ? i_reg : read_data_wen[14] && i_wb_mode == IRQ  ? i_wb_read_data       : r14_irq;
 
 
 
    // these registers are used in fast irq mode
 
    r13_firq <= reg_bank_wen_c[13] &&  firq_idec ? i_reg : read_data_wen[13] && i_wb_mode == FIRQ ? i_wb_read_data       : r13_firq;
 
    r14_firq <= reg_bank_wen_c[14] &&  firq_idec ? i_reg : read_data_wen[14] && i_wb_mode == FIRQ ? i_wb_read_data       : r14_firq;
 
 
 
    // these registers are used in all modes
    r15      <= pc_wen_c                         ?  i_pc : pc_dmem_wen ? i_wb_read_data[25:2] : r15;
    r15      <= pc_wen_c                         ?  i_pc : pc_dmem_wen ? i_wb_read_data[25:2] : r15;
    end
    end
 
 
 
 
// ========================================================
// ========================================================

powered by: WebSVN 2.1.0

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