Skip to content

Commit

Permalink
test: Add VCD generating annotations
Browse files Browse the repository at this point in the history
Each test now will produce a vcd trace in test_run_dir/<test_case>.

Signed-off-by: Wiktoria Kuna <[email protected]>
  • Loading branch information
wkkuna committed Jan 4, 2024
1 parent cb97634 commit 0e4d89a
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 17 deletions.
59 changes: 48 additions & 11 deletions src/test/scala/DMAController/ComponentSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,39 +19,76 @@ import DMAController.Worker._
import org.scalatest.{FlatSpec, Matchers}
import chisel3._
import chiseltest._
import chiseltest.iotesters._
import org.scalatest.freespec.AnyFreeSpec
import org.scalatest.flatspec.AnyFlatSpec
import DMAController.DMAConfig._

class ComponentSpec extends AnyFlatSpec with ChiselScalatestTester{
val cfg = new DMAConfig("AXI_AXIL_AXI")
class ComponentSpec extends AnyFlatSpec with ChiselScalatestTester {
val cfg = new DMAConfig("AXI_AXIL_AXI")
val testAnnotations = Seq(WriteVcdAnnotation)

def testFastVDMAComponent[T <: Module](
dutGen: => T,
tester: T => PeekPokeTester[T]
): Unit = {
test(dutGen)
.withAnnotations(testAnnotations)
.runPeekPoke(tester)
}

behavior of "ComponentSpec"

it should "generate addresses" in {
test(new AddressGenerator(32, 32, cfg)).runPeekPoke(new AddressGeneratorTest(_))
testFastVDMAComponent(
new AddressGenerator(32, 32, cfg),
new AddressGeneratorTest(_)
)
}
it should "split transfers" in {
test(new TransferSplitter(32, 32, 256, false, cfg)).runPeekPoke(new TransferSplitterTest(_))
testFastVDMAComponent(
new TransferSplitter(32, 32, 256, false, cfg),
new TransferSplitterTest(_)
)
}
it should "perform AXI Stream master transfers" in {
test(new AXIStreamMaster(32, 32, cfg)).runPeekPoke(new AXIStreamMasterTest(_))
testFastVDMAComponent(
new AXIStreamMaster(32, 32, cfg),
new AXIStreamMasterTest(_)
)
}
it should "perform AXI Stream slave transfers" in {
test(new AXIStreamSlave(32, 32, cfg)).runPeekPoke(new AXIStreamSlaveTest(_))
testFastVDMAComponent(
new AXIStreamSlave(32, 32, cfg),
new AXIStreamSlaveTest(_)
)
}
it should "perform AXI4 write transfers" in {
test(new AXI4Writer(32, 32, cfg)).runPeekPoke(new AXI4WriterTest(_))
testFastVDMAComponent(
new AXI4Writer(32, 32, cfg),
new AXI4WriterTest(_))
}
it should "perform AXI4 read transfers" in {
test(new AXI4Reader(32, 32, cfg)).runPeekPoke(new AXI4ReaderTest(_))
testFastVDMAComponent(
new AXI4Reader(32, 32, cfg),
new AXI4ReaderTest(_))
}
it should "perform Wishbone write transfers" in {
test(new WishboneClassicPipelinedWriter(32, 32, cfg)).runPeekPoke(new WishboneWriterTest(_))
testFastVDMAComponent(
new WishboneClassicPipelinedWriter(32, 32, cfg),
new WishboneWriterTest(_)
)
}
it should "perform Wishbone read transfers" in {
test(new WishboneClassicPipelinedReader(32, 32, cfg)).runPeekPoke(new WishboneReaderTest(_))
testFastVDMAComponent(
new WishboneClassicPipelinedReader(32, 32, cfg),
new WishboneReaderTest(_)
)
}
it should "trigger interrupts" in {
test(new InterruptController(cfg)).runPeekPoke(new InterruptControllerTest(_))
testFastVDMAComponent(
new InterruptController(cfg),
new InterruptControllerTest(_)
)
}
}
17 changes: 11 additions & 6 deletions src/test/scala/DMAController/ControllerSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,25 @@ package DMAController
import chiseltest.ChiselScalatestTester
import org.scalatest.flatspec.AnyFlatSpec
import DMAController.DMAConfig._
import chiseltest._

class ControllerSpec extends AnyFlatSpec with ChiselScalatestTester {
behavior of "ControllerSpec"
val dmaConfigMM2MM = new DMAConfig("AXI_AXIL_AXI")
it should "perform 2D MM2MM transfer with stride mem to mem" in {
test(new DMATop(dmaConfigMM2MM)).runPeekPoke(dut =>
new ImageTransfer(dut, new DMAFullMem(dut), dmaConfigMM2MM)
)
test(new DMATop(dmaConfigMM2MM))
.withAnnotations(Seq(WriteVcdAnnotation))
.runPeekPoke(dut =>
new ImageTransfer(dut, new DMAFullMem(dut), dmaConfigMM2MM)
)
}

val dmaConfigS2MM = new DMAConfig("AXIS_AXIL_AXI")
it should "perform 2D S2MM transfer with stride stream to mem" in {
test(new DMATop(dmaConfigS2MM)).runPeekPoke(dut =>
new ImageTransfer(dut, new DMAFullStream(dut), dmaConfigS2MM)
)
test(new DMATop(dmaConfigS2MM))
.withAnnotations(Seq(WriteVcdAnnotation))
.runPeekPoke(dut =>
new ImageTransfer(dut, new DMAFullStream(dut), dmaConfigS2MM)
)
}
}

0 comments on commit 0e4d89a

Please sign in to comment.