0

Hello I'm trying to learn chisel and I'm compiling an existing project, but I get a problem with the mem instantiation :

Compile result

How can i modify the int type to type T and what is type T ?

Waiting for your answers.

Thank you.

Mohammad Kanan
  • 4,452
  • 10
  • 23
  • 47
HAMZA
  • 21

1 Answers1

1

type T needs to be a subtype of Data. It appears numAddresses is an Int

From the UC Berkeley Chisel guide it looks like subtypes of Data include

  • Bool, SInt or UInt
  • Bundle or Vec

From here it looks like you could convert a Scala Int to a UInt as numAddresses.U (I assumed numAddresses is non-negative)

joel
  • 6,359
  • 2
  • 30
  • 55
  • Thank you Joel for your answer. How can i define numAddresses as a subtype of Chisel.Data ? – HAMZA Jul 19 '18 at 12:47
  • this is what i get : value asUInt is not a member of Long [error] val numAddresses = scala.math.pow(2, addressSize).round.asUInt – HAMZA Jul 20 '18 at 18:41
  • isn't asUInt for casting SInt to UInt? don't you need `.U` rather than `.asUInt`? – joel Jul 20 '18 at 22:06
  • value U is not a member of Long [error] val numAddresses = scala.math.pow(2, addressSize).round.U – HAMZA Jul 21 '18 at 09:58