AXI4RamTest.scala 2.8 KB
Newer Older
L
linjiawei 已提交
1 2 3 4 5 6 7 8
package device

import chipsalliance.rocketchip.config._
import chisel3._
import chiseltest._
import freechips.rocketchip.amba.axi4.{AXI4Deinterleaver, AXI4UserYanker}
import freechips.rocketchip.tilelink._
import freechips.rocketchip.diplomacy._
J
Jiuyang liu 已提交
9 10
import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.must.Matchers
L
linjiawei 已提交
11 12 13 14 15 16 17 18 19
import utils.DebugIdentityNode

class AXI4RamFuzzTest()(implicit p: Parameters) extends LazyModule {

  val addressSet = AddressSet(0x38000000L, 0x0000ffffL)

  val fuzz = LazyModule(new TLFuzzer(
    nOperations = 10,
    overrideAddress = Some(addressSet),
20
    inFlight = 10
L
linjiawei 已提交
21 22
  ))
  val ident = LazyModule(new DebugIdentityNode())
23
  val axiRam = LazyModule(new AXI4RAM(Seq(addressSet), memByte = 1024))
L
linjiawei 已提交
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41

  axiRam.node :=
    AXI4UserYanker() :=
    TLToAXI4() :=
    TLFragmenter(8, 8) :=
    ident.node :=
    fuzz.node

  lazy val module = new LazyModuleImp(this){
    val finished = IO(Output(Bool()))
    finished := fuzz.module.io.finished
  }
}

class AXI4RamBurstTest()(implicit p: Parameters) extends LazyModule {

  val addressSet = AddressSet(0x38000000L, 0x0000ffffL)
  val burst = LazyModule(new AXI4BurstMaster(startAddr = addressSet.base.toLong, nOp = 3))
42
  val axiRam = LazyModule(new AXI4RAM(Seq(addressSet), memByte = 1024))
L
linjiawei 已提交
43 44 45 46 47 48 49 50 51 52 53 54 55 56

  axiRam.node := burst.node

  lazy val module = new LazyModuleImp(this){
    val finished = IO(Output(Bool()))
    finished := burst.module.io.finished
  }

}

class AXI4RamTLBurstTest()(implicit p: Parameters) extends LazyModule {

  val addressSet = AddressSet(0x38000000L, 0x0000ffffL)

L
linjiawei 已提交
57
  val tlburst = LazyModule(new TLBurstMaster(startAddr = addressSet.base.toLong, nOp = 1, burstLen = 32))
L
linjiawei 已提交
58
  val ident = LazyModule(new DebugIdentityNode())
59
  val axiRam = LazyModule(new AXI4RAM(Seq(addressSet), memByte = 1024))
L
linjiawei 已提交
60 61 62 63

  axiRam.node :=
    AXI4UserYanker() :=
    TLToAXI4() :=
L
linjiawei 已提交
64
    TLFragmenter(8, 32 * 8, holdFirstDeny = true) :=
L
linjiawei 已提交
65 66 67 68 69 70 71 72 73
    ident.node :=
    tlburst.node

  lazy val module = new LazyModuleImp(this){
    val finished = IO(Output(Bool()))
    finished := tlburst.module.io.finished
  }
}

J
Jiuyang liu 已提交
74
class AXI4RamTest extends AnyFlatSpec with ChiselScalatestTester with Matchers {
L
linjiawei 已提交
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
  it should "run with fuzz" in {
    implicit val p = Parameters.empty
    test(LazyModule(new AXI4RamFuzzTest()).module){ c =>
      while (!c.finished.peek().litToBoolean){
        c.clock.step(1)
      }
    }
  }

  it should "run in burst mode with axi master" in {
    implicit val p = Parameters.empty
    test(LazyModule(new AXI4RamBurstTest()).module){c =>
      while (!c.finished.peek().litToBoolean){
        c.clock.step(1)
      }
    }
  }

  it should "run in burst mode with tilelink master" in {
    implicit val p = Parameters.empty
    test(LazyModule(new AXI4RamTLBurstTest()).module){c =>
      while (!c.finished.peek().litToBoolean){
        c.clock.step(1)
      }
    }
  }
}