Search code examples
chisel

Required: T Chisel Error


I get the following chisel errors for io.out(i) := Cat(io.in1(0) ,io.in2) line. What does it mean? and how do I rectify this? Please help.

type mismatch;
[error]  found   : chisel3.core.UInt
[error]  required: T
[error]     io.out(i) := Cat(io.in1(0) ,io.in2)

type mismatch;
[error]  found   : chisel3.core.Vec[chisel3.core.UInt]
[error]  required: T
[error]     io.out(i) := Cat(io.in1(0) ,io.in2)

Solution

  • As Chick mentioned, we really need to see more context but I think I have enough to glean what is going on. One part of the error message that I suspect you left off is:

    [error] inferred type arguments [chisel3.core.Data] do not conform to method apply's type parameter bounds [T <: chisel3.Bits]
    [error]   io.out(i) := Cat(io.in1(0), io.in2)
    [error]
    

    What this says is that the type of the arguments to Cat must be a subtype of chisel3.Bits. Vec is not a subtype of Bits, so you cannot pass a Vec to Cat.

    It would be helpful to have more information about what you're trying to do to give better advice, but if you're trying to construct a UInt that is the concatenation of a UInt and a Vec, you can convert the Vec to a UInt by calling .asUInt, eg. Cat(io.in1(0), io.in2.asUInt). If you're trying to construct a larger Vec by prepending a UInt to it you can try io.in1(0) +: io.in2.