Skip to content

Commit

Permalink
Merge pull request chipsalliance#260 from ucb-bar/w1ToClear
Browse files Browse the repository at this point in the history
W1 to clear
  • Loading branch information
hcook authored Sep 8, 2016
2 parents 9bfd8c1 + 60a503d commit a44fff5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/main/scala/uncore/tilelink2/Bundles.scala
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ final class TLBundleD(params: TLBundleParameters)
final class TLBundleE(params: TLBundleParameters)
extends TLBundleBase(params) with TLChannel
{
val sink = UInt(width = params.sourceBits) // to
val sink = UInt(width = params.sinkBits) // to
}

class TLBundle(params: TLBundleParameters) extends TLBundleBase(params)
Expand Down
12 changes: 9 additions & 3 deletions src/main/scala/uncore/tilelink2/RegField.scala
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ object RegWriteFn
})
// write to a DecoupledIO (only safe if there is a consistent sink draining data)
implicit def apply(x: DecoupledIO[UInt]): RegWriteFn = RegWriteFn((valid, data) => { x.valid := valid; x.bits := data; x.ready })
// updates a register
// updates a register (or adds a mux to a wire)
implicit def apply(x: UInt): RegWriteFn = RegWriteFn((valid, data) => { when (valid) { x := data }; Bool(true) })
// noop
implicit def apply(x: Unit): RegWriteFn = RegWriteFn((valid, data) => { Bool(true) })
Expand All @@ -73,8 +73,14 @@ object RegField
type Map = (Int, Seq[RegField])
def apply(n: Int) : RegField = apply(n, (), ())
def apply(n: Int, rw: UInt) : RegField = apply(n, rw, rw)
def R(n: Int, r: RegReadFn) : RegField = apply(n, r, ())
def W(n: Int, w: RegWriteFn) : RegField = apply(n, (), w)
def r(n: Int, r: RegReadFn) : RegField = apply(n, r, ())
def w(n: Int, w: RegWriteFn) : RegField = apply(n, (), w)

// This RegField allows 'set' to set bits in 'reg'.
// and to clear bits when the bus writes bits of value 1.
// Setting takes priority over clearing.
def w1ToClear(n: Int, reg: UInt, set: UInt): RegField =
RegField(n, reg, RegWriteFn((valid, data) => { reg := ~(~reg | Mux(valid, data, UInt(0))) | set; Bool(true) }))
}

trait HasRegMap
Expand Down

0 comments on commit a44fff5

Please sign in to comment.