1 // -*- mode: C++; c-file-style: "cc-mode" -*-
2 //
3 // This file ONLY is placed into the Public Domain, for any use,
4 // without warranty, 2008 by Lane Brooks.
5 // SPDX-License-Identifier: CC0-1.0
6 
7 #include "Vt_tri_inout.h"
8 
9 VM_PREFIX* tb = nullptr;
10 
sc_time_stamp()11 double sc_time_stamp() { return 0; }
12 
check()13 bool check() {
14     bool pass;
15     int Z;
16     if (tb->SEL) {
17         Z = tb->A;
18     } else {
19         Z = tb->B;
20     }
21 
22     if (tb->Z == tb->Y1 && tb->Z == tb->Y2 && tb->Z == Z) {
23         printf("PASS: ");
24         pass = true;
25     } else {
26         printf("FAIL: ");
27         pass = false;
28     }
29 #ifdef TEST_VERBOSE
30     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);
31 #endif
32     return pass;
33 }
34 
main()35 int main() {
36     bool pass = true;
37 
38     Verilated::debug(0);
39     tb = new Vt_tri_inout("tb");
40 
41     // loop through every possibility and check the result
42     for (tb->SEL = 0; tb->SEL < 2; tb->SEL++) {
43         for (tb->A = 0; tb->A < 2; tb->A++) {
44             for (tb->B = 0; tb->B < 2; tb->B++) {
45                 tb->eval();
46                 if (!check()) pass = false;
47             }
48         }
49     }
50 
51     if (pass) {
52         VL_PRINTF("*-* All Finished *-*\n");
53         tb->final();
54     } else {
55         vl_fatal(__FILE__, __LINE__, "top", "Unexpected results from inout test\n");
56     }
57     VL_DO_DANGLING(delete tb, tb);
58     return 0;
59 }
60