diff --git a/driver-vpi/main.c b/driver-vpi/main.c index 1785fbf78..b66f0c6ff 100644 --- a/driver-vpi/main.c +++ b/driver-vpi/main.c @@ -154,12 +154,15 @@ static int startsWith (char *prefix, char *str) static void appendn (char **ptr, char *app, int count) { - *ptr = (char *) realloc(*ptr,strlen(*ptr)+(count?count:strlen(app))+1); + char *nptr = (char *) realloc(*ptr, strlen(*ptr) + + (count?count:strlen(app)) + 1); - if (*ptr == NULL) { + if (nptr == NULL) { fprintf(stderr,"error: out of memory\n"); + free(*ptr); myExit(4); } + *ptr = nptr; if (count) strncat(*ptr,app,count); @@ -187,12 +190,14 @@ static void appendBackSlash(char **str) static void assignn (char **ptr, char *str, int count) { - *ptr = (char *) realloc(*ptr,(count?count:strlen(str))+1); + char *nptr = (char *) realloc(*ptr, (count?count:strlen(str)) + 1); - if (*ptr == NULL) { + if (nptr == NULL) { fprintf(stderr,"error: out of memory\n"); + free(*ptr); myExit(4); } + *ptr = nptr; if (count) { strncpy(*ptr,str,count); diff --git a/net_modulo.cc b/net_modulo.cc index 13cd262d7..7a5167824 100644 --- a/net_modulo.cc +++ b/net_modulo.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2008 Stephen Williams (steve@icarus.com) + * Copyright (c) 2000-2010 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 @@ -40,6 +40,7 @@ NetModulo::NetModulo(NetScope*s, perm_string n, unsigned wr, pin(0).set_dir(Link::OUTPUT); // Result pin(1).set_dir(Link::INPUT); // DataA pin(2).set_dir(Link::INPUT); // DataB + signed_flag_ = false; } NetModulo::~NetModulo() diff --git a/net_scope.cc b/net_scope.cc index ae84b6e39..5bae6462b 100644 --- a/net_scope.cc +++ b/net_scope.cc @@ -69,6 +69,9 @@ NetScope::NetScope(NetScope*up, const hname_t&n, NetScope::TYPE t) default: /* BEGIN_END and FORK_JOIN, do nothing */ break; } + lineno_ = 0; + def_lineno_ = 0; + genvar_tmp_val = 0; } NetScope::~NetScope() diff --git a/net_tran.cc b/net_tran.cc index aa36329f2..43c643989 100644 --- a/net_tran.cc +++ b/net_tran.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008 Stephen Williams (steve@icarus.com) + * Copyright (c) 2008-2010 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 @@ -50,6 +50,9 @@ NetTran::NetTran(NetScope*scope__, perm_string n, ivl_switch_type_t tt) if (pin_count() == 3) { pin(2).set_dir(Link::INPUT); // Enable } + wid_ = 0; + part_ = 0; + off_ = 0; } NetTran::NetTran(NetScope*scope__, perm_string n, unsigned wid, unsigned part, unsigned off) diff --git a/net_udp.cc b/net_udp.cc index b5c6dd5de..a2d7aa3d0 100644 --- a/net_udp.cc +++ b/net_udp.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000 Stephen Williams (steve@icarus.com) + * Copyright (c) 2000-2010 Stephen Williams (steve@icarus.com) * Copyright (c) 2001 Stephan Boettcher * * This source code is free software; you can redistribute it @@ -20,7 +20,6 @@ # include "config.h" # include "compiler.h" - # include "netlist.h" NetUDP::NetUDP(NetScope*s, perm_string n, unsigned pins, PUdp *u) @@ -30,56 +29,53 @@ NetUDP::NetUDP(NetScope*s, perm_string n, unsigned pins, PUdp *u) for (unsigned idx = 1 ; idx < pins ; idx += 1) { pin(idx).set_dir(Link::INPUT); } + table_idx = udp->tinput.count()-1; } bool NetUDP::first(string&inp, char&out) const { - table_idx = (unsigned) -1; - return next(inp, out); + table_idx = (unsigned) -1; + return next(inp, out); } bool NetUDP::next(string&inp, char&out) const { - table_idx++; + table_idx++; - if (table_idx >= udp->tinput.count()) - return false; + if (table_idx >= udp->tinput.count()) return false; - if (is_sequential()) - { - inp = string("") + udp->tcurrent[table_idx] + udp->tinput[table_idx]; - assert(inp.length() == pin_count()); - } - else - { - inp = udp->tinput[table_idx]; - assert(inp.length() == (pin_count()-1)); - } + if (is_sequential()) { + inp = string("") + udp->tcurrent[table_idx] + + udp->tinput[table_idx]; + assert(inp.length() == pin_count()); + } else { + inp = udp->tinput[table_idx]; + assert(inp.length() == (pin_count()-1)); + } - out = udp->toutput[table_idx]; - assert( (out == '0') - || (out == '1') - || (out == 'x') - || (is_sequential() && (out == '-'))); + out = udp->toutput[table_idx]; + assert((out == '0') || + (out == '1') || + (out == 'x') || + (is_sequential() && (out == '-'))); - return true; + return true; } char NetUDP::get_initial() const { - assert (is_sequential()); + assert (is_sequential()); - switch (udp->initial) - { - case verinum::V0: - return '0'; - case verinum::V1: - return '1'; - case verinum::Vx: - case verinum::Vz: + switch (udp->initial) { + case verinum::V0: + return '0'; + case verinum::V1: + return '1'; + case verinum::Vx: + case verinum::Vz: + return 'x'; + } + + assert(0); return 'x'; - } - - assert(0); - return 'x'; } diff --git a/synth.cc b/synth.cc index 25a963b61..2684f6c94 100644 --- a/synth.cc +++ b/synth.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999-2008 Stephen Williams (steve@icarus.com) + * Copyright (c) 1999-2010 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 @@ -113,6 +113,7 @@ int do_expr::event_wait(NetEvWait*stmt) class synth_f : public functor_t { public: + synth_f() { top_ = NULL; } void process(class Design*, class NetProcTop*); private: