0
votes

There appears to be either a bug with or undocumented changes to the bitwise negation operator between chisel2 and chisel3.

Chisel3 code not working

import chisel3._

class bitwise_neg extends Module {
    val io = new Bundle {
        val in   = Input(UInt(4.W))
        val out  = Output(UInt(4.W))
    }
    io.out := ~io.in
}

Error message generated for line containing "~":

type mismatch; found : ()chisel3.core.Bits required: chisel3.core.Data

Chisel2 working code

import Chisel._

class bitwise_neg extends Module {
    val io = new Bundle {
        val in        = UInt(INPUT, 4)
        val out       = UInt(OUTPUT, 4)
    }

    io.out := ~io.in
}

Any ideas on the new Chisel3 syntax or if this is a bug?

1
The chisel3 code you provided should work, and I have no problem running your example (with 1 minor change, in chisel3 you need to wrap your io Bundle with IO(...)). Can you share more about your build environment? - Jack Koenig
I'm using Scala IDE on Windows. I used SBT to generate the Eclipse project using scalaVersion 2.11.8. and Chisel 3.0-SNAPSHOT - plenn08
Works for me on MacOS with that scala version and Chisel 3 snapshot, I can't imagine how the IDE or Windows would make a difference here. Can you share the full error message and stack trace? - Jack Koenig

1 Answers

0
votes

The problem is not related to the ~, you will get the same error even if you remove the ~. Just as jkoenig said, chisel3 requires that you wrap the io bundle in an IO() like this:

class bitwise_neg extends Module {
  val io = IO(new Bundle {
    val in   = Input(UInt(4.W))
    val out  = Output(UInt(4.W))
  })
  io.out := ~io.in
}

If you want (but I wouldn't recommend it) you can use chisel2 notation using the compatibility layer in chisel3 with capital chisel import import Chisel._

import Chisel._

class bitwise_neg extends Module {
  val io = new Bundle {
    val in   = UInt(INPUT, 4.W)
    val out  = UInt(OUTPUT, 4.W)
  }
  io.out := io.in
}