Line 42... |
Line 42... |
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
//
|
//
|
// CVS Revision History
|
// CVS Revision History
|
//
|
//
|
// $Log: not supported by cvs2svn $
|
// $Log: not supported by cvs2svn $
|
|
// Revision 1.4 2002/02/01 19:56:54 lampret
|
|
// Fixed combinational loops.
|
|
//
|
// Revision 1.3 2002/01/28 01:16:00 lampret
|
// Revision 1.3 2002/01/28 01:16:00 lampret
|
// Changed 'void' nop-ops instead of insn[0] to use insn[16]. Debug unit stalls the tick timer. Prepared new flag generation for add and and insns. Blocked DC/IC while they are turned off. Fixed I/D MMU SPRs layout except WAYs. TODO: smart IC invalidate, l.j 2 and TLB ways.
|
// Changed 'void' nop-ops instead of insn[0] to use insn[16]. Debug unit stalls the tick timer. Prepared new flag generation for add and and insns. Blocked DC/IC while they are turned off. Fixed I/D MMU SPRs layout except WAYs. TODO: smart IC invalidate, l.j 2 and TLB ways.
|
//
|
//
|
// Revision 1.2 2002/01/14 06:18:22 lampret
|
// Revision 1.2 2002/01/14 06:18:22 lampret
|
// Fixed mem2reg bug in FAST implementation. Updated debug unit to work with new genpc/if.
|
// Fixed mem2reg bug in FAST implementation. Updated debug unit to work with new genpc/if.
|
Line 85... |
Line 88... |
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_cyc_i, icpu_stb_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,
|
|
|
// 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,
|
|
|
// IC i/f
|
// IC i/f
|
icimmu_rty_i, icimmu_err_i, icimmu_tag_i, icimmu_adr_o, icimmu_cyc_o, icimmu_stb_o, icimmu_ci_o
|
icimmu_rty_i, icimmu_err_i, icimmu_tag_i, icimmu_adr_o, icimmu_cycstb_o, icimmu_ci_o
|
);
|
);
|
|
|
parameter dw = `OR1200_OPERAND_WIDTH;
|
parameter dw = `OR1200_OPERAND_WIDTH;
|
parameter aw = `OR1200_OPERAND_WIDTH;
|
parameter aw = `OR1200_OPERAND_WIDTH;
|
|
|
Line 115... |
Line 118... |
//
|
//
|
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_cyc_i;
|
input icpu_cycstb_i;
|
input icpu_stb_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;
|
|
|
Line 138... |
Line 140... |
//
|
//
|
input icimmu_rty_i;
|
input icimmu_rty_i;
|
input icimmu_err_i;
|
input icimmu_err_i;
|
input [3:0] icimmu_tag_i;
|
input [3:0] icimmu_tag_i;
|
output [aw-1:0] icimmu_adr_o;
|
output [aw-1:0] icimmu_adr_o;
|
output icimmu_cyc_o;
|
output icimmu_cycstb_o;
|
output icimmu_stb_o;
|
|
output icimmu_ci_o;
|
output icimmu_ci_o;
|
|
|
//
|
//
|
// Internal wires and regs
|
// Internal wires and regs
|
//
|
//
|
Line 158... |
Line 159... |
wire itlb_done;
|
wire itlb_done;
|
wire fault;
|
wire fault;
|
wire miss;
|
wire miss;
|
reg [31:0] icpu_adr_o;
|
reg [31:0] icpu_adr_o;
|
reg itlb_en_r;
|
reg itlb_en_r;
|
|
reg [31:`OR1200_IMMU_PS] icpu_vpn_r;
|
|
|
//
|
//
|
// 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
|
Line 193... |
Line 195... |
// 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 icimmu_adr_o = icpu_adr_i;
|
assign icimmu_adr_o = icpu_adr_i;
|
assign icpu_tag_o = icimmu_tag_i;
|
assign icpu_tag_o = icimmu_tag_i;
|
assign icimmu_cyc_o = icpu_cyc_i;
|
assign icimmu_cycstb_o = icpu_cycstb_i;
|
assign icimmu_stb_o = icpu_stb_i;
|
|
assign icpu_rty_o = icimmu_rty_i;
|
assign icpu_rty_o = icimmu_rty_i;
|
assign icpu_err_o = icimmu_err_i;
|
assign icpu_err_o = icimmu_err_i;
|
assign icimmu_ci_o = icpu_adr_i[31];
|
assign icimmu_ci_o = `OR1200_IMMU_CI;
|
|
|
`else
|
`else
|
|
|
//
|
//
|
// ITLB SPR access
|
// ITLB SPR access
|
Line 243... |
Line 244... |
itlb_en_r <= #1 itlb_en;
|
itlb_en_r <= #1 itlb_en;
|
|
|
//
|
//
|
// Assert itlb_done one clock cycle after new address is first presented and tlb is enabled.
|
// Assert itlb_done one clock cycle after new address is first presented and tlb is enabled.
|
//
|
//
|
assign itlb_done = (icpu_adr_i == icpu_adr_o) & itlb_en_r;
|
// assign itlb_done = (icpu_adr_i == icpu_adr_o) & itlb_en_r;
|
|
assign itlb_done = itlb_en_r;
|
|
|
//
|
//
|
// Cut transfer if something goes wrong with translation. If IC is disabled,
|
// Cut transfer if something goes wrong with translation. If IC is disabled,
|
// use delayed signals.
|
// use delayed signals.
|
//
|
//
|
assign icimmu_cyc_o = (!ic_en & immu_en) ? ~(miss | fault) & itlb_done & icpu_cyc_i : (miss | fault) ? 1'b0 : icpu_cyc_i;
|
assign icimmu_cycstb_o = (!ic_en & immu_en) ? ~(miss | fault) & icpu_cycstb_i : (miss | fault) ? 1'b0 : icpu_cycstb_i;
|
assign icimmu_stb_o = (!ic_en & immu_en) ? ~(miss | fault) & itlb_done & icpu_stb_i : (miss | fault) ? 1'b0 : icpu_stb_i;
|
|
|
|
//
|
//
|
// Cache Inhibit
|
// Cache Inhibit
|
//
|
//
|
assign icimmu_ci_o = immu_en ? itlb_done & itlb_ci : icpu_adr_i[31];
|
assign icimmu_ci_o = immu_en ? itlb_done & itlb_ci : `OR1200_IMMU_CI;
|
|
|
|
//
|
|
// 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.
|
|
//
|
|
always @(posedge clk or posedge rst)
|
|
if (rst)
|
|
icpu_vpn_r <= #1 {31-`OR1200_IMMU_PS{1'b0}};
|
|
else
|
|
icpu_vpn_r <= #1 icpu_adr_i[31:`OR1200_IMMU_PS];
|
|
|
//
|
//
|
// 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 icimmu_adr_o = immu_en ? {itlb_ppn, icpu_adr_i[`OR1200_IMMU_PS-1:0]} : icpu_adr_i;
|
assign icimmu_adr_o = immu_en ? {itlb_ppn, icpu_adr_i[`OR1200_IMMU_PS-1:0]} : {icpu_vpn_r, icpu_adr_i[`OR1200_IMMU_PS-1:0]};
|
|
|
//
|
//
|
// Output to SPRS unit
|
// Output to SPRS unit
|
//
|
//
|
assign spr_dat_o = itlb_spr_access ? itlb_dat_o : 32'h00000000;
|
assign spr_dat_o = itlb_spr_access ? itlb_dat_o : 32'h00000000;
|
Line 283... |
Line 294... |
assign miss = itlb_done & !itlb_hit;
|
assign miss = itlb_done & !itlb_hit;
|
|
|
//
|
//
|
// ITLB Enable
|
// ITLB Enable
|
//
|
//
|
assign itlb_en = immu_en & icpu_cyc_i & icpu_stb_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(
|