Reduces LUT needed by mul extension
This commit is contained in:
15
src/main/scala/projet/Utils.scala
Normal file
15
src/main/scala/projet/Utils.scala
Normal file
@@ -0,0 +1,15 @@
|
||||
package projet
|
||||
|
||||
import chisel3._
|
||||
|
||||
object Utils {
|
||||
def two_complement(x: UInt, word_sized: Bool = false.B): UInt = {
|
||||
val result = Wire(UInt(64.W))
|
||||
when(word_sized) {
|
||||
result := "xFFFFFFFF".U - x + 1.U
|
||||
}.otherwise {
|
||||
result := "xFFFFFFFFFFFFFFFF".U - x + 1.U
|
||||
}
|
||||
result
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user