【发布时间】:2019-11-27 08:01:17
【问题描述】:
我无法与 进行部分批量连接。 我在书中看到了Digital Design with Chisel(4.3 批量连接)。 允许连接两个部分匹配的信号束。
我目前正在研究 chisel3.2。它似乎不起作用,并且在兴高采烈的过程中
报告
chisel3.internal.ChiselException: Connection between left (AnonymousBundle(IO io in Fetch)) and source (AnonymousBundle(IO io in Decode)) failed @.regB: Left Record missing field (regB).
这在某些版本中是否有所更改?
如果改了,现在怎么做部分连接?
这是测试代码(不要介意模块,只是为了防止信号优化):
class Fetch extends Module {
val io = IO(new Bundle {
val instr = Output(UInt(32.W))
val pc = Output(UInt(32.W))
})
val r = RegInit(0.U(32.W))
r := r + 1.U
io.pc := r
io.instr := r+1.U
}
class Decode extends Module {
val io = IO(new Bundle {
val instr = Input(UInt(32.W))
val pc = Input(UInt(32.W))
val aluOp = Output(UInt(5.W))
val regA = Output(UInt(32.W))
val regB = Output(UInt(32.W))
})
io.aluOp := io.pc
io.regA := io.instr
io.regB := io.instr
}
class Execute extends Module {
val io = IO(new Bundle {
val aluOp = Input(UInt(5.W))
val regA = Input(UInt(32.W))
val regB = Input(UInt(32.W))
val result = Output(UInt(32.W))
})
io.result := io.regA
when(io.aluOp > 10.U){
io.result := io.regB
}
}
object MAIN{
def main(args:Array[String]):Unit = {
Driver.execute(Array(""),()=>new Module{
val io = IO(new Bundle{
val result = Output(UInt(32.W))
})
val fetch = Module(new Fetch())
val decode = Module(new Decode())
val execute = Module(new Execute)
fetch.io <> decode.io
decode.io <> execute.io
io <> execute.io
})
}
}
【问题讨论】:
-
我想给出一个更详细的答案以及解决的选项,但目前没有时间。简而言之,这是故意删除的。多年来使用 Chisel 进行硬件设计,我们发现难以调试的错误的第一大原因是当我们重构一个块,将一个字段添加到一个 Bundle,然后该块的其他用户不知道关于添加,并且会有 Verilog 不起作用。请密切关注github.com/freechipsproject/www.chisel-lang.org/pull/48,我正在那里编写有关差异和迁移策略的文档。
-
我们编写不需要此功能的代码的方式是通过组合。如果您希望将一个 Bundle 中的字段连接到另一个 Bundle 中的相同字段,则通常最好创建一个包含这些字段的新 Bundle,并在每个其他 Bundle 中实例化新 Bundle。然后你就可以连接子字段了。
-
@JackKoenig 嗨,也许您可以详细说明
composition方法?对于这种情况,如果我们还想将fetch&decode、decode&exe、exe&io的对应端口连接在一起,该如何解决?
标签: chisel