diff --git a/Changes b/Changes index 42ce9b19b..b7afe9dca 100644 --- a/Changes +++ b/Changes @@ -7,6 +7,8 @@ indicates the contributor was also the author of the fix; Thanks! **** Add error message when modules have duplicate names. [Stefan Thiede] +**** Fix multiple .v files being read in random order. [Stefan Thiede] + * Verilator 3.661 2008/04/04 *** The --enable-defenv configure option added in 3.660 is now the default. diff --git a/src/V3Options.cpp b/src/V3Options.cpp index c3b1ec070..ef40e43ff 100644 --- a/src/V3Options.cpp +++ b/src/V3Options.cpp @@ -101,9 +101,9 @@ void V3Options::addLibraryFile(const string& filename) { } } void V3Options::addVFile(const string& filename) { - if (m_vFiles.find(filename) == m_vFiles.end()) { - m_vFiles.insert(filename); - } + // We use a list for v files, because it's legal to have includes + // in a specific order and multiple of them. + m_vFiles.push_back(filename); } void V3Options::addArg(const string& arg) { m_impp->m_allArgs.push_back(arg); diff --git a/src/V3Options.h b/src/V3Options.h index 48c4ae033..4f9a2c2a6 100644 --- a/src/V3Options.h +++ b/src/V3Options.h @@ -25,6 +25,7 @@ #include "config_build.h" #include "verilatedos.h" #include +#include #include #include "V3Global.h" @@ -70,6 +71,7 @@ public: class V3OptionsImp; class FileLine; +typedef vector V3StringList; typedef set V3StringSet; class V3Options { @@ -78,7 +80,7 @@ class V3Options { V3StringSet m_cppFiles; // argument: C++ files to link against V3StringSet m_libraryFiles; // argument: Verilog -v files - V3StringSet m_vFiles; // argument: Verilog files to read + V3StringList m_vFiles; // argument: Verilog files to read bool m_preprocOnly; // main switch: -E bool m_makeDepend; // main switch: -MMD @@ -217,7 +219,7 @@ class V3Options { string xAssign() const { return m_xAssign; } const V3StringSet& cppFiles() const { return m_cppFiles; } const V3StringSet& libraryFiles() const { return m_libraryFiles; } - const V3StringSet& vFiles() const { return m_vFiles; } + const V3StringList& vFiles() const { return m_vFiles; } const V3LangCode& language() const { return m_language; } // ACCESSORS (optimization options) diff --git a/src/Verilator.cpp b/src/Verilator.cpp index d378020b0..e846669c9 100644 --- a/src/Verilator.cpp +++ b/src/Verilator.cpp @@ -91,7 +91,7 @@ V3Global v3Global; void V3Global::readFiles() { V3Read reader (m_rootp); // Read top module - for (V3StringSet::iterator it = v3Global.opt.vFiles().begin(); + for (V3StringList::const_iterator it = v3Global.opt.vFiles().begin(); it != v3Global.opt.vFiles().end(); ++it) { string filename = *it; reader.readFile(new FileLine("CommandLine",0), filename, false); @@ -100,7 +100,7 @@ void V3Global::readFiles() { // Read libraries // To be compatible with other simulators, // this needs to be done after the top file is read - for (V3StringSet::iterator it = v3Global.opt.libraryFiles().begin(); + for (V3StringSet::const_iterator it = v3Global.opt.libraryFiles().begin(); it != v3Global.opt.libraryFiles().end(); ++it) { string filename = *it; reader.readFile(new FileLine("CommandLine",0), filename, true);