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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [or1200/] [rtl/] [verilog/] [or1200_immu_top.v] - Diff between revs 481 and 679

Only display areas with differences | Details | Blame | View Log

Rev 481 Rev 679
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
////                                                              ////
////                                                              ////
////  OR1200's Instruction MMU top level                          ////
////  OR1200's Instruction MMU top level                          ////
////                                                              ////
////                                                              ////
////  This file is part of the OpenRISC 1200 project              ////
////  This file is part of the OpenRISC 1200 project              ////
////  http://www.opencores.org/project,or1k                       ////
////  http://www.opencores.org/project,or1k                       ////
////                                                              ////
////                                                              ////
////  Description                                                 ////
////  Description                                                 ////
////  Instantiation of all IMMU blocks.                           ////
////  Instantiation of all IMMU blocks.                           ////
////                                                              ////
////                                                              ////
////  To Do:                                                      ////
////  To Do:                                                      ////
////   - cache inhibit                                            ////
////   - cache inhibit                                            ////
////                                                              ////
////                                                              ////
////  Author(s):                                                  ////
////  Author(s):                                                  ////
////      - Damjan Lampret, lampret@opencores.org                 ////
////      - Damjan Lampret, lampret@opencores.org                 ////
////                                                              ////
////                                                              ////
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
////                                                              ////
////                                                              ////
//// Copyright (C) 2000 Authors and OPENCORES.ORG                 ////
//// Copyright (C) 2000 Authors and OPENCORES.ORG                 ////
////                                                              ////
////                                                              ////
//// This source file may be used and distributed without         ////
//// This source file may be used and distributed without         ////
//// restriction provided that this copyright statement is not    ////
//// restriction provided that this copyright statement is not    ////
//// removed from the file and that any derivative work contains  ////
//// removed from the file and that any derivative work contains  ////
//// the original copyright notice and the associated disclaimer. ////
//// the original copyright notice and the associated disclaimer. ////
////                                                              ////
////                                                              ////
//// This source file is free software; you can redistribute it   ////
//// This source file is free software; you can redistribute it   ////
//// and/or modify it under the terms of the GNU Lesser General   ////
//// and/or modify it under the terms of the GNU Lesser General   ////
//// Public License as published by the Free Software Foundation; ////
//// Public License as published by the Free Software Foundation; ////
//// either version 2.1 of the License, or (at your option) any   ////
//// either version 2.1 of the License, or (at your option) any   ////
//// later version.                                               ////
//// later version.                                               ////
////                                                              ////
////                                                              ////
//// This source is distributed in the hope that it will be       ////
//// This source is distributed in the hope that it will be       ////
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
//// PURPOSE.  See the GNU Lesser General Public License for more ////
//// PURPOSE.  See the GNU Lesser General Public License for more ////
//// details.                                                     ////
//// details.                                                     ////
////                                                              ////
////                                                              ////
//// You should have received a copy of the GNU Lesser General    ////
//// You should have received a copy of the GNU Lesser General    ////
//// Public License along with this source; if not, download it   ////
//// Public License along with this source; if not, download it   ////
//// from http://www.opencores.org/lgpl.shtml                     ////
//// from http://www.opencores.org/lgpl.shtml                     ////
////                                                              ////
////                                                              ////
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
 
 
// synopsys translate_off
// synopsys translate_off
`include "timescale.v"
`include "timescale.v"
// synopsys translate_on
// synopsys translate_on
`include "or1200_defines.v"
`include "or1200_defines.v"
 
 
//
//
// Insn MMU
// Insn MMU
//
//
 
 
module or1200_immu_top(
module or1200_immu_top(
        // Rst and clk
        // Rst and clk
        clk, rst,
        clk, rst,
 
 
        // CPU i/f
        // CPU i/f
        ic_en, immu_en, supv, icpu_adr_i, icpu_cycstb_i,
        ic_en, immu_en, supv, icpu_adr_i, icpu_cycstb_i,
        icpu_adr_o, icpu_tag_o, icpu_rty_o, icpu_err_o,
        icpu_adr_o, icpu_tag_o, icpu_rty_o, icpu_err_o,
 
 
        // SR Interface
        // SR Interface
        boot_adr_sel_i,
        boot_adr_sel_i,
 
 
        // SPR access
        // SPR access
        spr_cs, spr_write, spr_addr, spr_dat_i, spr_dat_o,
        spr_cs, spr_write, spr_addr, spr_dat_i, spr_dat_o,
 
 
`ifdef OR1200_BIST
`ifdef OR1200_BIST
        // RAM BIST
        // RAM BIST
        mbist_si_i, mbist_so_o, mbist_ctrl_i,
        mbist_si_i, mbist_so_o, mbist_ctrl_i,
`endif
`endif
 
 
        // QMEM i/f
        // QMEM i/f
        qmemimmu_rty_i, qmemimmu_err_i, qmemimmu_tag_i, qmemimmu_adr_o, qmemimmu_cycstb_o, qmemimmu_ci_o
        qmemimmu_rty_i, qmemimmu_err_i, qmemimmu_tag_i, qmemimmu_adr_o, qmemimmu_cycstb_o, qmemimmu_ci_o
);
);
 
 
parameter dw = `OR1200_OPERAND_WIDTH;
parameter dw = `OR1200_OPERAND_WIDTH;
parameter aw = `OR1200_OPERAND_WIDTH;
parameter aw = `OR1200_OPERAND_WIDTH;
 
parameter boot_adr = `OR1200_BOOT_ADR;
 
 
//
//
// I/O
// I/O
//
//
 
 
//
//
// Clock and reset
// Clock and reset
//
//
input                           clk;
input                           clk;
input                           rst;
input                           rst;
 
 
//
//
// CPU I/F
// CPU I/F
//
//
input                           ic_en;
input                           ic_en;
input                           immu_en;
input                           immu_en;
input                           supv;
input                           supv;
input   [aw-1:0]         icpu_adr_i;
input   [aw-1:0]         icpu_adr_i;
input                           icpu_cycstb_i;
input                           icpu_cycstb_i;
output  [aw-1:0]         icpu_adr_o;
output  [aw-1:0]         icpu_adr_o;
output  [3:0]                    icpu_tag_o;
output  [3:0]                    icpu_tag_o;
output                          icpu_rty_o;
output                          icpu_rty_o;
output                          icpu_err_o;
output                          icpu_err_o;
 
 
//
//
// SR Interface
// SR Interface
//
//
input                           boot_adr_sel_i;
input                           boot_adr_sel_i;
 
 
//
//
// SPR access
// SPR access
//
//
input                           spr_cs;
input                           spr_cs;
input                           spr_write;
input                           spr_write;
input   [aw-1:0]         spr_addr;
input   [aw-1:0]         spr_addr;
input   [31:0]                   spr_dat_i;
input   [31:0]                   spr_dat_i;
output  [31:0]                   spr_dat_o;
output  [31:0]                   spr_dat_o;
 
 
`ifdef OR1200_BIST
`ifdef OR1200_BIST
//
//
// RAM BIST
// RAM BIST
//
//
input mbist_si_i;
input mbist_si_i;
input [`OR1200_MBIST_CTRL_WIDTH - 1:0] mbist_ctrl_i;
input [`OR1200_MBIST_CTRL_WIDTH - 1:0] mbist_ctrl_i;
output mbist_so_o;
output mbist_so_o;
`endif
`endif
 
 
//
//
// IC I/F
// IC I/F
//
//
input                           qmemimmu_rty_i;
input                           qmemimmu_rty_i;
input                           qmemimmu_err_i;
input                           qmemimmu_err_i;
input   [3:0]                    qmemimmu_tag_i;
input   [3:0]                    qmemimmu_tag_i;
output  [aw-1:0]         qmemimmu_adr_o;
output  [aw-1:0]         qmemimmu_adr_o;
output                          qmemimmu_cycstb_o;
output                          qmemimmu_cycstb_o;
output                          qmemimmu_ci_o;
output                          qmemimmu_ci_o;
 
 
//
//
// Internal wires and regs
// Internal wires and regs
//
//
wire                            itlb_spr_access;
wire                            itlb_spr_access;
wire    [31:`OR1200_IMMU_PS]    itlb_ppn;
wire    [31:`OR1200_IMMU_PS]    itlb_ppn;
wire                            itlb_hit;
wire                            itlb_hit;
wire                            itlb_uxe;
wire                            itlb_uxe;
wire                            itlb_sxe;
wire                            itlb_sxe;
wire    [31:0]                   itlb_dat_o;
wire    [31:0]                   itlb_dat_o;
wire                            itlb_en;
wire                            itlb_en;
wire                            itlb_ci;
wire                            itlb_ci;
wire                            itlb_done;
wire                            itlb_done;
wire                            fault;
wire                            fault;
wire                            miss;
wire                            miss;
wire                            page_cross;
wire                            page_cross;
reg     [31:0]                   icpu_adr_default;
reg     [31:0]                   icpu_adr_default;
wire    [31:0]                   icpu_adr_boot;
 
reg                             icpu_adr_select;
reg                             icpu_adr_select;
reg             [31:0]           icpu_adr_o;
reg             [31:0]           icpu_adr_o;
reg     [31:`OR1200_IMMU_PS]    icpu_vpn_r;
reg     [31:`OR1200_IMMU_PS]    icpu_vpn_r;
`ifdef OR1200_NO_IMMU
`ifdef OR1200_NO_IMMU
`else
`else
reg                             itlb_en_r;
reg                             itlb_en_r;
reg                             dis_spr_access_frst_clk;
reg                             dis_spr_access_frst_clk;
reg                             dis_spr_access_scnd_clk;
reg                             dis_spr_access_scnd_clk;
`endif
`endif
 
 
//
//
// Implemented bits inside match and translate registers
// Implemented bits inside match and translate registers
//
//
// itlbwYmrX: vpn 31-10  v 0
// itlbwYmrX: vpn 31-10  v 0
// itlbwYtrX: ppn 31-10  uxe 7  sxe 6
// itlbwYtrX: ppn 31-10  uxe 7  sxe 6
//
//
// itlb memory width:
// itlb memory width:
// 19 bits for ppn
// 19 bits for ppn
// 13 bits for vpn
// 13 bits for vpn
// 1 bit for valid
// 1 bit for valid
// 2 bits for protection
// 2 bits for protection
// 1 bit for cache inhibit
// 1 bit for cache inhibit
 
 
//
//
// icpu_adr_o
// icpu_adr_o
//
//
`ifdef OR1200_REGISTERED_OUTPUTS
`ifdef OR1200_REGISTERED_OUTPUTS
 
wire    [31:0]                   icpu_adr_boot = boot_adr;
 
 
always @(`OR1200_RST_EVENT rst or posedge clk)
always @(`OR1200_RST_EVENT rst or posedge clk)
        // default value 
        // default value 
        if (rst == `OR1200_RST_VALUE) begin
        if (rst == `OR1200_RST_VALUE) begin
                // select async. value due to reset state
                // select async. value due to reset state
                icpu_adr_default <=  32'h0000_0100;
                icpu_adr_default <=  32'h0000_0100;
                icpu_adr_select  <=  1'b1;
                icpu_adr_select  <=  1'b1;
        end
        end
        // selected value (different from default) is written 
        // selected value (different from default) is written 
        // into FF after reset state
        // into FF after reset state
        else if (icpu_adr_select) begin
        else if (icpu_adr_select) begin
                // dynamic value can only be assigned to FF out of reset!
                // dynamic value can only be assigned to FF out of reset!
                icpu_adr_default <=  icpu_adr_boot;
                icpu_adr_default <=  icpu_adr_boot;
                // select FF value 
                // select FF value 
                icpu_adr_select  <=  1'b0;
                icpu_adr_select  <=  1'b0;
        end
        end
        else begin
        else begin
                icpu_adr_default <=  icpu_adr_i;
                icpu_adr_default <=  icpu_adr_i;
        end
        end
 
 
// select async. value for boot address after reset - PC jumps to the address 
// select async. value for boot address after reset - PC jumps to the address 
// selected after boot! 
// selected after boot! 
   //assign icpu_adr_boot = {(boot_adr_sel_i ? `OR1200_EXCEPT_EPH1_P : 
   //assign icpu_adr_boot = {(boot_adr_sel_i ? `OR1200_EXCEPT_EPH1_P : 
   // `OR1200_EXCEPT_EPH0_P), 12'h100} ;
   // `OR1200_EXCEPT_EPH0_P), 12'h100} ;
   assign icpu_adr_boot = `OR1200_BOOT_ADR; // jb
 
 
 
always @(icpu_adr_boot or icpu_adr_default or icpu_adr_select)
always @(icpu_adr_boot or icpu_adr_default or icpu_adr_select)
        if (icpu_adr_select)
        if (icpu_adr_select)
                // async. value is selected due to reset state 
                // async. value is selected due to reset state 
                icpu_adr_o = icpu_adr_boot ;
                icpu_adr_o = icpu_adr_boot ;
        else
        else
                // FF value is selected 2nd clock after reset state 
                // FF value is selected 2nd clock after reset state 
                icpu_adr_o = icpu_adr_default ;
                icpu_adr_o = icpu_adr_default ;
`else
`else
Unsupported !!!
Unsupported !!!
`endif
`endif
 
 
//
//
// Page cross
// Page cross
//
//
// Asserted when CPU address crosses page boundary. Most of the time it is zero.
// Asserted when CPU address crosses page boundary. Most of the time it is zero.
//
//
assign page_cross = icpu_adr_i[31:`OR1200_IMMU_PS] != icpu_vpn_r;
assign page_cross = icpu_adr_i[31:`OR1200_IMMU_PS] != icpu_vpn_r;
 
 
//
//
// Register icpu_adr_i's VPN for use when IMMU is not enabled but PPN is expected to come
// Register icpu_adr_i's VPN for use when IMMU is not enabled but PPN is expected to come
// one clock cycle after offset part.
// one clock cycle after offset part.
//
//
always @(posedge clk or `OR1200_RST_EVENT rst)
always @(posedge clk or `OR1200_RST_EVENT rst)
        if (rst == `OR1200_RST_VALUE)
        if (rst == `OR1200_RST_VALUE)
                icpu_vpn_r <=  {32-`OR1200_IMMU_PS{1'b0}};
                icpu_vpn_r <=  {32-`OR1200_IMMU_PS{1'b0}};
        else
        else
                icpu_vpn_r <=  icpu_adr_i[31:`OR1200_IMMU_PS];
                icpu_vpn_r <=  icpu_adr_i[31:`OR1200_IMMU_PS];
 
 
`ifdef OR1200_NO_IMMU
`ifdef OR1200_NO_IMMU
 
 
//
//
// Put all outputs in inactive state
// Put all outputs in inactive state
//
//
assign spr_dat_o = 32'h00000000;
assign spr_dat_o = 32'h00000000;
assign qmemimmu_adr_o = icpu_adr_i;
assign qmemimmu_adr_o = icpu_adr_i;
assign icpu_tag_o = qmemimmu_tag_i;
assign icpu_tag_o = qmemimmu_tag_i;
assign qmemimmu_cycstb_o = icpu_cycstb_i & ~page_cross;
assign qmemimmu_cycstb_o = icpu_cycstb_i & ~page_cross;
assign icpu_rty_o = qmemimmu_rty_i;
assign icpu_rty_o = qmemimmu_rty_i;
assign icpu_err_o = qmemimmu_err_i;
assign icpu_err_o = qmemimmu_err_i;
assign qmemimmu_ci_o = `OR1200_IMMU_CI;
assign qmemimmu_ci_o = `OR1200_IMMU_CI;
`ifdef OR1200_BIST
`ifdef OR1200_BIST
assign mbist_so_o = mbist_si_i;
assign mbist_so_o = mbist_si_i;
`endif
`endif
`else
`else
 
 
//
//
// ITLB SPR access
// ITLB SPR access
//
//
// 1200 - 12FF  itlbmr w0
// 1200 - 12FF  itlbmr w0
// 1200 - 123F  itlbmr w0 [63:0]
// 1200 - 123F  itlbmr w0 [63:0]
//
//
// 1300 - 13FF  itlbtr w0
// 1300 - 13FF  itlbtr w0
// 1300 - 133F  itlbtr w0 [63:0]
// 1300 - 133F  itlbtr w0 [63:0]
//
//
assign itlb_spr_access = spr_cs & ~dis_spr_access_scnd_clk;
assign itlb_spr_access = spr_cs & ~dis_spr_access_scnd_clk;
 
 
//
//
// Disable ITLB SPR access
// Disable ITLB SPR access
//
//
// This flops are used to mask ITLB miss/fault exception
// This flops are used to mask ITLB miss/fault exception
// during first & second clock cycles of accessing ITLB SPR. In
// during first & second clock cycles of accessing ITLB SPR. In
// subsequent clock cycles it is assumed that ITLB SPR
// subsequent clock cycles it is assumed that ITLB SPR
// access was accomplished and that normal instruction fetching
// access was accomplished and that normal instruction fetching
// can proceed.
// can proceed.
//
//
// spr_cs sets dis_spr_access_frst_clk and icpu_rty_o clears it.
// spr_cs sets dis_spr_access_frst_clk and icpu_rty_o clears it.
// dis_spr_access_frst_clk  sets dis_spr_access_scnd_clk and 
// dis_spr_access_frst_clk  sets dis_spr_access_scnd_clk and 
// icpu_rty_o clears it.
// icpu_rty_o clears it.
//
//
always @(posedge clk or `OR1200_RST_EVENT rst)
always @(posedge clk or `OR1200_RST_EVENT rst)
        if (rst == `OR1200_RST_VALUE)
        if (rst == `OR1200_RST_VALUE)
                dis_spr_access_frst_clk  <=  1'b0;
                dis_spr_access_frst_clk  <=  1'b0;
        else if (!icpu_rty_o)
        else if (!icpu_rty_o)
                dis_spr_access_frst_clk  <=  1'b0;
                dis_spr_access_frst_clk  <=  1'b0;
        else if (spr_cs)
        else if (spr_cs)
                dis_spr_access_frst_clk  <=  1'b1;
                dis_spr_access_frst_clk  <=  1'b1;
 
 
always @(posedge clk or `OR1200_RST_EVENT rst)
always @(posedge clk or `OR1200_RST_EVENT rst)
        if (rst == `OR1200_RST_VALUE)
        if (rst == `OR1200_RST_VALUE)
                dis_spr_access_scnd_clk  <=  1'b0;
                dis_spr_access_scnd_clk  <=  1'b0;
        else if (!icpu_rty_o)
        else if (!icpu_rty_o)
                dis_spr_access_scnd_clk  <=  1'b0;
                dis_spr_access_scnd_clk  <=  1'b0;
        else if (dis_spr_access_frst_clk)
        else if (dis_spr_access_frst_clk)
                dis_spr_access_scnd_clk  <=  1'b1;
                dis_spr_access_scnd_clk  <=  1'b1;
 
 
//
//
// Tags:
// Tags:
//
//
// OR1200_ITAG_TE - TLB miss Exception
// OR1200_ITAG_TE - TLB miss Exception
// OR1200_ITAG_PE - Page fault Exception
// OR1200_ITAG_PE - Page fault Exception
//
//
assign icpu_tag_o = miss ? `OR1200_ITAG_TE : fault ? `OR1200_ITAG_PE : qmemimmu_tag_i;
assign icpu_tag_o = miss ? `OR1200_ITAG_TE : fault ? `OR1200_ITAG_PE : qmemimmu_tag_i;
 
 
//
//
// icpu_rty_o
// icpu_rty_o
//
//
// assign icpu_rty_o = !icpu_err_o & qmemimmu_rty_i;
// assign icpu_rty_o = !icpu_err_o & qmemimmu_rty_i;
//assign icpu_rty_o = qmemimmu_rty_i | itlb_spr_access & immu_en;
//assign icpu_rty_o = qmemimmu_rty_i | itlb_spr_access & immu_en;
assign icpu_rty_o = qmemimmu_rty_i;
assign icpu_rty_o = qmemimmu_rty_i;
 
 
//
//
// icpu_err_o
// icpu_err_o
//
//
assign icpu_err_o = miss | fault | qmemimmu_err_i;
assign icpu_err_o = miss | fault | qmemimmu_err_i;
 
 
//
//
// Assert itlb_en_r after one clock cycle and when there is no
// Assert itlb_en_r after one clock cycle and when there is no
// ITLB SPR access
// ITLB SPR access
//
//
always @(posedge clk or `OR1200_RST_EVENT rst)
always @(posedge clk or `OR1200_RST_EVENT rst)
        if (rst == `OR1200_RST_VALUE)
        if (rst == `OR1200_RST_VALUE)
                itlb_en_r <=  1'b0;
                itlb_en_r <=  1'b0;
        else
        else
                itlb_en_r <=  itlb_en & ~itlb_spr_access;
                itlb_en_r <=  itlb_en & ~itlb_spr_access;
 
 
//
//
// ITLB lookup successful
// ITLB lookup successful
//
//
assign itlb_done = itlb_en_r & ~page_cross;
assign itlb_done = itlb_en_r & ~page_cross;
 
 
//
//
// Cut transfer when access (mtspr/mfspr) to/from ITLB occure or if something goes 
// Cut transfer when access (mtspr/mfspr) to/from ITLB occure or if something goes 
// wrong with translation. If IC is disabled, use delayed signals.
// wrong with translation. If IC is disabled, use delayed signals.
//
//
// assign qmemimmu_cycstb_o = (!ic_en & immu_en) ? ~(miss | fault) & icpu_cycstb_i & ~page_cross : (miss | fault) ? 1'b0 : icpu_cycstb_i & ~page_cross; // DL
// assign qmemimmu_cycstb_o = (!ic_en & immu_en) ? ~(miss | fault) & icpu_cycstb_i & ~page_cross : (miss | fault) ? 1'b0 : icpu_cycstb_i & ~page_cross; // DL
//assign qmemimmu_cycstb_o = immu_en ? ~(miss | fault) & icpu_cycstb_i & ~page_cross & itlb_done : icpu_cycstb_i & ~page_cross;
//assign qmemimmu_cycstb_o = immu_en ? ~(miss | fault) & icpu_cycstb_i & ~page_cross & itlb_done : icpu_cycstb_i & ~page_cross;
assign qmemimmu_cycstb_o = immu_en ? ~(miss | fault) & icpu_cycstb_i & ~page_cross & itlb_done & ~itlb_spr_access : icpu_cycstb_i & ~page_cross;
assign qmemimmu_cycstb_o = immu_en ? ~(miss | fault) & icpu_cycstb_i & ~page_cross & itlb_done & ~itlb_spr_access : icpu_cycstb_i & ~page_cross;
 
 
//
//
// Cache Inhibit
// Cache Inhibit
//
//
// Cache inhibit is not really needed for instruction memory subsystem.
// Cache inhibit is not really needed for instruction memory subsystem.
// If we would doq it, we would doq it like this.
// If we would doq it, we would doq it like this.
// assign qmemimmu_ci_o = immu_en ? itlb_done & itlb_ci : `OR1200_IMMU_CI;
// assign qmemimmu_ci_o = immu_en ? itlb_done & itlb_ci : `OR1200_IMMU_CI;
// However this causes an async combinatorial loop so we stick to
// However this causes an async combinatorial loop so we stick to
// no cache inhibit.
// no cache inhibit.
//assign qmemimmu_ci_o = `OR1200_IMMU_CI;
//assign qmemimmu_ci_o = `OR1200_IMMU_CI;
// Cache inhibit without an async combinatorial loop 
// Cache inhibit without an async combinatorial loop 
assign qmemimmu_ci_o = immu_en ? itlb_ci : `OR1200_IMMU_CI;
assign qmemimmu_ci_o = immu_en ? itlb_ci : `OR1200_IMMU_CI;
 
 
 
 
//
//
// Physical address is either translated virtual address or
// Physical address is either translated virtual address or
// simply equal when IMMU is disabled
// simply equal when IMMU is disabled
//
//
//assign qmemimmu_adr_o = itlb_done ? {itlb_ppn, icpu_adr_i[`OR1200_IMMU_PS-1:0]} : {icpu_vpn_r, icpu_adr_i[`OR1200_IMMU_PS-1:0]}; // DL: immu_en
//assign qmemimmu_adr_o = itlb_done ? {itlb_ppn, icpu_adr_i[`OR1200_IMMU_PS-1:0]} : {icpu_vpn_r, icpu_adr_i[`OR1200_IMMU_PS-1:0]}; // DL: immu_en
assign qmemimmu_adr_o = immu_en & itlb_done ? {itlb_ppn, icpu_adr_i[`OR1200_IMMU_PS-1:2], 2'h0} : {icpu_vpn_r, icpu_adr_i[`OR1200_IMMU_PS-1:2], 2'h0};
assign qmemimmu_adr_o = immu_en & itlb_done ? {itlb_ppn, icpu_adr_i[`OR1200_IMMU_PS-1:2], 2'h0} : {icpu_vpn_r, icpu_adr_i[`OR1200_IMMU_PS-1:2], 2'h0};
 
 
reg     [31:0]                  spr_dat_reg;
reg     [31:0]                  spr_dat_reg;
//
//
// Output to SPRS unit
// Output to SPRS unit
//
//
// spr_dat_o is registered on the 1st clock of spr read 
// spr_dat_o is registered on the 1st clock of spr read 
// so itlb can continue with process during execution of mfspr.
// so itlb can continue with process during execution of mfspr.
always @(posedge clk or `OR1200_RST_EVENT rst)
always @(posedge clk or `OR1200_RST_EVENT rst)
        if (rst == `OR1200_RST_VALUE)
        if (rst == `OR1200_RST_VALUE)
                spr_dat_reg <=  32'h0000_0000;
                spr_dat_reg <=  32'h0000_0000;
        else if (spr_cs & !dis_spr_access_scnd_clk)
        else if (spr_cs & !dis_spr_access_scnd_clk)
                spr_dat_reg <=  itlb_dat_o;
                spr_dat_reg <=  itlb_dat_o;
 
 
assign spr_dat_o = itlb_spr_access ? itlb_dat_o : spr_dat_reg;
assign spr_dat_o = itlb_spr_access ? itlb_dat_o : spr_dat_reg;
 
 
//
//
// Page fault exception logic
// Page fault exception logic
//
//
assign fault = itlb_done &
assign fault = itlb_done &
                        (  (!supv & !itlb_uxe)          // Execute in user mode not enabled
                        (  (!supv & !itlb_uxe)          // Execute in user mode not enabled
                        || (supv & !itlb_sxe));         // Execute in supv mode not enabled
                        || (supv & !itlb_sxe));         // Execute in supv mode not enabled
 
 
//
//
// TLB Miss exception logic
// TLB Miss exception logic
//
//
assign miss = itlb_done & !itlb_hit;
assign miss = itlb_done & !itlb_hit;
 
 
//
//
// ITLB Enable
// ITLB Enable
//
//
assign itlb_en = immu_en & icpu_cycstb_i;
assign itlb_en = immu_en & icpu_cycstb_i;
 
 
//
//
// Instantiation of ITLB
// Instantiation of ITLB
//
//
or1200_immu_tlb or1200_immu_tlb(
or1200_immu_tlb or1200_immu_tlb(
        // Rst and clk
        // Rst and clk
        .clk(clk),
        .clk(clk),
        .rst(rst),
        .rst(rst),
 
 
        // I/F for translation
        // I/F for translation
        .tlb_en(itlb_en),
        .tlb_en(itlb_en),
        .vaddr(icpu_adr_i),
        .vaddr(icpu_adr_i),
        .hit(itlb_hit),
        .hit(itlb_hit),
        .ppn(itlb_ppn),
        .ppn(itlb_ppn),
        .uxe(itlb_uxe),
        .uxe(itlb_uxe),
        .sxe(itlb_sxe),
        .sxe(itlb_sxe),
        .ci(itlb_ci),
        .ci(itlb_ci),
 
 
`ifdef OR1200_BIST
`ifdef OR1200_BIST
        // RAM BIST
        // RAM BIST
        .mbist_si_i(mbist_si_i),
        .mbist_si_i(mbist_si_i),
        .mbist_so_o(mbist_so_o),
        .mbist_so_o(mbist_so_o),
        .mbist_ctrl_i(mbist_ctrl_i),
        .mbist_ctrl_i(mbist_ctrl_i),
`endif
`endif
 
 
        // SPR access
        // SPR access
        .spr_cs(itlb_spr_access),
        .spr_cs(itlb_spr_access),
        .spr_write(spr_write),
        .spr_write(spr_write),
        .spr_addr(spr_addr),
        .spr_addr(spr_addr),
        .spr_dat_i(spr_dat_i),
        .spr_dat_i(spr_dat_i),
        .spr_dat_o(itlb_dat_o)
        .spr_dat_o(itlb_dat_o)
);
);
 
 
`endif
`endif
 
 
endmodule
endmodule
 
 

powered by: WebSVN 2.1.0

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