separate PWM and basic example into separate packages
This commit is contained in:
@@ -1,27 +0,0 @@
|
|||||||
package example
|
|
||||||
|
|
||||||
import cde.{Parameters, Config, CDEMatchError}
|
|
||||||
import testchipip.WithSerialAdapter
|
|
||||||
import chisel3._
|
|
||||||
import diplomacy.LazyModule
|
|
||||||
|
|
||||||
class WithExampleTop extends Config(
|
|
||||||
(pname, site, here) => pname match {
|
|
||||||
case BuildExampleTop => (p: Parameters) => LazyModule(new ExampleTop(p))
|
|
||||||
case _ => throw new CDEMatchError
|
|
||||||
})
|
|
||||||
|
|
||||||
class WithPWM extends Config(
|
|
||||||
(pname, site, here) => pname match {
|
|
||||||
case BuildExampleTop => (p: Parameters) => LazyModule(new ExampleTopWithPWM(p))
|
|
||||||
case _ => throw new CDEMatchError
|
|
||||||
})
|
|
||||||
|
|
||||||
class SerialAdapterConfig extends Config(
|
|
||||||
new WithSerialAdapter ++ new rocketchip.BaseConfig)
|
|
||||||
|
|
||||||
class DefaultExampleConfig extends Config(
|
|
||||||
new WithExampleTop ++ new SerialAdapterConfig)
|
|
||||||
|
|
||||||
class PWMExampleConfig extends Config(
|
|
||||||
new WithPWM ++ new SerialAdapterConfig)
|
|
||||||
7
src/main/scala/example/Configs.scala
Normal file
7
src/main/scala/example/Configs.scala
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
package example
|
||||||
|
|
||||||
|
import cde.{Parameters, Config, CDEMatchError}
|
||||||
|
import testchipip.WithSerialAdapter
|
||||||
|
|
||||||
|
class DefaultExampleConfig extends Config(
|
||||||
|
new WithSerialAdapter ++ new rocketchip.BaseConfig)
|
||||||
@@ -5,9 +5,7 @@ import diplomacy.LazyModule
|
|||||||
import rocketchip._
|
import rocketchip._
|
||||||
import testchipip._
|
import testchipip._
|
||||||
import chisel3._
|
import chisel3._
|
||||||
import cde.{Parameters, Field}
|
import cde.Parameters
|
||||||
|
|
||||||
case object BuildExampleTop extends Field[Parameters => ExampleTop]
|
|
||||||
|
|
||||||
class TestHarness(implicit val p: Parameters) extends Module {
|
class TestHarness(implicit val p: Parameters) extends Module {
|
||||||
val io = new Bundle {
|
val io = new Bundle {
|
||||||
@@ -16,7 +14,7 @@ class TestHarness(implicit val p: Parameters) extends Module {
|
|||||||
|
|
||||||
def buildTop(p: Parameters): ExampleTop = LazyModule(new ExampleTop(p))
|
def buildTop(p: Parameters): ExampleTop = LazyModule(new ExampleTop(p))
|
||||||
|
|
||||||
val dut = p(BuildExampleTop)(p).module
|
val dut = buildTop(p).module
|
||||||
val ser = Module(new SimSerialWrapper(p(SerialInterfaceWidth)))
|
val ser = Module(new SimSerialWrapper(p(SerialInterfaceWidth)))
|
||||||
|
|
||||||
val nMemChannels = dut.io.mem_axi.size
|
val nMemChannels = dut.io.mem_axi.size
|
||||||
@@ -2,7 +2,6 @@ package example
|
|||||||
|
|
||||||
import chisel3._
|
import chisel3._
|
||||||
import cde.Parameters
|
import cde.Parameters
|
||||||
import diplomacy.LazyModule
|
|
||||||
import testchipip._
|
import testchipip._
|
||||||
import rocketchip._
|
import rocketchip._
|
||||||
|
|
||||||
@@ -22,15 +21,3 @@ class ExampleTopModule[+L <: ExampleTop, +B <: ExampleTopBundle](p: Parameters,
|
|||||||
with PeripheryBootROMModule with PeripheryCoreplexLocalInterrupterModule
|
with PeripheryBootROMModule with PeripheryCoreplexLocalInterrupterModule
|
||||||
with PeripheryMasterMemModule with PeripherySerialModule
|
with PeripheryMasterMemModule with PeripherySerialModule
|
||||||
with HardwiredResetVector with DirectConnection with NoDebug
|
with HardwiredResetVector with DirectConnection with NoDebug
|
||||||
|
|
||||||
class ExampleTopWithPWM(q: Parameters) extends ExampleTop(q)
|
|
||||||
with PeripheryPWM {
|
|
||||||
override lazy val module = Module(
|
|
||||||
new ExampleTopWithPWMModule(p, this, new ExampleTopWithPWMBundle(p)))
|
|
||||||
}
|
|
||||||
|
|
||||||
class ExampleTopWithPWMBundle(p: Parameters) extends ExampleTopBundle(p)
|
|
||||||
with PeripheryPWMBundle
|
|
||||||
|
|
||||||
class ExampleTopWithPWMModule(p: Parameters, l: ExampleTopWithPWM, b: => ExampleTopWithPWMBundle)
|
|
||||||
extends ExampleTopModule(p, l, b) with PeripheryPWMModule
|
|
||||||
6
src/main/scala/pwm/Configs.scala
Normal file
6
src/main/scala/pwm/Configs.scala
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
package pwm
|
||||||
|
|
||||||
|
import cde.{Parameters, Config, CDEMatchError}
|
||||||
|
import testchipip.WithSerialAdapter
|
||||||
|
|
||||||
|
class PWMConfig extends Config(new example.DefaultExampleConfig)
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package example
|
package pwm
|
||||||
|
|
||||||
import chisel3._
|
import chisel3._
|
||||||
import chisel3.util._
|
import chisel3.util._
|
||||||
17
src/main/scala/pwm/TestHarness.scala
Normal file
17
src/main/scala/pwm/TestHarness.scala
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
package pwm
|
||||||
|
|
||||||
|
import util.GeneratorApp
|
||||||
|
import cde.Parameters
|
||||||
|
import diplomacy.LazyModule
|
||||||
|
|
||||||
|
class TestHarness(q: Parameters) extends example.TestHarness()(q) {
|
||||||
|
override def buildTop(p: Parameters) =
|
||||||
|
LazyModule(new ExampleTopWithPWM(p))
|
||||||
|
}
|
||||||
|
|
||||||
|
object Generator extends GeneratorApp {
|
||||||
|
val longName = names.topModuleProject + "." +
|
||||||
|
names.topModuleClass + "." +
|
||||||
|
names.configs
|
||||||
|
generateFirrtl
|
||||||
|
}
|
||||||
17
src/main/scala/pwm/Top.scala
Normal file
17
src/main/scala/pwm/Top.scala
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
package pwm
|
||||||
|
|
||||||
|
import chisel3._
|
||||||
|
import example._
|
||||||
|
import cde.Parameters
|
||||||
|
|
||||||
|
class ExampleTopWithPWM(q: Parameters) extends ExampleTop(q)
|
||||||
|
with PeripheryPWM {
|
||||||
|
override lazy val module = Module(
|
||||||
|
new ExampleTopWithPWMModule(p, this, new ExampleTopWithPWMBundle(p)))
|
||||||
|
}
|
||||||
|
|
||||||
|
class ExampleTopWithPWMBundle(p: Parameters) extends ExampleTopBundle(p)
|
||||||
|
with PeripheryPWMBundle
|
||||||
|
|
||||||
|
class ExampleTopWithPWMModule(p: Parameters, l: ExampleTopWithPWM, b: => ExampleTopWithPWMBundle)
|
||||||
|
extends ExampleTopModule(p, l, b) with PeripheryPWMModule
|
||||||
Reference in New Issue
Block a user