Tests: Fix misc multithreaded issues, merge from threads branch.

This commit is contained in:
Wilson Snyder 2018-05-19 09:30:54 -04:00
parent b6e8133a4d
commit 5e22ca77ec
4 changed files with 27 additions and 15 deletions

View File

@ -186,9 +186,7 @@ public:
// METHODS
/// Check that the current thread ID is the same as the construction thread ID
void check() VL_MT_UNSAFE_ONE {
// Memoize results in local thread, to prevent slow get_id() call
VL_THREAD_LOCAL bool t_okThread = (m_threadid == VL_THREAD_ID());
if (!VL_LIKELY(t_okThread)) {
if (!VL_LIKELY(m_threadid == VL_THREAD_ID())) {
fatal_different();
}
}

View File

@ -28,8 +28,12 @@ VPATH += ../../$(VM_USER_DIR)
# Needed by DPI tests
CPPFLAGS += -DVERILATOR=1
# Needed by tracing routines
# Debugging
CPPFLAGS += -DVL_DEBUG=1
# Assertions disabled as SystemC libraries are not clean
#CPPFLAGS += -D_GLIBCXX_DEBUG
# Needed by tracing routines
CPPFLAGS += -DTEST_OBJ_DIR=$(TEST_OBJ_DIR)
CPPFLAGS += -DVM_PREFIX=$(VM_PREFIX)
CPPFLAGS += -DVM_PREFIX_INCLUDE="<$(VM_PREFIX).h>"

View File

@ -19,6 +19,9 @@ run(cmd => ["../bin/verilator_coverage",
# Older clib's didn't properly sort maps, but the coverage data doesn't
# really care about ordering. So avoid false failures by sorting.
# Set LC_ALL as suggested in the sort manpage to avoid sort order
# changes from the locale.
$ENV{LC_ALL} = "C";
run(cmd => ["sort",
"$Self->{obj_dir}/coverage.dat",
"> $Self->{obj_dir}/coverage-sort.dat",

View File

@ -156,20 +156,27 @@ struct params {
unsigned int scalar;
int type;
} attributes, children;
} values[] = {
{"onebit", {1, vpiNoDirection, 1, vpiReg}, {0, 0, 0, 0}},
{"twoone", {2, vpiNoDirection, 0, vpiReg}, {0, 0, 0, 0}},
{"onetwo", {2, vpiNoDirection, 0, TestSimulator::is_verilator() ? vpiReg : vpiMemory}, {0, 0, 0, 0}},
{"fourthreetwoone", {2, vpiNoDirection, 0, vpiMemory}, {2, vpiNoDirection, 0, vpiMemoryWord}},
{"clk", {1, vpiInput, 1, vpiPort}, {0, 0, 0, 0}},
{"testin", {16, vpiInput, 0, vpiPort}, {0, 0, 0, 0}},
{"testout", {24, vpiOutput, 0, vpiPort}, {0, 0, 0, 0}},
{"sub.subin", {1, vpiInput, 1, vpiPort}, {0, 0, 0, 0}},
{"sub.subout", {1, vpiOutput, 1, vpiPort}, {0, 0, 0, 0}},
{NULL, {0, 0, 0, 0}, {0, 0, 0, 0}}
};
int mon_check_props() {
// This table needs to be function-static.
// This avoids calling is_verilator() below at global-static init time.
// When global-static led to a race between the is_verilator call below, and
// the code that sets up the VerilatedAssertOneThread() check in
// verilated_vpi.cc, it was causing the check to falsely fail
// (due to m_threadid within the check not being initted yet.)
static struct params values[] = {
{"onebit", {1, vpiNoDirection, 1, vpiReg}, {0, 0, 0, 0}},
{"twoone", {2, vpiNoDirection, 0, vpiReg}, {0, 0, 0, 0}},
{"onetwo", {2, vpiNoDirection, 0, TestSimulator::is_verilator() ? vpiReg : vpiMemory}, {0, 0, 0, 0}},
{"fourthreetwoone", {2, vpiNoDirection, 0, vpiMemory}, {2, vpiNoDirection, 0, vpiMemoryWord}},
{"clk", {1, vpiInput, 1, vpiPort}, {0, 0, 0, 0}},
{"testin", {16, vpiInput, 0, vpiPort}, {0, 0, 0, 0}},
{"testout", {24, vpiOutput, 0, vpiPort}, {0, 0, 0, 0}},
{"sub.subin", {1, vpiInput, 1, vpiPort}, {0, 0, 0, 0}},
{"sub.subout", {1, vpiOutput, 1, vpiPort}, {0, 0, 0, 0}},
{NULL, {0, 0, 0, 0}, {0, 0, 0, 0}}
};
struct params* value = values;
while (value->signal) {
TestVpiHandle h = VPI_HANDLE(value->signal);