summaryrefslogtreecommitdiff
path: root/src/main/scala/Chisel
diff options
context:
space:
mode:
authorjackkoenig2016-05-20 13:38:18 -0700
committerjackkoenig2016-05-20 13:38:18 -0700
commitd7697eb14a0195cc3726bf45fdf38c631b6f6507 (patch)
tree7b9372829fd9167e6d15d7f5323f6dfd4e5b11f4 /src/main/scala/Chisel
parenta26a0ad4504e99182e3548db8f407c3dad7302b0 (diff)
Update BackendCompilationUtilities.verilogToCpp to specify top-module
This prevents Verilator from erroring when it cannot determine the top-module. It also changes the PRINTF_COND guard to correctly use the top-level reset instead of just the top of the Chisel-generated code.
Diffstat (limited to 'src/main/scala/Chisel')
-rw-r--r--src/main/scala/Chisel/Driver.scala9
-rw-r--r--src/main/scala/Chisel/testers/TesterDriver.scala2
2 files changed, 5 insertions, 6 deletions
diff --git a/src/main/scala/Chisel/Driver.scala b/src/main/scala/Chisel/Driver.scala
index d5952834..02204684 100644
--- a/src/main/scala/Chisel/Driver.scala
+++ b/src/main/scala/Chisel/Driver.scala
@@ -46,17 +46,15 @@ trait BackendCompilationUtilities {
* The Verilator prefix will be V$dutFile, and running this will generate
* C++ sources and headers as well as a makefile to compile them.
*
- * Verilator will automatically locate the top-level module as the one among
- * all the files which are not included elsewhere. If multiple ones exist,
- * the compilation will fail.
- *
* @param dutFile name of the DUT .v without the .v extension
+ * @param name of the top-level module in the design
* @param dir output directory
* @param vSources list of additional Verilog sources to compile
* @param cppHarness C++ testharness to compile/link against
*/
def verilogToCpp(
dutFile: String,
+ topModule: String,
dir: File,
vSources: Seq[File],
cppHarness: File
@@ -70,8 +68,9 @@ trait BackendCompilationUtilities {
"-Wno-STMTDLY",
"--trace",
"-O2",
+ "--top-module", topModule,
"+define+TOP_TYPE=V" + dutFile,
- s"+define+PRINTF_COND=!$dutFile.reset",
+ s"+define+PRINTF_COND=!$topModule.reset",
"-CFLAGS",
s"""-Wno-undefined-bool-conversion -O2 -DTOP_TYPE=V$dutFile -include V$dutFile.h""",
"-Mdir", dir.toString,
diff --git a/src/main/scala/Chisel/testers/TesterDriver.scala b/src/main/scala/Chisel/testers/TesterDriver.scala
index c0cdfb3f..a56bb8b7 100644
--- a/src/main/scala/Chisel/testers/TesterDriver.scala
+++ b/src/main/scala/Chisel/testers/TesterDriver.scala
@@ -47,7 +47,7 @@ object TesterDriver extends BackendCompilationUtilities {
// Use sys.Process to invoke a bunch of backend stuff, then run the resulting exe
if ((firrtlToVerilog(target, path) #&&
- verilogToCpp(target, path, additionalVFiles, cppHarness) #&&
+ verilogToCpp(target, target, path, additionalVFiles, cppHarness) #&&
cppToExe(target, path)).! == 0) {
executeExpectingSuccess(target, path)
} else {