2020-02-29 14:44:51 +00:00
|
|
|
// DESCRIPTION: Verilator: Verilog Test
|
|
|
|
//
|
|
|
|
// Copyright 2003-2020 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.
|
2020-03-21 15:24:24 +00:00
|
|
|
// SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
2020-02-29 14:44:51 +00:00
|
|
|
|
2020-10-28 22:42:36 +00:00
|
|
|
// clang-format off
|
2020-02-29 14:44:51 +00:00
|
|
|
#include "verilatedos.h"
|
|
|
|
#include VM_PREFIX_INCLUDE
|
|
|
|
#include "Vt_trace_two_b.h"
|
|
|
|
#include "verilated.h"
|
2020-03-02 02:39:23 +00:00
|
|
|
#ifdef TEST_HDR_TRACE
|
|
|
|
# ifdef TEST_FST
|
|
|
|
# include "verilated_fst_c.h"
|
|
|
|
# else
|
|
|
|
# include "verilated_vcd_c.h"
|
|
|
|
# endif
|
|
|
|
#endif
|
2020-10-28 22:42:36 +00:00
|
|
|
// clang-format on
|
2020-02-29 14:44:51 +00:00
|
|
|
|
|
|
|
// Compile in place
|
|
|
|
#include "Vt_trace_two_b.cpp"
|
|
|
|
#include "Vt_trace_two_b__Syms.cpp"
|
Introduce model interface class, make $root part or Syms (#3036)
This patch implements #3032. Verilator creates a module representing the
SystemVerilog $root scope (V3LinkLevel::wrapTop). Until now, this was
called the "TOP" module, which also acted as the user instantiated model
class. Syms used to hold a pointer to this root module, but hold
instances of any submodule. This patch renames this root scope module
from "TOP" to "$root", and introduces a separate model class which is
now an interface class. As the root module is no longer the user
interface class, it can now be made an instance of Syms, just like any
other submodule. This allows absolute references into the root module to
avoid an additional pointer indirection resulting in a potential speedup
(about 1.5% on OpenTitan). The model class now also contains all non
design specific generated code (e.g.: eval loops, trace config, etc),
which additionally simplifies Verilator internals.
Please see the updated documentation for the model interface changes.
2021-06-21 14:30:20 +00:00
|
|
|
#include "Vt_trace_two_b___024root.cpp"
|
|
|
|
#include "Vt_trace_two_b___024root__Slow.cpp"
|
2020-02-29 14:44:51 +00:00
|
|
|
#include "Vt_trace_two_b__Trace.cpp"
|
|
|
|
#include "Vt_trace_two_b__Trace__Slow.cpp"
|
|
|
|
|
|
|
|
VM_PREFIX* ap;
|
|
|
|
Vt_trace_two_b* bp;
|
|
|
|
vluint64_t main_time = 0;
|
|
|
|
double sc_time_stamp() { return main_time; }
|
|
|
|
|
|
|
|
int main(int argc, char** argv, char** env) {
|
2021-02-17 01:14:13 +00:00
|
|
|
vluint64_t sim_time = 1100;
|
2020-02-29 14:44:51 +00:00
|
|
|
Verilated::commandArgs(argc, argv);
|
|
|
|
Verilated::debug(0);
|
2020-03-02 02:39:23 +00:00
|
|
|
Verilated::traceEverOn(true);
|
2020-02-29 14:44:51 +00:00
|
|
|
srand48(5);
|
|
|
|
ap = new VM_PREFIX("topa");
|
|
|
|
bp = new Vt_trace_two_b("topb");
|
|
|
|
|
2020-10-28 22:42:36 +00:00
|
|
|
// clang-format off
|
2020-03-02 02:39:23 +00:00
|
|
|
#ifdef TEST_HDR_TRACE
|
2020-02-29 14:44:51 +00:00
|
|
|
Verilated::traceEverOn(true);
|
2020-03-02 02:39:23 +00:00
|
|
|
# ifdef TEST_FST
|
|
|
|
VerilatedFstC* tfp = new VerilatedFstC;
|
|
|
|
ap->trace(tfp, 99);
|
|
|
|
bp->trace(tfp, 99);
|
|
|
|
tfp->open(VL_STRINGIFY(TEST_OBJ_DIR) "/simx.fst");
|
|
|
|
# else
|
2020-02-29 14:44:51 +00:00
|
|
|
VerilatedVcdC* tfp = new VerilatedVcdC;
|
|
|
|
ap->trace(tfp, 99);
|
|
|
|
bp->trace(tfp, 99);
|
|
|
|
tfp->open(VL_STRINGIFY(TEST_OBJ_DIR) "/simx.vcd");
|
2020-03-02 02:39:23 +00:00
|
|
|
# endif
|
2020-03-07 23:39:58 +00:00
|
|
|
#endif
|
2020-10-28 22:42:36 +00:00
|
|
|
// clang-format on
|
2020-03-07 23:39:58 +00:00
|
|
|
|
|
|
|
#ifdef TEST_HDR_TRACE
|
|
|
|
ap->eval_step();
|
|
|
|
bp->eval_step();
|
|
|
|
ap->eval_end_step();
|
|
|
|
bp->eval_end_step();
|
2020-02-29 14:44:51 +00:00
|
|
|
if (tfp) tfp->dump(main_time);
|
|
|
|
#endif
|
2020-03-07 23:39:58 +00:00
|
|
|
|
2020-02-29 14:44:51 +00:00
|
|
|
{
|
|
|
|
ap->clk = false;
|
|
|
|
main_time += 10;
|
|
|
|
}
|
2021-02-17 01:14:13 +00:00
|
|
|
while (vl_time_stamp64() < sim_time && !Verilated::gotFinish()) {
|
2020-02-29 14:44:51 +00:00
|
|
|
ap->clk = !ap->clk;
|
|
|
|
bp->clk = ap->clk;
|
2020-03-02 02:39:23 +00:00
|
|
|
ap->eval_step();
|
|
|
|
bp->eval_step();
|
|
|
|
ap->eval_end_step();
|
|
|
|
bp->eval_end_step();
|
|
|
|
#ifdef TEST_HDR_TRACE
|
2020-02-29 14:44:51 +00:00
|
|
|
if (tfp) tfp->dump(main_time);
|
2020-03-02 02:39:23 +00:00
|
|
|
#endif
|
2020-02-29 14:44:51 +00:00
|
|
|
main_time += 5;
|
|
|
|
}
|
|
|
|
if (!Verilated::gotFinish()) {
|
|
|
|
vl_fatal(__FILE__, __LINE__, "main", "%Error: Timeout; never got a $finish");
|
|
|
|
}
|
|
|
|
ap->final();
|
|
|
|
bp->final();
|
2020-03-07 23:39:58 +00:00
|
|
|
|
2020-03-02 02:39:23 +00:00
|
|
|
#ifdef TEST_HDR_TRACE
|
2020-02-29 14:44:51 +00:00
|
|
|
if (tfp) tfp->close();
|
2021-02-26 01:38:38 +00:00
|
|
|
VL_DO_DANGLING(delete tfp, tfp);
|
2020-03-02 02:39:23 +00:00
|
|
|
#endif
|
2020-02-29 14:44:51 +00:00
|
|
|
|
|
|
|
VL_DO_DANGLING(delete ap, ap);
|
|
|
|
VL_DO_DANGLING(delete bp, bp);
|
2021-02-26 00:26:36 +00:00
|
|
|
return 0;
|
2020-02-29 14:44:51 +00:00
|
|
|
}
|