File: t_tri_inz.cpp

package info (click to toggle)
verilator 5.038-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 162,552 kB
  • sloc: cpp: 139,204; python: 20,931; ansic: 10,222; yacc: 6,000; lex: 1,925; makefile: 1,260; sh: 494; perl: 282; fortran: 22
file content (50 lines) | stat: -rw-r--r-- 1,409 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// -*- mode: C++; c-file-style: "cc-mode" -*-
// This file ONLY is placed under the Creative Commons Public Domain, for
// any use, without warranty, 2020 by Wilson Snyder.
// SPDX-License-Identifier: CC0-1.0

#include "Vt_tri_inz.h"
#include "Vt_tri_inz___024root.h"

VM_PREFIX* tb = nullptr;
bool pass = true;

double sc_time_stamp() { return 0; }

void checkone(const char* name, int got, int exp) {
    if (got != exp) {
        printf("%%Error: For %s got=%d exp=%d\n", name, got, exp);
        pass = false;
    }
}

void check(int d, int en, int exp0, int exp1, int expx, int expz) {
    tb->d = d;
    tb->rootp->d__en0 = en;
    tb->eval();
#ifdef TEST_VERBOSE
    printf("Drive d=%d en=%d got0=%d/1=%d/x=%d/z=%d  exp0=%d/1=%d/x=%d/z=%d\n", d, en, tb->ext0,
           tb->ext1, tb->extx, tb->extz, exp0, exp1, expx, expz);
#endif
    if (!expz) checkone("ext0", tb->ext0, exp0);
    if (!expz) checkone("ext1", tb->ext1, exp1);
    checkone("extx", tb->extx, expx);
    checkone("extz", tb->extz, expz);
}

int main() {
    Verilated::debug(0);
    tb = new VM_PREFIX{"tb"};
    check(0, 1, 1, 0, 0, 0);
    check(1, 1, 0, 1, 0, 0);
    check(0, 0, 0, 0, 0, 1);

    if (pass) {
        VL_PRINTF("*-* All Finished *-*\n");
        tb->final();
    } else {
        vl_fatal(__FILE__, __LINE__, "top", "Unexpected results from t_tri_inz\n");
    }
    VL_DO_DANGLING(delete tb, tb);
    return 0;
}