Skip to content

Commit b83dea3

Browse files
authored
Merge pull request #303 from SpinalHDL/improve-plru
Improve Plru doc and add it the the index
2 parents 721c016 + 02cbe5c commit b83dea3

2 files changed

Lines changed: 30 additions & 18 deletions

File tree

source/SpinalHDL/Libraries/Misc/Plru.rst

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,38 +6,49 @@ Plru
66

77
Introduction
88
------------
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
149

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.
1513

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:
1725

1826
.. code-block:: scala
1927
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
2331
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"
2534
val valids = withEntriesValid generate Bits(entries bits)
2635
}
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
2939
val id = UInt(log2Up(entries) bits)
3040
}
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
3344
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
3546
val state = Plru.State(entries)
3647
}
3748
}
3849
3950
40-
Example usage in a cache
51+
Example usage in a cache:
4152

4253
.. code-block:: scala
4354
@@ -51,13 +62,13 @@ Example usage in a cache
5162
}
5263
5364
54-
Get the ID of the way to evict from
65+
Get the ID of the way to evict from:
5566

5667
.. code-block:: scala
5768
5869
val replacedWay = plru.io.evict.id
5970
60-
Update recently used way
71+
Update recently used way:
6172

6273
.. code-block:: scala
6374

source/SpinalHDL/Libraries/Misc/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ Misc
77

88
*/*
99
service_plugin
10+
Plru

0 commit comments

Comments
 (0)