33#ifndef _RISCV_MMU_H
44#define _RISCV_MMU_H
55
6+ #include " bloom_filter.h"
67#include " decode.h"
78#include " trap.h"
89#include " common.h"
@@ -42,7 +43,6 @@ struct insn_fetch_t
4243
4344struct icache_entry_t {
4445 reg_t tag;
45- struct icache_entry_t * next;
4646 insn_fetch_t data;
4747};
4848
@@ -292,7 +292,7 @@ class mmu_t
292292 return have_reservation;
293293 }
294294
295- static const reg_t ICACHE_ENTRIES = 1024 ;
295+ static const reg_t ICACHE_ENTRIES = 4096 ;
296296
297297 inline size_t icache_index (reg_t addr)
298298 {
@@ -312,26 +312,15 @@ class mmu_t
312312 inline icache_entry_t * refill_icache (reg_t addr, icache_entry_t * entry)
313313 {
314314 insn_bits_t insn = fetch_insn_parcel (addr);
315+ unsigned length = insn_length (insn);
315316
316- int length = insn_length (insn);
317-
318- if (likely (length == 4 )) {
319- insn |= (insn_bits_t )fetch_insn_parcel (addr + 2 ) << 16 ;
320- } else if (length == 2 ) {
321- // entire instruction already fetched
322- } else if (length == 6 ) {
323- insn |= (insn_bits_t )fetch_insn_parcel (addr + 2 ) << 16 ;
324- insn |= (insn_bits_t )fetch_insn_parcel (addr + 4 ) << 32 ;
325- } else {
326- static_assert (sizeof (insn_bits_t ) == 8 , " insn_bits_t must be uint64_t" );
327- insn |= (insn_bits_t )fetch_insn_parcel (addr + 2 ) << 16 ;
328- insn |= (insn_bits_t )fetch_insn_parcel (addr + 4 ) << 32 ;
329- insn |= (insn_bits_t )fetch_insn_parcel (addr + 6 ) << 48 ;
317+ for (unsigned pos = sizeof (insn_parcel_t ); pos < length; pos += sizeof (insn_parcel_t )) {
318+ insn |= fetch_insn_parcel (addr + pos) << (8 * pos);
319+ length = insn_length (insn);
330320 }
331321
332322 insn_fetch_t fetch = {proc->decode_insn (insn), insn};
333323 entry->tag = addr;
334- entry->next = &icache[icache_index (addr + length)];
335324 entry->data = fetch;
336325
337326 auto [check_tracer, _, paddr] = access_tlb (tlb_insn, addr, TLB_FLAGS, TLB_CHECK_TRACER);
@@ -419,6 +408,14 @@ class mmu_t
419408 dtlb_entry_t tlb_store[TLB_ENTRIES];
420409 dtlb_entry_t tlb_insn[TLB_ENTRIES];
421410
411+ typedef bloom_filter_t <reg_t , simple_hash1, simple_hash2, TLB_ENTRIES * 16 , 3 > reverse_tags_t ;
412+ reverse_tags_t tlb_store_reverse_tags;
413+ reverse_tags_t tlb_insn_reverse_tags;
414+
415+ bool flush_tlb_ppn (reg_t ppn, dtlb_entry_t * tlb, reverse_tags_t & filter);
416+ void flush_itlb_ppn (reg_t ppn);
417+ void flush_stlb_ppn (reg_t ppn);
418+
422419 // finish translation on a TLB miss and update the TLB
423420 tlb_entry_t refill_tlb (reg_t vaddr, reg_t paddr, char * host_addr, access_type type);
424421 const char * fill_from_mmio (reg_t vaddr, reg_t paddr);
0 commit comments