2013-02-24 02:10:25 +00:00
|
|
|
// -*- mode: C++; c-file-style: "cc-mode" -*-
|
|
|
|
//
|
|
|
|
// DESCRIPTION: Verilator: Verilog Test module
|
|
|
|
//
|
2020-03-21 15:24:24 +00:00
|
|
|
// This file ONLY is placed under the Creative Commons Public Domain, for
|
|
|
|
// any use, without warranty, 2008 by Wilson Snyder.
|
|
|
|
// SPDX-License-Identifier: CC0-1.0
|
2013-02-24 02:10:25 +00:00
|
|
|
|
|
|
|
#include <verilated.h>
|
|
|
|
#include <verilated_vcd_c.h>
|
|
|
|
|
2022-08-05 09:56:57 +00:00
|
|
|
#include <memory>
|
|
|
|
|
2017-10-24 23:58:52 +00:00
|
|
|
#include VM_PREFIX_INCLUDE
|
2013-02-24 02:10:25 +00:00
|
|
|
|
|
|
|
unsigned long long main_time = 0;
|
2019-11-10 01:35:12 +00:00
|
|
|
double sc_time_stamp() { return (double)main_time; }
|
2013-02-24 02:10:25 +00:00
|
|
|
|
|
|
|
const char* trace_name() {
|
|
|
|
static char name[1000];
|
2019-12-14 00:11:37 +00:00
|
|
|
VL_SNPRINTF(name, 1000, VL_STRINGIFY(TEST_OBJ_DIR) "/simpart_%04d.vcd", (int)main_time);
|
2013-02-24 02:10:25 +00:00
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
2022-11-23 23:50:31 +00:00
|
|
|
int main(int argc, char** argv) {
|
2013-02-24 02:10:25 +00:00
|
|
|
Verilated::debug(0);
|
|
|
|
Verilated::traceEverOn(true);
|
2023-01-21 19:05:11 +00:00
|
|
|
Verilated::commandArgs(argc, argv);
|
|
|
|
|
|
|
|
std::unique_ptr<VM_PREFIX> top{new VM_PREFIX("top")};
|
2013-02-24 02:10:25 +00:00
|
|
|
|
2020-12-16 23:31:47 +00:00
|
|
|
std::unique_ptr<VerilatedVcdC> tfp{new VerilatedVcdC};
|
|
|
|
top->trace(tfp.get(), 99);
|
2013-02-24 02:10:25 +00:00
|
|
|
|
|
|
|
tfp->open(trace_name());
|
|
|
|
|
|
|
|
top->clk = 0;
|
|
|
|
|
|
|
|
while (main_time < 190) { // Creates 2 files
|
2017-11-06 02:47:55 +00:00
|
|
|
top->clk = !top->clk;
|
2019-05-08 02:34:09 +00:00
|
|
|
top->eval();
|
2013-02-24 02:10:25 +00:00
|
|
|
|
2019-05-08 02:34:09 +00:00
|
|
|
if ((main_time % 100) == 0) {
|
2013-02-24 02:10:25 +00:00
|
|
|
#if defined(T_TRACE_CAT)
|
2019-05-08 02:34:09 +00:00
|
|
|
tfp->openNext(true);
|
2013-02-24 02:10:25 +00:00
|
|
|
#elif defined(T_TRACE_CAT_REOPEN)
|
2019-05-08 02:34:09 +00:00
|
|
|
tfp->close();
|
|
|
|
tfp->open(trace_name());
|
2013-02-24 02:10:25 +00:00
|
|
|
#elif defined(T_TRACE_CAT_RENEW)
|
2019-05-08 02:34:09 +00:00
|
|
|
tfp->close();
|
2020-12-16 23:31:47 +00:00
|
|
|
tfp.reset(new VerilatedVcdC);
|
|
|
|
top->trace(tfp.get(), 99);
|
2019-05-08 02:34:09 +00:00
|
|
|
tfp->open(trace_name());
|
2013-02-24 02:10:25 +00:00
|
|
|
#else
|
2020-10-28 22:42:36 +00:00
|
|
|
#error "Unknown test"
|
2013-02-24 02:10:25 +00:00
|
|
|
#endif
|
2019-05-08 02:34:09 +00:00
|
|
|
}
|
|
|
|
tfp->dump((unsigned int)(main_time));
|
|
|
|
++main_time;
|
2013-02-24 02:10:25 +00:00
|
|
|
}
|
|
|
|
tfp->close();
|
|
|
|
top->final();
|
2020-12-16 23:31:47 +00:00
|
|
|
tfp.reset();
|
|
|
|
top.reset();
|
2018-08-25 13:52:45 +00:00
|
|
|
printf("*-* All Finished *-*\n");
|
2013-02-24 02:10:25 +00:00
|
|
|
return 0;
|
|
|
|
}
|