Skip to content

Commit

Permalink
The cleanup of &A and &PV can nest and cleanup some VCD memory.
Browse files Browse the repository at this point in the history
When cleaning up the &A<> and &PV<> we need to check if the handle
argument is a nested call to another &A<> or &PV<> if it is then
we need to also delete that construct.

We also need to cleanup the vcd_info information list.
  • Loading branch information
caryr authored and steveicarus committed Feb 3, 2009
1 parent f89f3dc commit ec1ca85
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 1 deletion.
7 changes: 7 additions & 0 deletions vpi/sys_vcd.c
Expand Up @@ -245,6 +245,7 @@ static PLI_INT32 dumpvars_cb(p_cb_data cause)

static PLI_INT32 finish_cb(p_cb_data cause)
{
struct vcd_info *cur, *next;

if (finish_status != 0) return 0;

Expand All @@ -257,6 +258,12 @@ static PLI_INT32 finish_cb(p_cb_data cause)
}

fclose(dump_file);

for (cur = vcd_list ; cur ; cur = next) {
next = cur->next;
free(cur->ident);
free(cur);
}
vcd_names_delete(&vcd_tab);
vcd_names_delete(&vcd_var);
nexus_ident_delete();
Expand Down
15 changes: 15 additions & 0 deletions vvp/array.cc
Expand Up @@ -1556,6 +1556,21 @@ void memory_delete(vpiHandle item)
void A_delete(vpiHandle item)
{
struct __vpiArrayVthrA*obj = (struct __vpiArrayVthrA*) item;
if (obj->address_handle) {
switch (obj->address_handle->vpi_type->type_code) {
case vpiMemoryWord:
if (vpi_get(_vpiFromThr, obj->address_handle) == _vpi_at_A) {
A_delete(obj->address_handle);
}
break;
case vpiPartSelect:
assert(vpi_get(_vpiFromThr, obj->address_handle) ==
_vpi_at_PV);
PV_delete(obj->address_handle);
break;
}
}

free(obj);
}
#endif
13 changes: 13 additions & 0 deletions vvp/vpi_signal.cc
Expand Up @@ -1292,6 +1292,19 @@ void vpip_part_select_value_change(struct __vpiCallback*cbh, vpiHandle ref)
void PV_delete(vpiHandle item)
{
struct __vpiPV *obj = (__vpiPV *) item;
if (obj->sbase) {
switch (obj->sbase->vpi_type->type_code) {
case vpiMemoryWord:
if (vpi_get(_vpiFromThr, obj->sbase) == _vpi_at_A) {
A_delete(obj->sbase);
}
break;
case vpiPartSelect:
assert(vpi_get(_vpiFromThr, obj->sbase) == _vpi_at_PV);
PV_delete(obj->sbase);
break;
}
}
vvp_fun_signal_base*sig_fun;
sig_fun = (vvp_fun_signal_base*) obj->net->fun;
sig_fun->clear_all_callbacks();
Expand Down
2 changes: 1 addition & 1 deletion vvp/vpi_tasks.cc
Expand Up @@ -653,7 +653,7 @@ void vpi_call_delete(vpiHandle item)
thread_word_delete(obj->args[arg]);
break;
default:
assert(0);;
assert(0);
}
break;
case vpiMemoryWord:
Expand Down

0 comments on commit ec1ca85

Please sign in to comment.