Skip to content

Commit aad21ed

Browse files
committedJun 12, 2012
Add support for ITLB miss generating page fault
1 parent fdfe002 commit aad21ed

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed
 

‎lm32_cpu.v

+7-4
Original file line numberDiff line numberDiff line change
@@ -780,6 +780,7 @@ reg ext_break_r;
780780

781781
`ifdef CFG_MMU_ENABLED
782782
wire dtlb_miss_exception;
783+
wire itlb_miss_exception;
783784
`endif
784785

785786
/////////////////////////////////////////////////////
@@ -1791,7 +1792,7 @@ assign non_debug_exception_x = (system_call_exception == `TRUE)
17911792
)
17921793
`endif
17931794
`ifdef CFG_MMU_ENABLED
1794-
|| (dtlb_miss_exception == `TRUE)
1795+
|| (dtlb_miss_exception == `TRUE || itlb_miss_exception == `TRUE)
17951796
`endif
17961797
;
17971798

@@ -1817,7 +1818,7 @@ assign exception_x = (system_call_exception == `TRUE)
18171818
)
18181819
`endif
18191820
`ifdef CFG_MMU_ENABLED
1820-
|| (dtlb_miss_exception == `TRUE)
1821+
|| (dtlb_miss_exception == `TRUE || itlb_miss_exception == `TRUE)
18211822
`endif
18221823
;
18231824
`endif
@@ -1868,8 +1869,10 @@ begin
18681869
else
18691870
`endif
18701871
`ifdef CFG_MMU_ENABLED
1871-
if (dtlb_miss_exception == `TRUE )
1872+
if (dtlb_miss_exception == `TRUE)
18721873
eid_x = `LM32_EID_DTLB_MISS;
1874+
else if (itlb_miss_exception == `TRUE)
1875+
eid_x = `LM32_EID_ITLB_MISS;
18731876
else
18741877
`endif
18751878
eid_x = `LM32_EID_SCALL;
@@ -2166,7 +2169,7 @@ begin
21662169
`endif
21672170
`LM32_CSR_CFG2: csr_read_data_x = cfg2;
21682171
`LM32_CSR_TLB_VADDRESS: csr_read_data_x = load_store_csr_read_data_x;
2169-
2172+
`LM32_CSR_TLB_PADDRESS: csr_read_data_x = instruction_csr_read_data_x;
21702173
default: csr_read_data_x = {`LM32_WORD_WIDTH{1'bx}};
21712174
endcase
21722175
end

‎lm32_icache.v

+4-4
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ reg itlb_flushing;
316316
reg [addr_itlb_index_width-1:0] itlb_flush_set;
317317
wire itlb_miss;
318318
reg itlb_miss_q = `FALSE;
319-
reg [`LM32_WORD_RNG] itlb_miss_addr;
319+
reg [`LM32_PC_RNG] itlb_miss_addr;
320320
wire itlb_data_valid;
321321
wire [`LM32_ITLB_LOOKUP_RANGE] itlb_lookup;
322322
reg go_to_user_mode;
@@ -673,7 +673,7 @@ assign kernel_mode = kernel_mode_reg;
673673
assign switch_to_kernel_mode = (/*(kernel_mode_reg == `LM32_KERNEL_MODE) && */csr_write_enable && (csr == `LM32_CSR_TLB_CTRL) && csr_write_data[5:0] == {`LM32_TLB_CTRL_SWITCH_TO_KERNEL_MODE, 1'b0});
674674
assign switch_to_user_mode = (/*(kernel_mode_reg == `LM32_KERNEL_MODE) && */csr_write_enable && (csr == `LM32_CSR_TLB_CTRL) && csr_write_data[5:0] == {`LM32_TLB_CTRL_SWITCH_TO_USER_MODE, 1'b0});
675675

676-
assign csr_read_data = itlb_miss_addr;
676+
assign csr_read_data = {itlb_miss_addr, 2'b0};
677677
assign itlb_miss = (kernel_mode_reg == `LM32_USER_MODE) && (read_enable_f) && ~(itlb_data_valid);
678678
assign itlb_miss_int = (itlb_miss || itlb_miss_q);
679679
assign itlb_read_tag = itlb_read_data[`LM32_ITLB_TAG_RANGE];
@@ -765,7 +765,7 @@ begin
765765
itlb_flush_set <= {addr_itlb_index_width{1'b1}};
766766
itlb_state <= `LM32_TLB_STATE_FLUSH;
767767
itlb_updating <= 0;
768-
itlb_miss_addr <= `LM32_WORD_WIDTH'd0;
768+
itlb_miss_addr <= {`LM32_PC_WIDTH{1'b0}};
769769
end
770770
else
771771
begin
@@ -778,7 +778,7 @@ begin
778778
if (itlb_miss == `TRUE)
779779
begin
780780
itlb_miss_addr <= address_f;
781-
$display("WARNING : ITLB MISS on addr 0x%08X at time %t", address_f, $time);
781+
$display("WARNING : ITLB MISS on addr 0x%08X at time %t", address_f * 4, $time);
782782
end
783783
if (csr_write_enable && ~csr_write_data[0])
784784
begin

‎lm32_include.v

+1
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,7 @@
318318
`define LM32_EID_INTERRUPT `LM32_EID_WIDTH'h6
319319
`define LM32_EID_SCALL `LM32_EID_WIDTH'h7
320320
`define LM32_EID_DTLB_MISS `LM32_EID_WIDTH'h8
321+
`define LM32_EID_ITLB_MISS `LM32_EID_WIDTH'h9
321322

322323
// Pipeline result selection mux controls
323324

0 commit comments

Comments
 (0)
Please sign in to comment.