Skip to content

Commit

Permalink
Merge branch 'master' of github.com:steveicarus/iverilog
Browse files Browse the repository at this point in the history
  • Loading branch information
steveicarus committed Dec 18, 2012
2 parents eaa315f + b098e31 commit a90e264
Show file tree
Hide file tree
Showing 13 changed files with 84 additions and 10 deletions.
4 changes: 2 additions & 2 deletions cppcheck.sup
@@ -1,3 +1,3 @@
// These are correct and are used to find the base (zero) pin.
thisSubtraction:netlist.h:4347
thisSubtraction:netlist.h:4356
thisSubtraction:netlist.h:4430
thisSubtraction:netlist.h:4439
2 changes: 1 addition & 1 deletion elab_net.cc
Expand Up @@ -553,7 +553,7 @@ NetNet* PEIdent::elaborate_lnet_common_(Design*des, NetScope*scope,
// itself.
ivl_assert(*this, member->packed_dims.size() <= 1);
ivl_assert(*this, path_tail.index.size() <= 1);
if (path_tail.index.size() > 0) {
if (! path_tail.index.empty()) {
long tmp_off;
unsigned long tmp_wid;
const index_component_t&tail_sel = path_tail.index.back();
Expand Down
3 changes: 1 addition & 2 deletions vvp/class_type.cc
Expand Up @@ -47,7 +47,7 @@ void compile_class_start(char*lab, char*nam, unsigned ntype)
assert(compile_class == 0);
compile_class = new class_type(nam, ntype);
compile_vpi_symbol(lab, compile_class);
delete[]lab;
free(lab);
delete[]nam;
}

Expand All @@ -64,4 +64,3 @@ void compile_class_done(void)
scope->classes[compile_class->class_name()] = compile_class;
compile_class = 0;
}

6 changes: 5 additions & 1 deletion vvp/codes.cc
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2001-2011 Stephen Williams (steve@icarus.com)
* Copyright (c) 2001-2012 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
Expand Down Expand Up @@ -117,6 +117,10 @@ void codespace_delete(void)
exec_ufunc_delete((cur+idx));
} else if ((cur+idx)->opcode == &of_FILE_LINE) {
delete((cur+idx)->handle);
} else if (((cur+idx)->opcode == &of_CONCATI_STR) ||
((cur+idx)->opcode == &of_NEW_DARRAY) ||
((cur+idx)->opcode == &of_PUSHI_STR)) {
delete [] ((cur+idx)->text);
}
if (count_opcodes == 0) break;
}
Expand Down
1 change: 1 addition & 0 deletions vvp/main.cc
Expand Up @@ -218,6 +218,7 @@ static void final_cleanup()
dec_str_delete();
modpath_delete();
vpi_handle_delete();
vpi_stack_delete();
udp_defns_delete();
island_delete();
signal_pool_delete();
Expand Down
12 changes: 12 additions & 0 deletions vvp/vpi_cobject.cc
Expand Up @@ -20,6 +20,10 @@

# include "compile.h"
# include "vpi_priv.h"
# include "config.h"
#ifdef CHECK_WITH_VALGRIND
# include "vvp_cleanup.h"
#endif

__vpiCobjectVar::__vpiCobjectVar(__vpiScope*sc, const char*na, vvp_net_t*ne)
: __vpiBaseVar(sc, na, ne)
Expand Down Expand Up @@ -48,3 +52,11 @@ vpiHandle vpip_make_cobject_var(const char*name, vvp_net_t*net)

return obj;
}

#ifdef CHECK_WITH_VALGRIND
void class_delete(vpiHandle item)
{
class __vpiCobjectVar*obj = dynamic_cast<__vpiCobjectVar*>(item);
delete obj;
}
#endif
8 changes: 8 additions & 0 deletions vvp/vpi_darray.cc
Expand Up @@ -76,3 +76,11 @@ vpiHandle vpip_make_darray_var(const char*name, vvp_net_t*net)

return obj;
}

#ifdef CHECK_WITH_VALGRIND
void darray_delete(vpiHandle item)
{
class __vpiDarrayVar*obj = dynamic_cast<__vpiDarrayVar*>(item);
delete obj;
}
#endif
9 changes: 5 additions & 4 deletions vvp/vpi_priv.h
Expand Up @@ -60,10 +60,11 @@ extern vpiHandle vpip_build_file_line(char*description,
#ifdef CHECK_WITH_VALGRIND
#define _vpiFromThr 0x1000001
# define _vpiNoThr 0
# define _vpiVThr 1
# define _vpiWord 2
# define _vpi_at_PV 3
# define _vpi_at_A 4
# define _vpiString 1
# define _vpiVThr 2
# define _vpiWord 3
# define _vpi_at_PV 4
# define _vpi_at_A 5
#endif


Expand Down
6 changes: 6 additions & 0 deletions vvp/vpi_scope.cc
Expand Up @@ -100,7 +100,13 @@ static void delete_sub_scopes(struct __vpiScope *scope)
port_delete((scope->intern)[idx]);
break;
case vpiStringVar:
string_delete((scope->intern)[idx]);
break;
case vpiClassVar:
class_delete((scope->intern)[idx]);
break;
case vpiRegArray:
darray_delete((scope->intern)[idx]);
break;
default:
fprintf(stderr, "Need support for type: %d\n",
Expand Down
8 changes: 8 additions & 0 deletions vvp/vpi_string.cc
Expand Up @@ -82,3 +82,11 @@ vpiHandle vpip_make_string_var(const char*name, vvp_net_t*net)

return obj;
}

#ifdef CHECK_WITH_VALGRIND
void string_delete(vpiHandle item)
{
class __vpiStringVar*obj = dynamic_cast<__vpiStringVar*>(item);
delete obj;
}
#endif
3 changes: 3 additions & 0 deletions vvp/vpi_tasks.cc
Expand Up @@ -843,6 +843,9 @@ void vpi_call_delete(vpiHandle item)
case _vpiNoThr:
constant_delete(obj->args[arg]);
break;
case _vpiString:
thread_string_delete(obj->args[arg]);
break;
case _vpiVThr:
thread_vthr_delete(obj->args[arg]);
break;
Expand Down
27 changes: 27 additions & 0 deletions vvp/vpi_vthr_vector.cc
Expand Up @@ -660,6 +660,10 @@ int __vpiVThrStrStack::vpi_get(int code)
switch (code) {
case vpiConstType:
return vpiStringConst;
#ifdef CHECK_WITH_VALGRIND
case _vpiFromThr:
return _vpiString;
#endif
default:
return 0;
}
Expand Down Expand Up @@ -698,3 +702,26 @@ vpiHandle vpip_make_vthr_str_stack(unsigned depth)
class __vpiVThrStrStack*obj = new __vpiVThrStrStack(depth);
return obj;
}

#ifdef CHECK_WITH_VALGRIND
static map<vpiHandle, bool> stack_map;

void thread_string_delete(vpiHandle item)
{
stack_map[item] = false;
}

static void thread_string_delete_real(vpiHandle item)
{
class __vpiVThrStrStack*obj = dynamic_cast<__vpiVThrStrStack*>(item);
delete obj;
}

void vpi_stack_delete()
{
map<vpiHandle, bool>::iterator iter;
for (iter = stack_map.begin(); iter != stack_map.end(); ++ iter ) {
thread_string_delete_real(iter->first);
}
}
#endif
5 changes: 5 additions & 0 deletions vvp/vvp_cleanup.h
Expand Up @@ -36,19 +36,24 @@ extern void root_table_delete(void);
extern void signal_pool_delete(void);
extern void udp_defns_delete(void);
extern void vpi_handle_delete(void);
extern void vpi_stack_delete(void);
extern void vvp_net_pool_delete(void);
extern void ufunc_pool_delete(void);

extern void A_delete(class __vpiHandle *item);
extern void PV_delete(class __vpiHandle *item);
extern void class_delete(class __vpiHandle *item);
extern void constant_delete(class __vpiHandle *item);
extern void contexts_delete(struct __vpiScope *scope);
extern void darray_delete(class __vpiHandle *item);
extern void enum_delete(class __vpiHandle *item);
extern void memory_delete(class __vpiHandle *item);
extern void named_event_delete(class __vpiHandle *item);
extern void parameter_delete(class __vpiHandle *item);
extern void signal_delete(class __vpiHandle *item);
extern void real_delete(class __vpiHandle *item);
extern void string_delete(class __vpiHandle *item);
extern void thread_string_delete(class __vpiHandle *item);
extern void thread_vthr_delete(class __vpiHandle *item);
extern void thread_word_delete(class __vpiHandle *item);
extern void vpi_call_delete(class __vpiHandle *item);
Expand Down

0 comments on commit a90e264

Please sign in to comment.