提交 63934268 编写于 作者: L linjiawei

Rewrite AXI4Timer, Add AXI4Timer Test

上级 0f26349f
......@@ -36,7 +36,7 @@ class AXI4SlaveModuleImp[T<:Data](outer: AXI4SlaveModule[T])
extends LazyModuleImp(outer)
{
val io = IO(new Bundle {
val extra = Option(outer._extra)
val extra = Option(outer._extra.cloneType)
})
val (in, edge) = outer.node.in.head
......
package device
import chisel3._
import chisel3.util._
import chisel3.util.experimental.BoringUtils
import bus.axi4._
import chipsalliance.rocketchip.config.Parameters
import freechips.rocketchip.diplomacy.AddressSet
import utils._
class TimerIO extends Bundle {
val mtip = Output(Bool())
}
class AXI4Timer(sim: Boolean = false) extends AXI4SlaveModule(new AXI4Lite, new TimerIO) {
class AXI4Timer
(
sim: Boolean = false,
address: AddressSet
)(implicit p: Parameters)
extends AXI4SlaveModule(address, executable = false, _extra = new TimerIO)
{
override lazy val module = new AXI4SlaveModuleImp[TimerIO](this){
val mtime = RegInit(0.U(64.W)) // unit: us
val mtimecmp = RegInit(0.U(64.W))
......@@ -42,4 +49,5 @@ class AXI4Timer(sim: Boolean = false) extends AXI4SlaveModule(new AXI4Lite, new
getOffset(waddr), in.w.fire(), in.w.bits.data, MaskExpand(in.w.bits.strb))
io.extra.get.mtip := RegNext(mtime >= mtimecmp)
}
}
package device
import chipsalliance.rocketchip.config._
import chisel3._
import chiseltest._
import freechips.rocketchip.amba.axi4.{AXI4Deinterleaver, AXI4UserYanker}
import org.scalatest.{FlatSpec, Matchers}
import freechips.rocketchip.tilelink._
import freechips.rocketchip.diplomacy._
import utils.DebugIdentityNode
class AXI4TimerTestTop(implicit p: Parameters) extends LazyModule {
val addressSet = AddressSet(0x38000000L, 0x0000ffffL)
val fuzz = LazyModule(new TLFuzzer(nOperations = 10, overrideAddress = Some(addressSet), inFlight = 1))
val ident = LazyModule(new DebugIdentityNode())
val axiTimer = LazyModule(new AXI4Timer(sim = true, addressSet))
axiTimer.node :=
AXI4UserYanker() :=
TLToAXI4() :=
ident.node :=
fuzz.node
lazy val module = new LazyModuleImp(this){
val finished = IO(Output(Bool()))
finished := fuzz.module.io.finished
}
}
class AXI4TimerTest extends FlatSpec with Matchers with ChiselScalatestTester {
it should "run" in {
implicit val p = Parameters.empty
test(LazyModule(new AXI4TimerTestTop()).module){ c =>
while (!c.finished.peek().litToBoolean){
c.clock.step(1)
}
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册