1
votes

I want to compare two Bits type values in chisel. First I tried this using === operator.

val byte = (typ === MT_B)

This gave the error "value === is not a member of chisel3.Bits". So I tried equals method as follows.

val byte    =   (typ.equals(MT_B))

And this gave the following error in a later part of the code where this byte value is used for the condition in a Mux.

found   : Boolean
[error]  required: chisel3.core.Bool
[error]         val dout    =   Mux(byte, Fill(4, din( 7,0)),

I can't find a way to convert the Boolean return of equals method to Bool typer for the Mux. And I couldn't find a substitute for the === operator from chisel 3 API ethier.

1

1 Answers

2
votes

Boolean is a Scala literal. The Chisel equivalent is Bool.

Cast into a Chisel Bool like this

val myBoolean = true // Scala literal
val myBool = Bool(myBoolean)

Alternatively, you can also use myBoolean.B to cast from Scala Boolean to Chisel Bool.