【问题标题】:How can I generate FIRRTL from chisel code?如何从凿码生成 FIRRTL?
【发布时间】:2016-12-29 14:34:01
【问题描述】:

如何从凿码生成 FIRRTL 文件?我已经根据 github wiki 安装了 sbt、firrtl 和 verilator。并为简单的加法器创建了凿子代码。我想生成 FIRRTL 并将其转换为 Verilog?我的问题是如何从凿子代码中获取 firrtl 文件。 谢谢。

源文件:MyQueueTest/src/main/scala/example/MyQueueDriver.scala

package example

import chisel3._
import chisel3.util._

class MyQueue extends Module {
  val io = IO(new Bundle {
    val a = Flipped(Decoupled(UInt(32.W)))
    val b = Flipped(Decoupled(UInt(32.W)))
    val z = Decoupled(UInt(32.W))
  })  

  val qa = Queue(io.a)
  val qb = Queue(io.b)

  qa.nodeq()
  qb.nodeq()

  when (qa.valid && qb.valid && io.z.ready) {
    io.z.enq(qa.deq() + qb.deq())
  }
}

object MyQueueDriver extends App {
  chisel3.Driver.execute(args, () => new MyQueue)
}

【问题讨论】:

    标签: chisel


    【解决方案1】:

    我问了一个类似的问题here。 解决方案可以是使用here提供的完整模板,或者您可以简单地这样做:

    在 scala 源代码的末尾添加这些行:

    object YourModuleDriver extends App {
      chisel3.Driver.execute(args, () => new YourModule)
    }
    

    将“YourModule”替换为您的模块名称。

    并使用以下行在源代码的同一目录中添加一个 build.sbt 文件:

    scalaVersion := "2.11.8"
    
    resolvers ++= Seq(
      Resolver.sonatypeRepo("snapshots"),
      Resolver.sonatypeRepo("releases")
    )
    
    libraryDependencies += "edu.berkeley.cs" %% "chisel3" % "3.0-SNAPSHOT"
    

    要生成 FIRRTL 和 Verilog,您只需:

    $ sbt "run-main YourModuleDriver"
    

    FIRRTL (yourmodule.fir) /Verilog (yourmodule.v) 源将在生成的目录中。

    【讨论】:

    • 非常感谢,我能够看到 Verilog 文件。当我的源代码中有package <some-package-name> 时,$ sbt "run-main YourModuleDriver" 不起作用。它给了 Class Not Found 异常。
    • 你的模块名称是什么?可以发资源吗?
    • 对于长时间延迟回复,我深表歉意。我将源代码添加到问题中。当我删除源代码中的package 并将源代码移动到目录 MyQueueTest/src/main/scala/ 时,它就像一个魅力。
    • 请不要忘记将问题标记为“已解决”。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-03-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-25
    相关资源
    最近更新 更多