예제 #1
0
static int check_sub(const char* name, int i) {
    svScope scope = svGetScopeFromName(name);
#ifdef TEST_VERBOSE
    printf("svGetScopeFromName(\"%s\") -> %p\n", name, scope);
#endif
    CHECK_RESULT_NNULL (scope);
    svScope prev = svGetScope();
    svScope sout = svSetScope(scope);
    CHECK_RESULT(svScope, sout, prev);
    CHECK_RESULT(svScope, svGetScope(), scope);
    int out = dpix_sub_inst(100*i);
    CHECK_RESULT(int, out, 100*i + i);

    return 0; // OK
}
예제 #2
0
int dpic_line() {
    svScope scope = svGetScope();
    if (!scope) {
	printf("%%Warning: svGetScope failed\n");
	return 0;
    }

#ifdef VERILATOR
    static int didDump = 0;
    if (didDump++ == 0) {
	Verilated::scopesDump();
    }
#endif

    const char* scopenamep = svGetNameFromScope(scope);
    if (!scopenamep) {
	printf("%%Warning: svGetNameFromScope failed\n");
	return 0;
    }
    if (scope != svGetScopeFromName(scopenamep)) {
	printf("%%Warning: svGetScopeFromName repeat failed\n");
	return 0;
    }

    const char* filenamep = "";
    int lineno = 0;
    if (svGetCallerInfo(&filenamep, &lineno)) {
	printf("Call from %s:%d:%s\n", filenamep, lineno, scopenamep);
    } else {
	printf("%%Warning: svGetCallerInfo failed\n");
	return 0;
    }
    return lineno;
}
예제 #3
0
int dpic_save(int value) {
    svScope scope = svGetScope();
    if (!scope) {
	printf("%%Warning: svGetScope failed\n");
	return 0;
    }

    if (svPutUserData(scope, &Dpic_Unique, (void*)(value))) {
	printf("%%Warning: svPutUserData failed\n");
	return 0;
    }
    return 1;
}
예제 #4
0
int dpic_restore() {
    svScope scope = svGetScope();
    if (!scope) {
	printf("%%Warning: svGetScope failed\n");
	return 0;
    }

    if (void* userp = svGetUserData(scope, &Dpic_Unique)) {
	return (int)(long long)(userp);
    } else {
	printf("%%Warning: svGetUserData failed\n");
	return 0;
    }
}
예제 #5
0
Vt_embed1_child* __get_modelp() {
    svScope scope = svGetScope();
    if (!scope) {
	vl_fatal(__FILE__,__LINE__,__FILE__,"svGetScope failed");
	return NULL;
    }

    void* __modelp = svGetUserData(scope, &T_Embed_Child_Unique);
    if (!__modelp) {
	// Create the model
	const char* scopenamep = svGetNameFromScope(scope);
	if (!scopenamep) vl_fatal(__FILE__,__LINE__,__FILE__,"svGetNameFromScope failed");
	__modelp = new Vt_embed1_child(scopenamep);
	if (svPutUserData(scope, &T_Embed_Child_Unique, __modelp)) {
	    vl_fatal(__FILE__,__LINE__,__FILE__,"svPutUserData failed");
	}
    }
    return (Vt_embed1_child*)(__modelp); 
}
예제 #6
0
int dpic_save(int value) {
    svScope scope = svGetScope();
    if (!scope) {
	printf("%%Warning: svGetScope failed\n");
	return 0;
    }

    // Use union to avoid cast to different size pointer warnings
    union valpack {
	void* ptr;
	int i;
    } vp;

    vp.i = value;
    if (svPutUserData(scope, &Dpic_Unique, vp.ptr)) {
	printf("%%Warning: svPutUserData failed\n");
	return 0;
    }
    return 1;
}
예제 #7
0
int dpic_restore() {
    svScope scope = svGetScope();
    if (!scope) {
	printf("%%Warning: svGetScope failed\n");
	return 0;
    }

    if (void* userp = svGetUserData(scope, (void*)&Dpic_Unique)) {
	// Use union to avoid cast to different size pointer warnings
	union valpack {
	    void* ptr;
	    int i;
	} vp;
	vp.ptr = userp;
	return vp.i;
    } else {
	printf("%%Warning: svGetUserData failed\n");
	return 0;
    }
}
예제 #8
0
unsigned dpic_getcontext() {
    svScope scope = svGetScope();
    printf("%%Info: svGetScope returned scope (%p) with name %s\n", scope, svGetNameFromScope(scope));
    return (unsigned) (uintptr_t) scope;
}