verilator/test_regress/t/t_multitop_sig.cpp
Tomasz Gorochowik 5b3717b369
Tests: Memory clean up in tests (#2645)
This patch normalizes what the tests do before exiting. After this
change each test should call final on the top module and explicitly
free the top module object before exiting.
2020-11-17 06:37:55 -05:00

48 lines
1.3 KiB
C++

// -*- mode: C++; c-file-style: "cc-mode" -*-
//
// DESCRIPTION: Verilator: Verilog Test module
//
// This file ONLY is placed under the Creative Commons Public Domain, for
// any use, without warranty, 2006 by Wilson Snyder.
// SPDX-License-Identifier: CC0-1.0
#include <iostream>
#include <verilated.h>
#include "Vt_multitop_sig.h"
// Use cout to avoid issues with %d/%lx etc
#define CHECK_RESULT(got, exp) \
if ((got) != (exp)) { \
std::cout << std::dec << "%Error: " << __FILE__ << ":" << __LINE__ << ": GOT = " << (got) \
<< " EXP = " << (exp) << std::endl; \
return __LINE__; \
}
int main(int argc, char* argv[]) {
Vt_multitop_sig* topp = new Vt_multitop_sig("");
Verilated::debug(0);
{
topp->a__02Ein = 0;
topp->b__02Ein = 0;
topp->uniq_in = 0;
topp->eval();
CHECK_RESULT(topp->a__02Eout, 1);
CHECK_RESULT(topp->b__02Eout, 0);
CHECK_RESULT(topp->uniq_out, 1);
topp->a__02Ein = 1;
topp->b__02Ein = 1;
topp->uniq_in = 1;
topp->eval();
CHECK_RESULT(topp->a__02Eout, 0);
CHECK_RESULT(topp->b__02Eout, 1);
CHECK_RESULT(topp->uniq_out, 0);
}
topp->final();
VL_DO_DANGLING(delete topp, topp);
printf("*-* All Finished *-*\n");
}