forked from OpenXiangShan/XiangShan
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into icache-missqueue
- Loading branch information
Showing
50 changed files
with
1,639 additions
and
337 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,12 @@ | ||
[submodule "rocket-chip"] | ||
path = rocket-chip | ||
url = https://github.com/chipsalliance/rocket-chip.git | ||
branch = 2bdb03dbca3f77ad4c378cc1b95ab4961bc1448a | ||
branch = d6bd3c61993637c3f10544c59e861fae8af29f39 | ||
[submodule "block-inclusivecache-sifive"] | ||
path = block-inclusivecache-sifive | ||
url = https://github.com/sifive/block-inclusivecache-sifive.git | ||
branch = d4db623ff534f775ffc49f59c4a9ef24d5d759d0 | ||
url = https://github.com/RISCVERS/block-inclusivecache-sifive.git | ||
branch = 5491dcc937ed3c6f7722bef9db448653daab75e8 | ||
[submodule "chiseltest"] | ||
path = chiseltest | ||
url = https://github.com/ucb-bar/chisel-testers2.git | ||
branch = 3e3ecc5b25b7b6bc48341ec07c7a54b7ad53bcb7 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule block-inclusivecache-sifive
updated
from d4db62 to 5ca433
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule chiseltest
added at
3e3ecc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule rocket-chip
updated
241 files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package utils | ||
|
||
import chisel3._ | ||
import chisel3.util._ | ||
|
||
class CircularQueuePtr(val entries: Int) extends Bundle { | ||
val PTR_WIDTH = log2Up(entries) | ||
|
||
val flag = Bool() | ||
val value = UInt(PTR_WIDTH.W) | ||
|
||
override def toPrintable: Printable = { | ||
p"$flag:$value" | ||
} | ||
} | ||
|
||
trait HasCircularQueuePtrHelper { | ||
|
||
implicit class QueuePtrHelper[T <: CircularQueuePtr](ptr: T) { | ||
|
||
final def +(v: UInt): T = { | ||
val entries = ptr.entries | ||
val new_ptr = Wire(ptr.cloneType) | ||
if(isPow2(entries)){ | ||
new_ptr := (Cat(ptr.flag, ptr.value) + v).asTypeOf(new_ptr) | ||
} else { | ||
val new_value = ptr.value +& v | ||
val diff = Cat(0.U(1.W), new_value).asSInt() - Cat(0.U(1.W), entries.U.asTypeOf(new_value)).asSInt() | ||
val reverse_flag = diff >= 0.S | ||
new_ptr.flag := Mux(reverse_flag, !ptr.flag, ptr.flag) | ||
new_ptr.value := Mux(reverse_flag, | ||
diff.asUInt(), | ||
new_value | ||
) | ||
} | ||
new_ptr | ||
} | ||
|
||
final def -(v: UInt): T = { | ||
val flipped_new_ptr = ptr + (ptr.entries.U - v) | ||
val new_ptr = Wire(ptr.cloneType) | ||
new_ptr.flag := !flipped_new_ptr.flag | ||
new_ptr.value := flipped_new_ptr.value | ||
new_ptr | ||
} | ||
|
||
final def === (that_ptr: T): Bool = ptr.asUInt()===that_ptr.asUInt() | ||
} | ||
|
||
|
||
def isEmpty[T <: CircularQueuePtr](enq_ptr: T, deq_ptr: T): Bool = { | ||
enq_ptr === deq_ptr | ||
} | ||
|
||
def isFull[T <: CircularQueuePtr](enq_ptr: T, deq_ptr: T): Bool = { | ||
(enq_ptr.flag =/= deq_ptr.flag) && (enq_ptr.value === deq_ptr.value) | ||
} | ||
|
||
def distanceBetween[T <: CircularQueuePtr](enq_ptr: T, deq_ptr: T): UInt = { | ||
assert(enq_ptr.entries == deq_ptr.entries) | ||
Mux(enq_ptr.flag === deq_ptr.flag, | ||
enq_ptr.value - deq_ptr.value, | ||
enq_ptr.entries.U + enq_ptr.value - deq_ptr.value) | ||
} | ||
|
||
def isAfter[T <: CircularQueuePtr](left: T, right: T): Bool = { | ||
Mux(left.flag === right.flag, left.value > right.value, left.value < right.value) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.