【问题标题】:Chisel Concatenation Error凿子连接错误
【发布时间】:2018-07-20 08:09:03
【问题描述】:
class CC extends Module {
  val io = IO(new Bundle {
    val in1 = Input(Vec(5, UInt(3.W)))
    val in2 = Input(Vec(5, UInt(3.W)))
    val out = Output(Vec(9, UInt(3.W)))
  })

  val L = 5
  val ml = 4
  var y = 0


  for (i <- 0 until ml) {
    when (io.in2(i) === io.in1(L - ml + i))
      y = y + 1
  }

  when (y === ml) {
    io.out := Cat(io.in1(0) ,io.in2)
  }

  io.out := io.in1
}

这是在检查它们是否匹配后连接两个字符串的代码。例如,如果 in1 是 1001,in2 是 0010,它必须连接并返回 10010

另外,我有几个问题

1) 我们可以连接向量吗?

2) '===' 运算符对向量有效吗?

3) 我们可以比较两个向量吗?

我得到的错误

1)

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

2)

value === is not a member of Int [error] when (y === ml)

3)

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

有人可以指导我吗?谢谢!

【问题讨论】:

  • 你的问题标题是“连接错误”你能给出你得到的错误吗?
  • 您的代码无法编译,因为 bundle 输入是 'i1' 并且您在代码中使用了 'in1'...
  • 该死,但是当我将它更改为捆绑包中的 in1 时,它显示相同的错误

标签: scala vector equality chisel


【解决方案1】:

这段代码有很多混乱。

第一个 'y' 应该是 Chisel 寄存器,而不是 scala Int 变量。

val y = RegInit(0.asUInt(8.W))

Scala for 循环在 VHDL 中用作 GENERATE,它用于“复制”一些代码行。

然后据我了解这个循环:

for (i <- 0 until ml){
    when (io.in2(i) === io.in1(L.U - ml.U + i))
    y = y + 1
}

事实上,值 'y' 应该是一个向量:

val y = RegInit(VecInit(Seq.fill(m1)(0.asUInt(8.W))))

你的循环应该是这样的:

for (i <- 0 until ml){
    when (io.in2(i) === io.in1(L - ml + i)){
       y(i) := y(i) + 1.U
    }

    io.out(i) := 0.U
    when (y(i) === ml){
      io.out(i) := io.in2(i) 
    }
}
io.out(m1+1) := io.in1(0)

io.out 应该是 6 的 Vec 大小 而不是 9:

val out = Output(Vec(6, UInt(3.W)))

【讨论】:

  • 非常感谢。但我仍然发现错误 1)value asUint is not a member of Int [error] val y = RegInit(VecInit(Seq.fill(ml)(0.asUint(8.W)))) 和 2)inferred type arguments [chisel3.core.Data] do not conform to method apply's type parameter bounds [T &lt;: chisel3.Bits] [error] io.out := Cat(io.in1(0) ,io.in2)
  • 我的错,是 asUInt()(我大写)
  • 我仍然在连接行中遇到错误inferred type arguments [chisel3.core.Data] do not conform to method apply's type parameter bounds [T &lt;: chisel3.Bits] [error] io.out := Cat(io.in1(0) ,io.in2) [error] ^
  • hmm,听起来 Cat 函数不返回 Vec() 而是返回 UInt:github.com/freechipsproject/chisel3/blob/master/src/main/scala/… 实际上你不应该这样返回。 (我编辑了回复)
  • 它仍然显示相同的错误type arguments [chisel3.core.Data] do not conform to method apply's type parameter bounds [T &lt;: chisel3.Bits] [error] io.out(i) := Cat(io.in1(0) ,io.in2)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多