Skip to content

Commit

Permalink
Merge pull request chipsalliance#2152 from chipsalliance/has-amba-con…
Browse files Browse the repository at this point in the history
…trol-reg-map

AMBA: HasAHBControlRegMap and HasAPBControlRegMap
  • Loading branch information
hcook authored Oct 18, 2019
2 parents 1ff0e27 + 9ac50e6 commit 7f87a76
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/main/scala/amba/ahb/RegisterRouter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,17 @@ class AHBRegisterRouter[B <: AHBRegBundleBase, M <: LazyModuleImp]

lazy val module = moduleBuilder(bundleBuilder(AHBRegBundleArg()), this)
}

/** Mix this trait into a RegisterRouter to be able to attach its register map to an AXI4 bus */
trait HasAHBControlRegMap { this: RegisterRouter[_] =>
// Externally, this node should be used to connect the register control port to a bus
val controlNode = AHBRegisterNode(
address = address.head,
concurrency = concurrency,
beatBytes = beatBytes,
undefZero = undefZero,
executable = executable)

// Internally, this function should be used to populate the control port with registers
protected def regmap(mapping: RegField.Map*) { controlNode.regmap(mapping:_*) }
}
14 changes: 14 additions & 0 deletions src/main/scala/amba/apb/RegisterRouter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,17 @@ class APBRegisterRouter[B <: APBRegBundleBase, M <: LazyModuleImp]

lazy val module = moduleBuilder(bundleBuilder(APBRegBundleArg()), this)
}

/** Mix this trait into a RegisterRouter to be able to attach its register map to an AXI4 bus */
trait HasAPBControlRegMap { this: RegisterRouter[_] =>
// Externally, this node should be used to connect the register control port to a bus
val controlNode = APBRegisterNode(
address = address.head,
concurrency = concurrency,
beatBytes = beatBytes,
undefZero = undefZero,
executable = executable)

// Internally, this function should be used to populate the control port with registers
protected def regmap(mapping: RegField.Map*) { controlNode.regmap(mapping:_*) }
}

0 comments on commit 7f87a76

Please sign in to comment.