diff --git a/tgt-vvp/vvp_scope.c b/tgt-vvp/vvp_scope.c index 3177e7976..492645372 100644 --- a/tgt-vvp/vvp_scope.c +++ b/tgt-vvp/vvp_scope.c @@ -2252,11 +2252,15 @@ int draw_scope(ivl_scope_t net, ivl_scope_t parent) if (ivl_scope_type(net)==IVL_SCT_FUNCTION) { switch (ivl_scope_func_type(net)) { case IVL_VT_LOGIC: - case IVL_VT_BOOL: snprintf(suffix, sizeof suffix, ".vec4.%c%u", ivl_scope_func_signed(net)? 'u' : 's', ivl_scope_func_width(net)); break; + case IVL_VT_BOOL: + snprintf(suffix, sizeof suffix, ".vec2.%c%u", + ivl_scope_func_signed(net)? 'u' : 's', + ivl_scope_func_width(net)); + break; case IVL_VT_REAL: snprintf(suffix, sizeof suffix, ".real"); break; diff --git a/vvp/vpi_priv.h b/vvp/vpi_priv.h index 301b8989c..1ccc91c5d 100644 --- a/vvp/vpi_priv.h +++ b/vvp/vpi_priv.h @@ -295,8 +295,8 @@ class __vpiScope : public __vpiHandle { class vpiScopeFunction : public __vpiScope { public: inline vpiScopeFunction(const char*nam, const char*tnam, - bool auto_flag, int func_type, unsigned func_wid) - : __vpiScope(nam,tnam, auto_flag), func_type_(func_type), func_wid_(func_wid) + bool auto_flag, int func_type, unsigned func_wid, vvp_bit4_t func_init_val) + : __vpiScope(nam,tnam, auto_flag), func_type_(func_type), func_wid_(func_wid), func_init_val_(func_init_val) { } int get_type_code(void) const { return vpiFunction; } @@ -312,10 +312,12 @@ class vpiScopeFunction : public __vpiScope { public: inline unsigned get_func_width(void) const { return func_wid_; } + inline vvp_bit4_t get_func_init_val(void) const { return func_init_val_; } private: int func_type_; unsigned func_wid_; + vvp_bit4_t func_init_val_; }; extern __vpiScope* vpip_peek_current_scope(void); diff --git a/vvp/vpi_scope.cc b/vvp/vpi_scope.cc index a795efd4a..746fb4d72 100644 --- a/vvp/vpi_scope.cc +++ b/vvp/vpi_scope.cc @@ -462,13 +462,14 @@ compile_scope_decl(char*label, char*type, char*name, char*tname, long def_file_idx, long def_lineno, long is_cell) { count_vpi_scopes += 1; + char vec_type; char sign_flag; unsigned wid; __vpiScope*scope; if (strcmp(type,"module") == 0) { scope = new vpiScopeModule(name, tname); - } else if ( sscanf(type, "function.vec4.%c%u", &sign_flag, &wid) == 2 ) { + } else if ( sscanf(type, "function.vec%c.%c%u", &vec_type, &sign_flag, &wid) == 3 ) { int type_code; if (sign_flag=='s') { type_code = vpiSizedSignedFunc; @@ -480,9 +481,10 @@ compile_scope_decl(char*label, char*type, char*name, char*tname, assert(0); type_code = vpiSizedFunc; } - scope = new vpiScopeFunction(name, tname, false, type_code, wid); + vvp_bit4_t init_val = vec_type == '4' ? BIT4_X : BIT4_0; + scope = new vpiScopeFunction(name, tname, false, type_code, wid, init_val); - } else if ( sscanf(type, "autofunction.vec4.%c%u", &sign_flag, &wid) == 2 ) { + } else if ( sscanf(type, "autofunction.vec%c.%c%u", &vec_type, &sign_flag, &wid) == 3 ) { int type_code; switch (sign_flag) { case 's': @@ -496,24 +498,25 @@ compile_scope_decl(char*label, char*type, char*name, char*tname, type_code = vpiSizedFunc; break; } - scope = new vpiScopeFunction(name, tname, true, type_code, wid); + vvp_bit4_t init_val = vec_type == '4' ? BIT4_X : BIT4_0; + scope = new vpiScopeFunction(name, tname, true, type_code, wid, init_val); } else if (strcmp(type,"function.obj") == 0) { - scope = new vpiScopeFunction(name, tname, false, vpiSizedFunc, 0); + scope = new vpiScopeFunction(name, tname, false, vpiSizedFunc, 0, BIT4_0); } else if (strcmp(type,"autofunction.obj") == 0) { - scope = new vpiScopeFunction(name, tname, true, vpiSizedFunc, 0); + scope = new vpiScopeFunction(name, tname, true, vpiSizedFunc, 0, BIT4_0); } else if (strcmp(type,"function.real") == 0) { - scope = new vpiScopeFunction(name, tname, false, vpiRealFunc, 0); + scope = new vpiScopeFunction(name, tname, false, vpiRealFunc, 0, BIT4_0); } else if (strcmp(type,"autofunction.real") == 0) { - scope = new vpiScopeFunction(name, tname, true, vpiRealFunc, 0); + scope = new vpiScopeFunction(name, tname, true, vpiRealFunc, 0, BIT4_0); } else if (strcmp(type,"function.str") == 0) { - scope = new vpiScopeFunction(name, tname, false, vpiOtherFunc, 0); + scope = new vpiScopeFunction(name, tname, false, vpiOtherFunc, 0, BIT4_0); } else if (strcmp(type,"autofunction.str") == 0) { - scope = new vpiScopeFunction(name, tname, true, vpiOtherFunc, 0); + scope = new vpiScopeFunction(name, tname, true, vpiOtherFunc, 0, BIT4_0); } else if (strcmp(type,"function.void") == 0) { - scope = new vpiScopeFunction(name, tname, false, vpiOtherFunc, 0); + scope = new vpiScopeFunction(name, tname, false, vpiOtherFunc, 0, BIT4_0); } else if (strcmp(type,"autofunction.void") == 0) { - scope = new vpiScopeFunction(name, tname, true, vpiOtherFunc, 0); + scope = new vpiScopeFunction(name, tname, true, vpiOtherFunc, 0, BIT4_0); } else if (strcmp(type,"task") == 0) { scope = new vpiScopeTask(name, tname); } else if (strcmp(type,"autotask") == 0) { diff --git a/vvp/vthread.cc b/vvp/vthread.cc index d42d2eb16..c61456411 100644 --- a/vvp/vthread.cc +++ b/vvp/vthread.cc @@ -1380,7 +1380,7 @@ bool of_CALLF_VEC4(vthread_t thr, vvp_code_t cp) // This is the return value. Push a place-holder value. The function // will replace this with the actual value using a %ret/real instruction. - thr->push_vec4(vvp_vector4_t(scope_func->get_func_width())); + thr->push_vec4(vvp_vector4_t(scope_func->get_func_width(), scope_func->get_func_init_val())); child->args_vec4.push_back(0); return do_callf_void(thr, child); @@ -6328,7 +6328,7 @@ bool of_EXEC_UFUNC_VEC4(vthread_t thr, vvp_code_t cp) /* Create a temporary thread and run it immediately. */ vthread_t child = vthread_new(cp->cptr, child_scope); - thr->push_vec4(vvp_vector4_t(scope_func->get_func_width())); + thr->push_vec4(vvp_vector4_t(scope_func->get_func_width(), scope_func->get_func_init_val())); child->args_vec4.push_back(0); return do_exec_ufunc(thr, cp, child);