1
0

LazyModule: provide Parameters

This tracks PR #478 in rocketchip.
This commit is contained in:
Wesley W. Terpstra 2016-12-07 13:21:20 -08:00
parent 1443834186
commit 45c491cd69
7 changed files with 27 additions and 27 deletions

View File

@ -11,9 +11,9 @@ import util.AsyncResetRegVec
case class GPIOConfig(address: BigInt, width: Int) case class GPIOConfig(address: BigInt, width: Int)
trait HasGPIOParameters { trait HasGPIOParameters {
val params: Tuple2[Parameters, GPIOConfig] implicit val p: Parameters
implicit val p = params._1 val params: GPIOConfig
val c = params._2 val c = params
} }
// YAGNI: Make the PUE, DS, and // YAGNI: Make the PUE, DS, and
@ -289,7 +289,7 @@ object GPIOInputPinCtrl {
} }
// Magic TL2 Incantation to create a TL2 Slave // Magic TL2 Incantation to create a TL2 Slave
class TLGPIO(p: Parameters, c: GPIOConfig) class TLGPIO(c: GPIOConfig)(implicit p: Parameters)
extends TLRegisterRouter(c.address, interrupts = c.width, beatBytes = p(PeripheryBusConfig).beatBytes)( extends TLRegisterRouter(c.address, interrupts = c.width, beatBytes = p(PeripheryBusConfig).beatBytes)(
new TLRegBundle(Tuple2(p, c), _) with GPIOBundle)( new TLRegBundle(c, _) with GPIOBundle)(
new TLRegModule(Tuple2(p, c), _, _) with GPIOModule) new TLRegModule(c, _, _) with GPIOModule)

View File

@ -8,7 +8,7 @@ import uncore.tilelink2.TLFragmenter
trait PeripheryGPIO { trait PeripheryGPIO {
this: TopNetwork { val gpioConfig: GPIOConfig } => this: TopNetwork { val gpioConfig: GPIOConfig } =>
val gpio = LazyModule(new TLGPIO(p, gpioConfig)) val gpio = LazyModule(new TLGPIO(gpioConfig))
gpio.node := TLFragmenter(peripheryBusConfig.beatBytes, cacheBlockBytes)(peripheryBus.node) gpio.node := TLFragmenter(peripheryBusConfig.beatBytes, cacheBlockBytes)(peripheryBus.node)
intBus.intnode := gpio.intnode intBus.intnode := gpio.intnode
} }

View File

@ -21,9 +21,9 @@ case class MockAONConfig(
} }
trait HasMockAONParameters { trait HasMockAONParameters {
val params: (MockAONConfig, Parameters) implicit val p: Parameters
val c = params._1 val params: MockAONConfig
implicit val p = params._2 val c = params
} }
class MockAONPMUIO extends Bundle { class MockAONPMUIO extends Bundle {
@ -99,7 +99,7 @@ trait MockAONModule extends Module with HasRegMap with HasMockAONParameters {
} }
class MockAON(c: MockAONConfig)(implicit val p: Parameters) class MockAON(c: MockAONConfig)(implicit p: Parameters)
extends TLRegisterRouter(c.address, interrupts = 2, size = c.size, beatBytes = p(PeripheryBusConfig).beatBytes, concurrency = 1)( extends TLRegisterRouter(c.address, interrupts = 2, size = c.size, beatBytes = p(PeripheryBusConfig).beatBytes, concurrency = 1)(
new TLRegBundle((c, p), _) with MockAONBundle)( new TLRegBundle(c, _) with MockAONBundle)(
new TLRegModule((c, p), _, _) with MockAONModule) new TLRegModule(c, _, _) with MockAONModule)

View File

@ -27,7 +27,7 @@ class MockAONWrapperBundle extends Bundle {
val rsts = new MockAONMOffRstIO() val rsts = new MockAONMOffRstIO()
} }
class MockAONWrapper(c: MockAONConfig)(implicit val p: Parameters) extends LazyModule { class MockAONWrapper(c: MockAONConfig)(implicit p: Parameters) extends LazyModule {
val node = TLAsyncInputNode() val node = TLAsyncInputNode()
val intnode = IntOutputNode() val intnode = IntOutputNode()

View File

@ -56,9 +56,9 @@ case class PWMBundleConfig(
} }
trait HasPWMParameters { trait HasPWMParameters {
val params: (PWMConfig, Parameters) implicit val p: Parameters
val c = params._1 val params: PWMConfig
implicit val p = params._2 val c = params
} }
trait PWMBundle extends Bundle with HasPWMParameters { trait PWMBundle extends Bundle with HasPWMParameters {
@ -76,7 +76,7 @@ trait PWMModule extends Module with HasRegMap with HasPWMParameters {
regmap((GenericTimer.timerRegMap(pwm, 0, c.regBytes)):_*) regmap((GenericTimer.timerRegMap(pwm, 0, c.regBytes)):_*)
} }
class TLPWM(c: PWMConfig)(implicit val p: Parameters) class TLPWM(c: PWMConfig)(implicit p: Parameters)
extends TLRegisterRouter(c.address, interrupts = c.ncmp, size = c.size, beatBytes = p(PeripheryBusConfig).beatBytes)( extends TLRegisterRouter(c.address, interrupts = c.ncmp, size = c.size, beatBytes = p(PeripheryBusConfig).beatBytes)(
new TLRegBundle((c, p), _) with PWMBundle)( new TLRegBundle(c, _) with PWMBundle)(
new TLRegModule((c, p), _, _) with PWMModule) new TLRegModule(c, _, _) with PWMModule)

View File

@ -118,7 +118,7 @@ class SPITopModule[B <: SPITopBundle](c: SPIConfigBase, bundle: => B, outer: TLS
RegField.r(1, ip.rxwm))) RegField.r(1, ip.rxwm)))
} }
abstract class TLSPIBase(c: SPIConfigBase)(implicit val p: Parameters) extends LazyModule { abstract class TLSPIBase(c: SPIConfigBase)(implicit p: Parameters) extends LazyModule {
require(isPow2(c.rSize)) require(isPow2(c.rSize))
val rnode = TLRegisterNode(address = AddressSet(c.rAddress, c.rSize-1), beatBytes = p(PeripheryBusConfig).beatBytes) val rnode = TLRegisterNode(address = AddressSet(c.rAddress, c.rSize-1), beatBytes = p(PeripheryBusConfig).beatBytes)
val intnode = IntSourceNode(1) val intnode = IntSourceNode(1)

View File

@ -46,9 +46,9 @@ class UARTPortIO extends Bundle {
} }
trait MixUARTParameters { trait MixUARTParameters {
val params: (UARTConfig, Parameters) implicit val p: Parameters
val c = params._1 val params: UARTConfig
implicit val p = params._2 val c = params
} }
trait UARTTopBundle extends Bundle with MixUARTParameters with HasUARTParameters { trait UARTTopBundle extends Bundle with MixUARTParameters with HasUARTParameters {
@ -269,7 +269,7 @@ class Majority(in: Set[Bool]) {
} }
// Magic TL2 Incantation to create a TL2 Slave // Magic TL2 Incantation to create a TL2 Slave
class UART(c: UARTConfig)(implicit val p: Parameters) class UART(c: UARTConfig)(implicit p: Parameters)
extends TLRegisterRouter(c.address, interrupts = 1, beatBytes = p(PeripheryBusConfig).beatBytes)( extends TLRegisterRouter(c.address, interrupts = 1, beatBytes = p(PeripheryBusConfig).beatBytes)(
new TLRegBundle((c, p), _) with UARTTopBundle)( new TLRegBundle(c, _) with UARTTopBundle)(
new TLRegModule((c, p), _, _) with UARTTopModule) new TLRegModule(c, _, _) with UARTTopModule)