错误:尝试实例化模块而不将其包装在Module()中

时间:2019-10-20 21:33:48

标签: chisel

顶部模块如下;

sbt 'test:runMain noc.PEMain'

我认为这是凿子3的普通样式。 我执行以下sbt来 lint 代码;

[warn] Multiple main classes detected.  Run 'show discoveredMainClasses' to see the list
[info] Running noc.NoCMain 
[info] [0.002] Elaborating design...
[error] (run-main-0) chisel3.internal.ChiselException: Error: attempted to instantiate a Module without wrapping it in Module().
[error] chisel3.internal.ChiselException: Error: attempted to instantiate a Module without wrapping it in Module().
[error]     at chisel3.internal.throwException$.apply(Error.scala:13)
[error]     at chisel3.core.BaseModule.<init>(Module.scala:90)
[error]     at chisel3.core.UserModule.<init>(UserModule.scala:18)
[error]     at chisel3.core.ImplicitModule.<init>(UserModule.scala:102)
[error]     at chisel3.core.LegacyModule.<init>(UserModule.scala:127)
[error]     at noc.NumGen.<init>(NoC.scala:328)
[error]     at noc.FanIn_Link.<init>(NoC.scala:376)
[error]     at noc.PE$$anonfun$12.apply(NoC.scala:490)
[error]     at noc.PE$$anonfun$12.apply(NoC.scala:490)
[error]     at chisel3.core.Module$.do_apply(Module.scala:49)
[error]     at noc.PE.<init>(NoC.scala:490)
[error]     at noc.NoCMain$$anonfun$1.apply(NoCMain.scala:27)
[error]     at noc.NoCMain$$anonfun$1.apply(NoCMain.scala:27)
            ...
[error]     at chisel3.internal.Builder$$anonfun$build$1.apply(Builder.scala:297)
[error]     at chisel3.internal.Builder$$anonfun$build$1.apply(Builder.scala:295)
[error]     at scala.util.DynamicVariable.withValue(DynamicVariable.scala:58)
[error]     at chisel3.internal.Builder$.build(Builder.scala:295)
[error]     at chisel3.Driver$.elaborate(Driver.scala:93)
[error]     at chisel3.Driver$.execute(Driver.scala:140)
[error]     at chisel3.iotesters.setupTreadleBackend$.apply(TreadleBackend.scala:139)
            ...
[error]     at logger.Logger$$anonfun$makeScope$1.apply(Logger.scala:138)
[error]     at scala.util.DynamicVariable.withValue(DynamicVariable.scala:58)
[error]     at logger.Logger$.makeScope(Logger.scala:136)
            ...
[error]     at scala.util.DynamicVariable.withValue(DynamicVariable.scala:58)
[error]     at chisel3.iotesters.Driver$.execute(Driver.scala:38)
[error]     at chisel3.iotesters.Driver$.execute(Driver.scala:100)
[error]     at noc.NoCMain$.delayedEndpoint$noc$NoCMain$1(NoCMain.scala:27)
[error]     at noc.NoCMain$delayedInit$body.apply(NoCMain.scala:26)
[error]     at scala.Function0$class.apply$mcV$sp(Function0.scala:34)
            ...
[error]     at scala.App$class.main(App.scala:76)
[error]     at noc.NoCMain$.main(NoCMain.scala:26)
[error]     at noc.NoCMain.main(NoCMain.scala)
[error]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            ...
[error]     at java.lang.Thread.run(Thread.java:745)

然后我收到下面的错误消息;

[error] (Test / runMain) Nonzero exit code: 1

最后这个错误:

[warn] Multiple main classes detected.  Run 'show discoveredMainClasses' to see the list

我发现以下警告:

sbt 'show discoveredMainClasses'

显示[info] Loading settings from plugins.sbt ... [info] Loading project definition from /Users/hoge/Desktop/NoC/project [info] Loading settings from build.sbt ... [info] Set current project to en-noc (in build file:/Users/hoge/Desktop/NoC/) [info] * [success] Total time: 1 s, completed 2019/10/22 2:08:49 的命令;

sbt 'testOnly noc.PETester'

此错误消息是什么意思,我该如何解决?

[info]   at chisel3.core.LegacyModule.<init>(UserModule.scala:127)

介绍了

    val io = IO(new Bundle {
        val No = Output(Vec(NumLinks, UInt((log2Ceil(NumLinks)).W)))
    })

这是由于

    port := os.Getenv("PORT")
    if port == "" {
            port = "8080"
            log.Printf("Defaulting to port %s", port)
    }
    log.Fatal(http.ListenAndServe(fmt.Sprintf(":%s", port), nil))

1 个答案:

答案 0 :(得分:1)

看来主要问题是:

attempted to instantiate a Module without wrapping it in Module()

这可能是因为您创建了一个从 Module 扩展的类的新实例,但您可能没有将它包装成一个。 例如你在你的代码中你正在做这样的事情:

val test = new module_class

你应该做什么 val 测试 = 模块(新模块类)