You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: source/SpinalHDL/Libraries/Misc/Plru.rst
+29-18Lines changed: 29 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,38 +6,49 @@ Plru
6
6
7
7
Introduction
8
8
------------
9
-
- Pseudo least recently used combinatorial logic
10
-
- io.context.state need to be handled externally.
11
-
- When you want to specify a access to a entry, you can use the io.update interface to get the new state value.
12
-
- plru.io.evict.id tells you the id of the next block to be evicted
13
-
- plru.io.update.id lets you update what you recently used
14
9
10
+
The `Pseudo Least Recently Used <https://en.wikipedia.org/wiki/Pseudo-LRU>`_
11
+
algorithm can be used for example in cache to select efficiently a line
12
+
for eviction.
15
13
16
-
PLRU Code
14
+
It is used for example `in the VexiiRiscV core <https://github.com/SpinalHDL/VexiiRiscv/blob/3cff1cc2411ca97e6ee9ef64414ef274d30371e1/src/main/scala/vexiiriscv/execute/lsu/LsuL1Plugin.scala#L830>`_
15
+
or in `spinal.lib.bus.tilelink.coherent.Cache <https://github.com/SpinalHDL/SpinalHDL/blob/78f29dc66110fc099a777992b6daa2f803ab445e/lib/src/main/scala/spinal/lib/bus/tilelink/coherent/Cache.scala#L1026>`_.
16
+
17
+
- ``io.context.state`` need to be handled externally.
18
+
- When you want to specify a access to a entry, you can use the ``io.update``
19
+
interface to get the new state value.
20
+
- ``plru.io.evict.id`` tells you the id of the next block to be evicted
21
+
- ``plru.io.update.id`` lets you update what you recently used
22
+
23
+
24
+
PLRU Code:
17
25
18
26
.. code-block:: scala
19
27
20
-
val io = new Bundle{
21
-
val context = new Bundle{
22
-
//user -> plru, specify the current state
28
+
val io = new Bundle{
29
+
val context = new Bundle{
30
+
//user -> plru, specify the current state
23
31
val state = Plru.State(entries)
24
-
//user -> plru, allow to specify prefered entries to remove. each bit set mean : "i would prefer that way to not to be selected by PLRU"
32
+
// user -> plru, allow to specify preferred entries to remove. Each bit
33
+
// set mean : "i would prefer that way to not to be selected by PLRU"
25
34
val valids = withEntriesValid generate Bits(entries bits)
26
35
}
27
-
val evict = new Bundle{
28
-
//PLRU -> user, Tells you the least recently used entry for the given context provided above
36
+
val evict = new Bundle {
37
+
// PLRU -> user, Tells you the least recently used entry for the
38
+
// given context provided above
29
39
val id = UInt(log2Up(entries) bits)
30
40
}
31
-
val update = new Bundle{
32
-
// user -> PLRU specify which entry the user want to mark as most recently used
41
+
val update = new Bundle {
42
+
// user -> PLRU specify which entry the user want to mark as
43
+
// most recently used
33
44
val id = UInt(log2Up(entries) bits)
34
-
// PLRU -> user specfy what should then be the new value of the PLRU status
45
+
// PLRU -> user specfy what should then be the new value of the PLRU status
0 commit comments