【问题标题】:chisel partial bulk connection with "<>" operator用“<>”运算符凿出部分批量连接
【发布时间】: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&decodedecode&exeexe&io的对应端口连接在一起,该如何解决?

标签: chisel


【解决方案1】:

链接:chisel3-vs-chisel2

在不受支持的结构章节中:

  • 在 Chisel2 中,批量连接 与未连接的源组件不会更新未连接组件的连接。
  • 在 Chisel3 中,批量连接严格遵守最后连接语义,未连接的 OUTPUT 将连接到 INPUT,从而为这些输入分配随机值。

很抱歉我还没有完全理解如何在Chisel3中使用。我认为你应该避免在Chisel3中使用。

这是 Chisel3 中可用的示例。

代码来自here

import Chisel.Queue
import chisel3._
import chisel3.stage.{ChiselGeneratorAnnotation, ChiselStage}
import chisel3.util.Decoupled
import layered.stage.ElkStage

class MyQueue extends Module {
    // Example circuit using a Queue
    val io = IO(new Bundle {
        val in = Flipped(Decoupled(UInt(8.W)))
        val out = Decoupled(UInt(8.W))
    })
    val queue = Queue(io.in, 2)  // 2-element queue
    io.out <> queue
}

object MyQueue extends App{
    (new ChiselStage).emitVerilog(new MyQueue,Array("-td", "vout"))
    
    // gengerate graph file and it can be viewed by using IDEA plugin named EasySocHDL
    (new ElkStage).execute(
        Array("-td", "vout", "--lowFir"),
        Seq(ChiselGeneratorAnnotation(() => new MyQueue))
    )
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-03-29
    • 1970-01-01
    • 1970-01-01
    • 2012-01-20
    • 2013-03-15
    • 2011-01-03
    • 2010-09-24
    相关资源
    最近更新 更多