From bda831d82bd716adc2834f1736ac380649d739f4 Mon Sep 17 00:00:00 2001 From: Mahir Abbas <74065513+MahirAbbas@users.noreply.github.com> Date: Sat, 30 Mar 2024 13:06:45 +0000 Subject: [PATCH 01/16] Create Plru.rst --- source/SpinalHDL/Libraries/Misc/Plru.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 source/SpinalHDL/Libraries/Misc/Plru.rst diff --git a/source/SpinalHDL/Libraries/Misc/Plru.rst b/source/SpinalHDL/Libraries/Misc/Plru.rst new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/source/SpinalHDL/Libraries/Misc/Plru.rst @@ -0,0 +1 @@ + From a97ae45eb4751f688d2a8d58a772a83cf1df4036 Mon Sep 17 00:00:00 2001 From: Mahir Abbas <74065513+MahirAbbas@users.noreply.github.com> Date: Sat, 30 Mar 2024 13:10:24 +0000 Subject: [PATCH 02/16] Update Plru.rst --- source/SpinalHDL/Libraries/Misc/Plru.rst | 32 ++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/source/SpinalHDL/Libraries/Misc/Plru.rst b/source/SpinalHDL/Libraries/Misc/Plru.rst index 8b137891791..89dcc4dc464 100644 --- a/source/SpinalHDL/Libraries/Misc/Plru.rst +++ b/source/SpinalHDL/Libraries/Misc/Plru.rst @@ -1 +1,33 @@ +.. role:: raw-html-m2r(raw) + :format: html + +Plru +========================== + +Introduction +-------------------- +/** + * Pseudo least recently used combinatorial logic + * io.context.state need to be handled externaly. + * When you want to specify a access to a entry, you can use the io.update interface + * to get the new state value. + */ + + +.. code-block:: scala + + class MyPlugin extends FiberPlugin { + val logic = during setup new Area { + // Here we are executing code in the setup phase + awaitBuild() + // Here we are executing code in the build phase + } + } + + class MyPlugin2 extends FiberPlugin { + val logic = during build new Area { + // Here we are executing code in the build phase + } + } + From c73c720aead08b306f3974ae1d8abbe3ab2d56e6 Mon Sep 17 00:00:00 2001 From: Mahir Abbas <74065513+MahirAbbas@users.noreply.github.com> Date: Sat, 30 Mar 2024 13:18:31 +0000 Subject: [PATCH 03/16] Update Plru.rst --- source/SpinalHDL/Libraries/Misc/Plru.rst | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/source/SpinalHDL/Libraries/Misc/Plru.rst b/source/SpinalHDL/Libraries/Misc/Plru.rst index 89dcc4dc464..bea3adbc86c 100644 --- a/source/SpinalHDL/Libraries/Misc/Plru.rst +++ b/source/SpinalHDL/Libraries/Misc/Plru.rst @@ -16,18 +16,14 @@ Introduction .. code-block:: scala - class MyPlugin extends FiberPlugin { - val logic = during setup new Area { - // Here we are executing code in the setup phase - awaitBuild() - // Here we are executing code in the build phase - } - } - - class MyPlugin2 extends FiberPlugin { - val logic = during build new Area { - // Here we are executing code in the build phase - } - } + val PLRU = Payload(Plru.State(wayCount)) + val plru = new Area { + val ram = Mem.fill(nSets)(Plru.State(wayCount)) + val write = ram.writePort + val fromLoad, fromStore = cloneOf(write) + write.valid := fromLoad.valid || fromStore.valid + write.payload := fromLoad.valid.mux(fromLoad.payload, fromStore.payload) + + } From 70aff6ddb8f209bc38c7a014048d12d067c957e4 Mon Sep 17 00:00:00 2001 From: Mahir Abbas <74065513+MahirAbbas@users.noreply.github.com> Date: Sat, 30 Mar 2024 13:19:17 +0000 Subject: [PATCH 04/16] Update Plru.rst --- source/SpinalHDL/Libraries/Misc/Plru.rst | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/source/SpinalHDL/Libraries/Misc/Plru.rst b/source/SpinalHDL/Libraries/Misc/Plru.rst index bea3adbc86c..c5570a885f3 100644 --- a/source/SpinalHDL/Libraries/Misc/Plru.rst +++ b/source/SpinalHDL/Libraries/Misc/Plru.rst @@ -16,14 +16,13 @@ Introduction .. code-block:: scala - val PLRU = Payload(Plru.State(wayCount)) - val plru = new Area { - val ram = Mem.fill(nSets)(Plru.State(wayCount)) - val write = ram.writePort - val fromLoad, fromStore = cloneOf(write) - write.valid := fromLoad.valid || fromStore.valid - write.payload := fromLoad.valid.mux(fromLoad.payload, fromStore.payload) - - } + val PLRU = Payload(Plru.State(wayCount)) + val plru = new Area { + val ram = Mem.fill(nSets)(Plru.State(wayCount)) + val write = ram.writePort + val fromLoad, fromStore = cloneOf(write) + write.valid := fromLoad.valid || fromStore.valid + write.payload := fromLoad.valid.mux(fromLoad.payload, fromStore.payload) + } From 3d56a94230d6a3b7e869a326cc4ef92c051b22d4 Mon Sep 17 00:00:00 2001 From: Mahir Abbas <74065513+MahirAbbas@users.noreply.github.com> Date: Sat, 30 Mar 2024 13:22:15 +0000 Subject: [PATCH 05/16] Update Plru.rst --- source/SpinalHDL/Libraries/Misc/Plru.rst | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/source/SpinalHDL/Libraries/Misc/Plru.rst b/source/SpinalHDL/Libraries/Misc/Plru.rst index c5570a885f3..ecb1a94bc74 100644 --- a/source/SpinalHDL/Libraries/Misc/Plru.rst +++ b/source/SpinalHDL/Libraries/Misc/Plru.rst @@ -6,12 +6,19 @@ Plru Introduction -------------------- -/** - * Pseudo least recently used combinatorial logic - * io.context.state need to be handled externaly. - * When you want to specify a access to a entry, you can use the io.update interface - * to get the new state value. - */ +Pseudo least recently used combinatorial logic +io.context.state need to be handled externaly. +When you want to specify a access to a entry, you can use the io.update interface +to get the new state value. + +Defined as + +.. code-block:: scala + + object Plru{ + def State(entries : Int) = Vec.tabulate(log2Up(entries))(l => Bits(1 << l bits)) + } + .. code-block:: scala From b3f4e3c365298c4d0fb7f5a6ac6a3d1921ce6411 Mon Sep 17 00:00:00 2001 From: Mahir Abbas <74065513+MahirAbbas@users.noreply.github.com> Date: Sat, 30 Mar 2024 13:23:57 +0000 Subject: [PATCH 06/16] Update Plru.rst --- source/SpinalHDL/Libraries/Misc/Plru.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/source/SpinalHDL/Libraries/Misc/Plru.rst b/source/SpinalHDL/Libraries/Misc/Plru.rst index ecb1a94bc74..e6e82898f57 100644 --- a/source/SpinalHDL/Libraries/Misc/Plru.rst +++ b/source/SpinalHDL/Libraries/Misc/Plru.rst @@ -20,6 +20,7 @@ Defined as } +Example usage .. code-block:: scala From 13ac081b82330a71da186fc1ade74193ebd1d63b Mon Sep 17 00:00:00 2001 From: Mahir Abbas <74065513+MahirAbbas@users.noreply.github.com> Date: Mon, 1 Apr 2024 17:30:37 +0100 Subject: [PATCH 07/16] Add Dolu Code + comments, and give simple example area of plru --- source/SpinalHDL/Libraries/Misc/Plru.rst | 34 +++++++++++++++++++----- 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/source/SpinalHDL/Libraries/Misc/Plru.rst b/source/SpinalHDL/Libraries/Misc/Plru.rst index e6e82898f57..d80f1ac4fb8 100644 --- a/source/SpinalHDL/Libraries/Misc/Plru.rst +++ b/source/SpinalHDL/Libraries/Misc/Plru.rst @@ -20,17 +20,39 @@ Defined as } -Example usage +PLRU Code + +.. code-block:: scala + + val io = new Bundle{ + val context = new Bundle{ + //user -> plru, specify the current state + val state = Plru.State(entries) + //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" + val valids = withEntriesValid generate Bits(entries bits) + } + val evict = new Bundle{ + //PLRU -> user, Tells you the least recently used entry for the given context provided above + val id = UInt(log2Up(entries) bits) + } + val update = new Bundle{ + // user -> PLRU specify which entry the user want to mark as most recently used + val id = UInt(log2Up(entries) bits) + // PLRU -> user specfy what should then be the new value of the PLRU status + val state = Plru.State(entries) + } + } + + +Example usage in a cache .. code-block:: scala - val PLRU = Payload(Plru.State(wayCount)) val plru = new Area { + // Define a Mem, to track the state of each set val ram = Mem.fill(nSets)(Plru.State(wayCount)) - val write = ram.writePort + val write = ram.writePort val fromLoad, fromStore = cloneOf(write) write.valid := fromLoad.valid || fromStore.valid - write.payload := fromLoad.valid.mux(fromLoad.payload, fromStore.payload) + write.payload := fromLoad.valid.mux(fromLoad.payload, fromStore.payload) } - - From 1b6d1f8fff0efabf345a05207fe929e723b43db6 Mon Sep 17 00:00:00 2001 From: Mahir Abbas <74065513+MahirAbbas@users.noreply.github.com> Date: Tue, 2 Apr 2024 10:35:21 +0100 Subject: [PATCH 08/16] Update Plru.rst --- source/SpinalHDL/Libraries/Misc/Plru.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/source/SpinalHDL/Libraries/Misc/Plru.rst b/source/SpinalHDL/Libraries/Misc/Plru.rst index d80f1ac4fb8..245419fd4f6 100644 --- a/source/SpinalHDL/Libraries/Misc/Plru.rst +++ b/source/SpinalHDL/Libraries/Misc/Plru.rst @@ -56,3 +56,8 @@ Example usage in a cache write.valid := fromLoad.valid || fromStore.valid write.payload := fromLoad.valid.mux(fromLoad.payload, fromStore.payload) } + + + +plru.io.evict.id tells you the id of the next block to be evicted +plru.io.update.id lets you update what you recently used From 1e6d80daa20771113c10899d9e85aea5777b7358 Mon Sep 17 00:00:00 2001 From: Mahir Abbas <74065513+MahirAbbas@users.noreply.github.com> Date: Tue, 2 Apr 2024 10:35:42 +0100 Subject: [PATCH 09/16] Update Plru.rst --- source/SpinalHDL/Libraries/Misc/Plru.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/SpinalHDL/Libraries/Misc/Plru.rst b/source/SpinalHDL/Libraries/Misc/Plru.rst index 245419fd4f6..fd3a662c64f 100644 --- a/source/SpinalHDL/Libraries/Misc/Plru.rst +++ b/source/SpinalHDL/Libraries/Misc/Plru.rst @@ -59,5 +59,5 @@ Example usage in a cache -plru.io.evict.id tells you the id of the next block to be evicted -plru.io.update.id lets you update what you recently used +- plru.io.evict.id tells you the id of the next block to be evicted +- plru.io.update.id lets you update what you recently used From 7755afabcdc0c7dbd465c1b62b1c08a65878a0f5 Mon Sep 17 00:00:00 2001 From: Mahir Abbas <74065513+MahirAbbas@users.noreply.github.com> Date: Tue, 2 Apr 2024 10:36:13 +0100 Subject: [PATCH 10/16] Update Plru.rst --- source/SpinalHDL/Libraries/Misc/Plru.rst | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/source/SpinalHDL/Libraries/Misc/Plru.rst b/source/SpinalHDL/Libraries/Misc/Plru.rst index fd3a662c64f..d14b2d6aded 100644 --- a/source/SpinalHDL/Libraries/Misc/Plru.rst +++ b/source/SpinalHDL/Libraries/Misc/Plru.rst @@ -6,10 +6,9 @@ Plru Introduction -------------------- -Pseudo least recently used combinatorial logic -io.context.state need to be handled externaly. -When you want to specify a access to a entry, you can use the io.update interface -to get the new state value. +- Pseudo least recently used combinatorial logic +- io.context.state need to be handled externaly. +- When you want to specify a access to a entry, you can use the io.update interface to get the new state value. Defined as From bb1dba53788a06de1ebc572a99766303fcc6bbb0 Mon Sep 17 00:00:00 2001 From: Mahir Abbas <74065513+MahirAbbas@users.noreply.github.com> Date: Tue, 2 Apr 2024 11:34:38 +0100 Subject: [PATCH 11/16] Update Plru.rst --- source/SpinalHDL/Libraries/Misc/Plru.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/source/SpinalHDL/Libraries/Misc/Plru.rst b/source/SpinalHDL/Libraries/Misc/Plru.rst index d14b2d6aded..60859c3256f 100644 --- a/source/SpinalHDL/Libraries/Misc/Plru.rst +++ b/source/SpinalHDL/Libraries/Misc/Plru.rst @@ -9,6 +9,8 @@ Introduction - Pseudo least recently used combinatorial logic - io.context.state need to be handled externaly. - When you want to specify a access to a entry, you can use the io.update interface to get the new state value. +- plru.io.evict.id tells you the id of the next block to be evicted +- plru.io.update.id lets you update what you recently used Defined as @@ -58,5 +60,4 @@ Example usage in a cache -- plru.io.evict.id tells you the id of the next block to be evicted -- plru.io.update.id lets you update what you recently used + From 1da54c4681b50f78e44341e45c946a6d1673e6b1 Mon Sep 17 00:00:00 2001 From: Mahir Abbas <74065513+MahirAbbas@users.noreply.github.com> Date: Tue, 2 Apr 2024 11:39:54 +0100 Subject: [PATCH 12/16] Update Plru.rst --- source/SpinalHDL/Libraries/Misc/Plru.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/source/SpinalHDL/Libraries/Misc/Plru.rst b/source/SpinalHDL/Libraries/Misc/Plru.rst index 60859c3256f..02e42a945da 100644 --- a/source/SpinalHDL/Libraries/Misc/Plru.rst +++ b/source/SpinalHDL/Libraries/Misc/Plru.rst @@ -58,6 +58,14 @@ Example usage in a cache write.payload := fromLoad.valid.mux(fromLoad.payload, fromStore.payload) } +Then you can do +.. code-block:: scala + val replacedWay = plru.io.evict.id + +And you can update recently used way +.. code-block:: scala + plru.update.id := refillWay + From 9366335eb4b1676766f2d5dee0229027b1ee86f7 Mon Sep 17 00:00:00 2001 From: Mahir Abbas <74065513+MahirAbbas@users.noreply.github.com> Date: Tue, 2 Apr 2024 11:40:30 +0100 Subject: [PATCH 13/16] Update Plru.rst --- source/SpinalHDL/Libraries/Misc/Plru.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/SpinalHDL/Libraries/Misc/Plru.rst b/source/SpinalHDL/Libraries/Misc/Plru.rst index 02e42a945da..ab5c429da31 100644 --- a/source/SpinalHDL/Libraries/Misc/Plru.rst +++ b/source/SpinalHDL/Libraries/Misc/Plru.rst @@ -59,10 +59,12 @@ Example usage in a cache } Then you can do + .. code-block:: scala val replacedWay = plru.io.evict.id And you can update recently used way + .. code-block:: scala plru.update.id := refillWay From 779a0e6256fc55a02285f10c657281bcbb79fd7a Mon Sep 17 00:00:00 2001 From: Mahir Abbas <74065513+MahirAbbas@users.noreply.github.com> Date: Tue, 2 Apr 2024 11:40:49 +0100 Subject: [PATCH 14/16] Update Plru.rst --- source/SpinalHDL/Libraries/Misc/Plru.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/SpinalHDL/Libraries/Misc/Plru.rst b/source/SpinalHDL/Libraries/Misc/Plru.rst index ab5c429da31..3ba256af259 100644 --- a/source/SpinalHDL/Libraries/Misc/Plru.rst +++ b/source/SpinalHDL/Libraries/Misc/Plru.rst @@ -61,11 +61,13 @@ Example usage in a cache Then you can do .. code-block:: scala + val replacedWay = plru.io.evict.id And you can update recently used way .. code-block:: scala + plru.update.id := refillWay From 9b252fe990b43a21d1a891541fbd7a840216cc34 Mon Sep 17 00:00:00 2001 From: Mahir Abbas <74065513+MahirAbbas@users.noreply.github.com> Date: Tue, 2 Apr 2024 11:41:43 +0100 Subject: [PATCH 15/16] Update Plru.rst --- source/SpinalHDL/Libraries/Misc/Plru.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/source/SpinalHDL/Libraries/Misc/Plru.rst b/source/SpinalHDL/Libraries/Misc/Plru.rst index 3ba256af259..f02052fddf5 100644 --- a/source/SpinalHDL/Libraries/Misc/Plru.rst +++ b/source/SpinalHDL/Libraries/Misc/Plru.rst @@ -58,13 +58,14 @@ Example usage in a cache write.payload := fromLoad.valid.mux(fromLoad.payload, fromStore.payload) } -Then you can do + +Get the ID of the way to evict from .. code-block:: scala val replacedWay = plru.io.evict.id -And you can update recently used way +Update recently used way .. code-block:: scala From 22f99809f0a51932b03c3bf91172e384c4ff2b5b Mon Sep 17 00:00:00 2001 From: Mahir Abbas <74065513+MahirAbbas@users.noreply.github.com> Date: Tue, 2 Apr 2024 11:42:04 +0100 Subject: [PATCH 16/16] Update Plru.rst --- source/SpinalHDL/Libraries/Misc/Plru.rst | 8 -------- 1 file changed, 8 deletions(-) diff --git a/source/SpinalHDL/Libraries/Misc/Plru.rst b/source/SpinalHDL/Libraries/Misc/Plru.rst index f02052fddf5..c0ff0edc72f 100644 --- a/source/SpinalHDL/Libraries/Misc/Plru.rst +++ b/source/SpinalHDL/Libraries/Misc/Plru.rst @@ -12,14 +12,6 @@ Introduction - plru.io.evict.id tells you the id of the next block to be evicted - plru.io.update.id lets you update what you recently used -Defined as - -.. code-block:: scala - - object Plru{ - def State(entries : Int) = Vec.tabulate(log2Up(entries))(l => Bits(1 << l bits)) - } - PLRU Code