本文介绍了测试工具中的凿子运行时错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

凿子代码可以正常运行:

chiselMainTest(Array[String]("--backend", "c", "--genHarness"), () => Module( new Cache(nways = 16, nsets = 32)  )){c => new CacheTests(c)}

但是,这是一个很小的变化,会产生运行时错误:

However this one - a small variation - produces run-time error:

val cache_inst = new Cache(nways = 16, nsets = 32)
chiselMainTest(Array[String]("--backend", "c", "--genHarness"), () => Module(cache_inst)){c => new CacheTests(c)}


[error] (run-main) java.util.NoSuchElementException: head of empty list
java.util.NoSuchElementException: head of empty list
    at scala.collection.immutable.Nil$.head(List.scala:337)
    at scala.collection.immutable.Nil$.head(List.scala:334)

推荐答案

模块的任何实例化都必须使用"Module()"进行包装.

Any instantiation of a module must be wrapped with "Module()".

这只是一个猜测,请尝试一下:

This is just a guess, but give this a try:

val cache_inst = Module(new Cache(nways = 16, nsets = 32))
ChiselMainTest(.....),() => (cache_inst){....}

发生这种情况的原因是IIRC,因为"Module()"有助于Chisel了解在Cache对象中创建的电线/对象的父源(实质上是在构建图形时推动并弹出Module堆栈).

The reason for this, IIRC, is that "Module()" helps Chisel understand the parentage of wires/objects created within your Cache object (essentially pushing and popping the Module stack as the graph is constructed).

这篇关于测试工具中的凿子运行时错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-22 18:53