You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a module and test below that uses module initialization value which works and tests fine under chiseltest but when ported over to ChiselSim, it started to fail.
// Run with scala-cli test thisfile.scala//>usingscala2.13.14//>usingdeporg.scalatest::scalatest:3.2.19//>usingdeporg.chipsalliance::chisel:6.4.0//>usingdepedu.berkeley.cs::chiseltest:6.0.0//>usingpluginorg.chipsalliance:::chisel-plugin:6.4.0importchisel3._importorg.scalatest._importflatspec._importmatchers._classPCPort(bitWidth: Int=32) extendsBundle {
valdataIn=Input(UInt(bitWidth.W))
valPC=Output(UInt(bitWidth.W))
valPC4=Output(UInt(bitWidth.W))
valwriteEnable=Input(Bool())
valwriteAdd=Input(Bool()) // 1 => Add dataIn to PC, 0 => Set dataIn to PC
}
classProgramCounter(regWidth: Int=32, entryPoint: BigInt=0)
extendsModule {
valio=IO(newPCPort(regWidth))
valpc=RegInit(entryPoint.U(regWidth.W))
when(io.writeEnable) {
pc :=Mux(io.writeAdd, (pc.asSInt + io.dataIn.asSInt).asUInt, io.dataIn)
}
io.PC4:= pc +4.U
io.PC:= pc
}
// Use the following to run the test using ChiselSimimportchisel3.simulator.EphemeralSimulator._classProgramCounterSpecChiselSimextendsAnyFlatSpecwith should.Matchers {
it should "initialize to 0" in {
simulate(newProgramCounter()) { c =>
c.io.PC.peek().litValue should be(0)
}
}
it should "initialize to 0x00400000" in { // This fails here but works on chiseltest
simulate(newProgramCounter(entryPoint =0x400000)) { c =>
c.io.PC.peek().litValue should be(0x400000)
}
}
}
// Use the following to run the test using chiseltest// import chiseltest._// class ProgramCounterSpecChiselTest// extends AnyFlatSpec// with ChiselScalatestTester// with should.Matchers {// it should "initialize to 0" in {// test(new ProgramCounter()) { c =>// c.io.PC.peek().litValue should be(0)// }// }// it should "initialize to 0x00400000" in {// test(new ProgramCounter(entryPoint = 0x400000)) { c =>// c.io.PC.peek().litValue should be(0x400000)// }// }// }
It might be my own code logic that is wrong but it's strange it started failing when I ported to ChiselSim. The Module works fine on simulation and FPGA.
The text was updated successfully, but these errors were encountered:
I have a module and test below that uses module initialization value which works and tests fine under chiseltest but when ported over to ChiselSim, it started to fail.
It might be my own code logic that is wrong but it's strange it started failing when I ported to ChiselSim. The Module works fine on simulation and FPGA.
The text was updated successfully, but these errors were encountered: