An error occured while testing Queue. 'FlitTypes' must be hardware, not a bare Chisel type

20 Views Asked by At

I want to test Queue API,and I define my element of queue called "Flit". When I poke value to flit_type(flit_type is a ChiselEnum type),chisel report error:

node requested directionality on 'UInt\<2\>' must be hardware, not a bare Chisel type. Perhaps you forgot to wrap it in Wire(_) or IO(_)?
chisel3.package$ExpectedHardwareException: node requested directionality on 'UInt\<2\>' must be hardware, not a bare Chisel type. Perhaps you forgot to wrap it in Wire(_) or IO(_)?
at chisel3.internal.requireIsHardware$.apply(Binding.scala:19)
at chisel3.experimental.DataMirror$.directionOf(Data.scala:132)
at chiseltest.package$testableData.pokeBits(package.scala:90)
at chiseltest.package$testableData.poke(package.scala:103)
at chapter04.RouterQueueTest$$anonfun$1$$anonfun$apply$mcV$sp$2.apply(**RouterQueueTest.scala:15**)
at chapter04.RouterQueueTest$$anonfun$1$$anonfun$apply$mcV$sp$2.apply(RouterQueueTest.scala:12)
at chiseltest.backends.treadle.TreadleBackend$$anonfun$1.apply$mcV$sp(TreadleBackend.scala:152)
at chiseltest.internal.ThreadedBackend$TesterThread$$anon$1$$anonfun$run$1.apply$mcV$sp(ThreadedBackend.scala:507)
at chiseltest.backends.treadle.TreadleBackend.doTimescope(TreadleBackend.scala:109)
at chiseltest.internal.ThreadedBackend$TesterThread$$anon$1.run(ThreadedBackend.scala:507)
at java.lang.Thread.run(Thread.java:745)

So how can I poke value to ChiselEnum type?or choose another plan to achieve that? The relevant codes is shown below:

import chisel3._
import chisel3.util.Queue
import chiseltest._
import org.scalatest.{FlatSpec, Matchers}
import design.{Flit,FlitTypes, RouteTarget, Router}

class RouterQueueTest extends FlatSpec with ChiselScalatestTester with Matchers{
  behavior of "RouterQueue"
  it should "pass" in {
    test(new Queue(new Flit,entries = 8)) { q =>
      val flit_in = new Flit
      flit_in.header.flit_type.poke(FlitTypes.head)
      flit_in.header.vc_id.poke(0.U)
      flit_in.load.poke(0x2BCD1234.U)
      q.io.enq.bits.poke(flit_in)
      q.io.enq.bits.poke(flit_in)
      q.io.enq.valid.poke(true.B)
      q.io.deq.ready.poke(true.B)

      q.clock.step(1)
      println(s"q.io.out.bits=${q.io.deq.bits.peek().litValue()}\n")

      flit_in.header.flit_type.poke(1.U)
      flit_in.load.poke(0x2BCD1235.U)
      q.clock.step(1)
      println(s"q.io.out.bits=${q.io.deq.bits.peek().litValue()}\n")
    }
  }
}
class Flit extends Bundle {
  val header = new FlitHeader
  val load = Bits(128.W)
}


class FlitHeader extends Bundle {
  val flit_type = FlitTypes()
  val vc_id = UInt(log2Ceil(2).W)
}

object FlitTypes extends ChiselEnum {
  val head = Value
  val body = Value
  val tail = Value
  val single = Value
}
// See README.md for license details.
// ThisBuild / scalaVersion     := "2.11.9"
ThisBuild / scalaVersion     := "2.11.9"
ThisBuild / version          := "0.1.0"
ThisBuild / organization     := "%ORGANIZATION%"

val chiselVersion = "3.4.3"

lazy val root = (project in file("."))
  .settings(
    name := "MyRouter",
    libraryDependencies ++= Seq(
      "edu.berkeley.cs" %% "chisel3" % chiselVersion,
      "edu.berkeley.cs" %% "chiseltest" % "0.3.3" % "test",
      "edu.berkeley.cs" %% "chisel-iotesters" % "1.5.2"
    ),
    scalacOptions ++= Seq(
      "-language:reflectiveCalls",
      "-deprecation",
      "-feature",
      "-Xcheckinit"
    ),
    //addCompilerPlugin("org.chipsalliance" % "chisel-plugin" % chiselVersion cross CrossVersion.full),
  )

I tried change flit_in.header.flit_type.poke(FlitTypes.head) to flit_in.header.flit_type.poke(Wire(FlitTypes.head)) but it still not work.

0

There are 0 best solutions below