2016-11-29 142 views
1

如何從鑿子代碼生成FIRRTL文件?根據github wiki,我已經安裝了sbt,firrtl和verilator。併爲簡單的加法器創建了一個鑿子代碼。我想生成FIRRTL並將其轉換爲Verilog?我的問題是如何從鑿子代碼中獲取firrtl文件。 謝謝。如何從鑿子代碼生成FIRRTL?

源文件:MyQueueTest/src目錄/主/斯卡拉/例子/ 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) 
} 

回答

3

我問過類似的問題here。 解決辦法可以使用完整的模板提供here,或者你可以簡單地這樣做:

在你的斯卡拉源的末尾添加這些行:

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)源將在生成的目錄中。

+0

非常感謝,我能夠看到Verilog文件。 當我在源碼 中包含'package '時,$ sbt「run-main YourModuleDriver」沒有任何作用。它給了Class Not Found異常。 –

+0

你的模塊的名稱是什麼?你可以發佈消息嗎? – FabienM

+0

對於長時間的迴應,我表示歉意。我將源代碼添加到問題中。當我移除源代碼中的'package'並將源代碼移到dir MyQueueTest/src/main/scala /時,它就像一個魅力一樣。 –