2020-02-29 15:44:51 +01:00
|
|
|
// DESCRIPTION: Verilator: Verilog Test
|
|
|
|
|
//
|
2026-01-27 02:24:34 +01:00
|
|
|
// 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-FileCopyrightText: 2003-2020 Wilson Snyder
|
2020-03-21 16:24:24 +01:00
|
|
|
// SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
2020-02-29 15:44:51 +01:00
|
|
|
|
2020-10-28 23:42:36 +01:00
|
|
|
// clang-format off
|
2020-02-29 15:44:51 +01:00
|
|
|
#include "verilatedos.h"
|
|
|
|
|
#include VM_PREFIX_INCLUDE
|
|
|
|
|
#include "Vt_trace_two_b.h"
|
|
|
|
|
#include "verilated.h"
|
2020-03-02 03:39:23 +01:00
|
|
|
#ifdef TEST_HDR_TRACE
|
2026-03-12 16:21:02 +01:00
|
|
|
# include VL_STRINGIFY(TRACE_HEADER_C)
|
2020-03-02 03:39:23 +01:00
|
|
|
#endif
|
2020-10-28 23:42:36 +01:00
|
|
|
// clang-format on
|
2020-02-29 15:44:51 +01:00
|
|
|
|
|
|
|
|
// Compile in place
|
2021-07-19 18:46:17 +02:00
|
|
|
#include "Vt_trace_two_b__ALL.cpp"
|
2020-02-29 15:44:51 +01:00
|
|
|
|
|
|
|
|
VM_PREFIX* ap;
|
|
|
|
|
Vt_trace_two_b* bp;
|
|
|
|
|
|
2022-11-24 00:50:31 +01:00
|
|
|
int main(int argc, char** argv) {
|
2026-03-12 16:21:02 +01:00
|
|
|
VerilatedContext context{};
|
2022-07-09 15:50:50 +02:00
|
|
|
|
2022-03-27 21:03:25 +02:00
|
|
|
uint64_t sim_time = 1100;
|
2026-03-12 16:21:02 +01:00
|
|
|
context.debug(0);
|
|
|
|
|
context.commandArgs(argc, argv);
|
|
|
|
|
context.traceEverOn(true);
|
2020-02-29 15:44:51 +01:00
|
|
|
srand48(5);
|
2026-03-12 16:21:02 +01:00
|
|
|
ap = new VM_PREFIX{&context, "topa"};
|
|
|
|
|
bp = new Vt_trace_two_b{&context, "topb"};
|
2020-02-29 15:44:51 +01:00
|
|
|
|
2020-03-02 03:39:23 +01:00
|
|
|
#ifdef TEST_HDR_TRACE
|
2026-03-12 16:21:02 +01:00
|
|
|
VERILATED_TRACE_C* tfp = new VERILATED_TRACE_C;
|
2020-03-02 03:39:23 +01:00
|
|
|
ap->trace(tfp, 99);
|
|
|
|
|
bp->trace(tfp, 99);
|
2026-03-12 16:21:02 +01:00
|
|
|
tfp->open(VL_STRINGIFY(TEST_OBJ_DIR) "/simx." VL_STRINGIFY(TRACE_FMT));
|
2020-03-08 00:39:58 +01:00
|
|
|
|
|
|
|
|
ap->eval_step();
|
|
|
|
|
bp->eval_step();
|
|
|
|
|
ap->eval_end_step();
|
|
|
|
|
bp->eval_end_step();
|
2026-03-12 16:21:02 +01:00
|
|
|
if (tfp) tfp->dump(context.time());
|
2020-02-29 15:44:51 +01:00
|
|
|
#endif
|
2020-03-08 00:39:58 +01:00
|
|
|
|
2020-02-29 15:44:51 +01:00
|
|
|
{
|
|
|
|
|
ap->clk = false;
|
2026-03-12 16:21:02 +01:00
|
|
|
context.timeInc(10);
|
2020-02-29 15:44:51 +01:00
|
|
|
}
|
2026-03-12 16:21:02 +01:00
|
|
|
while (context.time() < sim_time && !context.gotFinish()) {
|
2020-02-29 15:44:51 +01:00
|
|
|
ap->clk = !ap->clk;
|
|
|
|
|
bp->clk = ap->clk;
|
2020-03-02 03:39:23 +01:00
|
|
|
ap->eval_step();
|
|
|
|
|
bp->eval_step();
|
|
|
|
|
ap->eval_end_step();
|
|
|
|
|
bp->eval_end_step();
|
|
|
|
|
#ifdef TEST_HDR_TRACE
|
2026-03-12 16:21:02 +01:00
|
|
|
if (tfp) tfp->dump(context.time());
|
2020-03-02 03:39:23 +01:00
|
|
|
#endif
|
2026-03-12 16:21:02 +01:00
|
|
|
context.timeInc(5);
|
2020-02-29 15:44:51 +01:00
|
|
|
}
|
2026-03-12 16:21:02 +01:00
|
|
|
if (!context.gotFinish()) {
|
2020-02-29 15:44:51 +01:00
|
|
|
vl_fatal(__FILE__, __LINE__, "main", "%Error: Timeout; never got a $finish");
|
|
|
|
|
}
|
|
|
|
|
ap->final();
|
|
|
|
|
bp->final();
|
2020-03-08 00:39:58 +01:00
|
|
|
|
2020-03-02 03:39:23 +01:00
|
|
|
#ifdef TEST_HDR_TRACE
|
2020-02-29 15:44:51 +01:00
|
|
|
if (tfp) tfp->close();
|
2021-02-26 02:38:38 +01:00
|
|
|
VL_DO_DANGLING(delete tfp, tfp);
|
2020-03-02 03:39:23 +01:00
|
|
|
#endif
|
2020-02-29 15:44:51 +01:00
|
|
|
|
|
|
|
|
VL_DO_DANGLING(delete ap, ap);
|
|
|
|
|
VL_DO_DANGLING(delete bp, bp);
|
2021-02-26 01:26:36 +01:00
|
|
|
return 0;
|
2020-02-29 15:44:51 +01:00
|
|
|
}
|