2016-11-28 01:16:37 +01:00
|
|
|
// See LICENSE.SiFive for license details.
|
2016-09-08 22:49:29 +02:00
|
|
|
|
2017-07-07 19:48:16 +02:00
|
|
|
package freechips.rocketchip.tilelink
|
2016-09-08 22:49:29 +02:00
|
|
|
|
|
|
|
import Chisel._
|
2017-07-07 19:48:16 +02:00
|
|
|
import freechips.rocketchip.config.Parameters
|
|
|
|
import freechips.rocketchip.regmapper._
|
2016-09-08 22:49:29 +02:00
|
|
|
|
|
|
|
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
|
2017-03-01 08:12:36 +01:00
|
|
|
class TLExample(params: ExampleParams)(implicit p: Parameters)
|
|
|
|
extends TLRegisterRouter(params.address, "somedev", Seq("ucbbar,random-interface"), 4)(
|
2016-12-02 02:46:52 +01:00
|
|
|
new TLRegBundle(params, _) with ExampleBundle)(
|
|
|
|
new TLRegModule(params, _, _) with ExampleModule)
|