Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parameterized tests fail during Verilator compile #213

Open
stevenmburns opened this issue Oct 19, 2018 · 0 comments
Open

Parameterized tests fail during Verilator compile #213

stevenmburns opened this issue Oct 19, 2018 · 0 comments

Comments

@stevenmburns
Copy link

The following one file test case (put in src/test/scala and run sbt test fails with a verilator compile error.

package mult.imp {

  import chisel3._
  import chisel3.util._

  class MultXfc (val N: Int) extends Module {
    val io = IO(new Bundle {
      val X = Input (UInt(N.W))
    })
  }

}

package mult.test {

  import chisel3._
  import chisel3.iotesters._
  import org.scalatest.{Matchers,FlatSpec}

  import mult.imp._

  class MultTester[T <: MultXfc] (c : T ) extends PeekPokeTester(c)

  class MultXfcWrapper( factory:  (Int) => MultXfc,
                        N: Int) extends MultXfc (N) {
    val m = Module (factory (N))
    m.io.X := io.X
  }

  class MultTest (factory: (Int) => MultXfc, N:Int, backend : String = "firrtl")
      extends FlatSpec with Matchers {
    val optionsManager = new TesterOptionsManager {
      testerOptions = testerOptions.copy(
        backendName = backend
      )
    }

    behavior of "multiplier"

    it should "multiply correctly" in {

      val dutFactory = () => new MultXfcWrapper(factory, N)
      chisel3.iotesters.Driver.execute ( dutFactory, optionsManager) {
        c => new MultTester(c)
      } should be (true)
    }
  }

}

package mult.test {

  import chisel3._
  import mult.imp._

  object M8Factory {
    def multFactory = ((N: Int) => new MultXfc(8))
  }

  class M8Test extends MultTest (M8Factory.multFactory, 8, "verilator")

}

package db32mult.test {

  import chisel3._
  import mult.imp._
  import mult.test._


  object M32Factory {
    def multFactory = ((N: Int) => new MultXfc(32))
  }

  class M32Test extends MultTest (M32Factory.multFactory, 32, "verilator")

}

It will work if you change the name of the final package to db32mul.test (strange, but probably the tests are run in the opposite order.)
It seems that the parameterized test harnesses do not get fully regenerated and the 32 bit tests tries to run using an 8 bit harness.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant