VexRiscv icon indicating copy to clipboard operation
VexRiscv copied to clipboard

Provide MMU / MemoryTranslatorPlugin example

Open xobs opened this issue 6 years ago • 5 comments

VexRiscv implements a simple MMU. This MMU is effective, but nonstandard, and requires extended instructions to do refilling.

Would it be possible to give a simple example of how to use it? For example, how would mappings be added and removed in order to create a simple context switch for a protected memory operating system?

xobs avatar Mar 16 '19 14:03 xobs

The instruction are : def TLBW0 = M"0000000----------111-----0001111" def TLBW1 = M"0000001----------111-----0001111"

For instance, those 5 line : https://github.com/Dolu1990/pinsecSoftware/blob/VexRiscv/tests/mmu/src/crt.S#L121 Will map the virtual address 0xC2000000 to 0x20000000 in execute read write mode without user rights via the second shared TLB entry

The mapping of the instructions into the shared TLB is done there : https://github.com/SpinalHDL/VexRiscv/blob/master/src/main/scala/vexriscv/plugin/MemoryTranslatorPlugin.scala#L137

The number of shared TLB entry is defined by the plugin arguments.

Let's me know if something isn't clear :)

Also, i'm currently implementing a hardware refilled MMU : https://github.com/SpinalHDL/VexRiscv/issues/60#issuecomment-473652087

Dolu1990 avatar Mar 17 '19 22:03 Dolu1990

In the Linux branch, there is a Linux config in the demo folder, cacheless iBus dBus with self refilled MMU. It pass all my tests, the debug interface is broken at the moment. Maybe it would be better than using the self refilled MMU for your use case ? In that branch, i also fixed, and bring back many fixes from daveshah1 and kgugala. In medium term, it will be merged back into master.

Dolu1990 avatar Mar 23 '19 20:03 Dolu1990

Self-refilled should be fine, whichever has the lower gate count is preferable.

xobs avatar Mar 24 '19 08:03 xobs

The overhead should't be high, about 100-150 lut max for the same sizeof associative iTLB dTLB cache, but it can even turn into a area gain, because you can probably reduce the size of the associative iTLB dTLB cache (self refilling is fast :D)

Dolu1990 avatar Mar 24 '19 09:03 Dolu1990

@xobs Hi, How things are going ? Did you tried the self refilled MMU ?

Dolu1990 avatar May 25 '19 14:05 Dolu1990