File: t_tri_inout.cpp

package info (click to toggle)
verilator 3.833-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 10,196 kB
  • sloc: cpp: 49,566; perl: 7,111; yacc: 2,221; lex: 1,702; makefile: 651; sh: 175
file content (61 lines) | stat: -rw-r--r-- 1,169 bytes parent folder | download | duplicates (3)
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
51
52
53
54
55
56
57
58
59
60
61
// -*- mode: C++; c-file-style: "cc-mode" -*-
//
// This file ONLY is placed into the Public Domain, for any use,
// without warranty, 2008 by Lane Brooks

#include "Vt_tri_inout.h"

Vt_tri_inout *tb = NULL;

double sc_time_stamp() {
    return 0;
}

bool check() {
    bool pass;
    int Z;
    if (tb->SEL) {
	Z = tb->A;
    } else {
	Z = tb->B;
    }

    if (tb->Z == tb->Y1 && tb->Z == tb->Y2 && tb->Z == Z) {
	printf("PASS: ");
	pass = true;
    } else {
	printf("FAIL: ");
	pass = false;
    }
#ifdef TEST_VERBOSE
    printf ("SEL=%d A=%d B=%d Z=%d Y1=%d Y2=%d\n", tb->SEL, tb->A, tb->B, tb->Z, tb->Y1, tb->Y2);
#endif
    return pass;
}

int main() {
    bool pass = true;

    Verilated::debug(0);
    tb = new Vt_tri_inout("tb");

    // loop through every possibility and check the result
    for (tb->SEL=0; tb->SEL<2; tb->SEL++) {
	for (tb->A=0; tb->A<2; tb->A++) {
	    for (tb->B=0; tb->B<2; tb->B++) {
		tb->eval();
		if (!check()) {
		    pass = false;
		}
	    }
	}
    }

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