From d7697eb14a0195cc3726bf45fdf38c631b6f6507 Mon Sep 17 00:00:00 2001 From: jackkoenig Date: Fri, 20 May 2016 13:38:18 -0700 Subject: 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. --- src/main/scala/Chisel/Driver.scala | 9 ++++----- src/main/scala/Chisel/testers/TesterDriver.scala | 2 +- src/test/scala/chiselTests/Harness.scala | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) (limited to 'src') 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 { diff --git a/src/test/scala/chiselTests/Harness.scala b/src/test/scala/chiselTests/Harness.scala index b06f4572..bc838766 100644 --- a/src/test/scala/chiselTests/Harness.scala +++ b/src/test/scala/chiselTests/Harness.scala @@ -55,7 +55,7 @@ int main(int argc, char **argv, char **env) { val cppHarness = makeCppHarness(fname) make(fname) - verilogToCpp(target, path, Seq(), cppHarness).! + verilogToCpp(target, target, path, Seq(), cppHarness).! cppToExe(target, path).! (path, target) } -- cgit v1.2.3