1
0

Better foldR

This commit is contained in:
Henry Cook 2012-02-25 15:27:09 -08:00
parent df97de0fd3
commit db6d480778
2 changed files with 18 additions and 15 deletions

View File

@ -18,41 +18,43 @@ class MemData extends Bundle {
} }
class TransactionInit extends Bundle { class TransactionInit extends Bundle {
val ttype = Bits(width = TTYPE_BITS) val t_type = Bits(width = TTYPE_BITS)
val tileTransactionID = Bits(width = TILE_XACT_ID_BITS) val has_data = Bool()
val tile_xact_id = Bits(width = TILE_XACT_ID_BITS)
val address = Bits(width = PADDR_BITS) val address = Bits(width = PADDR_BITS)
} }
class TransactionInitData extends MemData class TransactionInitData extends MemData
class TransactionAbort extends Bundle { class TransactionAbort extends Bundle {
val tileTransactionID = Bits(width = TILE_XACT_ID_BITS) val tile_xact_id = Bits(width = TILE_XACT_ID_BITS)
} }
class ProbeRequest extends Bundle { class ProbeRequest extends Bundle {
val ptype = Bits(width = PTYPE_BITS) val p_type = Bits(width = PTYPE_BITS)
val globalTransactionID = Bits(width = GLOBAL_XACT_ID_BITS) val global_xact_id = Bits(width = GLOBAL_XACT_ID_BITS)
val address = Bits(width = PADDR_BITS) val address = Bits(width = PADDR_BITS)
} }
class ProbeReply extends Bundle { class ProbeReply extends Bundle {
val ptype = Bits(width = PTYPE_BITS) val p_type = Bits(width = PTYPE_BITS)
val hasData = Bool() val has_data = Bool()
val globalTransactionID = Bits(width = GLOBAL_XACT_ID_BITS) val global_xact_id = Bits(width = GLOBAL_XACT_ID_BITS)
} }
class ProbeReplyData extends MemData class ProbeReplyData extends MemData
class TransactionReply extends Bundle { class TransactionReply extends Bundle {
val ttype = Bits(width = TTYPE_BITS) val t_type = Bits(width = TTYPE_BITS)
val tileTransactionID = Bits(width = TILE_XACT_ID_BITS) val has_data = Bool()
val globalTransactionID = Bits(width = GLOBAL_XACT_ID_BITS) val tile_xact_id = Bits(width = TILE_XACT_ID_BITS)
val global_xact_id = Bits(width = GLOBAL_XACT_ID_BITS)
} }
class TransactionReplyData extends MemData class TransactionReplyData extends MemData
class TransactionFinish extends Bundle { class TransactionFinish extends Bundle {
val globalTransactionID = Bits(width = GLOBAL_XACT_ID_BITS) val global_xact_id = Bits(width = GLOBAL_XACT_ID_BITS)
} }
class ioTileLink extends Bundle { class ioTileLink extends Bundle {
@ -142,7 +144,7 @@ trait FourStateCoherence extends CoherencePolicy {
def getMetaUpdateOnProbe (incoming: ProbeRequest): Bits = { def getMetaUpdateOnProbe (incoming: ProbeRequest): Bits = {
val state = UFix(0) val state = UFix(0)
switch(incoming.ptype) { switch(incoming.p_type) {
is(probeInvalidate) { state := tileInvalid } is(probeInvalidate) { state := tileInvalid }
is(probeDowngrade) { state := tileShared } is(probeDowngrade) { state := tileShared }
} }

View File

@ -5,10 +5,11 @@ import Chisel._
import Node._ import Node._
import scala.math._ import scala.math._
object foldR object foldR
{ {
def apply[T <: Bits](x: Seq[T], f: (T, T) => T): T = def apply[T <: Bits](x: Seq[T])(f: (T, T) => T): T =
if (x.length == 1) x(0) else f(x(0), foldR(x.slice(1, x.length), f)) if (x.length == 1) x(0) else f(x(0), foldR(x.slice(1, x.length))(f))
} }
object log2up object log2up