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,
|
2020-03-21 15:24:24 +00:00
|
|
|
// without warranty, 2008 by Lane Brooks.
|
|
|
|
// SPDX-License-Identifier: CC0-1.0
|
2009-01-06 16:03:57 +00:00
|
|
|
|
|
|
|
#include "Vt_tri_pullup.h"
|
|
|
|
|
2020-08-24 22:49:36 +00:00
|
|
|
VM_PREFIX* tb = nullptr;
|
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 Z, Y, X;
|
|
|
|
if (tb->OE) {
|
2019-05-08 02:34:09 +00:00
|
|
|
Z = tb->A;
|
|
|
|
Y = tb->A;
|
|
|
|
X = tb->A;
|
2009-01-06 16:03:57 +00:00
|
|
|
} else {
|
2019-05-08 02:34:09 +00:00
|
|
|
Z = 1;
|
|
|
|
Y = 0;
|
|
|
|
X = 1;
|
2009-01-06 16:03:57 +00:00
|
|
|
}
|
|
|
|
|
2012-04-21 23:30:08 +00:00
|
|
|
#ifdef TEST_VERBOSE
|
|
|
|
bool verbose = true;
|
|
|
|
#else
|
|
|
|
bool verbose = false;
|
|
|
|
#endif
|
|
|
|
|
2019-11-10 01:35:12 +00:00
|
|
|
if (tb->Z == Z && tb->Y == Y && tb->X == X) {
|
2019-05-08 02:34:09 +00:00
|
|
|
if (verbose) printf("PASS: ");
|
|
|
|
pass = true;
|
2009-01-06 16:03:57 +00:00
|
|
|
} else {
|
2019-05-08 02:34:09 +00:00
|
|
|
printf("%%E-FAIL: ");
|
|
|
|
verbose = true;
|
|
|
|
pass = false;
|
2009-01-06 16:03:57 +00:00
|
|
|
}
|
2019-11-10 01:35:12 +00:00
|
|
|
if (verbose)
|
|
|
|
printf("OE=%d A=%d X=%d xexp=%d Y=%d yexp=%d Z=%d zexp=%d\n", tb->OE, tb->A, tb->X, X,
|
|
|
|
tb->Y, Y, tb->Z, Z);
|
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);
|
2022-08-30 03:50:32 +00:00
|
|
|
tb = new Vt_tri_pullup{"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->OE = 0; tb->OE < 2; tb->OE++) {
|
|
|
|
for (tb->A = 0; tb->A < 2; tb->A++) {
|
2019-05-08 02:34:09 +00:00
|
|
|
tb->eval();
|
2021-02-22 02:25:21 +00:00
|
|
|
if (!check()) pass = false;
|
2019-05-08 02:34:09 +00:00
|
|
|
}
|
2009-01-06 16:03:57 +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 pullup test\n");
|
2009-01-06 16:03:57 +00:00
|
|
|
}
|
2020-11-17 11:37:55 +00:00
|
|
|
VL_DO_DANGLING(delete tb, tb);
|
2009-01-06 16:03:57 +00:00
|
|
|
return 0;
|
|
|
|
}
|