isururathnayaka
isururathnayaka

Reputation: 141

Chisel memory write mask

I am trying to use a write mask for a Mem in chisel 3 like given below.

chipMem.write(data_idx, wdata, wmask)

I am generating wmask (the write mask) as follows,

val wmask = write_mask.toBools

since write_mask is a UInt and the write function requires a Bool Sequence for the write mask argument. However, this gives the following error.

Cannot prove that chisel3.core.UInt <:< chisel3.core.Vec[_].
[error]              chipMem.write(data_idx, wdata, wmask)
[error]                           ^
[error] one error found

I really don't understand what the error message says. Is it a problem with the way I create wmask?

Upvotes: 1

Views: 492

Answers (2)

samadpls
samadpls

Reputation: 133

mask work only when memory Datatype is vector. you can directly write instruction if memory is not Vector example:

val memory = Mem (32 , UInt (32. W ) )
memory . write ( io . addr , io . data_in)

Upvotes: 1

Jack Koenig
Jack Koenig

Reputation: 6064

The compiler is complaining that it cannot prove that a Chisel UInt is a subtype of Chisel Vec (because it isn't).

Taking a look at the documentation for Mem.write, it notes that "this is only allowed if the memory's element data type is a Vec." This could probably be phrased a little better, but basically Chisel does not assume anything about how the write mask corresponds to the data. If you want to use write masks, the datatype of your Mem must be a Vec. Also note that the write mask Vec must have the same number of entries as the datatype Vec.

Upvotes: 1

Related Questions