Sink 和 Source 是不同长度的 Vecs
Sink and Source are different length Vecs
下面的代码是连接两个字符串。它正在编译,但在详细说明后显示错误。
代码:
package problems
import chisel3._
import chisel3.util._
class Compare1 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(6, UInt(3.W)))
})
val L = 5
io.out := io.in2
val ml = 4
for (l <- 0 until ml) {
when (io.in2(l) === io.in1(L - ml + l)) {
io.out(l) := io.in1(l)
}
}
val m = (2*L) - ml
for (i <- ml until m) {
io.out(i) := io.in2(i - (L - ml))
}
}
测试平台:
我正在戳 19333 和 23599 并期待 154671
错误:
总结一下,这就是我得到的
Errors: 1: in the following tutorials
Tutorial Compare1: exception Connection between sink (Vec(chisel3.core.UInt@80, chisel3.core.UInt@82, chisel3.core.UInt@84, chisel3.core.UInt@86, chisel3.core.UInt@88, chisel3.core.UInt@8a)) and source (Vec(chisel3.core.UInt@6a, chisel3.core.UInt@6c, chisel3.core.UInt@6e, chisel3.core.UInt@70, chisel3.core.UInt@72)) failed @: Sink and Source are different length Vecs.
错误与以下行有关:io.out := io.in2
,io.out 是长度为 6 的 Vec,而 io.in2
是长度为 5 的 Vec。如错误所述,您无法连接不同长度的vec在一起。
如果您希望将 io.in2
的索引 0 到 4 连接到 io.out
,请尝试
for (i <- 0 until io.in2.size) { io.out(i) := io.in2(i) }
下面的代码是连接两个字符串。它正在编译,但在详细说明后显示错误。
代码:
package problems
import chisel3._
import chisel3.util._
class Compare1 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(6, UInt(3.W)))
})
val L = 5
io.out := io.in2
val ml = 4
for (l <- 0 until ml) {
when (io.in2(l) === io.in1(L - ml + l)) {
io.out(l) := io.in1(l)
}
}
val m = (2*L) - ml
for (i <- ml until m) {
io.out(i) := io.in2(i - (L - ml))
}
}
测试平台:
我正在戳 19333 和 23599 并期待 154671
错误:
总结一下,这就是我得到的
Errors: 1: in the following tutorials
Tutorial Compare1: exception Connection between sink (Vec(chisel3.core.UInt@80, chisel3.core.UInt@82, chisel3.core.UInt@84, chisel3.core.UInt@86, chisel3.core.UInt@88, chisel3.core.UInt@8a)) and source (Vec(chisel3.core.UInt@6a, chisel3.core.UInt@6c, chisel3.core.UInt@6e, chisel3.core.UInt@70, chisel3.core.UInt@72)) failed @: Sink and Source are different length Vecs.
错误与以下行有关:io.out := io.in2
,io.out 是长度为 6 的 Vec,而 io.in2
是长度为 5 的 Vec。如错误所述,您无法连接不同长度的vec在一起。
如果您希望将 io.in2
的索引 0 到 4 连接到 io.out
,请尝试
for (i <- 0 until io.in2.size) { io.out(i) := io.in2(i) }