C++-ify the __vpiScope classes.
This commit is contained in:
parent
c88a60537a
commit
fff69390ac
18
vvp/array.cc
18
vvp/array.cc
|
|
@ -275,7 +275,7 @@ int __vpiArray::vpi_get(int code)
|
||||||
return get_size();
|
return get_size();
|
||||||
|
|
||||||
case vpiAutomatic:
|
case vpiAutomatic:
|
||||||
return (int) scope->is_automatic;
|
return scope->is_automatic()? 1 : 0;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -361,7 +361,7 @@ int __vpiArrayWord::as_word_t::vpi_get(int code)
|
||||||
return val.value.integer;
|
return val.value.integer;
|
||||||
|
|
||||||
case vpiAutomatic:
|
case vpiAutomatic:
|
||||||
return (int) parent->get_scope()->is_automatic;
|
return parent->get_scope()->is_automatic()? 1 : 0;
|
||||||
|
|
||||||
#if defined(CHECK_WITH_VALGRIND) || defined(BR916_STOPGAP_FIX)
|
#if defined(CHECK_WITH_VALGRIND) || defined(BR916_STOPGAP_FIX)
|
||||||
case _vpiFromThr:
|
case _vpiFromThr:
|
||||||
|
|
@ -393,7 +393,7 @@ int __vpiArrayVthrA::vpi_get(int code)
|
||||||
return (int)get_address() + array->first_addr.get_value();
|
return (int)get_address() + array->first_addr.get_value();
|
||||||
|
|
||||||
case vpiAutomatic:
|
case vpiAutomatic:
|
||||||
return (int) array->get_scope()->is_automatic;
|
return array->get_scope()->is_automatic() ? 1 : 0;
|
||||||
|
|
||||||
#if defined(CHECK_WITH_VALGRIND) || defined(BR916_STOPGAP_FIX)
|
#if defined(CHECK_WITH_VALGRIND) || defined(BR916_STOPGAP_FIX)
|
||||||
case _vpiFromThr:
|
case _vpiFromThr:
|
||||||
|
|
@ -504,7 +504,7 @@ int __vpiArrayVthrAPV::vpi_get(int code)
|
||||||
return (int)word_sel;
|
return (int)word_sel;
|
||||||
|
|
||||||
case vpiAutomatic:
|
case vpiAutomatic:
|
||||||
return (int) array->get_scope()->is_automatic;
|
return array->get_scope()->is_automatic() ? 1 : 0;
|
||||||
|
|
||||||
#if defined(CHECK_WITH_VALGRIND) || defined(BR916_STOPGAP_FIX)
|
#if defined(CHECK_WITH_VALGRIND) || defined(BR916_STOPGAP_FIX)
|
||||||
case _vpiFromThr:
|
case _vpiFromThr:
|
||||||
|
|
@ -855,7 +855,7 @@ void compile_var_array(char*label, char*name, int last, int first,
|
||||||
|
|
||||||
/* Make the words. */
|
/* Make the words. */
|
||||||
arr->vals_width = labs(msb-lsb) + 1;
|
arr->vals_width = labs(msb-lsb) + 1;
|
||||||
if (vpip_peek_current_scope()->is_automatic) {
|
if (vpip_peek_current_scope()->is_automatic()) {
|
||||||
arr->vals4 = new vvp_vector4array_aa(arr->vals_width,
|
arr->vals4 = new vvp_vector4array_aa(arr->vals_width,
|
||||||
arr->get_size());
|
arr->get_size());
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -1201,7 +1201,7 @@ void vvp_fun_arrayport_aa::check_word_change_(unsigned long addr,
|
||||||
|
|
||||||
void vvp_fun_arrayport_aa::check_word_change(unsigned long addr)
|
void vvp_fun_arrayport_aa::check_word_change(unsigned long addr)
|
||||||
{
|
{
|
||||||
if (arr_->get_scope()->is_automatic) {
|
if (arr_->get_scope()->is_automatic()) {
|
||||||
assert(vthread_get_wt_context());
|
assert(vthread_get_wt_context());
|
||||||
check_word_change_(addr, vthread_get_wt_context());
|
check_word_change_(addr, vthread_get_wt_context());
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -1218,7 +1218,7 @@ static void array_attach_port(vvp_array_t array, vvp_fun_arrayport*fun)
|
||||||
assert(fun->next_ == 0);
|
assert(fun->next_ == 0);
|
||||||
fun->next_ = array->ports_;
|
fun->next_ = array->ports_;
|
||||||
array->ports_ = fun;
|
array->ports_ = fun;
|
||||||
if (!array->get_scope()->is_automatic) {
|
if (!array->get_scope()->is_automatic()) {
|
||||||
/* propagate initial values for variable arrays */
|
/* propagate initial values for variable arrays */
|
||||||
if (array->vals4) {
|
if (array->vals4) {
|
||||||
vvp_vector4_t tmp(array->vals_width, BIT4_X);
|
vvp_vector4_t tmp(array->vals_width, BIT4_X);
|
||||||
|
|
@ -1355,12 +1355,12 @@ bool array_port_resolv_list_t::resolve(bool mes)
|
||||||
|
|
||||||
vvp_fun_arrayport*fun;
|
vvp_fun_arrayport*fun;
|
||||||
if (use_addr)
|
if (use_addr)
|
||||||
if (vpip_peek_current_scope()->is_automatic)
|
if (vpip_peek_current_scope()->is_automatic())
|
||||||
fun = new vvp_fun_arrayport_aa(mem, ptr, addr);
|
fun = new vvp_fun_arrayport_aa(mem, ptr, addr);
|
||||||
else
|
else
|
||||||
fun = new vvp_fun_arrayport_sa(mem, ptr, addr);
|
fun = new vvp_fun_arrayport_sa(mem, ptr, addr);
|
||||||
else
|
else
|
||||||
if (vpip_peek_current_scope()->is_automatic)
|
if (vpip_peek_current_scope()->is_automatic())
|
||||||
fun = new vvp_fun_arrayport_aa(mem, ptr);
|
fun = new vvp_fun_arrayport_aa(mem, ptr);
|
||||||
else
|
else
|
||||||
fun = new vvp_fun_arrayport_sa(mem, ptr);
|
fun = new vvp_fun_arrayport_sa(mem, ptr);
|
||||||
|
|
|
||||||
|
|
@ -768,7 +768,7 @@ void compile_event(char*label, char*type, unsigned argc, struct symb_s*argv)
|
||||||
|
|
||||||
free(type);
|
free(type);
|
||||||
|
|
||||||
if (vpip_peek_current_scope()->is_automatic) {
|
if (vpip_peek_current_scope()->is_automatic()) {
|
||||||
fun = new vvp_fun_anyedge_aa;
|
fun = new vvp_fun_anyedge_aa;
|
||||||
} else {
|
} else {
|
||||||
fun = new vvp_fun_anyedge_sa;
|
fun = new vvp_fun_anyedge_sa;
|
||||||
|
|
@ -786,7 +786,7 @@ void compile_event(char*label, char*type, unsigned argc, struct symb_s*argv)
|
||||||
assert(argc <= 4);
|
assert(argc <= 4);
|
||||||
free(type);
|
free(type);
|
||||||
|
|
||||||
if (vpip_peek_current_scope()->is_automatic) {
|
if (vpip_peek_current_scope()->is_automatic()) {
|
||||||
fun = new vvp_fun_edge_aa(edge);
|
fun = new vvp_fun_edge_aa(edge);
|
||||||
} else {
|
} else {
|
||||||
fun = new vvp_fun_edge_sa(edge);
|
fun = new vvp_fun_edge_sa(edge);
|
||||||
|
|
@ -807,7 +807,7 @@ void compile_event(char*label, char*type, unsigned argc, struct symb_s*argv)
|
||||||
static void compile_event_or(char*label, unsigned argc, struct symb_s*argv)
|
static void compile_event_or(char*label, unsigned argc, struct symb_s*argv)
|
||||||
{
|
{
|
||||||
vvp_net_t* ptr = new vvp_net_t;
|
vvp_net_t* ptr = new vvp_net_t;
|
||||||
if (vpip_peek_current_scope()->is_automatic) {
|
if (vpip_peek_current_scope()->is_automatic()) {
|
||||||
ptr->fun = new vvp_fun_event_or_aa;
|
ptr->fun = new vvp_fun_event_or_aa;
|
||||||
} else {
|
} else {
|
||||||
ptr->fun = new vvp_fun_event_or_sa;
|
ptr->fun = new vvp_fun_event_or_sa;
|
||||||
|
|
@ -835,7 +835,7 @@ void compile_named_event(char*label, char*name)
|
||||||
|
|
||||||
vpiHandle obj = vpip_make_named_event(name, ptr);
|
vpiHandle obj = vpip_make_named_event(name, ptr);
|
||||||
|
|
||||||
if (vpip_peek_current_scope()->is_automatic) {
|
if (vpip_peek_current_scope()->is_automatic()) {
|
||||||
ptr->fun = new vvp_named_event_aa(obj);
|
ptr->fun = new vvp_named_event_aa(obj);
|
||||||
} else {
|
} else {
|
||||||
ptr->fun = new vvp_named_event_sa(obj);
|
ptr->fun = new vvp_named_event_sa(obj);
|
||||||
|
|
|
||||||
|
|
@ -411,7 +411,7 @@ void compile_part_select(char*label, char*source,
|
||||||
unsigned base, unsigned wid)
|
unsigned base, unsigned wid)
|
||||||
{
|
{
|
||||||
vvp_fun_part*fun = 0;
|
vvp_fun_part*fun = 0;
|
||||||
if (vpip_peek_current_scope()->is_automatic) {
|
if (vpip_peek_current_scope()->is_automatic()) {
|
||||||
fun = new vvp_fun_part_aa(base, wid);
|
fun = new vvp_fun_part_aa(base, wid);
|
||||||
} else {
|
} else {
|
||||||
fun = new vvp_fun_part_sa(base, wid);
|
fun = new vvp_fun_part_sa(base, wid);
|
||||||
|
|
@ -431,7 +431,7 @@ void compile_part_select_var(char*label, char*source, char*var,
|
||||||
unsigned wid, bool is_signed)
|
unsigned wid, bool is_signed)
|
||||||
{
|
{
|
||||||
vvp_fun_part_var*fun = 0;
|
vvp_fun_part_var*fun = 0;
|
||||||
if (vpip_peek_current_scope()->is_automatic) {
|
if (vpip_peek_current_scope()->is_automatic()) {
|
||||||
fun = new vvp_fun_part_var_aa(wid, is_signed);
|
fun = new vvp_fun_part_var_aa(wid, is_signed);
|
||||||
} else {
|
} else {
|
||||||
fun = new vvp_fun_part_var_sa(wid, is_signed);
|
fun = new vvp_fun_part_var_sa(wid, is_signed);
|
||||||
|
|
|
||||||
20
vvp/stop.cc
20
vvp/stop.cc
|
|
@ -139,7 +139,7 @@ static void cmd_call(unsigned argc, char*argv[])
|
||||||
case vpiNamedBegin:
|
case vpiNamedBegin:
|
||||||
case vpiNamedFork:
|
case vpiNamedFork:
|
||||||
scope = dynamic_cast<__vpiScope*>(table[idx]);
|
scope = dynamic_cast<__vpiScope*>(table[idx]);
|
||||||
if (strcmp(scope->name, argv[idx+1]) == 0)
|
if (strcmp(scope->scope_name(), argv[idx+1]) == 0)
|
||||||
handle = table[tmp];
|
handle = table[tmp];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
@ -234,32 +234,32 @@ static void cmd_list(unsigned, char*[])
|
||||||
switch (table[idx]->get_type_code()) {
|
switch (table[idx]->get_type_code()) {
|
||||||
case vpiModule:
|
case vpiModule:
|
||||||
scope = dynamic_cast<__vpiScope*>(table[idx]);
|
scope = dynamic_cast<__vpiScope*>(table[idx]);
|
||||||
printf("module : %s\n", scope->name);
|
printf("module : %s\n", scope->scope_name());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case vpiGenScope:
|
case vpiGenScope:
|
||||||
scope = dynamic_cast<__vpiScope*>(table[idx]);
|
scope = dynamic_cast<__vpiScope*>(table[idx]);
|
||||||
printf("generate: %s\n", scope->name);
|
printf("generate: %s\n", scope->scope_name());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case vpiTask:
|
case vpiTask:
|
||||||
scope = dynamic_cast<__vpiScope*>(table[idx]);
|
scope = dynamic_cast<__vpiScope*>(table[idx]);
|
||||||
printf("task : %s\n", scope->name);
|
printf("task : %s\n", scope->scope_name());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case vpiFunction:
|
case vpiFunction:
|
||||||
scope = dynamic_cast<__vpiScope*>(table[idx]);
|
scope = dynamic_cast<__vpiScope*>(table[idx]);
|
||||||
printf("function: %s\n", scope->name);
|
printf("function: %s\n", scope->scope_name());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case vpiNamedBegin:
|
case vpiNamedBegin:
|
||||||
scope = dynamic_cast<__vpiScope*>(table[idx]);
|
scope = dynamic_cast<__vpiScope*>(table[idx]);
|
||||||
printf("block : %s\n", scope->name);
|
printf("block : %s\n", scope->scope_name());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case vpiNamedFork:
|
case vpiNamedFork:
|
||||||
scope = dynamic_cast<__vpiScope*>(table[idx]);
|
scope = dynamic_cast<__vpiScope*>(table[idx]);
|
||||||
printf("fork : %s\n", scope->name);
|
printf("fork : %s\n", scope->scope_name());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case vpiParameter:
|
case vpiParameter:
|
||||||
|
|
@ -343,7 +343,7 @@ static void cmd_push(unsigned argc, char* argv[])
|
||||||
|
|
||||||
/* This is a scope, and the name matches, then
|
/* This is a scope, and the name matches, then
|
||||||
report that I found the child. */
|
report that I found the child. */
|
||||||
if (strcmp(cp->name, argv[idx]) == 0) {
|
if (strcmp(cp->scope_name(), argv[idx]) == 0) {
|
||||||
child = cp;
|
child = cp;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -401,10 +401,10 @@ static void cmd_where(unsigned, char*[])
|
||||||
while (cur) {
|
while (cur) {
|
||||||
switch (cur->get_type_code()) {
|
switch (cur->get_type_code()) {
|
||||||
case vpiModule:
|
case vpiModule:
|
||||||
printf("module %s\n", cur->name);
|
printf("module %s\n", cur->scope_name());
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
printf("scope (%d) %s;\n", cur->get_type_code(), cur->name);
|
printf("scope (%d) %s;\n", cur->get_type_code(), cur->scope_name());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ int __vpiNamedEvent::vpi_get(int code)
|
||||||
switch (code) {
|
switch (code) {
|
||||||
|
|
||||||
case vpiAutomatic:
|
case vpiAutomatic:
|
||||||
return (int) scope_->is_automatic;
|
return scope_->is_automatic()? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
|
|
@ -236,21 +236,29 @@ struct __vpiPortInfo : public __vpiHandle {
|
||||||
* objects hold the items and properties that are knowingly bound to a
|
* objects hold the items and properties that are knowingly bound to a
|
||||||
* scope.
|
* scope.
|
||||||
*/
|
*/
|
||||||
struct __vpiScope : public __vpiHandle {
|
class __vpiScope : public __vpiHandle {
|
||||||
|
|
||||||
|
public:
|
||||||
int vpi_get(int code);
|
int vpi_get(int code);
|
||||||
char* vpi_get_str(int code);
|
char* vpi_get_str(int code);
|
||||||
vpiHandle vpi_handle(int code);
|
vpiHandle vpi_handle(int code);
|
||||||
vpiHandle vpi_iterate(int code);
|
vpiHandle vpi_iterate(int code);
|
||||||
|
|
||||||
|
public:
|
||||||
|
// Return the BASE name of the scope. This does not include
|
||||||
|
// any of the parent hierarchy.
|
||||||
|
inline const char*scope_name() const { return name_; }
|
||||||
|
|
||||||
|
inline const char*scope_def_name() const { return tname_; }
|
||||||
|
// TRUE if this is an automatic func/task/block
|
||||||
|
inline bool is_automatic() const { return is_automatic_; }
|
||||||
|
|
||||||
|
public:
|
||||||
struct __vpiScope *scope;
|
struct __vpiScope *scope;
|
||||||
/* The scope has a name. */
|
|
||||||
const char*name;
|
|
||||||
const char*tname;
|
|
||||||
unsigned file_idx;
|
unsigned file_idx;
|
||||||
unsigned lineno;
|
unsigned lineno;
|
||||||
unsigned def_file_idx;
|
unsigned def_file_idx;
|
||||||
unsigned def_lineno;
|
unsigned def_lineno;
|
||||||
bool is_automatic;
|
|
||||||
bool is_cell;
|
bool is_cell;
|
||||||
/* The scope has a system time of its own. */
|
/* The scope has a system time of its own. */
|
||||||
struct __vpiScopedTime scoped_time;
|
struct __vpiScopedTime scoped_time;
|
||||||
|
|
@ -274,7 +282,15 @@ struct __vpiScope : public __vpiHandle {
|
||||||
signed int time_precision :8;
|
signed int time_precision :8;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
inline __vpiScope() { }
|
__vpiScope(const char*nam, const char*tnam);
|
||||||
|
|
||||||
|
private:
|
||||||
|
/* The scope has a name. */
|
||||||
|
const char*name_;
|
||||||
|
const char*tname_;
|
||||||
|
protected:
|
||||||
|
/* the scope may be "automatic" */
|
||||||
|
bool is_automatic_;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern struct __vpiScope* vpip_peek_current_scope(void);
|
extern struct __vpiScope* vpip_peek_current_scope(void);
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ static int real_var_get(int code, vpiHandle ref)
|
||||||
return 0; // Not implemented for now!
|
return 0; // Not implemented for now!
|
||||||
|
|
||||||
case vpiAutomatic:
|
case vpiAutomatic:
|
||||||
return (int) vpip_scope(rfp)->is_automatic;
|
return vpip_scope(rfp)->is_automatic()? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
169
vvp/vpi_scope.cc
169
vvp/vpi_scope.cc
|
|
@ -169,37 +169,6 @@ void root_table_delete(void)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int scope_get(int code, vpiHandle obj)
|
|
||||||
{
|
|
||||||
struct __vpiScope*ref = dynamic_cast<__vpiScope*>(obj);
|
|
||||||
assert(obj);
|
|
||||||
|
|
||||||
switch (code) {
|
|
||||||
case vpiCellInstance:
|
|
||||||
return (int) ref->is_cell;
|
|
||||||
|
|
||||||
case vpiDefLineNo:
|
|
||||||
return ref->def_lineno;
|
|
||||||
|
|
||||||
case vpiLineNo:
|
|
||||||
return ref->lineno;
|
|
||||||
|
|
||||||
case vpiTimeUnit:
|
|
||||||
return ref->time_units;
|
|
||||||
|
|
||||||
case vpiTimePrecision:
|
|
||||||
return ref->time_precision;
|
|
||||||
|
|
||||||
case vpiTopModule:
|
|
||||||
return 0x0 == ref->scope;
|
|
||||||
|
|
||||||
case vpiAutomatic:
|
|
||||||
return (int) ref->is_automatic;
|
|
||||||
}
|
|
||||||
|
|
||||||
return vpiUndefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void construct_scope_fullname(struct __vpiScope*ref, char*buf)
|
static void construct_scope_fullname(struct __vpiScope*ref, char*buf)
|
||||||
{
|
{
|
||||||
if (ref->scope) {
|
if (ref->scope) {
|
||||||
|
|
@ -207,7 +176,7 @@ static void construct_scope_fullname(struct __vpiScope*ref, char*buf)
|
||||||
strcat(buf, ".");
|
strcat(buf, ".");
|
||||||
}
|
}
|
||||||
|
|
||||||
strcat(buf, ref->name);
|
strcat(buf, ref->scope_name());
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char* scope_get_type(int code)
|
static const char* scope_get_type(int code)
|
||||||
|
|
@ -254,11 +223,11 @@ static char* scope_get_str(int code, vpiHandle obj)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case vpiName:
|
case vpiName:
|
||||||
p = ref->name;
|
p = ref->scope_name();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case vpiDefName:
|
case vpiDefName:
|
||||||
p = ref->tname;
|
p = ref->scope_def_name();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case vpiType:
|
case vpiType:
|
||||||
|
|
@ -361,8 +330,41 @@ static vpiHandle module_iter(int code, vpiHandle obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
__vpiScope::__vpiScope(const char*nam, const char*tnam)
|
||||||
|
: is_automatic_(false)
|
||||||
|
{
|
||||||
|
name_ = vpip_name_string(nam);
|
||||||
|
tname_ = vpip_name_string(tnam? tnam : "");
|
||||||
|
}
|
||||||
|
|
||||||
int __vpiScope::vpi_get(int code)
|
int __vpiScope::vpi_get(int code)
|
||||||
{ return scope_get(code, this); }
|
{
|
||||||
|
switch (code) {
|
||||||
|
case vpiCellInstance:
|
||||||
|
return is_cell? 1 : 0;
|
||||||
|
|
||||||
|
case vpiDefLineNo:
|
||||||
|
return def_lineno;
|
||||||
|
|
||||||
|
case vpiLineNo:
|
||||||
|
return lineno;
|
||||||
|
|
||||||
|
case vpiTimeUnit:
|
||||||
|
return time_units;
|
||||||
|
|
||||||
|
case vpiTimePrecision:
|
||||||
|
return time_precision;
|
||||||
|
|
||||||
|
case vpiTopModule:
|
||||||
|
return 0x0 == scope;
|
||||||
|
|
||||||
|
case vpiAutomatic:
|
||||||
|
return is_automatic_? 1 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return vpiUndefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
char*__vpiScope::vpi_get_str(int code)
|
char*__vpiScope::vpi_get_str(int code)
|
||||||
{ return scope_get_str(code, this); }
|
{ return scope_get_str(code, this); }
|
||||||
|
|
@ -374,43 +376,80 @@ vpiHandle __vpiScope::vpi_iterate(int code)
|
||||||
{ return module_iter(code, this); }
|
{ return module_iter(code, this); }
|
||||||
|
|
||||||
|
|
||||||
struct vpiScopeModule : public __vpiScope {
|
class vpiScopeModule : public __vpiScope {
|
||||||
inline vpiScopeModule() { }
|
public:
|
||||||
|
inline vpiScopeModule(const char*nam, const char*tnam)
|
||||||
|
: __vpiScope(nam,tnam) { }
|
||||||
int get_type_code(void) const { return vpiModule; }
|
int get_type_code(void) const { return vpiModule; }
|
||||||
};
|
};
|
||||||
|
|
||||||
struct vpiScopePackage : public __vpiScope {
|
struct vpiScopePackage : public __vpiScope {
|
||||||
inline vpiScopePackage() { }
|
inline vpiScopePackage(const char*nam, const char*tnam)
|
||||||
|
: __vpiScope(nam,tnam) { }
|
||||||
int get_type_code(void) const { return vpiPackage; }
|
int get_type_code(void) const { return vpiPackage; }
|
||||||
};
|
};
|
||||||
|
|
||||||
struct vpiScopeTask : public __vpiScope {
|
struct vpiScopeTask : public __vpiScope {
|
||||||
inline vpiScopeTask() { }
|
inline vpiScopeTask(const char*nam, const char*tnam)
|
||||||
|
: __vpiScope(nam,tnam) { }
|
||||||
int get_type_code(void) const { return vpiTask; }
|
int get_type_code(void) const { return vpiTask; }
|
||||||
};
|
};
|
||||||
|
|
||||||
struct vpiScopeFunction : public __vpiScope {
|
struct vpiScopeTaskAuto : public __vpiScope {
|
||||||
inline vpiScopeFunction() { }
|
inline vpiScopeTaskAuto(const char*nam, const char*tnam)
|
||||||
|
: __vpiScope(nam,tnam) { is_automatic_=true; }
|
||||||
|
int get_type_code(void) const { return vpiTask; }
|
||||||
|
};
|
||||||
|
|
||||||
|
class vpiScopeFunction : public __vpiScope {
|
||||||
|
public:
|
||||||
|
inline vpiScopeFunction(const char*nam, const char*tnam)
|
||||||
|
: __vpiScope(nam,tnam) { }
|
||||||
|
int get_type_code(void) const { return vpiFunction; }
|
||||||
|
};
|
||||||
|
|
||||||
|
class vpiScopeFunctionAuto : public __vpiScope {
|
||||||
|
public:
|
||||||
|
inline vpiScopeFunctionAuto(const char*nam, const char*tnam)
|
||||||
|
: __vpiScope(nam,tnam) { is_automatic_=true; }
|
||||||
int get_type_code(void) const { return vpiFunction; }
|
int get_type_code(void) const { return vpiFunction; }
|
||||||
};
|
};
|
||||||
|
|
||||||
struct vpiScopeBegin : public __vpiScope {
|
struct vpiScopeBegin : public __vpiScope {
|
||||||
inline vpiScopeBegin() { }
|
inline vpiScopeBegin(const char*nam, const char*tnam)
|
||||||
|
: __vpiScope(nam,tnam) { }
|
||||||
|
int get_type_code(void) const { return vpiNamedBegin; }
|
||||||
|
};
|
||||||
|
|
||||||
|
class vpiScopeBeginAuto : public __vpiScope {
|
||||||
|
public:
|
||||||
|
inline vpiScopeBeginAuto(const char*nam, const char*tnam)
|
||||||
|
: __vpiScope(nam,tnam) { is_automatic_=true; }
|
||||||
int get_type_code(void) const { return vpiNamedBegin; }
|
int get_type_code(void) const { return vpiNamedBegin; }
|
||||||
};
|
};
|
||||||
|
|
||||||
struct vpiScopeGenerate : public __vpiScope {
|
struct vpiScopeGenerate : public __vpiScope {
|
||||||
inline vpiScopeGenerate() { }
|
inline vpiScopeGenerate(const char*nam, const char*tnam)
|
||||||
|
: __vpiScope(nam,tnam) { }
|
||||||
int get_type_code(void) const { return vpiGenScope; }
|
int get_type_code(void) const { return vpiGenScope; }
|
||||||
};
|
};
|
||||||
|
|
||||||
struct vpiScopeFork : public __vpiScope {
|
struct vpiScopeFork : public __vpiScope {
|
||||||
inline vpiScopeFork() { }
|
inline vpiScopeFork(const char*nam, const char*tnam)
|
||||||
|
: __vpiScope(nam,tnam) { }
|
||||||
|
int get_type_code(void) const { return vpiNamedFork; }
|
||||||
|
};
|
||||||
|
|
||||||
|
class vpiScopeForkAuto : public __vpiScope {
|
||||||
|
public:
|
||||||
|
inline vpiScopeForkAuto(const char*nam, const char*tnam)
|
||||||
|
: __vpiScope(nam,tnam) { is_automatic_=true; }
|
||||||
int get_type_code(void) const { return vpiNamedFork; }
|
int get_type_code(void) const { return vpiNamedFork; }
|
||||||
};
|
};
|
||||||
|
|
||||||
struct vpiScopeClass : public __vpiScope {
|
struct vpiScopeClass : public __vpiScope {
|
||||||
inline vpiScopeClass() { }
|
inline vpiScopeClass(const char*nam, const char*tnam)
|
||||||
|
: __vpiScope(nam,tnam) { }
|
||||||
int get_type_code(void) const { return vpiClassTypespec; }
|
int get_type_code(void) const { return vpiClassTypespec; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -449,50 +488,40 @@ compile_scope_decl(char*label, char*type, char*name, char*tname,
|
||||||
{
|
{
|
||||||
count_vpi_scopes += 1;
|
count_vpi_scopes += 1;
|
||||||
|
|
||||||
bool is_automatic = false;
|
|
||||||
|
|
||||||
struct __vpiScope*scope;
|
struct __vpiScope*scope;
|
||||||
if (strcmp(type,"module") == 0) {
|
if (strcmp(type,"module") == 0) {
|
||||||
scope = new vpiScopeModule;
|
scope = new vpiScopeModule(name, tname);
|
||||||
} else if (strcmp(type,"function") == 0) {
|
} else if (strcmp(type,"function") == 0) {
|
||||||
scope = new vpiScopeFunction;
|
scope = new vpiScopeFunction(name, tname);
|
||||||
} else if (strcmp(type,"autofunction") == 0) {
|
} else if (strcmp(type,"autofunction") == 0) {
|
||||||
scope = new vpiScopeFunction;
|
scope = new vpiScopeFunctionAuto(name, tname);
|
||||||
is_automatic = true;
|
|
||||||
} else if (strcmp(type,"task") == 0) {
|
} else if (strcmp(type,"task") == 0) {
|
||||||
scope = new vpiScopeTask;
|
scope = new vpiScopeTask(name, tname);
|
||||||
} else if (strcmp(type,"autotask") == 0) {
|
} else if (strcmp(type,"autotask") == 0) {
|
||||||
scope = new vpiScopeTask;
|
scope = new vpiScopeTaskAuto(name, tname);
|
||||||
is_automatic = true;
|
|
||||||
} else if (strcmp(type,"fork") == 0) {
|
} else if (strcmp(type,"fork") == 0) {
|
||||||
scope = new vpiScopeFork;
|
scope = new vpiScopeFork(name, tname);
|
||||||
} else if (strcmp(type,"autofork") == 0) {
|
} else if (strcmp(type,"autofork") == 0) {
|
||||||
scope = new vpiScopeFork;
|
scope = new vpiScopeForkAuto(name, tname);
|
||||||
is_automatic = true;
|
|
||||||
} else if (strcmp(type,"begin") == 0) {
|
} else if (strcmp(type,"begin") == 0) {
|
||||||
scope = new vpiScopeBegin;
|
scope = new vpiScopeBegin(name, tname);
|
||||||
} else if (strcmp(type,"autobegin") == 0) {
|
} else if (strcmp(type,"autobegin") == 0) {
|
||||||
scope = new vpiScopeBegin;
|
scope = new vpiScopeBeginAuto(name, tname);
|
||||||
is_automatic = true;
|
|
||||||
} else if (strcmp(type,"generate") == 0) {
|
} else if (strcmp(type,"generate") == 0) {
|
||||||
scope = new vpiScopeGenerate;
|
scope = new vpiScopeGenerate(name, tname);
|
||||||
} else if (strcmp(type,"package") == 0) {
|
} else if (strcmp(type,"package") == 0) {
|
||||||
scope = new vpiScopePackage;
|
scope = new vpiScopePackage(name, tname);
|
||||||
} else if (strcmp(type,"class") == 0) {
|
} else if (strcmp(type,"class") == 0) {
|
||||||
scope = new vpiScopeClass;
|
scope = new vpiScopeClass(name, tname);
|
||||||
} else {
|
} else {
|
||||||
scope = new vpiScopeModule;
|
scope = new vpiScopeModule(name, tname);
|
||||||
assert(0);
|
assert(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
scope->name = vpip_name_string(name);
|
|
||||||
if (tname) scope->tname = vpip_name_string(tname);
|
|
||||||
else scope->tname = vpip_name_string("");
|
|
||||||
scope->file_idx = (unsigned) file_idx;
|
scope->file_idx = (unsigned) file_idx;
|
||||||
scope->lineno = (unsigned) lineno;
|
scope->lineno = (unsigned) lineno;
|
||||||
scope->def_file_idx = (unsigned) def_file_idx;
|
scope->def_file_idx = (unsigned) def_file_idx;
|
||||||
scope->def_lineno = (unsigned) def_lineno;
|
scope->def_lineno = (unsigned) def_lineno;
|
||||||
scope->is_automatic = is_automatic;
|
|
||||||
scope->intern = 0;
|
scope->intern = 0;
|
||||||
scope->nintern = 0;
|
scope->nintern = 0;
|
||||||
scope->item = 0;
|
scope->item = 0;
|
||||||
|
|
@ -577,7 +606,7 @@ struct __vpiScope* vpip_peek_context_scope(void)
|
||||||
/* A context is allocated for each automatic task or function.
|
/* A context is allocated for each automatic task or function.
|
||||||
Storage for nested scopes (named blocks) is allocated in
|
Storage for nested scopes (named blocks) is allocated in
|
||||||
the parent context. */
|
the parent context. */
|
||||||
while (scope->scope && scope->scope->is_automatic)
|
while (scope->scope && scope->scope->is_automatic())
|
||||||
scope = scope->scope;
|
scope = scope->scope;
|
||||||
|
|
||||||
return scope;
|
return scope;
|
||||||
|
|
@ -587,7 +616,7 @@ unsigned vpip_add_item_to_context(automatic_hooks_s*item,
|
||||||
struct __vpiScope*scope)
|
struct __vpiScope*scope)
|
||||||
{
|
{
|
||||||
assert(scope);
|
assert(scope);
|
||||||
assert(scope->is_automatic);
|
assert(scope->is_automatic());
|
||||||
|
|
||||||
unsigned idx = scope->nitem++;
|
unsigned idx = scope->nitem++;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -571,7 +571,7 @@ static int signal_get(int code, vpiHandle ref)
|
||||||
return (rfp->msb.get_value() != rfp->lsb.get_value());
|
return (rfp->msb.get_value() != rfp->lsb.get_value());
|
||||||
|
|
||||||
case vpiAutomatic:
|
case vpiAutomatic:
|
||||||
return (int) vpip_scope(rfp)->is_automatic;
|
return vpip_scope(rfp)->is_automatic() ? 1 : 0;
|
||||||
|
|
||||||
#ifdef BR916_STOPGAP_FIX
|
#ifdef BR916_STOPGAP_FIX
|
||||||
case _vpiFromThr:
|
case _vpiFromThr:
|
||||||
|
|
@ -760,7 +760,7 @@ static void signal_get_value(vpiHandle ref, s_vpi_value*vp)
|
||||||
"value type %d not implemented."
|
"value type %d not implemented."
|
||||||
" Signal is %s in scope %s\n",
|
" Signal is %s in scope %s\n",
|
||||||
(int)vp->format, vpi_get_str(vpiName, ref),
|
(int)vp->format, vpi_get_str(vpiName, ref),
|
||||||
vpip_scope(rfp)->name);
|
vpip_scope(rfp)->scope_name());
|
||||||
assert(0);
|
assert(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -425,7 +425,7 @@ static void multiply_array_imm(unsigned long*res, unsigned long*val,
|
||||||
*/
|
*/
|
||||||
static vvp_context_t vthread_alloc_context(struct __vpiScope*scope)
|
static vvp_context_t vthread_alloc_context(struct __vpiScope*scope)
|
||||||
{
|
{
|
||||||
assert(scope->is_automatic);
|
assert(scope->is_automatic());
|
||||||
|
|
||||||
vvp_context_t context = scope->free_contexts;
|
vvp_context_t context = scope->free_contexts;
|
||||||
if (context) {
|
if (context) {
|
||||||
|
|
@ -453,7 +453,7 @@ static vvp_context_t vthread_alloc_context(struct __vpiScope*scope)
|
||||||
*/
|
*/
|
||||||
static void vthread_free_context(vvp_context_t context, struct __vpiScope*scope)
|
static void vthread_free_context(vvp_context_t context, struct __vpiScope*scope)
|
||||||
{
|
{
|
||||||
assert(scope->is_automatic);
|
assert(scope->is_automatic());
|
||||||
assert(context);
|
assert(context);
|
||||||
|
|
||||||
if (context == scope->live_contexts) {
|
if (context == scope->live_contexts) {
|
||||||
|
|
@ -2887,7 +2887,7 @@ bool of_FORK(vthread_t thr, vvp_code_t cp)
|
||||||
{
|
{
|
||||||
vthread_t child = vthread_new(cp->cptr2, cp->scope);
|
vthread_t child = vthread_new(cp->cptr2, cp->scope);
|
||||||
|
|
||||||
if (cp->scope->is_automatic) {
|
if (cp->scope->is_automatic()) {
|
||||||
/* The context allocated for this child is the top entry
|
/* The context allocated for this child is the top entry
|
||||||
on the write context stack. */
|
on the write context stack. */
|
||||||
child->wt_context = thr->wt_context;
|
child->wt_context = thr->wt_context;
|
||||||
|
|
@ -5802,7 +5802,7 @@ bool of_EXEC_UFUNC(vthread_t thr, vvp_code_t cp)
|
||||||
|
|
||||||
/* If an automatic function, allocate a context for this call. */
|
/* If an automatic function, allocate a context for this call. */
|
||||||
vvp_context_t child_context = 0;
|
vvp_context_t child_context = 0;
|
||||||
if (child_scope->is_automatic) {
|
if (child_scope->is_automatic()) {
|
||||||
child_context = vthread_alloc_context(child_scope);
|
child_context = vthread_alloc_context(child_scope);
|
||||||
thr->wt_context = child_context;
|
thr->wt_context = child_context;
|
||||||
thr->rd_context = child_context;
|
thr->rd_context = child_context;
|
||||||
|
|
@ -5845,7 +5845,7 @@ bool of_REAP_UFUNC(vthread_t thr, vvp_code_t cp)
|
||||||
cp->ufunc_core_ptr->finish_thread();
|
cp->ufunc_core_ptr->finish_thread();
|
||||||
|
|
||||||
/* If an automatic function, free the context for this call. */
|
/* If an automatic function, free the context for this call. */
|
||||||
if (child_scope->is_automatic) {
|
if (child_scope->is_automatic()) {
|
||||||
vthread_free_context(thr->rd_context, child_scope);
|
vthread_free_context(thr->rd_context, child_scope);
|
||||||
thr->wt_context = 0;
|
thr->wt_context = 0;
|
||||||
thr->rd_context = 0;
|
thr->rd_context = 0;
|
||||||
|
|
|
||||||
16
vvp/words.cc
16
vvp/words.cc
|
|
@ -37,7 +37,7 @@ static void __compile_var_real(char*label, char*name,
|
||||||
{
|
{
|
||||||
vvp_net_t*net = new vvp_net_t;
|
vvp_net_t*net = new vvp_net_t;
|
||||||
|
|
||||||
if (vpip_peek_current_scope()->is_automatic) {
|
if (vpip_peek_current_scope()->is_automatic()) {
|
||||||
vvp_fun_signal_real_aa*tmp = new vvp_fun_signal_real_aa;
|
vvp_fun_signal_real_aa*tmp = new vvp_fun_signal_real_aa;
|
||||||
net->fil = tmp;
|
net->fil = tmp;
|
||||||
net->fun = tmp;
|
net->fun = tmp;
|
||||||
|
|
@ -54,7 +54,7 @@ static void __compile_var_real(char*label, char*name,
|
||||||
if (name) {
|
if (name) {
|
||||||
assert(!array);
|
assert(!array);
|
||||||
vpip_attach_to_current_scope(obj);
|
vpip_attach_to_current_scope(obj);
|
||||||
if (!vpip_peek_current_scope()->is_automatic)
|
if (!vpip_peek_current_scope()->is_automatic())
|
||||||
schedule_init_vector(vvp_net_ptr_t(net,0), 0.0);
|
schedule_init_vector(vvp_net_ptr_t(net,0), 0.0);
|
||||||
}
|
}
|
||||||
if (array) {
|
if (array) {
|
||||||
|
|
@ -82,7 +82,7 @@ void compile_var_string(char*label, char*name)
|
||||||
{
|
{
|
||||||
vvp_net_t*net = new vvp_net_t;
|
vvp_net_t*net = new vvp_net_t;
|
||||||
|
|
||||||
if (vpip_peek_current_scope()->is_automatic) {
|
if (vpip_peek_current_scope()->is_automatic()) {
|
||||||
vvp_fun_signal_string_aa*tmp = new vvp_fun_signal_string_aa;
|
vvp_fun_signal_string_aa*tmp = new vvp_fun_signal_string_aa;
|
||||||
net->fil = tmp;
|
net->fil = tmp;
|
||||||
net->fun = tmp;
|
net->fun = tmp;
|
||||||
|
|
@ -105,7 +105,7 @@ void compile_var_darray(char*label, char*name)
|
||||||
{
|
{
|
||||||
vvp_net_t*net = new vvp_net_t;
|
vvp_net_t*net = new vvp_net_t;
|
||||||
|
|
||||||
if (vpip_peek_current_scope()->is_automatic) {
|
if (vpip_peek_current_scope()->is_automatic()) {
|
||||||
vvp_fun_signal_object_aa*tmp = new vvp_fun_signal_object_aa;
|
vvp_fun_signal_object_aa*tmp = new vvp_fun_signal_object_aa;
|
||||||
net->fil = tmp;
|
net->fil = tmp;
|
||||||
net->fun = tmp;
|
net->fun = tmp;
|
||||||
|
|
@ -128,7 +128,7 @@ void compile_var_queue(char*label, char*name)
|
||||||
{
|
{
|
||||||
vvp_net_t*net = new vvp_net_t;
|
vvp_net_t*net = new vvp_net_t;
|
||||||
|
|
||||||
if (vpip_peek_current_scope()->is_automatic) {
|
if (vpip_peek_current_scope()->is_automatic()) {
|
||||||
vvp_fun_signal_object_aa*tmp = new vvp_fun_signal_object_aa;
|
vvp_fun_signal_object_aa*tmp = new vvp_fun_signal_object_aa;
|
||||||
net->fil = tmp;
|
net->fil = tmp;
|
||||||
net->fun = tmp;
|
net->fun = tmp;
|
||||||
|
|
@ -151,7 +151,7 @@ void compile_var_cobject(char*label, char*name)
|
||||||
{
|
{
|
||||||
vvp_net_t*net = new vvp_net_t;
|
vvp_net_t*net = new vvp_net_t;
|
||||||
|
|
||||||
if (vpip_peek_current_scope()->is_automatic) {
|
if (vpip_peek_current_scope()->is_automatic()) {
|
||||||
vvp_fun_signal_object_aa*tmp = new vvp_fun_signal_object_aa;
|
vvp_fun_signal_object_aa*tmp = new vvp_fun_signal_object_aa;
|
||||||
net->fil = tmp;
|
net->fil = tmp;
|
||||||
net->fun = tmp;
|
net->fun = tmp;
|
||||||
|
|
@ -182,7 +182,7 @@ void compile_variable(char*label, char*name,
|
||||||
|
|
||||||
vvp_net_t*net = new vvp_net_t;
|
vvp_net_t*net = new vvp_net_t;
|
||||||
|
|
||||||
if (vpip_peek_current_scope()->is_automatic) {
|
if (vpip_peek_current_scope()->is_automatic()) {
|
||||||
vvp_fun_signal4_aa*tmp = new vvp_fun_signal4_aa(wid);
|
vvp_fun_signal4_aa*tmp = new vvp_fun_signal4_aa(wid);
|
||||||
net->fil = tmp;
|
net->fil = tmp;
|
||||||
net->fun = tmp;
|
net->fun = tmp;
|
||||||
|
|
@ -221,7 +221,7 @@ void compile_variable(char*label, char*name,
|
||||||
// scope as a signal.
|
// scope as a signal.
|
||||||
if (name) {
|
if (name) {
|
||||||
if (obj) vpip_attach_to_current_scope(obj);
|
if (obj) vpip_attach_to_current_scope(obj);
|
||||||
if (!vpip_peek_current_scope()->is_automatic) {
|
if (!vpip_peek_current_scope()->is_automatic()) {
|
||||||
vvp_vector4_t tmp;
|
vvp_vector4_t tmp;
|
||||||
vfil->vec4_value(tmp);
|
vfil->vec4_value(tmp);
|
||||||
schedule_init_vector(vvp_net_ptr_t(net,0), tmp);
|
schedule_init_vector(vvp_net_ptr_t(net,0), tmp);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue