2012-04-13 01:08:20 +00:00
|
|
|
// -*- mode: C++; c-file-style: "cc-mode" -*-
|
|
|
|
//
|
2009-01-06 16:03:57 +00:00
|
|
|
// This file ONLY is placed into the Public Domain, for any use,
|
|
|
|
// without warranty, 2008 by Lane Brooks
|
|
|
|
|
2017-10-24 23:58:52 +00:00
|
|
|
#include VM_PREFIX_INCLUDE
|
2009-01-06 16:57:25 +00:00
|
|
|
|
|
|
|
VM_PREFIX* tb = NULL;
|
2009-01-06 16:03:57 +00:00
|
|
|
|
2019-11-10 01:35:12 +00:00
|
|
|
double sc_time_stamp() { return 0; }
|
2009-01-06 16:03:57 +00:00
|
|
|
|
|
|
|
bool check() {
|
|
|
|
bool pass;
|
|
|
|
int c = (tb->A >> tb->SEL) & 0x1;
|
2012-04-21 23:30:08 +00:00
|
|
|
#ifdef TEST_VERBOSE
|
|
|
|
bool verbose = true;
|
|
|
|
#else
|
|
|
|
bool verbose = false;
|
|
|
|
#endif
|
2009-01-06 16:03:57 +00:00
|
|
|
|
2019-11-10 01:35:12 +00:00
|
|
|
if (tb->W == c && tb->X == c && tb->Y == c && tb->Z == c) {
|
2019-05-08 02:34:09 +00:00
|
|
|
pass = true;
|
|
|
|
if (verbose) printf("- pass: ");
|
2009-01-06 16:03:57 +00:00
|
|
|
} else {
|
2019-05-08 02:34:09 +00:00
|
|
|
pass = false;
|
|
|
|
verbose = true;
|
|
|
|
printf("%%E-FAIL: ");
|
2012-04-21 23:30:08 +00:00
|
|
|
}
|
|
|
|
if (verbose) {
|
2019-11-10 01:35:12 +00:00
|
|
|
printf("SEL=%d A=%d got: W=%d X=%d Y=%d Z=%d exp: WXYZ=%d\n", tb->SEL, tb->A, tb->W,
|
|
|
|
tb->X, tb->Y, tb->Z, c);
|
2009-01-06 16:03:57 +00:00
|
|
|
}
|
|
|
|
return pass;
|
|
|
|
}
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
bool pass = true;
|
2009-01-06 16:57:25 +00:00
|
|
|
|
|
|
|
Verilated::debug(0);
|
2018-08-25 13:52:45 +00:00
|
|
|
tb = new VM_PREFIX("tb");
|
2009-01-06 16:03:57 +00:00
|
|
|
|
|
|
|
// loop through every possibility and check the result
|
2019-11-10 01:35:12 +00:00
|
|
|
for (tb->SEL = 0; tb->SEL < 2; tb->SEL++) {
|
|
|
|
for (tb->A = 0; tb->A < 4; tb->A++) {
|
2019-05-08 02:34:09 +00:00
|
|
|
tb->eval();
|
2019-11-10 01:35:12 +00:00
|
|
|
if (!check()) { pass = false; }
|
2019-05-08 02:34:09 +00:00
|
|
|
}
|
2009-01-06 16:03:57 +00:00
|
|
|
}
|
|
|
|
|
2019-11-10 01:35:12 +00:00
|
|
|
if (pass) {
|
2019-05-08 02:34:09 +00:00
|
|
|
VL_PRINTF("*-* All Finished *-*\n");
|
|
|
|
tb->final();
|
2009-01-06 16:03:57 +00:00
|
|
|
} else {
|
2019-11-10 01:35:12 +00:00
|
|
|
vl_fatal(__FILE__, __LINE__, "top", "Unexpected results from tristate test\n");
|
2009-01-06 16:03:57 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|