Search code examples
scalachisel

Chisel not finding the implicit value of a parameter


I am trying to customize and use the ALU source file of Sodor processor/Rocket core in a different project. So I copied the common folder that contains configurations.scala file hoping to use the parameters added to that in the alu source file. However, when I run sbt "test-only..." I get the following error which I couldn't find a solution for up to now.

[info] Compiling 1 Scala source to /home/isuru/fyp/ChiselProjects/RiscvIoT/target/scala-2.11/test-classes...
[error] /home/isuru/fyp/ChiselProjects/RiscvIoT/src/test/scala/core/aluTest.scala:42: could not find implicit value for parameter conf: Common.SodorConfiguration
[error]       Driver(() => new ALU, backendName) {
[error]                    ^
[error] one error found
[error] (test:compileIncremental) Compilation failed
[error] Total time: 0 s, completed Dec 6, 2016 10:45:25 PM

This the section of the source file that includes implicit parameters. I am posting only that section since the complete text is very long.

class ALUIO(implicit conf: SodorConfiguration) extends Bundle {
  val fn = Bits(INPUT, SZ_ALU_FN)
  val in2 = UInt(INPUT, conf.xprlen)
  val in1 = UInt(INPUT, conf.xprlen)
  val out = UInt(OUTPUT, conf.xprlen)
  val adder_out = UInt(OUTPUT, conf.xprlen)
}

class ALU(implicit conf: SodorConfiguration) extends Module
{
  val io = new ALUIO

  val msb = conf.xprlen-1
...
}

Solution

  • As Kamyar pointed out, you need to have an implicit SodorConfiguration in scope where you instantiate the ALU.

    Try adding:

    implicit val conf = new SodorConfiguration
    

    before the Driver invocation.

    Note that SodorConfiguration is defined in: https://github.com/ucb-bar/riscv-sodor/blob/master/src/common/configurations.scala