1
0

get rid of duplicated code in rocket Util

This commit is contained in:
Howard Mao 2016-08-18 18:40:07 -07:00
parent 7671811ac9
commit d34e790ac0
7 changed files with 7 additions and 21 deletions

View File

@ -6,6 +6,7 @@ import Chisel._
import junctions._ import junctions._
import cde.{Parameters, Field} import cde.{Parameters, Field}
import Util._ import Util._
import uncore.util._
case object BtbKey extends Field[BtbParameters] case object BtbKey extends Field[BtbParameters]

View File

@ -7,6 +7,7 @@ import Util._
import Instructions._ import Instructions._
import cde.{Parameters, Field} import cde.{Parameters, Field}
import uncore.devices._ import uncore.devices._
import uncore.util._
import junctions.AddrMap import junctions.AddrMap
class MStatus extends Bundle { class MStatus extends Bundle {

View File

@ -7,6 +7,7 @@ import Instructions._
import Util._ import Util._
import FPConstants._ import FPConstants._
import uncore.constants.MemoryOpConstants._ import uncore.constants.MemoryOpConstants._
import uncore.util._
import cde.{Parameters, Field} import cde.{Parameters, Field}
case object SFMALatency extends Field[Int] case object SFMALatency extends Field[Int]

View File

@ -6,6 +6,7 @@ import Chisel._
import uncore.agents._ import uncore.agents._
import uncore.constants._ import uncore.constants._
import Util._ import Util._
import uncore.util._
import cde.{Parameters, Field} import cde.{Parameters, Field}
class PTWReq(implicit p: Parameters) extends CoreBundle()(p) { class PTWReq(implicit p: Parameters) extends CoreBundle()(p) {

View File

@ -4,6 +4,7 @@ import Chisel._
import Chisel.ImplicitConversions._ import Chisel.ImplicitConversions._
import Util._ import Util._
import cde.Parameters import cde.Parameters
import uncore.util._
class ExpandedInstruction extends Bundle { class ExpandedInstruction extends Bundle {
val bits = UInt(width = 32) val bits = UInt(width = 32)

View File

@ -9,6 +9,7 @@ import scala.math._
import cde.{Parameters, Field} import cde.{Parameters, Field}
import uncore.agents.PseudoLRU import uncore.agents.PseudoLRU
import uncore.coherence._ import uncore.coherence._
import uncore.util._
case object NTLBEntries extends Field[Int] case object NTLBEntries extends Field[Int]

View File

@ -3,7 +3,7 @@
package rocket package rocket
import Chisel._ import Chisel._
import uncore._ import uncore.util._
import scala.math._ import scala.math._
import cde.{Parameters, Field} import cde.{Parameters, Field}
@ -29,26 +29,6 @@ object Util {
implicit def booleanToIntConv(x: Boolean) = new AnyRef { implicit def booleanToIntConv(x: Boolean) = new AnyRef {
def toInt: Int = if (x) 1 else 0 def toInt: Int = if (x) 1 else 0
} }
implicit class SeqToAugmentedSeq[T <: Data](val x: Seq[T]) extends AnyVal {
def apply(idx: UInt): T = {
if (x.size == 1) {
x.head
} else {
val half = 1 << (log2Ceil(x.size) - 1)
val newIdx = idx & (half - 1)
Mux(idx >= UInt(half), x.drop(half)(newIdx), x.take(half)(newIdx))
}
}
def asUInt(): UInt = Cat(x.map(_.asUInt).reverse)
}
implicit class UIntIsOneOf(val x: UInt) extends AnyVal {
def isOneOf(s: Seq[UInt]): Bool = s.map(x === _).reduce(_||_)
def isOneOf(u1: UInt, u2: UInt*): Bool = isOneOf(u1 +: u2.toSeq)
}
} }
import Util._ import Util._