2016-09-08 22:49:29 +02:00
|
|
|
// See LICENSE for license details.
|
|
|
|
|
|
|
|
package uncore.tilelink2
|
|
|
|
|
|
|
|
import Chisel._
|
|
|
|
|
|
|
|
case class ExampleParams(num: Int, address: BigInt)
|
|
|
|
|
|
|
|
trait ExampleBundle
|
|
|
|
{
|
|
|
|
val params: ExampleParams
|
|
|
|
val gpio = UInt(width = params.num)
|
|
|
|
}
|
|
|
|
|
|
|
|
trait ExampleModule extends HasRegMap
|
|
|
|
{
|
|
|
|
val params: ExampleParams
|
|
|
|
val io: ExampleBundle
|
2016-09-09 22:12:52 +02:00
|
|
|
val interrupts: Vec[Bool]
|
2016-09-08 22:49:29 +02:00
|
|
|
|
|
|
|
val state = RegInit(UInt(0))
|
2016-09-09 22:12:52 +02:00
|
|
|
val pending = RegInit(UInt(0xf, width = 4))
|
|
|
|
|
2016-09-08 22:49:29 +02:00
|
|
|
io.gpio := state
|
2016-09-09 22:12:52 +02:00
|
|
|
interrupts := pending.toBools
|
2016-09-08 22:49:29 +02:00
|
|
|
|
2016-09-09 22:12:52 +02:00
|
|
|
regmap(
|
|
|
|
0 -> Seq(
|
|
|
|
RegField(params.num, state)),
|
2016-09-23 04:49:29 +02:00
|
|
|
4 -> Seq(
|
2016-09-09 22:12:52 +02:00
|
|
|
RegField.w1ToClear(4, pending, state)))
|
2016-09-08 22:49:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Create a concrete TL2 version of the abstract Example slave
|
2016-09-09 22:12:52 +02:00
|
|
|
class TLExample(p: ExampleParams) extends TLRegisterRouter(p.address, 4)(
|
2016-09-08 22:49:29 +02:00
|
|
|
new TLRegBundle(p, _) with ExampleBundle)(
|
|
|
|
new TLRegModule(p, _, _) with ExampleModule)
|