Emit timescale in hierarchical block only when timescale is specified (#2735)

* Add a test for hierarchical verilation without timescale

* Emit timeunit in hierarchical wrapper only when it is specified in the input design or command line option.

* Update src/V3AstNodes.h

Co-authored-by: Wilson Snyder <[email protected]>

Co-authored-by: Wilson Snyder <[email protected]>
This commit is contained in:
Yutetsu TAKATSUKASA
2021-01-02 08:31:27 +09:00
committed by GitHub
co-authored by Wilson Snyder
parent bd602d0e2d
commit 7a18adc716
6 changed files with 15 additions and 9 deletions
+6 -8
View File
@@ -135,20 +135,18 @@ private:
"See instructions in your simulator for how"
" to use DPI libraries\n");
bool timescaleShown = false;
if (v3Global.opt.hierChild() && !modp->timeunit().isNone()) {
// Emit timescale for hierarhical verilation
timescaleShown = true;
txtp->addText(fl, string("`timescale ") + modp->timeunit().ascii() + "/"
+ v3Global.rootp()->timeprecision().ascii() + "\n\n");
}
// Module declaration
m_modPortsp = new AstTextBlock(fl, "module " + m_libName + " (\n", false, true);
txtp->addNodep(m_modPortsp);
txtp->addText(fl, ");\n\n");
// Timescale
if (!timescaleShown) {
if (v3Global.opt.hierChild() && v3Global.rootp()->timescaleSpecified()) {
// Emit timescale for hierarhical verilation if input HDL specifies timespec
txtp->addText(fl, string("timeunit ") + modp->timeunit().ascii() + ";\n");
txtp->addText(fl, string("timeprecision ") + +v3Global.rootp()->timeprecision().ascii()
+ ";\n");
} else {
addComment(txtp, fl,
"Precision of submodule"
" (commented out to avoid requiring timescale on all modules)");