From 8301fdc6d35cfd78ccaee6a4381be5bc161bfb7f Mon Sep 17 00:00:00 2001 From: Szymon Gizler <151655464+sgizler@users.noreply.github.com> Date: Thu, 28 Mar 2024 12:32:18 +0100 Subject: [PATCH] Add JSON AST dumps (#5020) --- Makefile.in | 1 + bin/verilator | 2 + ci/ci-install.bash | 8 +- docs/guide/exe_verilator.rst | 14 +- docs/guide/install.rst | 3 +- docs/internals.rst | 20 +- src/.gdbinit | 20 ++ src/.gdbinit.py | 80 +++++ src/V3Ast.cpp | 31 +- src/V3Ast.h | 8 +- src/V3Error.cpp | 6 +- src/V3Error.h | 6 +- src/V3Global.cpp | 20 +- src/Verilator.cpp | 2 +- test_regress/t/t_dump.v | 85 ++++++ test_regress/t/t_dump_json.out | 525 +++++++++++++++++++++++++++++++++ test_regress/t/t_dump_json.pl | 23 ++ 17 files changed, 828 insertions(+), 26 deletions(-) create mode 100644 src/.gdbinit.py create mode 100644 test_regress/t/t_dump.v create mode 100644 test_regress/t/t_dump_json.out create mode 100755 test_regress/t/t_dump_json.pl diff --git a/Makefile.in b/Makefile.in index c26650d8a..9d2ce218f 100644 --- a/Makefile.in +++ b/Makefile.in @@ -438,6 +438,7 @@ PY_PROGRAMS = \ src/cppcheck_filtered \ src/flexfix \ src/vlcovgen \ + src/.gdbinit.py \ test_regress/t/*.pf \ nodist/clang_check_attributes \ nodist/code_coverage \ diff --git a/bin/verilator b/bin/verilator index 253981f18..8b7de97da 100755 --- a/bin/verilator +++ b/bin/verilator @@ -348,10 +348,12 @@ detailed descriptions of these arguments. --dump-tree Enable dumping Ast .tree files --dump-tree-addrids Use short identifiers instead of addresses --dump-tree-dot Enable dumping Ast .tree.dot debug files + --dump-tree-json Enable dumping Ast .tree.json files and .tree.meta.json file --dump- Enable dumping everything in source file --dumpi-dfg Enable dumping DfgGraphs to .dot files at level --dumpi-graph Enable dumping V3Graphs to .dot files at level --dumpi-tree Enable dumping Ast .tree files at level + --dumpi-tree-json Enable dumping Ast .tree.json files at level --dumpi- Enable dumping everything in source file at level -E Preprocess, but do not compile --error-limit Abort after this number of errors diff --git a/ci/ci-install.bash b/ci/ci-install.bash index 98adb30b3..0907d081e 100755 --- a/ci/ci-install.bash +++ b/ci/ci-install.bash @@ -92,8 +92,8 @@ elif [ "$CI_BUILD_STAGE_NAME" = "test" ]; then sudo apt-get update || sudo apt-get update # libfl-dev needed for internal coverage's test runs - sudo apt-get install gdb gtkwave lcov libfl-dev ccache || - sudo apt-get install gdb gtkwave lcov libfl-dev ccache + sudo apt-get install gdb gtkwave lcov libfl-dev ccache jq || + sudo apt-get install gdb gtkwave lcov libfl-dev ccache jq # Required for test_regress/t/t_dist_attributes.pl if [ "$CI_RUNS_ON" = "ubuntu-22.04" ]; then sudo apt-get install python3-clang mold || @@ -106,10 +106,10 @@ elif [ "$CI_BUILD_STAGE_NAME" = "test" ]; then elif [ "$CI_OS_NAME" = "osx" ]; then brew update # brew cask install gtkwave # fst2vcd hangs at launch, so don't bother - brew install ccache perl + brew install ccache perl jq elif [ "$CI_OS_NAME" = "freebsd" ]; then # fst2vcd fails with "Could not open '', exiting." - sudo pkg install -y ccache gmake perl5 python3 + sudo pkg install -y ccache gmake perl5 python3 jq else fatal "Unknown os: '$CI_OS_NAME'" fi diff --git a/docs/guide/exe_verilator.rst b/docs/guide/exe_verilator.rst index 02b2adee1..7bd370b2c 100644 --- a/docs/guide/exe_verilator.rst +++ b/docs/guide/exe_verilator.rst @@ -413,6 +413,12 @@ Summary: :vlopt:`--debug --no-dump-tree <--dump-tree>` may be useful if the dump files are large and not desired. +.. option:: --dump-tree-json + + Rarely needed. Enable dumping Ast .json.tree debug files with dumping level 3, + which dumps the standard critical stages. For details on the format, see + the Verilator Internals manual. + .. option:: --dump-tree-dot Rarely needed. Enable dumping Ast .tree.dot debug files in Graphviz @@ -448,6 +454,11 @@ Summary: Rarely needed - for developer use. Set internal Ast dumping level globally to the specified value. +.. option:: --dumpi-tree-json + + Rarely needed - for developer use. Set internal Ast JSON dumping level + globally to the specified value. + .. option:: --dumpi- Rarely needed - for developer use. Set the dumping level in the @@ -1798,7 +1809,8 @@ Summary: format is still evolving; there will be some changes in future versions. This option disables some more aggressive transformations and dumps only - the final state of the AST. + the final state of the AST. For more granular and unaltered dumps, meant + mainly for debugging see :vlopt:`--dump-tree-json`. .. option:: --json-only-meta-output diff --git a/docs/guide/install.rst b/docs/guide/install.rst index 7b8d3f834..8ae132f9c 100644 --- a/docs/guide/install.rst +++ b/docs/guide/install.rst @@ -126,8 +126,9 @@ Those developing Verilator itself may also want these (see internals.rst): :: sudo apt-get install clang clang-format-14 cmake gdb gprof graphviz lcov - sudo apt-get install python3-clang yapf3 bear + sudo apt-get install python3-clang yapf3 bear jq sudo pip3 install sphinx sphinx_rtd_theme sphinxcontrib-spelling breathe ruff + sudo pip3 install git+https://github.com/antmicro/astsee.git cpan install Pod::Perldoc cpan install Parallel::Forker diff --git a/docs/internals.rst b/docs/internals.rst index 1d6064182..72a0f3b3a 100644 --- a/docs/internals.rst +++ b/docs/internals.rst @@ -1701,7 +1701,7 @@ Similarly, the ``NETLIST`` has a list of modules referred to by its ``.tree.json``` is an alternative dump format to ``.tree`` that is meant for programmatic processing (e.g. with `astsee `_). -To enable this dump format, use :vlopt:`--json-only`. +To enable this dump format, use :vlopt:`--dump-tree-json` or :vlopt:`--json-only`. Structure: :: @@ -1743,8 +1743,8 @@ Structure: .tree.meta.json Output ---------------- - -.tree.meta.json contains metadata that is common across the whole AST tree. +.tree.meta.json contains metadata that is common across the whole AST tree +(in case of --dump-tree-json, multiple trees share one meta file). Besides de-duplication of data shared between multiple stages, .meta.json enables offloading unstable data (that can vary from machine-to-machine or run-to-run) from main .tree.json. @@ -1846,6 +1846,20 @@ To print a node: pnt nodep # or: call dumpTreeGdb(nodep) # aliased to "pnt" in src/.gdbinit +``src/.gdbinit`` and ``src/.gdbinit.py`` define handy utilities for working with +JSON AST dumps. For example: + +* ``jstash nodep`` - Perform a JSON AST dump and save it into GDB value history (e.g. ``$1``) +* ``jtree nodep`` - Perform a JSON AST dump and pretty print it using ``astsee_verilator``. +* ``jtree $1`` - Pretty print a dump that was previously saved by ``jstash``. +* ``jtree nodep -d '.file, .timeunit'`` - Perform a JSON AST dump, filter out some fields and pretty print it. +* ``jtree 0x55555613dca0`` - Pretty print using address literal (rather than actual pointer). +* ``jtree $1 nodep`` - Diff ``nodep`` against an older dump. + +A detailed description of ``jstash`` and ``jtree`` can be displayed using ``gdb``'s ``help`` command. + +These commands require `astsee `_ to be installed. + When GDB halts, it is useful to understand that the backtrace will commonly show the iterator functions between each invocation of ``visit`` in the backtrace. You will typically see a frame sequence something like: diff --git a/src/.gdbinit b/src/.gdbinit index df31f80f4..1a6bac586 100644 --- a/src/.gdbinit +++ b/src/.gdbinit @@ -20,6 +20,26 @@ document pnt Verilator: Print AstNode NODEP's tree end +# Source python-based gdb config with jshow/jdiff definitions +# (Stored in separate file, so it can be highlighted/linted/formatted as Python) +python +import os +if "VERILATOR_ROOT" in os.environ: + gdbinit_py = os.environ["VERILATOR_ROOT"] + "/src/.gdbinit.py" + gdb.execute("source" + gdbinit_py) +end + +define jstash + call (char*) &(AstNode::dumpTreeJsonGdb($arg0)[0]) +end +document jstash +Verilator: Perform a JSON dump of the given AST node and save it in value history (e.g. $1) for later +inspection using jtree. The node can be a pointer identifier or an address literal. +end + +alias -a js=jstash +alias -a jt=jtree + define dtf call AstNode::dumpTreeFileGdb($arg0, 0) end diff --git a/src/.gdbinit.py b/src/.gdbinit.py new file mode 100644 index 000000000..767f88387 --- /dev/null +++ b/src/.gdbinit.py @@ -0,0 +1,80 @@ +# pylint: disable=line-too-long,invalid-name,multiple-statements,missing-function-docstring,missing-class-docstring,missing-module-docstring,no-else-return,too-few-public-methods,unused-argument +# DESCRIPTION: Verilator: GDB startup file with useful define +# +# Copyright 2023 by Wilson Snyder. This program is free software; you +# can redistribute it and/or modify the Verilator internals under the terms +# of either the GNU Lesser General Public License Version 3 or the Perl +# Artistic License Version 2.0. +# +# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0 +###################################################################### + +import tempfile +import gdb # pylint: disable=import-error + + +def _vltgdb_get_dump(node): + gdb.execute(f'set $_gdb_dump_json_str = AstNode::dumpTreeJsonGdb({node})') + dump = gdb.execute('printf "%s", $_gdb_dump_json_str', to_string=True) + gdb.execute('call free($_gdb_dump_json_str)') + return dump + + +def _vltgdb_tmpfile(): + return tempfile.NamedTemporaryFile(mode="wt") # write, text mode + + +def _vltgdb_fwrite(file, s): + """Write to file and flush buffer before passing the file to astsee""" + file.write(s) + file.flush() + + +class AstseeCmd(gdb.Command): + """Verilator: Pretty print or diff nodes using `astsee`. A node can be: + * an pointer identifier, + * an address literal, + * a GDB value (like `$1`) that stores a dump previously done by the `jstash` command. + Apart from not taking input from a file, it works exactly like `verilator_astsee`: + * passing one node gives you a pretty print, + * passing two nodes gives you a diff, + * for more options see `astsee` readme/help. + For examples see internals.rst + """ + + def __init__(self): + super().__init__("jtree", gdb.COMMAND_USER, gdb.COMPLETE_EXPRESSION) + + def _null_check(self, old, new): + err = "" + if old == "\n": err += "old == \n" + if new == "\n": err += "new == " + if err: raise gdb.GdbError(err.strip("\n")) + + def invoke(self, arg_str, from_tty): + from astsee import verilator_cli as astsee # pylint: disable=import-error,import-outside-toplevel + # we import it here so "no module X" error would occur on typing `jtree` rather than on every gdb start + + # We hack `astsee_verilator`'s arg parser to find arguments with nodes + # After finding them, we replace them with proper files + astsee_args = astsee.parser.parse_args(gdb.string_to_argv(arg_str)) + with _vltgdb_tmpfile() as oldfile, _vltgdb_tmpfile( + ) as newfile, _vltgdb_tmpfile() as metafile: + if astsee_args.file: + _vltgdb_fwrite(oldfile, _vltgdb_get_dump(astsee_args.file)) + astsee_args.file = oldfile.name + if astsee_args.newfile: + _vltgdb_fwrite(newfile, _vltgdb_get_dump(astsee_args.newfile)) + astsee_args.newfile = newfile.name + if astsee_args.meta is None: + # pass + gdb.execute( + f'call AstNode::dumpJsonMetaFileGdb("{metafile.name}")') + astsee_args.meta = metafile.name + try: + astsee.main(astsee_args) + except SystemExit as e: # astsee prints nice errmsgs on exit(), so rethrow it as GdbError to suppress cryptic python trace + raise gdb.GdbError("astsee exited with non-zero code") from e + + +AstseeCmd() diff --git a/src/V3Ast.cpp b/src/V3Ast.cpp index 4117f9ba1..88372b106 100644 --- a/src/V3Ast.cpp +++ b/src/V3Ast.cpp @@ -17,7 +17,6 @@ #include "V3PchAstMT.h" #include "V3Broken.h" -#include "V3EmitV.h" #include "V3File.h" #include @@ -1198,6 +1197,23 @@ void AstNode::checkTreeIter(const AstNode* prevBackp) const VL_MT_STABLE { } } +// cppcheck-suppress unusedFunction // Debug only +char* AstNode::dumpTreeJsonGdb(const AstNode* nodep) { + if (!nodep) return strdup("{\"addr\":\"NULL\"}\n"); + std::stringstream nodepStream; + nodep->dumpTreeJson(nodepStream); + const std::string str = nodepStream.rdbuf()->str(); + return strdup(str.c_str()); +} +// cppcheck-suppress unusedFunction // Debug only +// identity func to allow for passing already done dumps to jtree +char* AstNode::dumpTreeJsonGdb(const char* str) { return strdup(str); } +// cppcheck-suppress unusedFunction // Debug only +// allow for passing pointer literals like 0x42.. without manual cast +char* AstNode::dumpTreeJsonGdb(intptr_t nodep) { + if (!nodep) return strdup("{\"addr\":\"NULL\"}\n"); + return dumpTreeJsonGdb((const AstNode*)nodep); +} // cppcheck-suppress unusedFunction // Debug only void AstNode::dumpGdb(const AstNode* nodep) { // For GDB only // LCOV_EXCL_LINE if (!nodep) { @@ -1301,7 +1317,7 @@ void AstNode::dumpTreeAndNext(std::ostream& os, const string& indent, int maxDep } } -void AstNode::dumpTreeFile(const string& filename, bool doDump, bool doCheck) { +void AstNode::dumpTreeFile(const string& filename, bool doDump) { // Not const function as calls checkTree if (doDump) { { // Write log & close @@ -1319,14 +1335,6 @@ void AstNode::dumpTreeFile(const string& filename, bool doDump, bool doCheck) { } } } - if (doDump && v3Global.opt.debugEmitV()) V3EmitV::debugEmitV(filename + ".v"); - if (doCheck && (v3Global.opt.debugCheck() || ::dumpTreeLevel())) { - // Error check - checkTree(); - // Broken isn't part of check tree because it can munge iterp's - // set by other steps if it is called in the middle of other operations - if (AstNetlist* const netp = VN_CAST(this, Netlist)) V3Broken::brokenAll(netp); - } } static void drawChildren(std::ostream& os, const AstNode* thisp, const AstNode* childp, @@ -1365,10 +1373,11 @@ void AstNode::dumpTreeJsonFile(const string& filename, bool doDump) { *treejsonp << '\n'; } +void AstNode::dumpJsonMetaFileGdb(const char* filename) { dumpJsonMetaFile(filename); } void AstNode::dumpJsonMetaFile(const string& filename) { UINFO(2, "Dumping " << filename << endl); const std::unique_ptr treejsonp{V3File::new_ofstream(filename)}; - if (treejsonp->fail()) v3fatal("Can't write " << filename); + if (treejsonp->fail()) v3fatalStatic("Can't write " << filename); *treejsonp << '{'; FileLine::fileNameNumMapDumpJson(*treejsonp); *treejsonp << ','; diff --git a/src/V3Ast.h b/src/V3Ast.h index 884e28948..b03d983b3 100644 --- a/src/V3Ast.h +++ b/src/V3Ast.h @@ -2203,6 +2203,9 @@ public: string warnOther() const VL_REQUIRES(V3Error::s().m_mutex) { return fileline()->warnOther(); } virtual void dump(std::ostream& str = std::cout) const; + static char* dumpTreeJsonGdb(const AstNode* nodep); // For GDB only, free()d by caller + static char* dumpTreeJsonGdb(const char* str); // For GDB only, free()d by caller + static char* dumpTreeJsonGdb(intptr_t nodep); // For GDB only, free()d by caller static void dumpGdb(const AstNode* nodep); // For GDB only void dumpGdbHeader() const; @@ -2253,7 +2256,7 @@ public: static void dumpTreeGdb(const AstNode* nodep); // For GDB only void dumpTreeAndNext(std::ostream& os = std::cout, const string& indent = " ", int maxDepth = 0) const; - void dumpTreeFile(const string& filename, bool doDump = true, bool doCheck = true); + void dumpTreeFile(const string& filename, bool doDump = true); static void dumpTreeFileGdb(const AstNode* nodep, const char* filenamep = nullptr); void dumpTreeDot(std::ostream& os = std::cout) const; void dumpTreeDotFile(const string& filename, bool doDump = true); @@ -2264,7 +2267,8 @@ public: virtual void dumpTreeJsonOpGen(std::ostream& os, const string& indent) const {}; void dumpTreeJson(std::ostream& os, const string& indent = "") const; void dumpTreeJsonFile(const string& filename, bool doDump = true); - void dumpJsonMetaFile(const string& filename); + static void dumpJsonMetaFileGdb(const char* filename); + static void dumpJsonMetaFile(const string& filename); // Render node address for dumps. By default this is just the address // printed as hex, but with --dump-tree-addrids we map addresses to short diff --git a/src/V3Error.cpp b/src/V3Error.cpp index 6b6b09f73..bbb6982bf 100644 --- a/src/V3Error.cpp +++ b/src/V3Error.cpp @@ -221,12 +221,16 @@ void V3ErrorGuarded::v3errorEnd(std::ostringstream& sstr, const string& extra) tellManual(2); } #ifndef V3ERROR_NO_GLOBAL_ - if (dumpTreeLevel() || debug()) { + if (dumpTreeLevel() || dumpTreeJsonLevel() || debug()) { V3Broken::allowMidvisitorCheck(true); const V3ThreadPool::ScopedExclusiveAccess exclusiveAccess; if (dumpTreeLevel()) { v3Global.rootp()->dumpTreeFile(v3Global.debugFilename("final.tree", 990)); } + if (dumpTreeJsonLevel()) { + v3Global.rootp()->dumpTreeJsonFile( + v3Global.debugFilename("final.tree.json", 990)); + } if (debug()) { execErrorExitCb(); V3Stats::statsFinalAll(v3Global.rootp()); diff --git a/src/V3Error.h b/src/V3Error.h index d3546aeba..ba463010c 100644 --- a/src/V3Error.h +++ b/src/V3Error.h @@ -685,7 +685,11 @@ void v3errorEndFatal(std::ostringstream& sstr) VL_DEFINE_DUMP(DfgLevel, "dfg"); /* Define 'int dumpDfgLevel()' for --dumpi-level */ \ VL_DEFINE_DUMP(GraphLevel, "graph"); /* Define 'int dumpGraphLevel()' for dumpi-graph */ \ VL_DEFINE_DUMP(TreeLevel, "tree"); /* Define 'int dumpTreeLevel()' for dumpi-tree */ \ - VL_ATTR_UNUSED static int dumpTreeEitherLevel() { return dumpTreeLevel(); } \ + VL_DEFINE_DUMP(TreeJsonLevel, \ + "tree-json"); /* Define 'int dumpTreeJsonLevel()' for dumpi-tree-json */ \ + VL_ATTR_UNUSED static int dumpTreeEitherLevel() { \ + return dumpTreeJsonLevel() >= dumpTreeLevel() ? dumpTreeJsonLevel() : dumpTreeLevel(); \ + } \ static_assert(true, "") //---------------------------------------------------------------------- diff --git a/src/V3Global.cpp b/src/V3Global.cpp index 3505fceb4..8bc0d61ef 100644 --- a/src/V3Global.cpp +++ b/src/V3Global.cpp @@ -16,6 +16,10 @@ #include "V3PchAstMT.h" +#include "V3Global.h" + +#include "V3EmitV.h" +#include "V3Error.h" #include "V3File.h" #include "V3HierBlock.h" #include "V3LinkCells.h" @@ -23,6 +27,8 @@ #include "V3ParseSym.h" #include "V3Stats.h" +VL_DEFINE_DEBUG_FUNCTIONS; + //###################################################################### // V3Global @@ -106,11 +112,23 @@ string V3Global::digitsFilename(int number) { void V3Global::dumpCheckGlobalTree(const string& stagename, int newNumber, bool doDump) { const string treeFilename = v3Global.debugFilename(stagename + ".tree", newNumber); - v3Global.rootp()->dumpTreeFile(treeFilename, doDump); + if (dumpTreeLevel()) v3Global.rootp()->dumpTreeFile(treeFilename, doDump); + if (dumpTreeJsonLevel()) { + v3Global.rootp()->dumpTreeJsonFile(treeFilename + ".json", doDump); + } if (v3Global.opt.dumpTreeDot()) { v3Global.rootp()->dumpTreeDotFile(treeFilename + ".dot", doDump); } if (v3Global.opt.stats()) V3Stats::statsStage(stagename); + + if (doDump && v3Global.opt.debugEmitV()) V3EmitV::debugEmitV(treeFilename + ".v"); + if (v3Global.opt.debugCheck() || dumpTreeEitherLevel()) { + // Error check + v3Global.rootp()->checkTree(); + // Broken isn't part of check tree because it can munge iterp's + // set by other steps if it is called in the middle of other operations + V3Broken::brokenAll(v3Global.rootp()); + } } void V3Global::idPtrMapDumpJson(std::ostream& os) { diff --git a/src/Verilator.cpp b/src/Verilator.cpp index 1882b9afa..672307a06 100644 --- a/src/Verilator.cpp +++ b/src/Verilator.cpp @@ -709,7 +709,7 @@ static void verilate(const string& argString) { // Final steps V3Global::dumpCheckGlobalTree("final", 990, dumpTreeEitherLevel() >= 3); - if (v3Global.opt.jsonOnly()) { + if (v3Global.opt.jsonOnly() || dumpTreeJsonLevel()) { const string filename = (v3Global.opt.jsonOnlyMetaOutput().empty() ? v3Global.opt.makeDir() + "/" + v3Global.opt.prefix() + ".tree.meta.json" diff --git a/test_regress/t/t_dump.v b/test_regress/t/t_dump.v new file mode 100644 index 000000000..2467605e5 --- /dev/null +++ b/test_regress/t/t_dump.v @@ -0,0 +1,85 @@ +// DESCRIPTION: Verilator: Verilog Test module +// +// This file ONLY is placed under the Creative Commons Public Domain, for +// any use, without warranty, 2024 by Wilson Snyder. +// SPDX-License-Identifier: CC0-1.0 + +module t(/*AUTOARG*/ + // Inputs + clk + ); + input clk; + + integer cyc = 0; + reg [63:0] crc; + reg [63:0] sum; + + // Take CRC data and apply to testblock inputs + wire [31:0] in = crc[31:0]; + + /*AUTOWIRE*/ + // Beginning of automatic wires (for undeclared instantiated-module outputs) + wire [31:0] out; // From test of Test.v + // End of automatics + + Test test(/*AUTOINST*/ + // Outputs + .out (out[31:0]), + // Inputs + .clk (clk), + .in (in[31:0])); + + // Aggregate outputs into a single result vector + wire [63:0] result = {32'h0, out}; + + // Test loop + always @ (posedge clk) begin +`ifdef TEST_VERBOSE + $write("[%0t] cyc==%0d crc=%x result=%x\n", $time, cyc, crc, result); +`endif + cyc <= cyc + 1; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; + sum <= result ^ {sum[62:0], sum[63] ^ sum[2] ^ sum[0]}; + if (cyc == 0) begin + // Setup + crc <= 64'h5aef0c8d_d70a4497; + sum <= '0; + end + else if (cyc < 10) begin + sum <= '0; + end + else if (cyc < 90) begin + end + else if (cyc == 99) begin + $write("[%0t] cyc==%0d crc=%x sum=%x\n", $time, cyc, crc, sum); + if (crc !== 64'hc77bb9b3784ea091) $stop; + // What checksum will we end up with (above print should match) +`define EXPECTED_SUM 64'h4afe43fb79d7b71e + if (sum !== `EXPECTED_SUM) $stop; + $write("*-* All Finished *-*\n"); + $finish; + end + end + +endmodule + +module Test(/*AUTOARG*/ + // Outputs + out, + // Inputs + clk, in + ); + + // Replace this module with the device under test. + // + // Change the code in the t module to apply values to the inputs and + // merge the output values into the result vector. + + input clk; + input [31:0] in; + output reg [31:0] out; + + always @(posedge clk) begin + out <= in; + end +endmodule diff --git a/test_regress/t/t_dump_json.out b/test_regress/t/t_dump_json.out new file mode 100644 index 000000000..69c2dddea --- /dev/null +++ b/test_regress/t/t_dump_json.out @@ -0,0 +1,525 @@ +{"type":"NETLIST","name":"$root","addr":"(B)","loc":"a,0:0,0:0","timeunit":"1ps","timeprecision":"1ps","typeTablep":"(C)","constPoolp":"(D)","dollarUnitPkgp":"UNLINKED","stdPackagep":"UNLINKED","evalp":"UNLINKED","evalNbap":"UNLINKED","dpiExportTriggerp":"UNLINKED","delaySchedulerp":"UNLINKED","nbaEventp":"UNLINKED","nbaEventTriggerp":"UNLINKED","topScopep":"UNLINKED", + "modulesp": [ + {"type":"MODULE","name":"t","addr":"(E)","loc":"d,7:8,7:9","origName":"t","level":2,"modPublic":false,"inLibrary":false,"dead":false,"recursiveClone":false,"recursive":false,"timeunit":"1ps","inlinesp": [], + "stmtsp": [ + {"type":"PORT","name":"clk","addr":"(F)","loc":"d,9:4,9:7","exprp": []}, + {"type":"VAR","name":"clk","addr":"(G)","loc":"d,11:10,11:13","dtypep":"UNLINKED","origName":"clk","isSc":false,"isPrimaryIO":false,"direction":"INPUT","isConst":false,"isPullup":false,"isPulldown":false,"isUsedClock":false,"isSigPublic":false,"isLatched":false,"isUsedLoopIdx":false,"noReset":false,"attrIsolateAssign":false,"attrFileDescr":false,"isDpiOpenArray":false,"isFuncReturn":false,"isFuncLocal":false,"attrClocker":"UNKNOWN","lifetime":"NONE","varType":"PORT","isSigUserRdPublic":false,"isSigUserRWPublic":false,"isGParam":false,"isParam":false,"attrScBv":false,"attrSFormat":false,"sensIfacep":"UNLINKED", + "childDTypep": [ + {"type":"BASICDTYPE","name":"LOGIC_IMPLICIT","addr":"(H)","loc":"d,11:10,11:13","dtypep":"(H)","keyword":"LOGIC_IMPLICIT","generic":false,"rangep": []} + ],"delayp": [],"valuep": [],"attrsp": []}, + {"type":"VAR","name":"cyc","addr":"(I)","loc":"d,13:12,13:15","dtypep":"UNLINKED","origName":"cyc","isSc":false,"isPrimaryIO":false,"direction":"NONE","isConst":false,"isPullup":false,"isPulldown":false,"isUsedClock":false,"isSigPublic":false,"isLatched":false,"isUsedLoopIdx":false,"noReset":false,"attrIsolateAssign":false,"attrFileDescr":false,"isDpiOpenArray":false,"isFuncReturn":false,"isFuncLocal":false,"attrClocker":"UNKNOWN","lifetime":"NONE","varType":"VAR","isSigUserRdPublic":false,"isSigUserRWPublic":false,"isGParam":false,"isParam":false,"attrScBv":false,"attrSFormat":false,"sensIfacep":"UNLINKED", + "childDTypep": [ + {"type":"BASICDTYPE","name":"integer","addr":"(J)","loc":"d,13:4,13:11","dtypep":"(J)","keyword":"integer","range":"31:0","generic":false,"rangep": []} + ],"delayp": [], + "valuep": [ + {"type":"CONST","name":"?32?sh0","addr":"(K)","loc":"d,13:18,13:19","dtypep":"(L)"} + ],"attrsp": []}, + {"type":"VAR","name":"crc","addr":"(M)","loc":"d,14:15,14:18","dtypep":"UNLINKED","origName":"crc","isSc":false,"isPrimaryIO":false,"direction":"NONE","isConst":false,"isPullup":false,"isPulldown":false,"isUsedClock":false,"isSigPublic":false,"isLatched":false,"isUsedLoopIdx":false,"noReset":false,"attrIsolateAssign":false,"attrFileDescr":false,"isDpiOpenArray":false,"isFuncReturn":false,"isFuncLocal":false,"attrClocker":"UNKNOWN","lifetime":"NONE","varType":"VAR","isSigUserRdPublic":false,"isSigUserRWPublic":false,"isGParam":false,"isParam":false,"attrScBv":false,"attrSFormat":false,"sensIfacep":"UNLINKED", + "childDTypep": [ + {"type":"BASICDTYPE","name":"logic","addr":"(N)","loc":"d,14:4,14:7","dtypep":"(N)","keyword":"logic","generic":false, + "rangep": [ + {"type":"RANGE","name":"","addr":"(O)","loc":"d,14:8,14:9","ascending":false, + "leftp": [ + {"type":"CONST","name":"?32?sh3f","addr":"(P)","loc":"d,14:9,14:11","dtypep":"(Q)"} + ], + "rightp": [ + {"type":"CONST","name":"?32?sh0","addr":"(R)","loc":"d,14:12,14:13","dtypep":"(L)"} + ]} + ]} + ],"delayp": [],"valuep": [],"attrsp": []}, + {"type":"VAR","name":"sum","addr":"(S)","loc":"d,15:15,15:18","dtypep":"UNLINKED","origName":"sum","isSc":false,"isPrimaryIO":false,"direction":"NONE","isConst":false,"isPullup":false,"isPulldown":false,"isUsedClock":false,"isSigPublic":false,"isLatched":false,"isUsedLoopIdx":false,"noReset":false,"attrIsolateAssign":false,"attrFileDescr":false,"isDpiOpenArray":false,"isFuncReturn":false,"isFuncLocal":false,"attrClocker":"UNKNOWN","lifetime":"NONE","varType":"VAR","isSigUserRdPublic":false,"isSigUserRWPublic":false,"isGParam":false,"isParam":false,"attrScBv":false,"attrSFormat":false,"sensIfacep":"UNLINKED", + "childDTypep": [ + {"type":"BASICDTYPE","name":"logic","addr":"(T)","loc":"d,15:4,15:7","dtypep":"(T)","keyword":"logic","generic":false, + "rangep": [ + {"type":"RANGE","name":"","addr":"(U)","loc":"d,15:8,15:9","ascending":false, + "leftp": [ + {"type":"CONST","name":"?32?sh3f","addr":"(V)","loc":"d,15:9,15:11","dtypep":"(Q)"} + ], + "rightp": [ + {"type":"CONST","name":"?32?sh0","addr":"(W)","loc":"d,15:12,15:13","dtypep":"(L)"} + ]} + ]} + ],"delayp": [],"valuep": [],"attrsp": []}, + {"type":"VAR","name":"in","addr":"(X)","loc":"d,18:16,18:18","dtypep":"UNLINKED","origName":"in","isSc":false,"isPrimaryIO":false,"direction":"NONE","isConst":false,"isPullup":false,"isPulldown":false,"isUsedClock":false,"isSigPublic":false,"isLatched":false,"isUsedLoopIdx":false,"noReset":false,"attrIsolateAssign":false,"attrFileDescr":false,"isDpiOpenArray":false,"isFuncReturn":false,"isFuncLocal":false,"attrClocker":"UNKNOWN","lifetime":"NONE","varType":"WIRE","isSigUserRdPublic":false,"isSigUserRWPublic":false,"isGParam":false,"isParam":false,"attrScBv":false,"attrSFormat":false,"sensIfacep":"UNLINKED", + "childDTypep": [ + {"type":"BASICDTYPE","name":"logic","addr":"(Y)","loc":"d,18:9,18:10","dtypep":"(Y)","keyword":"logic","generic":false, + "rangep": [ + {"type":"RANGE","name":"","addr":"(Z)","loc":"d,18:9,18:10","ascending":false, + "leftp": [ + {"type":"CONST","name":"?32?sh1f","addr":"(AB)","loc":"d,18:10,18:12","dtypep":"(BB)"} + ], + "rightp": [ + {"type":"CONST","name":"?32?sh0","addr":"(CB)","loc":"d,18:13,18:14","dtypep":"(L)"} + ]} + ]} + ],"delayp": [],"valuep": [],"attrsp": []}, + {"type":"ASSIGNW","name":"","addr":"(DB)","loc":"d,18:19,18:20","dtypep":"UNLINKED", + "rhsp": [ + {"type":"SELEXTRACT","name":"","addr":"(EB)","loc":"d,18:24,18:25","dtypep":"UNLINKED", + "fromp": [ + {"type":"PARSEREF","name":"crc","addr":"(FB)","loc":"d,18:21,18:24","dtypep":"UNLINKED","expect":"TEXT","lhsp": [],"ftaskrefp": []} + ], + "leftp": [ + {"type":"CONST","name":"?32?sh1f","addr":"(GB)","loc":"d,18:25,18:27","dtypep":"(BB)"} + ], + "rightp": [ + {"type":"CONST","name":"?32?sh0","addr":"(HB)","loc":"d,18:28,18:29","dtypep":"(L)"} + ],"attrp": []} + ], + "lhsp": [ + {"type":"PARSEREF","name":"in","addr":"(IB)","loc":"d,18:16,18:18","dtypep":"UNLINKED","expect":"TEXT","lhsp": [],"ftaskrefp": []} + ],"timingControlp": [],"strengthSpecp": []}, + {"type":"VAR","name":"out","addr":"(JB)","loc":"d,22:25,22:28","dtypep":"UNLINKED","origName":"out","isSc":false,"isPrimaryIO":false,"direction":"NONE","isConst":false,"isPullup":false,"isPulldown":false,"isUsedClock":false,"isSigPublic":false,"isLatched":false,"isUsedLoopIdx":false,"noReset":false,"attrIsolateAssign":false,"attrFileDescr":false,"isDpiOpenArray":false,"isFuncReturn":false,"isFuncLocal":false,"attrClocker":"UNKNOWN","lifetime":"NONE","varType":"WIRE","isSigUserRdPublic":false,"isSigUserRWPublic":false,"isGParam":false,"isParam":false,"attrScBv":false,"attrSFormat":false,"sensIfacep":"UNLINKED", + "childDTypep": [ + {"type":"BASICDTYPE","name":"logic","addr":"(KB)","loc":"d,22:9,22:10","dtypep":"(KB)","keyword":"logic","generic":false, + "rangep": [ + {"type":"RANGE","name":"","addr":"(LB)","loc":"d,22:9,22:10","ascending":false, + "leftp": [ + {"type":"CONST","name":"?32?sh1f","addr":"(MB)","loc":"d,22:10,22:12","dtypep":"(BB)"} + ], + "rightp": [ + {"type":"CONST","name":"?32?sh0","addr":"(NB)","loc":"d,22:13,22:14","dtypep":"(L)"} + ]} + ]} + ],"delayp": [],"valuep": [],"attrsp": []}, + {"type":"CELL","name":"test","addr":"(OB)","loc":"d,25:9,25:13","origName":"test","recursive":false,"modp":"(PB)", + "pinsp": [ + {"type":"PIN","name":"out","addr":"(QB)","loc":"d,27:15,27:18","svDotName":true,"svImplicit":false,"modVarp":"UNLINKED","modPTypep":"UNLINKED", + "exprp": [ + {"type":"SELEXTRACT","name":"","addr":"(RB)","loc":"d,27:45,27:46","dtypep":"UNLINKED", + "fromp": [ + {"type":"PARSEREF","name":"out","addr":"(SB)","loc":"d,27:42,27:45","dtypep":"UNLINKED","expect":"TEXT","lhsp": [],"ftaskrefp": []} + ], + "leftp": [ + {"type":"CONST","name":"?32?sh1f","addr":"(TB)","loc":"d,27:46,27:48","dtypep":"(BB)"} + ], + "rightp": [ + {"type":"CONST","name":"?32?sh0","addr":"(UB)","loc":"d,27:49,27:50","dtypep":"(L)"} + ],"attrp": []} + ]}, + {"type":"PIN","name":"clk","addr":"(VB)","loc":"d,29:15,29:18","svDotName":true,"svImplicit":false,"modVarp":"UNLINKED","modPTypep":"UNLINKED", + "exprp": [ + {"type":"PARSEREF","name":"clk","addr":"(WB)","loc":"d,29:42,29:45","dtypep":"UNLINKED","expect":"TEXT","lhsp": [],"ftaskrefp": []} + ]}, + {"type":"PIN","name":"in","addr":"(XB)","loc":"d,30:15,30:17","svDotName":true,"svImplicit":false,"modVarp":"UNLINKED","modPTypep":"UNLINKED", + "exprp": [ + {"type":"SELEXTRACT","name":"","addr":"(YB)","loc":"d,30:44,30:45","dtypep":"UNLINKED", + "fromp": [ + {"type":"PARSEREF","name":"in","addr":"(ZB)","loc":"d,30:42,30:44","dtypep":"UNLINKED","expect":"TEXT","lhsp": [],"ftaskrefp": []} + ], + "leftp": [ + {"type":"CONST","name":"?32?sh1f","addr":"(AC)","loc":"d,30:45,30:47","dtypep":"(BB)"} + ], + "rightp": [ + {"type":"CONST","name":"?32?sh0","addr":"(BC)","loc":"d,30:48,30:49","dtypep":"(L)"} + ],"attrp": []} + ]} + ],"paramsp": [],"rangep": [],"intfRefsp": []}, + {"type":"VAR","name":"result","addr":"(CC)","loc":"d,33:16,33:22","dtypep":"UNLINKED","origName":"result","isSc":false,"isPrimaryIO":false,"direction":"NONE","isConst":false,"isPullup":false,"isPulldown":false,"isUsedClock":false,"isSigPublic":false,"isLatched":false,"isUsedLoopIdx":false,"noReset":false,"attrIsolateAssign":false,"attrFileDescr":false,"isDpiOpenArray":false,"isFuncReturn":false,"isFuncLocal":false,"attrClocker":"UNKNOWN","lifetime":"NONE","varType":"WIRE","isSigUserRdPublic":false,"isSigUserRWPublic":false,"isGParam":false,"isParam":false,"attrScBv":false,"attrSFormat":false,"sensIfacep":"UNLINKED", + "childDTypep": [ + {"type":"BASICDTYPE","name":"logic","addr":"(DC)","loc":"d,33:9,33:10","dtypep":"(DC)","keyword":"logic","generic":false, + "rangep": [ + {"type":"RANGE","name":"","addr":"(EC)","loc":"d,33:9,33:10","ascending":false, + "leftp": [ + {"type":"CONST","name":"?32?sh3f","addr":"(FC)","loc":"d,33:10,33:12","dtypep":"(Q)"} + ], + "rightp": [ + {"type":"CONST","name":"?32?sh0","addr":"(GC)","loc":"d,33:13,33:14","dtypep":"(L)"} + ]} + ]} + ],"delayp": [],"valuep": [],"attrsp": []}, + {"type":"ASSIGNW","name":"","addr":"(HC)","loc":"d,33:23,33:24","dtypep":"UNLINKED", + "rhsp": [ + {"type":"REPLICATE","name":"","addr":"(IC)","loc":"d,33:25,33:26","dtypep":"(JC)", + "srcp": [ + {"type":"CONCAT","name":"","addr":"(KC)","loc":"d,33:31,33:32","dtypep":"UNLINKED", + "lhsp": [ + {"type":"CONST","name":"32'h0","addr":"(LC)","loc":"d,33:26,33:31","dtypep":"(MC)"} + ], + "rhsp": [ + {"type":"PARSEREF","name":"out","addr":"(NC)","loc":"d,33:33,33:36","dtypep":"UNLINKED","expect":"TEXT","lhsp": [],"ftaskrefp": []} + ]} + ], + "countp": [ + {"type":"CONST","name":"32'h1","addr":"(OC)","loc":"d,33:25,33:26","dtypep":"(MC)"} + ]} + ], + "lhsp": [ + {"type":"PARSEREF","name":"result","addr":"(PC)","loc":"d,33:16,33:22","dtypep":"UNLINKED","expect":"TEXT","lhsp": [],"ftaskrefp": []} + ],"timingControlp": [],"strengthSpecp": []}, + {"type":"ALWAYS","name":"","addr":"(QC)","loc":"d,36:4,36:10","keyword":"always","isSuspendable":false,"needProcess":false,"sensesp": [], + "stmtsp": [ + {"type":"EVENTCONTROL","name":"","addr":"(RC)","loc":"d,36:11,36:12", + "sensesp": [ + {"type":"SENTREE","name":"","addr":"(SC)","loc":"d,36:11,36:12","isMulti":false, + "sensesp": [ + {"type":"SENITEM","name":"","addr":"(TC)","loc":"d,36:14,36:21","edgeType":"POS", + "sensp": [ + {"type":"PARSEREF","name":"clk","addr":"(UC)","loc":"d,36:22,36:25","dtypep":"UNLINKED","expect":"TEXT","lhsp": [],"ftaskrefp": []} + ],"condp": []} + ]} + ], + "stmtsp": [ + {"type":"BEGIN","name":"","addr":"(VC)","loc":"d,36:27,36:32","generate":false,"genfor":false,"implied":false,"needProcess":false,"unnamed":true,"genforp": [], + "stmtsp": [ + {"type":"ASSIGNDLY","name":"","addr":"(WC)","loc":"d,40:11,40:13","dtypep":"UNLINKED", + "rhsp": [ + {"type":"ADD","name":"","addr":"(XC)","loc":"d,40:18,40:19","dtypep":"UNLINKED", + "lhsp": [ + {"type":"PARSEREF","name":"cyc","addr":"(YC)","loc":"d,40:14,40:17","dtypep":"UNLINKED","expect":"TEXT","lhsp": [],"ftaskrefp": []} + ], + "rhsp": [ + {"type":"CONST","name":"?32?sh1","addr":"(ZC)","loc":"d,40:20,40:21","dtypep":"(L)"} + ]} + ], + "lhsp": [ + {"type":"PARSEREF","name":"cyc","addr":"(AD)","loc":"d,40:7,40:10","dtypep":"UNLINKED","expect":"TEXT","lhsp": [],"ftaskrefp": []} + ],"timingControlp": []}, + {"type":"ASSIGNDLY","name":"","addr":"(BD)","loc":"d,41:11,41:13","dtypep":"UNLINKED", + "rhsp": [ + {"type":"REPLICATE","name":"","addr":"(CD)","loc":"d,41:14,41:15","dtypep":"(JC)", + "srcp": [ + {"type":"CONCAT","name":"","addr":"(DD)","loc":"d,41:24,41:25","dtypep":"UNLINKED", + "lhsp": [ + {"type":"SELEXTRACT","name":"","addr":"(ED)","loc":"d,41:18,41:19","dtypep":"UNLINKED", + "fromp": [ + {"type":"PARSEREF","name":"crc","addr":"(FD)","loc":"d,41:15,41:18","dtypep":"UNLINKED","expect":"TEXT","lhsp": [],"ftaskrefp": []} + ], + "leftp": [ + {"type":"CONST","name":"?32?sh3e","addr":"(GD)","loc":"d,41:19,41:21","dtypep":"(Q)"} + ], + "rightp": [ + {"type":"CONST","name":"?32?sh0","addr":"(HD)","loc":"d,41:22,41:23","dtypep":"(L)"} + ],"attrp": []} + ], + "rhsp": [ + {"type":"XOR","name":"","addr":"(ID)","loc":"d,41:43,41:44","dtypep":"UNLINKED", + "lhsp": [ + {"type":"XOR","name":"","addr":"(JD)","loc":"d,41:34,41:35","dtypep":"UNLINKED", + "lhsp": [ + {"type":"SELBIT","name":"","addr":"(KD)","loc":"d,41:29,41:30","dtypep":"UNLINKED", + "fromp": [ + {"type":"PARSEREF","name":"crc","addr":"(LD)","loc":"d,41:26,41:29","dtypep":"UNLINKED","expect":"TEXT","lhsp": [],"ftaskrefp": []} + ], + "bitp": [ + {"type":"CONST","name":"?32?sh3f","addr":"(MD)","loc":"d,41:30,41:32","dtypep":"(Q)"} + ],"thsp": [],"attrp": []} + ], + "rhsp": [ + {"type":"SELBIT","name":"","addr":"(ND)","loc":"d,41:39,41:40","dtypep":"UNLINKED", + "fromp": [ + {"type":"PARSEREF","name":"crc","addr":"(OD)","loc":"d,41:36,41:39","dtypep":"UNLINKED","expect":"TEXT","lhsp": [],"ftaskrefp": []} + ], + "bitp": [ + {"type":"CONST","name":"?32?sh2","addr":"(PD)","loc":"d,41:40,41:41","dtypep":"(QD)"} + ],"thsp": [],"attrp": []} + ]} + ], + "rhsp": [ + {"type":"SELBIT","name":"","addr":"(RD)","loc":"d,41:48,41:49","dtypep":"UNLINKED", + "fromp": [ + {"type":"PARSEREF","name":"crc","addr":"(SD)","loc":"d,41:45,41:48","dtypep":"UNLINKED","expect":"TEXT","lhsp": [],"ftaskrefp": []} + ], + "bitp": [ + {"type":"CONST","name":"?32?sh0","addr":"(TD)","loc":"d,41:49,41:50","dtypep":"(L)"} + ],"thsp": [],"attrp": []} + ]} + ]} + ], + "countp": [ + {"type":"CONST","name":"32'h1","addr":"(UD)","loc":"d,41:14,41:15","dtypep":"(MC)"} + ]} + ], + "lhsp": [ + {"type":"PARSEREF","name":"crc","addr":"(VD)","loc":"d,41:7,41:10","dtypep":"UNLINKED","expect":"TEXT","lhsp": [],"ftaskrefp": []} + ],"timingControlp": []}, + {"type":"ASSIGNDLY","name":"","addr":"(WD)","loc":"d,42:11,42:13","dtypep":"UNLINKED", + "rhsp": [ + {"type":"XOR","name":"","addr":"(XD)","loc":"d,42:21,42:22","dtypep":"UNLINKED", + "lhsp": [ + {"type":"PARSEREF","name":"result","addr":"(YD)","loc":"d,42:14,42:20","dtypep":"UNLINKED","expect":"TEXT","lhsp": [],"ftaskrefp": []} + ], + "rhsp": [ + {"type":"REPLICATE","name":"","addr":"(ZD)","loc":"d,42:23,42:24","dtypep":"(JC)", + "srcp": [ + {"type":"CONCAT","name":"","addr":"(AE)","loc":"d,42:33,42:34","dtypep":"UNLINKED", + "lhsp": [ + {"type":"SELEXTRACT","name":"","addr":"(BE)","loc":"d,42:27,42:28","dtypep":"UNLINKED", + "fromp": [ + {"type":"PARSEREF","name":"sum","addr":"(CE)","loc":"d,42:24,42:27","dtypep":"UNLINKED","expect":"TEXT","lhsp": [],"ftaskrefp": []} + ], + "leftp": [ + {"type":"CONST","name":"?32?sh3e","addr":"(DE)","loc":"d,42:28,42:30","dtypep":"(Q)"} + ], + "rightp": [ + {"type":"CONST","name":"?32?sh0","addr":"(EE)","loc":"d,42:31,42:32","dtypep":"(L)"} + ],"attrp": []} + ], + "rhsp": [ + {"type":"XOR","name":"","addr":"(FE)","loc":"d,42:52,42:53","dtypep":"UNLINKED", + "lhsp": [ + {"type":"XOR","name":"","addr":"(GE)","loc":"d,42:43,42:44","dtypep":"UNLINKED", + "lhsp": [ + {"type":"SELBIT","name":"","addr":"(HE)","loc":"d,42:38,42:39","dtypep":"UNLINKED", + "fromp": [ + {"type":"PARSEREF","name":"sum","addr":"(IE)","loc":"d,42:35,42:38","dtypep":"UNLINKED","expect":"TEXT","lhsp": [],"ftaskrefp": []} + ], + "bitp": [ + {"type":"CONST","name":"?32?sh3f","addr":"(JE)","loc":"d,42:39,42:41","dtypep":"(Q)"} + ],"thsp": [],"attrp": []} + ], + "rhsp": [ + {"type":"SELBIT","name":"","addr":"(KE)","loc":"d,42:48,42:49","dtypep":"UNLINKED", + "fromp": [ + {"type":"PARSEREF","name":"sum","addr":"(LE)","loc":"d,42:45,42:48","dtypep":"UNLINKED","expect":"TEXT","lhsp": [],"ftaskrefp": []} + ], + "bitp": [ + {"type":"CONST","name":"?32?sh2","addr":"(ME)","loc":"d,42:49,42:50","dtypep":"(QD)"} + ],"thsp": [],"attrp": []} + ]} + ], + "rhsp": [ + {"type":"SELBIT","name":"","addr":"(NE)","loc":"d,42:57,42:58","dtypep":"UNLINKED", + "fromp": [ + {"type":"PARSEREF","name":"sum","addr":"(OE)","loc":"d,42:54,42:57","dtypep":"UNLINKED","expect":"TEXT","lhsp": [],"ftaskrefp": []} + ], + "bitp": [ + {"type":"CONST","name":"?32?sh0","addr":"(PE)","loc":"d,42:58,42:59","dtypep":"(L)"} + ],"thsp": [],"attrp": []} + ]} + ]} + ], + "countp": [ + {"type":"CONST","name":"32'h1","addr":"(QE)","loc":"d,42:23,42:24","dtypep":"(MC)"} + ]} + ]} + ], + "lhsp": [ + {"type":"PARSEREF","name":"sum","addr":"(RE)","loc":"d,42:7,42:10","dtypep":"UNLINKED","expect":"TEXT","lhsp": [],"ftaskrefp": []} + ],"timingControlp": []}, + {"type":"IF","name":"","addr":"(SE)","loc":"d,43:7,43:9", + "condp": [ + {"type":"EQ","name":"","addr":"(TE)","loc":"d,43:15,43:17","dtypep":"(UE)", + "lhsp": [ + {"type":"PARSEREF","name":"cyc","addr":"(VE)","loc":"d,43:11,43:14","dtypep":"UNLINKED","expect":"TEXT","lhsp": [],"ftaskrefp": []} + ], + "rhsp": [ + {"type":"CONST","name":"?32?sh0","addr":"(WE)","loc":"d,43:18,43:19","dtypep":"(L)"} + ]} + ], + "thensp": [ + {"type":"BEGIN","name":"","addr":"(XE)","loc":"d,43:21,43:26","generate":false,"genfor":false,"implied":false,"needProcess":false,"unnamed":true,"genforp": [], + "stmtsp": [ + {"type":"ASSIGNDLY","name":"","addr":"(YE)","loc":"d,45:14,45:16","dtypep":"UNLINKED", + "rhsp": [ + {"type":"CONST","name":"64'h5aef0c8dd70a4497","addr":"(ZE)","loc":"d,45:17,45:38","dtypep":"(AF)"} + ], + "lhsp": [ + {"type":"PARSEREF","name":"crc","addr":"(BF)","loc":"d,45:10,45:13","dtypep":"UNLINKED","expect":"TEXT","lhsp": [],"ftaskrefp": []} + ],"timingControlp": []}, + {"type":"ASSIGNDLY","name":"","addr":"(CF)","loc":"d,46:14,46:16","dtypep":"UNLINKED", + "rhsp": [ + {"type":"CONST","name":"'0","addr":"(DF)","loc":"d,46:17,46:19","dtypep":"(UE)"} + ], + "lhsp": [ + {"type":"PARSEREF","name":"sum","addr":"(EF)","loc":"d,46:10,46:13","dtypep":"UNLINKED","expect":"TEXT","lhsp": [],"ftaskrefp": []} + ],"timingControlp": []} + ]} + ], + "elsesp": [ + {"type":"IF","name":"","addr":"(FF)","loc":"d,48:12,48:14", + "condp": [ + {"type":"LT","name":"","addr":"(GF)","loc":"d,48:20,48:21","dtypep":"(UE)", + "lhsp": [ + {"type":"PARSEREF","name":"cyc","addr":"(HF)","loc":"d,48:16,48:19","dtypep":"UNLINKED","expect":"TEXT","lhsp": [],"ftaskrefp": []} + ], + "rhsp": [ + {"type":"CONST","name":"?32?sha","addr":"(IF)","loc":"d,48:22,48:24","dtypep":"(JF)"} + ]} + ], + "thensp": [ + {"type":"BEGIN","name":"","addr":"(KF)","loc":"d,48:26,48:31","generate":false,"genfor":false,"implied":false,"needProcess":false,"unnamed":true,"genforp": [], + "stmtsp": [ + {"type":"ASSIGNDLY","name":"","addr":"(LF)","loc":"d,49:14,49:16","dtypep":"UNLINKED", + "rhsp": [ + {"type":"CONST","name":"'0","addr":"(MF)","loc":"d,49:17,49:19","dtypep":"(UE)"} + ], + "lhsp": [ + {"type":"PARSEREF","name":"sum","addr":"(NF)","loc":"d,49:10,49:13","dtypep":"UNLINKED","expect":"TEXT","lhsp": [],"ftaskrefp": []} + ],"timingControlp": []} + ]} + ], + "elsesp": [ + {"type":"IF","name":"","addr":"(OF)","loc":"d,51:12,51:14", + "condp": [ + {"type":"LT","name":"","addr":"(PF)","loc":"d,51:20,51:21","dtypep":"(UE)", + "lhsp": [ + {"type":"PARSEREF","name":"cyc","addr":"(QF)","loc":"d,51:16,51:19","dtypep":"UNLINKED","expect":"TEXT","lhsp": [],"ftaskrefp": []} + ], + "rhsp": [ + {"type":"CONST","name":"?32?sh5a","addr":"(RF)","loc":"d,51:22,51:24","dtypep":"(SF)"} + ]} + ], + "thensp": [ + {"type":"BEGIN","name":"","addr":"(TF)","loc":"d,51:26,51:31","generate":false,"genfor":false,"implied":false,"needProcess":false,"unnamed":true,"genforp": [],"stmtsp": []} + ], + "elsesp": [ + {"type":"IF","name":"","addr":"(UF)","loc":"d,53:12,53:14", + "condp": [ + {"type":"EQ","name":"","addr":"(VF)","loc":"d,53:20,53:22","dtypep":"(UE)", + "lhsp": [ + {"type":"PARSEREF","name":"cyc","addr":"(WF)","loc":"d,53:16,53:19","dtypep":"UNLINKED","expect":"TEXT","lhsp": [],"ftaskrefp": []} + ], + "rhsp": [ + {"type":"CONST","name":"?32?sh63","addr":"(XF)","loc":"d,53:23,53:25","dtypep":"(SF)"} + ]} + ], + "thensp": [ + {"type":"BEGIN","name":"","addr":"(YF)","loc":"d,53:27,53:32","generate":false,"genfor":false,"implied":false,"needProcess":false,"unnamed":true,"genforp": [], + "stmtsp": [ + {"type":"DISPLAY","name":"","addr":"(ZF)","loc":"d,54:10,54:16", + "fmtp": [ + {"type":"SFORMATF","name":"","addr":"(AG)","loc":"d,54:10,54:16","dtypep":"(BG)", + "exprsp": [ + {"type":"CONST","name":"232'h5b2530745d206379633d3d253064206372633d25782073756d3d25780a","addr":"(CG)","loc":"d,54:17,54:49","dtypep":"(DG)"}, + {"type":"TIME","name":"","addr":"(EG)","loc":"d,54:51,54:56","dtypep":"(FG)","timeunit":"NONE"}, + {"type":"PARSEREF","name":"cyc","addr":"(GG)","loc":"d,54:58,54:61","dtypep":"UNLINKED","expect":"TEXT","lhsp": [],"ftaskrefp": []}, + {"type":"PARSEREF","name":"crc","addr":"(HG)","loc":"d,54:63,54:66","dtypep":"UNLINKED","expect":"TEXT","lhsp": [],"ftaskrefp": []}, + {"type":"PARSEREF","name":"sum","addr":"(IG)","loc":"d,54:68,54:71","dtypep":"UNLINKED","expect":"TEXT","lhsp": [],"ftaskrefp": []} + ],"scopeNamep": []} + ],"filep": []}, + {"type":"IF","name":"","addr":"(JG)","loc":"d,55:10,55:12", + "condp": [ + {"type":"NEQCASE","name":"","addr":"(KG)","loc":"d,55:18,55:21","dtypep":"(UE)", + "lhsp": [ + {"type":"PARSEREF","name":"crc","addr":"(LG)","loc":"d,55:14,55:17","dtypep":"UNLINKED","expect":"TEXT","lhsp": [],"ftaskrefp": []} + ], + "rhsp": [ + {"type":"CONST","name":"64'hc77bb9b3784ea091","addr":"(MG)","loc":"d,55:22,55:42","dtypep":"(AF)"} + ]} + ], + "thensp": [ + {"type":"STOP","name":"","addr":"(NG)","loc":"d,55:44,55:49"} + ],"elsesp": []}, + {"type":"IF","name":"","addr":"(OG)","loc":"d,58:10,58:12", + "condp": [ + {"type":"NEQCASE","name":"","addr":"(PG)","loc":"d,58:18,58:21","dtypep":"(UE)", + "lhsp": [ + {"type":"PARSEREF","name":"sum","addr":"(QG)","loc":"d,58:14,58:17","dtypep":"UNLINKED","expect":"TEXT","lhsp": [],"ftaskrefp": []} + ], + "rhsp": [ + {"type":"CONST","name":"64'h4afe43fb79d7b71e","addr":"(RG)","loc":"d,58:22,58:42","dtypep":"(AF)"} + ]} + ], + "thensp": [ + {"type":"STOP","name":"","addr":"(SG)","loc":"d,58:44,58:49"} + ],"elsesp": []}, + {"type":"DISPLAY","name":"","addr":"(TG)","loc":"d,59:10,59:16", + "fmtp": [ + {"type":"SFORMATF","name":"","addr":"(UG)","loc":"d,59:10,59:16","dtypep":"(BG)", + "exprsp": [ + {"type":"CONST","name":"168'h2a2d2a20416c6c2046696e6973686564202a2d2a0a","addr":"(VG)","loc":"d,59:17,59:41","dtypep":"(WG)"} + ],"scopeNamep": []} + ],"filep": []}, + {"type":"FINISH","name":"","addr":"(XG)","loc":"d,60:10,60:17"} + ]} + ],"elsesp": []} + ]} + ]} + ]} + ]} + ]} + ]} + ],"activesp": []}, + {"type":"MODULE","name":"Test","addr":"(PB)","loc":"d,66:8,66:12","origName":"Test","level":3,"modPublic":false,"inLibrary":false,"dead":false,"recursiveClone":false,"recursive":false,"timeunit":"1ps","inlinesp": [], + "stmtsp": [ + {"type":"PORT","name":"out","addr":"(YG)","loc":"d,68:4,68:7","exprp": []}, + {"type":"PORT","name":"clk","addr":"(ZG)","loc":"d,70:4,70:7","exprp": []}, + {"type":"PORT","name":"in","addr":"(AH)","loc":"d,70:9,70:11","exprp": []}, + {"type":"VAR","name":"clk","addr":"(BH)","loc":"d,78:10,78:13","dtypep":"UNLINKED","origName":"clk","isSc":false,"isPrimaryIO":false,"direction":"INPUT","isConst":false,"isPullup":false,"isPulldown":false,"isUsedClock":false,"isSigPublic":false,"isLatched":false,"isUsedLoopIdx":false,"noReset":false,"attrIsolateAssign":false,"attrFileDescr":false,"isDpiOpenArray":false,"isFuncReturn":false,"isFuncLocal":false,"attrClocker":"UNKNOWN","lifetime":"NONE","varType":"PORT","isSigUserRdPublic":false,"isSigUserRWPublic":false,"isGParam":false,"isParam":false,"attrScBv":false,"attrSFormat":false,"sensIfacep":"UNLINKED", + "childDTypep": [ + {"type":"BASICDTYPE","name":"LOGIC_IMPLICIT","addr":"(CH)","loc":"d,78:10,78:13","dtypep":"(CH)","keyword":"LOGIC_IMPLICIT","generic":false,"rangep": []} + ],"delayp": [],"valuep": [],"attrsp": []}, + {"type":"VAR","name":"in","addr":"(DH)","loc":"d,79:17,79:19","dtypep":"UNLINKED","origName":"in","isSc":false,"isPrimaryIO":false,"direction":"INPUT","isConst":false,"isPullup":false,"isPulldown":false,"isUsedClock":false,"isSigPublic":false,"isLatched":false,"isUsedLoopIdx":false,"noReset":false,"attrIsolateAssign":false,"attrFileDescr":false,"isDpiOpenArray":false,"isFuncReturn":false,"isFuncLocal":false,"attrClocker":"UNKNOWN","lifetime":"NONE","varType":"PORT","isSigUserRdPublic":false,"isSigUserRWPublic":false,"isGParam":false,"isParam":false,"attrScBv":false,"attrSFormat":false,"sensIfacep":"UNLINKED", + "childDTypep": [ + {"type":"BASICDTYPE","name":"logic","addr":"(EH)","loc":"d,79:10,79:11","dtypep":"(EH)","keyword":"logic","generic":false, + "rangep": [ + {"type":"RANGE","name":"","addr":"(FH)","loc":"d,79:10,79:11","ascending":false, + "leftp": [ + {"type":"CONST","name":"?32?sh1f","addr":"(GH)","loc":"d,79:11,79:13","dtypep":"(BB)"} + ], + "rightp": [ + {"type":"CONST","name":"?32?sh0","addr":"(HH)","loc":"d,79:14,79:15","dtypep":"(L)"} + ]} + ]} + ],"delayp": [],"valuep": [],"attrsp": []}, + {"type":"VAR","name":"out","addr":"(IH)","loc":"d,80:22,80:25","dtypep":"UNLINKED","origName":"out","isSc":false,"isPrimaryIO":false,"direction":"OUTPUT","isConst":false,"isPullup":false,"isPulldown":false,"isUsedClock":false,"isSigPublic":false,"isLatched":false,"isUsedLoopIdx":false,"noReset":false,"attrIsolateAssign":false,"attrFileDescr":false,"isDpiOpenArray":false,"isFuncReturn":false,"isFuncLocal":false,"attrClocker":"UNKNOWN","lifetime":"NONE","varType":"PORT","isSigUserRdPublic":false,"isSigUserRWPublic":false,"isGParam":false,"isParam":false,"attrScBv":false,"attrSFormat":false,"sensIfacep":"UNLINKED", + "childDTypep": [ + {"type":"BASICDTYPE","name":"logic","addr":"(JH)","loc":"d,80:11,80:14","dtypep":"(JH)","keyword":"logic","generic":false, + "rangep": [ + {"type":"RANGE","name":"","addr":"(KH)","loc":"d,80:15,80:16","ascending":false, + "leftp": [ + {"type":"CONST","name":"?32?sh1f","addr":"(LH)","loc":"d,80:16,80:18","dtypep":"(BB)"} + ], + "rightp": [ + {"type":"CONST","name":"?32?sh0","addr":"(MH)","loc":"d,80:19,80:20","dtypep":"(L)"} + ]} + ]} + ],"delayp": [],"valuep": [],"attrsp": []}, + {"type":"ALWAYS","name":"","addr":"(NH)","loc":"d,82:4,82:10","keyword":"always","isSuspendable":false,"needProcess":false,"sensesp": [], + "stmtsp": [ + {"type":"EVENTCONTROL","name":"","addr":"(OH)","loc":"d,82:11,82:12", + "sensesp": [ + {"type":"SENTREE","name":"","addr":"(PH)","loc":"d,82:11,82:12","isMulti":false, + "sensesp": [ + {"type":"SENITEM","name":"","addr":"(QH)","loc":"d,82:13,82:20","edgeType":"POS", + "sensp": [ + {"type":"PARSEREF","name":"clk","addr":"(RH)","loc":"d,82:21,82:24","dtypep":"UNLINKED","expect":"TEXT","lhsp": [],"ftaskrefp": []} + ],"condp": []} + ]} + ], + "stmtsp": [ + {"type":"BEGIN","name":"","addr":"(SH)","loc":"d,82:26,82:31","generate":false,"genfor":false,"implied":false,"needProcess":false,"unnamed":true,"genforp": [], + "stmtsp": [ + {"type":"ASSIGNDLY","name":"","addr":"(TH)","loc":"d,83:11,83:13","dtypep":"UNLINKED", + "rhsp": [ + {"type":"PARSEREF","name":"in","addr":"(UH)","loc":"d,83:14,83:16","dtypep":"UNLINKED","expect":"TEXT","lhsp": [],"ftaskrefp": []} + ], + "lhsp": [ + {"type":"PARSEREF","name":"out","addr":"(VH)","loc":"d,83:7,83:10","dtypep":"UNLINKED","expect":"TEXT","lhsp": [],"ftaskrefp": []} + ],"timingControlp": []} + ]} + ]} + ]} + ],"activesp": []} +],"filesp": [], + "miscsp": [ + {"type":"TYPETABLE","name":"","addr":"(C)","loc":"a,0:0,0:0","constraintRefp":"UNLINKED","emptyQueuep":"UNLINKED","queueIndexp":"UNLINKED","streamp":"UNLINKED","voidp":"(WH)", + "typesp": [ + {"type":"BASICDTYPE","name":"integer","addr":"(XH)","loc":"c,31:27,31:28","dtypep":"(XH)","keyword":"integer","range":"31:0","generic":true,"rangep": []}, + {"type":"BASICDTYPE","name":"logic","addr":"(L)","loc":"c,33:32,33:33","dtypep":"(L)","keyword":"logic","range":"31:0","generic":true,"rangep": []}, + {"type":"BASICDTYPE","name":"logic","addr":"(UE)","loc":"c,50:22,50:24","dtypep":"(UE)","keyword":"logic","generic":true,"rangep": []}, + {"type":"VOIDDTYPE","name":"","addr":"(WH)","loc":"c,51:21,51:30","dtypep":"(WH)","generic":false}, + {"type":"BASICDTYPE","name":"logic","addr":"(QD)","loc":"c,119:22,119:23","dtypep":"(QD)","keyword":"logic","range":"31:0","generic":true,"rangep": []}, + {"type":"BASICDTYPE","name":"logic","addr":"(YH)","loc":"c,121:22,121:23","dtypep":"(YH)","keyword":"logic","range":"31:0","generic":true,"rangep": []}, + {"type":"BASICDTYPE","name":"logic","addr":"(ZH)","loc":"c,156:17,156:56","dtypep":"(ZH)","keyword":"logic","range":"295:0","generic":true,"rangep": []}, + {"type":"BASICDTYPE","name":"string","addr":"(BG)","loc":"c,156:10,156:16","dtypep":"(BG)","keyword":"string","generic":true,"rangep": []}, + {"type":"BASICDTYPE","name":"logic","addr":"(Q)","loc":"d,14:9,14:11","dtypep":"(Q)","keyword":"logic","range":"31:0","generic":true,"rangep": []}, + {"type":"BASICDTYPE","name":"logic","addr":"(BB)","loc":"d,18:10,18:12","dtypep":"(BB)","keyword":"logic","range":"31:0","generic":true,"rangep": []}, + {"type":"BASICDTYPE","name":"logic","addr":"(MC)","loc":"d,33:26,33:31","dtypep":"(MC)","keyword":"logic","range":"31:0","generic":true,"rangep": []}, + {"type":"BASICDTYPE","name":"logic","addr":"(JC)","loc":"d,33:25,33:26","dtypep":"(JC)","keyword":"logic","generic":true,"rangep": []}, + {"type":"BASICDTYPE","name":"logic","addr":"(AF)","loc":"d,45:17,45:38","dtypep":"(AF)","keyword":"logic","range":"63:0","generic":true,"rangep": []}, + {"type":"BASICDTYPE","name":"logic","addr":"(JF)","loc":"d,48:22,48:24","dtypep":"(JF)","keyword":"logic","range":"31:0","generic":true,"rangep": []}, + {"type":"BASICDTYPE","name":"logic","addr":"(SF)","loc":"d,51:22,51:24","dtypep":"(SF)","keyword":"logic","range":"31:0","generic":true,"rangep": []}, + {"type":"BASICDTYPE","name":"logic","addr":"(DG)","loc":"d,54:17,54:49","dtypep":"(DG)","keyword":"logic","range":"231:0","generic":true,"rangep": []}, + {"type":"BASICDTYPE","name":"QData","addr":"(FG)","loc":"d,54:51,54:56","dtypep":"(FG)","keyword":"QData","range":"63:0","generic":true,"rangep": []}, + {"type":"BASICDTYPE","name":"logic","addr":"(WG)","loc":"d,59:17,59:41","dtypep":"(WG)","keyword":"logic","range":"167:0","generic":true,"rangep": []} + ]}, + {"type":"CONSTPOOL","name":"","addr":"(D)","loc":"a,0:0,0:0", + "modulep": [ + {"type":"MODULE","name":"@CONST-POOL@","addr":"(AI)","loc":"a,0:0,0:0","origName":"@CONST-POOL@","level":0,"modPublic":false,"inLibrary":false,"dead":false,"recursiveClone":false,"recursive":false,"timeunit":"NONE","inlinesp": [], + "stmtsp": [ + {"type":"SCOPE","name":"@CONST-POOL@","addr":"(BI)","loc":"a,0:0,0:0","aboveScopep":"UNLINKED","aboveCellp":"UNLINKED","modp":"(AI)","varsp": [],"blocksp": []} + ],"activesp": []} + ]} +]} diff --git a/test_regress/t/t_dump_json.pl b/test_regress/t/t_dump_json.pl new file mode 100755 index 000000000..435b25067 --- /dev/null +++ b/test_regress/t/t_dump_json.pl @@ -0,0 +1,23 @@ +#!/usr/bin/env perl +if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; } +# DESCRIPTION: Verilator: Verilog Test driver/expect definition +# +# Copyright 2003 by Wilson Snyder. This program is free software; you +# can redistribute it and/or modify it under the terms of either the GNU +# Lesser General Public License Version 3 or the Perl Artistic License +# Version 2.0. +# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0 + +scenarios(vlt => 1); + +top_filename("t/t_dump.v"); + +lint( + v_flags => ["--dump-tree-json --no-json-edit-nums"], + ); + +files_identical("$Self->{obj_dir}/Vt_dump_json_001_cells.tree.json", $Self->{golden_filename}, 'logfile'); + +ok(1); + +1;