AXI4RamTest.scala 2.7 KB
Newer Older
L
linjiawei 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
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 AXI4RamFuzzTest()(implicit p: Parameters) extends LazyModule {

  val addressSet = AddressSet(0x38000000L, 0x0000ffffL)

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

  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))
L
linjiawei 已提交
41
  val axiRam = LazyModule(new AXI4RAM(addressSet, memByte = 1024))
L
linjiawei 已提交
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57

  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)

  val tlburst = LazyModule(new TLBurstMaster(startAddr = addressSet.base.toLong, nOp = 3))
  val ident = LazyModule(new DebugIdentityNode())
L
linjiawei 已提交
58
  val axiRam = LazyModule(new AXI4RAM(addressSet, memByte = 1024))
L
linjiawei 已提交
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 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

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

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

class AXI4RamTest extends FlatSpec with ChiselScalatestTester with Matchers {
  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)
      }
    }
  }
}