diff --git a/HName.h b/HName.h index e78b7bb3f..2409a356a 100644 --- a/HName.h +++ b/HName.h @@ -1,7 +1,7 @@ #ifndef __HName_H #define __HName_H /* - * Copyright (c) 2001-2008 Stephen Williams (steve@icarus.com) + * Copyright (c) 2001-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 @@ -94,10 +94,10 @@ inline ostream& operator<< (ostream&out, const list&ll) { list::const_iterator cur = ll.begin(); out << *cur; - cur ++; + ++ cur; while (cur != ll.end()) { out << "." << *cur; - cur ++; + ++ cur; } return out; } diff --git a/Makefile.in b/Makefile.in index 32f87f1e8..e785c0f56 100644 --- a/Makefile.in +++ b/Makefile.in @@ -83,7 +83,8 @@ INCLUDE_PATH = -I. -I$(srcdir) endif CPPFLAGS = @DEFS@ $(INCLUDE_PATH) @CPPFLAGS@ -CXXFLAGS = @WARNING_FLAGS@ @CXXFLAGS@ +CFLAGS = @WARNING_FLAGS@ @CFLAGS@ +CXXFLAGS = @WARNING_FLAGS@ @WARNING_FLAGS_CXX@ @CXXFLAGS@ PICFLAGS = @PICFLAG@ LDFLAGS = @rdynamic@ @LDFLAGS@ @@ -157,12 +158,13 @@ endif rm -rf autom4te.cache cppcheck: $(O:.o=.cc) $(srcdir)/dosify.c $(srcdir)/version.c - cppcheck --enable=all -f $(INCLUDE_PATH) $^ + cppcheck --enable=all -f --suppressions $(srcdir)/cppcheck.sup \ + $(INCLUDE_PATH) $^ cppcheck-all: $(foreach dir,$(SUBDIRS),$(MAKE) -C $(dir) cppcheck && ) true $(foreach dir,$(NOTUSED),$(MAKE) -C $(dir) cppcheck && ) true - cppcheck + $(MAKE) cppcheck Makefile: $(srcdir)/Makefile.in config.status ./config.status --file=$@ @@ -210,7 +212,8 @@ iverilog-vpi: $(srcdir)/iverilog-vpi.sh Makefile -e 's;@SUFFIX@;$(suffix);' \ -e 's;@IVCC@;$(CC);' \ -e 's;@IVCXX@;$(CXX);' \ - -e 's;@IVCFLAGS@;$(CXXFLAGS);' \ + -e 's;@IVCFLAGS@;$(CFLAGS);' \ + -e 's;@IVCXXFLAGS@;$(CXXFLAGS);' \ -e 's;@INCLUDEDIR@;$(includedir);' \ -e 's;@LIBDIR@;@libdir@;' $< > $@ chmod +x $@ diff --git a/Module.cc b/Module.cc index 215dfb379..40871d059 100644 --- a/Module.cc +++ b/Module.cc @@ -93,8 +93,7 @@ unsigned Module::find_port(const char*name) const PGate* Module::get_gate(perm_string name) { for (list::iterator cur = gates_.begin() - ; cur != gates_.end() - ; cur ++ ) { + ; cur != gates_.end() ; ++ cur ) { if ((*cur)->get_name() == name) return *cur; diff --git a/PExpr.cc b/PExpr.cc index 35ec1b336..cefe23bc7 100644 --- a/PExpr.cc +++ b/PExpr.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998-2008,2010 Stephen Williams + * Copyright (c) 1998-2010 Stephen Williams * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -39,7 +39,7 @@ PExpr::~PExpr() { } -void PExpr::declare_implicit_nets(LexicalScope*scope, NetNet::Type type) +void PExpr::declare_implicit_nets(LexicalScope*, NetNet::Type) { } @@ -53,18 +53,19 @@ bool PExpr::is_the_same(const PExpr*that) const return typeid(this) == typeid(that); } -NetNet* PExpr::elaborate_lnet(Design*des, NetScope*) const +NetNet* PExpr::elaborate_lnet(Design*, NetScope*) const { - cerr << get_fileline() << ": error: expression not valid in assign l-value: " - << *this << endl; + cerr << get_fileline() << ": error: " + << "expression not valid in assign l-value: " + << *this << endl; return 0; } -NetNet* PExpr::elaborate_bi_net(Design*des, NetScope*) const +NetNet* PExpr::elaborate_bi_net(Design*, NetScope*) const { cerr << get_fileline() << ": error: " - << "expression not valid as argument to inout port: " - << *this << endl; + << "expression not valid as argument to inout port: " + << *this << endl; return 0; } diff --git a/PGate.h b/PGate.h index 6de2c3f58..e45f95ec3 100644 --- a/PGate.h +++ b/PGate.h @@ -241,7 +241,10 @@ class PGModule : public PGate { void elaborate_scope_mod_(Design*des, Module*mod, NetScope*sc) const; void elaborate_scope_mod_instances_(Design*des, Module*mod, NetScope*sc) const; bool elaborate_sig_mod_(Design*des, NetScope*scope, Module*mod) const; + // Not currently used. +#if 0 bool elaborate_sig_udp_(Design*des, NetScope*scope, PUdp*udp) const; +#endif NetNet*resize_net_to_port_(Design*des, NetScope*scope, NetNet*sig, unsigned port_wid, diff --git a/StringHeap.cc b/StringHeap.cc index a9ec03839..4ee081a07 100644 --- a/StringHeap.cc +++ b/StringHeap.cc @@ -18,10 +18,10 @@ */ # include "StringHeap.h" -# include "ivl_alloc.h" # include # include # include +# include "ivl_alloc.h" #ifdef CHECK_WITH_VALGRIND static char **string_pool = NULL; diff --git a/cadpli/cadpli.c b/cadpli/cadpli.c index 572d73681..4b9d21e95 100644 --- a/cadpli/cadpli.c +++ b/cadpli/cadpli.c @@ -17,7 +17,6 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ -# include "ivl_alloc.h" # include # include # include @@ -25,6 +24,7 @@ # include # include "config.h" # include "ivl_dlfcn.h" +# include "ivl_alloc.h" typedef void* (*funcvp)(void); diff --git a/configure.in b/configure.in index 5fd273e8e..edbcf90c9 100644 --- a/configure.in +++ b/configure.in @@ -69,9 +69,18 @@ AC_SUBST(DEPENDENCY_FLAG, [-xMMD]) AC_SUBST(WARNING_FLAGS, [""]) AC_SUBST(WARNING_FLAGS_CXX, [""]) else +# Check to see if -Wextra is supported. +iverilog_temp_cflags="$CFLAGS" +CFLAGS="-Wextra $CFLAGS" +AC_MSG_CHECKING(if gcc supports -Wextra) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], + [[iverilog_wextra_flag="-Wextra";] AC_MSG_RESULT(yes)], + [[iverilog_wextra_flag="-W";] AC_MSG_RESULT(no)]) +CFLAGS="$iverilog_temp_cflags" + AC_SUBST(DEPENDENCY_FLAG, [-MD]) AC_SUBST(WARNING_FLAGS, ["-Wall -Wshadow"]) -AC_SUBST(WARNING_FLAGS_CXX, ["-Wextra"]) +AC_SUBST(WARNING_FLAGS_CXX, ["$iverilog_wextra_flag"]) fi AC_LANG(C++) diff --git a/cppcheck.sup b/cppcheck.sup new file mode 100644 index 000000000..76827e0c2 --- /dev/null +++ b/cppcheck.sup @@ -0,0 +1,3 @@ +// These are correct and are used to find the base (zero) pin. +thisSubtraction:netlist.h:4119 +thisSubtraction:netlist.h:4128 diff --git a/cprop.cc b/cprop.cc index fd5751e6b..a4306766b 100644 --- a/cprop.cc +++ b/cprop.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998-2009 Stephen Williams (steve@icarus.com) + * Copyright (c) 1998-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 @@ -48,11 +48,11 @@ struct cprop_functor : public functor_t { virtual void lpm_mux(Design*des, NetMux*obj); }; -void cprop_functor::signal(Design*des, NetNet*obj) +void cprop_functor::signal(Design*, NetNet*) { } -void cprop_functor::lpm_add_sub(Design*des, NetAddSub*obj) +void cprop_functor::lpm_add_sub(Design*, NetAddSub*) { } @@ -70,11 +70,11 @@ void cprop_functor::lpm_compare(Design*des, NetCompare*obj) } } -void cprop_functor::lpm_compare_eq_(Design*des, NetCompare*obj) +void cprop_functor::lpm_compare_eq_(Design*, NetCompare*) { } -void cprop_functor::lpm_ff(Design*des, NetFF*obj) +void cprop_functor::lpm_ff(Design*, NetFF*obj) { // Look for and count unlinked FF outputs. Note that if the // Data and Q pins are connected together, they can be removed @@ -91,7 +91,7 @@ void cprop_functor::lpm_ff(Design*des, NetFF*obj) } } -void cprop_functor::lpm_logic(Design*des, NetLogic*obj) +void cprop_functor::lpm_logic(Design*, NetLogic*) { } @@ -167,7 +167,7 @@ struct nexus_info_s { unsigned out; }; -void cprop_dc_functor::lpm_const(Design*des, NetConst*obj) +void cprop_dc_functor::lpm_const(Design*, NetConst*obj) { // 'bz constant values drive high impedance to whatever is // connected to it. In other words, it is a noop. But that is diff --git a/design_dump.cc b/design_dump.cc index c15428db4..298f92831 100644 --- a/design_dump.cc +++ b/design_dump.cc @@ -1115,7 +1115,7 @@ void NetScope::dump(ostream&o) const { map::const_iterator pp; for (pp = parameters.begin() - ; pp != parameters.end() ; pp ++) { + ; pp != parameters.end() ; ++ pp ) { o << " parameter "; o << pp->second.type << " "; @@ -1165,7 +1165,7 @@ void NetScope::dump(ostream&o) const } for (pp = localparams.begin() - ; pp != localparams.end() ; pp ++) { + ; pp != localparams.end() ; ++ pp ) { o << " localparam " << (*pp).first << " = " << *(*pp).second.expr << ";" << endl; } @@ -1175,7 +1175,7 @@ void NetScope::dump(ostream&o) const { list >::const_iterator pp; for (pp = defparams.begin() - ; pp != defparams.end() ; pp ++ ) { + ; pp != defparams.end() ; ++ pp ) { o << " defparam " << (*pp).first << " = " << *(*pp).second << ";" << endl; } @@ -1184,7 +1184,7 @@ void NetScope::dump(ostream&o) const { list,NetExpr*> >::const_iterator pp; for (pp = defparams_later.begin() - ; pp != defparams_later.end() ; pp ++ ) { + ; pp != defparams_later.end() ; ++ pp ) { o << " defparam(later) " << pp->first << " = " << *(pp->second) << ";" << endl; } @@ -1223,7 +1223,7 @@ void NetScope::dump(ostream&o) const // Dump specparams typedef map::const_iterator specparam_it_t; for (specparam_it_t cur = specparams.begin() - ; cur != specparams.end() ; cur ++ ) { + ; cur != specparams.end() ; ++ cur ) { o << " specparam " << (*cur).first << " = "; spec_val_t value = (*cur).second; @@ -1260,7 +1260,7 @@ void NetScope::dump(ostream&o) const /* Dump any sub-scopes. */ for (map::const_iterator cur = children_.begin() - ; cur != children_.end() ; cur ++) + ; cur != children_.end() ; ++ cur ) cur->second->dump(o); } @@ -1345,6 +1345,9 @@ void NetEBinary::dump(ostream&o) const case 'a': o << "&&"; break; + case 'A': + o << "~&"; + break; case 'E': o << "==="; break; @@ -1530,12 +1533,18 @@ void NetEUFunc::dump(ostream&o) const void NetEUnary::dump(ostream&o) const { switch (op_) { + case 'A': + o << "~&"; + break; case 'm': o << "abs"; break; case 'N': o << "~|"; break; + case 'X': + o << "~^"; + break; default: o << op_; break; @@ -1550,7 +1559,7 @@ void Design::dump(ostream&o) const o << "DESIGN TIME PRECISION: 10e" << get_precision() << endl; o << "SCOPES:" << endl; for (list::const_iterator scope = root_scopes_.begin(); - scope != root_scopes_.end(); scope++) + scope != root_scopes_.end(); ++ scope ) (*scope)->dump(o); o << "ELABORATED NODES:" << endl; diff --git a/driver/main.c b/driver/main.c index 898c21e91..ebee88961 100644 --- a/driver/main.c +++ b/driver/main.c @@ -50,7 +50,6 @@ const char HELP[] = #define MAXSIZE 4096 -#include "ivl_alloc.h" #include #include #include @@ -64,11 +63,13 @@ const char HELP[] = #endif #ifdef __MINGW32__ -#include +# include +# include #ifdef HAVE_LIBIBERTY_H -#include +# include #endif #endif +#include #if HAVE_GETOPT_H #include @@ -94,6 +95,7 @@ extern const char*optarg; # include "globals.h" #include "cfparse_misc.h" /* cfparse() */ +#include "ivl_alloc.h" #ifdef __MINGW32__ const char sep = '\\'; @@ -211,8 +213,6 @@ char *get_cmd_file() } #ifdef __MINGW32__ -# include -# include static FILE*fopen_safe(const char*path) { FILE*file = 0; @@ -225,7 +225,6 @@ static FILE*fopen_safe(const char*path) return file; } #else -# include static FILE*fopen_safe(const char*path) { FILE*file = 0; diff --git a/driver/substit.c b/driver/substit.c index e90c9f899..3aa0fc420 100644 --- a/driver/substit.c +++ b/driver/substit.c @@ -17,10 +17,10 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ -# include "ivl_alloc.h" # include # include # include +# include "ivl_alloc.h" char* substitutions(const char*str) diff --git a/elab_expr.cc b/elab_expr.cc index ff9055960..128bf6ba6 100644 --- a/elab_expr.cc +++ b/elab_expr.cc @@ -129,8 +129,8 @@ NetExpr* elaborate_rval_expr(Design*des, NetScope*scope, * The default behavior for the test_width method is to just return the * minimum width that is passed in. */ -unsigned PExpr::test_width(Design*des, NetScope*scope, - unsigned min, unsigned lval, +unsigned PExpr::test_width(Design*, NetScope*, + unsigned min, unsigned, ivl_variable_type_t&, bool&) { if (debug_elaborate) { @@ -228,9 +228,12 @@ unsigned PEBinary::test_width(Design*des, NetScope*scope, break; } - if (type_is_vectorable(expr_type_)) + if (type_is_vectorable(expr_type_)) { + // We don't use (need?) lval so make sure the minimum width + // is greater than or equal to the the L-value width. + assert(min >= lval); expr_width_ = min; - else + } else expr_width_ = 1; expr_type__ = expr_type_; @@ -449,7 +452,7 @@ NetExpr* PEBinary::elaborate_expr_base_bits_(Design*des, NetExpr* PEBinary::elaborate_expr_base_div_(Design*des, NetExpr*lp, NetExpr*rp, - int expr_wid, bool is_pexpr) const + int expr_wid, bool) const { /* The % operator does not support real arguments in baseline Verilog. But we allow it in our extended @@ -739,7 +742,7 @@ NetExpr* PEBinary::elaborate_expr_base_rshift_(Design*des, return tmp; } -NetExpr* PEBinary::elaborate_expr_base_mult_(Design*des, +NetExpr* PEBinary::elaborate_expr_base_mult_(Design*, NetExpr*lp, NetExpr*rp, int expr_wid, bool is_pexpr) const { @@ -802,7 +805,7 @@ NetExpr* PEBinary::elaborate_expr_base_mult_(Design*des, return tmp; } -NetExpr* PEBinary::elaborate_expr_base_add_(Design*des, +NetExpr* PEBinary::elaborate_expr_base_add_(Design*, NetExpr*lp, NetExpr*rp, int expr_wid, bool is_pexpr) const { @@ -890,7 +893,7 @@ unsigned PEBComp::test_width(Design*des, NetScope*scope, unsigned, unsigned, } NetExpr* PEBComp::elaborate_expr(Design*des, NetScope*scope, - int expr_width_dummy, bool sys_task_arg) const + int, bool) const { assert(left_); assert(right_); @@ -945,10 +948,10 @@ NetExpr* PEBComp::elaborate_expr(Design*des, NetScope*scope, return tmp; } -unsigned PEBLogic::test_width(Design*des, NetScope*scope, - unsigned min, unsigned lval, +unsigned PEBLogic::test_width(Design*, NetScope*, + unsigned, unsigned, ivl_variable_type_t&expr_type_out, - bool&unsized_flag) + bool&) { expr_type_ = IVL_VT_LOGIC; expr_width_ = 1; @@ -957,7 +960,7 @@ unsigned PEBLogic::test_width(Design*des, NetScope*scope, } NetExpr*PEBLogic::elaborate_expr(Design*des, NetScope*scope, - int expr_width_dummp, bool sys_task_arg) const + int, bool) const { assert(left_); assert(right_); @@ -1040,7 +1043,7 @@ unsigned PEBLeftWidth::test_width(Design*des, NetScope*scope, } NetExpr*PEBLeftWidth::elaborate_expr(Design*des, NetScope*scope, - int expr_wid, bool sys_task_arg) const + int expr_wid, bool) const { assert(left_); assert(right_); @@ -1067,7 +1070,7 @@ NetExpr*PEBLeftWidth::elaborate_expr(Design*des, NetScope*scope, return elaborate_expr_leaf(des, lp, rp, expr_wid); } -NetExpr*PEBPower::elaborate_expr_leaf(Design*des, NetExpr*lp, NetExpr*rp, +NetExpr*PEBPower::elaborate_expr_leaf(Design*, NetExpr*lp, NetExpr*rp, int expr_wid) const { if (debug_elaborate) { @@ -1131,6 +1134,9 @@ unsigned PECallFunction::test_width_sfunc_(Design*des, NetScope*scope, << " argument width = " << expr_width_ << ", result width = " << min << "." << endl; + // We don't use (need?) lval so make sure the minimum width + // is greater than or equal to the the L-value width. + assert(min >= lval); return min; } @@ -1612,7 +1618,7 @@ NetExpr* PECallFunction::elaborate_expr(Design*des, NetScope*scope, } unsigned PEConcat::test_width(Design*des, NetScope*scope, - unsigned min, unsigned lval, + unsigned, unsigned, ivl_variable_type_t&expr_type__, bool&unsized_flag) { @@ -1809,8 +1815,8 @@ NetExpr* PEConcat::elaborate_expr(Design*des, NetScope*scope, * * Absent any better idea, we call all real valued results a width of 1. */ -unsigned PEFNumber::test_width(Design*des, NetScope*scope, - unsigned min, unsigned lval, +unsigned PEFNumber::test_width(Design*, NetScope*, + unsigned, unsigned, ivl_variable_type_t&expr_type__, bool&unsized_flag) { @@ -1822,7 +1828,7 @@ unsigned PEFNumber::test_width(Design*des, NetScope*scope, return 1; } -NetExpr* PEFNumber::elaborate_expr(Design*des, NetScope*scope, int, bool) const +NetExpr* PEFNumber::elaborate_expr(Design*, NetScope*, int, bool) const { NetECReal*tmp = new NetECReal(*value_); tmp->set_line(*this); @@ -1955,7 +1961,7 @@ NetExpr* PEIdent::calculate_up_do_base_(Design*des, NetScope*scope) const return tmp; } -bool PEIdent::calculate_param_range_(Design*des, NetScope*scope, +bool PEIdent::calculate_param_range_(Design*, NetScope*, const NetExpr*par_msb, long&par_msv, const NetExpr*par_lsb, long&par_lsv, long length) const @@ -1986,7 +1992,7 @@ static void probe_index_expr_width(Design*des, NetScope*scope, const name_component_t&name) { for (list::const_iterator cur = name.index.begin() - ; cur != name.index.end() ; cur ++) { + ; cur != name.index.end() ; ++ cur ) { if (cur->msb) probe_expr_width(des, scope, cur->msb); @@ -2107,7 +2113,7 @@ unsigned PEIdent::test_width(Design*des, NetScope*scope, // This is a parameter. If it is sized (meaning it was // declared with range expressions) then the range // expressions would have been caught above. So if we - // got there there we know this is an unsized constant. + // got here then we know this is an unsized constant. expr_width_ = par->expr_width(); unsized_flag = true; return expr_width_; @@ -2118,6 +2124,10 @@ unsigned PEIdent::test_width(Design*des, NetScope*scope, expr_type_ = IVL_VT_NO_TYPE; expr_width_ = min; + // We don't use (need?) lval so make sure the minimum width + // is greater than or equal to the the L-value width. + assert(min >= lval); + expr_type__ = expr_type_; return min; } @@ -2387,7 +2397,7 @@ static verinum param_part_select_bits(const verinum&par_val, long wid, NetExpr* PEIdent::elaborate_expr_param_part_(Design*des, NetScope*scope, const NetExpr*par, - NetScope*found_in, + NetScope*, const NetExpr*par_msb, const NetExpr*par_lsb) const { @@ -2511,7 +2521,7 @@ static void warn_param_ob(long par_msv, long par_lsv, bool defined, NetExpr* PEIdent::elaborate_expr_param_idx_up_(Design*des, NetScope*scope, const NetExpr*par, - NetScope*found_in, + NetScope*, const NetExpr*par_msb, const NetExpr*par_lsb) const { @@ -2590,7 +2600,7 @@ NetExpr* PEIdent::elaborate_expr_param_idx_up_(Design*des, NetScope*scope, NetExpr* PEIdent::elaborate_expr_param_idx_do_(Design*des, NetScope*scope, const NetExpr*par, - NetScope*found_in, + NetScope*, const NetExpr*par_msb, const NetExpr*par_lsb) const { @@ -2994,7 +3004,7 @@ NetExpr* PEIdent::elaborate_expr_net_word_(Design*des, NetScope*scope, * Handle part selects of NetNet identifiers. */ NetExpr* PEIdent::elaborate_expr_net_part_(Design*des, NetScope*scope, - NetESignal*net, NetScope*found_in) const + NetESignal*net, NetScope*) const { long msv, lsv; bool parts_defined_flag; @@ -3099,7 +3109,7 @@ NetExpr* PEIdent::elaborate_expr_net_part_(Design*des, NetScope*scope, * Part select indexed up, i.e. net[ +: ] */ NetExpr* PEIdent::elaborate_expr_net_idx_up_(Design*des, NetScope*scope, - NetESignal*net, NetScope*found_in) const + NetESignal*net, NetScope*) const { NetExpr*base = calculate_up_do_base_(des, scope); @@ -3187,7 +3197,7 @@ NetExpr* PEIdent::elaborate_expr_net_idx_up_(Design*des, NetScope*scope, * Part select indexed down, i.e. net[ -: ] */ NetExpr* PEIdent::elaborate_expr_net_idx_do_(Design*des, NetScope*scope, - NetESignal*net, NetScope*found_in)const + NetESignal*net, NetScope*)const { NetExpr*base = calculate_up_do_base_(des, scope); @@ -3271,7 +3281,7 @@ NetExpr* PEIdent::elaborate_expr_net_idx_do_(Design*des, NetScope*scope, } NetExpr* PEIdent::elaborate_expr_net_bit_(Design*des, NetScope*scope, - NetESignal*net, NetScope*found_in) const + NetESignal*net, NetScope*) const { const name_component_t&name_tail = path_.back(); ivl_assert(*this, !name_tail.index.empty()); @@ -3439,7 +3449,7 @@ unsigned PENumber::test_width(Design*, NetScope*, return use_wid; } -NetEConst* PENumber::elaborate_expr(Design*des, NetScope*, +NetEConst* PENumber::elaborate_expr(Design*, NetScope*, int expr_width__, bool) const { assert(value_); @@ -3463,10 +3473,10 @@ NetEConst* PENumber::elaborate_expr(Design*des, NetScope*, return tmp; } -unsigned PEString::test_width(Design*des, NetScope*scope, +unsigned PEString::test_width(Design*, NetScope*, unsigned min, unsigned lval, ivl_variable_type_t&expr_type__, - bool&unsized_flag) + bool&) { expr_type_ = IVL_VT_BOOL; expr_width_ = text_? 8*strlen(text_) : 0; @@ -3474,11 +3484,14 @@ unsigned PEString::test_width(Design*des, NetScope*scope, expr_width_ = min; expr_type__ = expr_type_; + // We don't use (need?) lval so make sure the minimum width + // is greater than or equal to the the L-value width. + assert(expr_width_ >= lval); return expr_width_; } -NetEConst* PEString::elaborate_expr(Design*des, NetScope*, - int expr_width_dummy, bool) const +NetEConst* PEString::elaborate_expr(Design*, NetScope*, + int, bool) const { NetEConst*tmp = new NetEConst(value()); tmp->set_line(*this); diff --git a/elab_lval.cc b/elab_lval.cc index 5ef8f8957..bc785a299 100644 --- a/elab_lval.cc +++ b/elab_lval.cc @@ -66,9 +66,7 @@ * is to try to make a net elaboration, and see if the result is * suitable for assignment. */ -NetAssign_* PExpr::elaborate_lval(Design*des, - NetScope*scope, - bool is_force) const +NetAssign_* PExpr::elaborate_lval(Design*, NetScope*, bool) const { NetNet*ll = 0; if (ll == 0) { diff --git a/elab_pexpr.cc b/elab_pexpr.cc index 228549650..7e76c6d13 100644 --- a/elab_pexpr.cc +++ b/elab_pexpr.cc @@ -28,7 +28,7 @@ # include # include "ivl_assert.h" -NetExpr*PExpr::elaborate_pexpr(Design*des, NetScope*sc) const +NetExpr*PExpr::elaborate_pexpr(Design*des, NetScope*) const { cerr << get_fileline() << ": error: invalid parameter expression: " << *this << endl; @@ -220,6 +220,7 @@ NetExpr*PEIdent::elaborate_pexpr(Design*des, NetScope*scope) const list tmp = eval_scope_path(des, scope, oldpath); pscope = des->find_scope(scope, tmp); } + ivl_assert(*this, pscope); const NetExpr*ex_msb; const NetExpr*ex_lsb; diff --git a/elab_scope.cc b/elab_scope.cc index 4ebde70e5..26e15da8d 100644 --- a/elab_scope.cc +++ b/elab_scope.cc @@ -54,7 +54,7 @@ static void collect_scope_parameters_(NetScope*scope, const map¶meters) { for (mparm_it_t cur = parameters.begin() - ; cur != parameters.end() ; cur ++) { + ; cur != parameters.end() ; ++ cur ) { NetEParam*tmp = new NetEParam; tmp->set_line(*((*cur).second.expr)); @@ -69,7 +69,7 @@ static void collect_scope_localparams_(NetScope*scope, const map&localparams) { for (mparm_it_t cur = localparams.begin() - ; cur != localparams.end() ; cur ++) { + ; cur != localparams.end() ; ++ cur ) { NetEParam*tmp = new NetEParam; tmp->set_line(*((*cur).second.expr)); @@ -173,7 +173,7 @@ static void elaborate_scope_parameters_(Design*des, NetScope*scope, const map¶meters) { for (mparm_it_t cur = parameters.begin() - ; cur != parameters.end() ; cur ++) { + ; cur != parameters.end() ; ++ cur ) { // A parameter can not have the same name as a genvar. if (scope->find_genvar((*cur).first)) { @@ -192,7 +192,7 @@ static void elaborate_scope_localparams_(Design*des, NetScope*scope, const map&localparams) { for (mparm_it_t cur = localparams.begin() - ; cur != localparams.end() ; cur ++) { + ; cur != localparams.end() ; ++ cur ) { // A localparam can not have the same name as a genvar. if (scope->find_genvar((*cur).first)) { @@ -293,7 +293,7 @@ static void replace_scope_parameters_(NetScope*scope, const LineInfo&loc, const Module::replace_t&replacements) { for (Module::replace_t::const_iterator cur = replacements.begin() - ; cur != replacements.end() ; cur ++) { + ; cur != replacements.end() ; ++ cur ) { NetExpr*val = (*cur).second; if (val == 0) { @@ -323,20 +323,19 @@ static void elaborate_scope_events_(Design*des, NetScope*scope, const map&events) { for (map::const_iterator et = events.begin() - ; et != events.end() ; et ++ ) { + ; et != events.end() ; ++ et ) { (*et).second->elaborate_scope(des, scope); } } static void elaborate_scope_tasks(Design*des, NetScope*scope, - const LineInfo&loc, const map&tasks) { typedef map::const_iterator tasks_it_t; for (tasks_it_t cur = tasks.begin() - ; cur != tasks.end() ; cur ++ ) { + ; cur != tasks.end() ; ++ cur ) { hname_t use_name( (*cur).first ); // A task can not have the same name as another scope object. @@ -385,13 +384,12 @@ static void elaborate_scope_tasks(Design*des, NetScope*scope, } static void elaborate_scope_funcs(Design*des, NetScope*scope, - const LineInfo&loc, const map&funcs) { typedef map::const_iterator funcs_it_t; for (funcs_it_t cur = funcs.begin() - ; cur != funcs.end() ; cur ++ ) { + ; cur != funcs.end() ; ++ cur ) { hname_t use_name( (*cur).first ); // A function can not have the same name as another scope object. @@ -459,7 +457,7 @@ class generate_schemes_work_item_t : public elaborator_work_item_t { // elaboration. typedef list::const_iterator generate_it_t; for (generate_it_t cur = mod_->generate_schemes.begin() - ; cur != mod_->generate_schemes.end() ; cur ++ ) { + ; cur != mod_->generate_schemes.end() ; ++ cur ) { (*cur) -> generate_scope(des, scope_); } } @@ -482,7 +480,7 @@ bool Module::elaborate_scope(Design*des, NetScope*scope, // Add the genvars to the scope. typedef map::const_iterator genvar_it_t; - for (genvar_it_t cur = genvars.begin(); cur != genvars.end(); cur++ ) { + for (genvar_it_t cur = genvars.begin(); cur != genvars.end(); ++ cur ) { scope->add_genvar((*cur).first, (*cur).second); } @@ -531,7 +529,7 @@ bool Module::elaborate_scope(Design*des, NetScope*scope, typedef list::const_iterator defparms_iter_t; for (defparms_iter_t cur = defparms.begin() - ; cur != defparms.end() ; cur ++) { + ; cur != defparms.end() ; ++ cur ) { PExpr*ex = cur->second; assert(ex); @@ -567,21 +565,21 @@ bool Module::elaborate_scope(Design*des, NetScope*scope, // elaborate_scope method of the PTask for detailed // processing. - elaborate_scope_tasks(des, scope, *this, tasks); + elaborate_scope_tasks(des, scope, tasks); // Functions are very similar to tasks, at least from the // perspective of scopes. So handle them exactly the same // way. - elaborate_scope_funcs(des, scope, *this, funcs); + elaborate_scope_funcs(des, scope, funcs); // Gates include modules, which might introduce new scopes, so // scan all of them to create those scopes. typedef list::const_iterator gates_it_t; for (gates_it_t cur = gates_.begin() - ; cur != gates_.end() ; cur ++ ) { + ; cur != gates_.end() ; ++ cur ) { (*cur) -> elaborate_scope(des, scope); } @@ -594,7 +592,7 @@ bool Module::elaborate_scope(Design*des, NetScope*scope, typedef list::const_iterator proc_it_t; for (proc_it_t cur = behaviors.begin() - ; cur != behaviors.end() ; cur ++ ) { + ; cur != behaviors.end() ; ++ cur ) { (*cur) -> statement() -> elaborate_scope(des, scope); } @@ -934,7 +932,7 @@ bool PGenerate::generate_scope_case_(Design*des, NetScope*container) // Detect that the item is a default. if (item->item_test.size() == 0) { default_item = item; - cur ++; + ++ cur; continue; } @@ -966,7 +964,7 @@ bool PGenerate::generate_scope_case_(Design*des, NetScope*container) if (match_flag) break; - cur ++; + ++ cur; } delete case_value_co; @@ -1102,7 +1100,7 @@ void PGenerate::elaborate_subscope_direct_(Design*des, NetScope*scope) { typedef list::const_iterator generate_it_t; for (generate_it_t cur = generate_schemes.begin() - ; cur != generate_schemes.end() ; cur ++ ) { + ; cur != generate_schemes.end() ; ++ cur ) { (*cur) -> generate_scope(des, scope); } } @@ -1111,7 +1109,7 @@ void PGenerate::elaborate_subscope_(Design*des, NetScope*scope) { // Add the genvars to this scope. typedef map::const_iterator genvar_it_t; - for (genvar_it_t cur = genvars.begin(); cur != genvars.end(); cur++ ) { + for (genvar_it_t cur = genvars.begin(); cur != genvars.end(); ++ cur ) { scope->add_genvar((*cur).first, (*cur).second); } @@ -1121,7 +1119,7 @@ void PGenerate::elaborate_subscope_(Design*des, NetScope*scope) typedef list::const_iterator generate_it_t; for (generate_it_t cur = generate_schemes.begin() - ; cur != generate_schemes.end() ; cur ++ ) { + ; cur != generate_schemes.end() ; ++ cur ) { (*cur) -> generate_scope(des, scope); } @@ -1135,20 +1133,20 @@ void PGenerate::elaborate_subscope_(Design*des, NetScope*scope) // Scan through all the task and function declarations in this // scope. - elaborate_scope_tasks(des, scope, *this, tasks); - elaborate_scope_funcs(des, scope, *this, funcs); + elaborate_scope_tasks(des, scope, tasks); + elaborate_scope_funcs(des, scope, funcs); // Scan the generated scope for gates that may create // their own scopes. typedef list::const_iterator pgate_list_it_t; for (pgate_list_it_t cur = gates.begin() - ; cur != gates.end() ; cur ++) { + ; cur != gates.end() ; ++ cur ) { (*cur) ->elaborate_scope(des, scope); } typedef list::const_iterator proc_it_t; for (proc_it_t cur = behaviors.begin() - ; cur != behaviors.end() ; cur ++ ) { + ; cur != behaviors.end() ; ++ cur ) { (*cur) -> statement() -> elaborate_scope(des, scope); } @@ -1437,7 +1435,7 @@ void PGModule::elaborate_scope_mod_instances_(Design*des, Module*mod, NetScope*s // parameter value with the new expression. for (mparm_local_it_t cur = replace.begin() - ; cur != replace.end() ; cur ++ ) { + ; cur != replace.end() ; ++ cur ) { PExpr*tmp = (*cur).second; // No expression means that the parameter is not diff --git a/elab_sig.cc b/elab_sig.cc index a479497d2..6e1e3bfba 100644 --- a/elab_sig.cc +++ b/elab_sig.cc @@ -78,7 +78,7 @@ static bool get_const_argument(NetExpr*exp, long&res) return true; } -void Statement::elaborate_sig(Design*des, NetScope*scope) const +void Statement::elaborate_sig(Design*, NetScope*) const { } @@ -87,7 +87,7 @@ bool PScope::elaborate_sig_wires_(Design*des, NetScope*scope) const bool flag = true; for (map::const_iterator wt = wires.begin() - ; wt != wires.end() ; wt ++ ) { + ; wt != wires.end() ; ++ wt ) { PWire*cur = (*wt).second; NetNet*sig = cur->elaborate_sig(des, scope); @@ -143,7 +143,7 @@ static void elaborate_sig_funcs(Design*des, NetScope*scope, typedef map::const_iterator mfunc_it_t; for (mfunc_it_t cur = funcs.begin() - ; cur != funcs.end() ; cur ++) { + ; cur != funcs.end() ; ++ cur ) { hname_t use_name ( (*cur).first ); NetScope*fscope = scope->child(use_name); @@ -165,7 +165,7 @@ static void elaborate_sig_tasks(Design*des, NetScope*scope, typedef map::const_iterator mtask_it_t; for (mtask_it_t cur = tasks.begin() - ; cur != tasks.end() ; cur ++) { + ; cur != tasks.end() ; ++ cur ) { NetScope*tscope = scope->child( hname_t((*cur).first) ); assert(tscope); (*cur).second->elaborate_sig(des, tscope); @@ -229,7 +229,7 @@ bool Module::elaborate_sig(Design*des, NetScope*scope) const // scope in. typedef list::const_iterator generate_it_t; for (generate_it_t cur = generate_schemes.begin() - ; cur != generate_schemes.end() ; cur ++ ) { + ; cur != generate_schemes.end() ; ++ cur ) { (*cur) -> elaborate_sig(des, scope); } @@ -241,8 +241,7 @@ bool Module::elaborate_sig(Design*des, NetScope*scope) const const list&gl = get_gates(); for (list::const_iterator gt = gl.begin() - ; gt != gl.end() - ; gt ++ ) { + ; gt != gl.end() ; ++ gt ) { flag &= (*gt)->elaborate_sig(des, scope); } @@ -261,7 +260,7 @@ bool Module::elaborate_sig(Design*des, NetScope*scope) const typedef list::const_iterator proc_it_t; for (proc_it_t cur = behaviors.begin() - ; cur != behaviors.end() ; cur ++ ) { + ; cur != behaviors.end() ; ++ cur ) { (*cur) -> statement() -> elaborate_sig(des, scope); } @@ -269,17 +268,17 @@ bool Module::elaborate_sig(Design*des, NetScope*scope) const return flag; } -bool PGate::elaborate_sig(Design*des, NetScope*scope) const +bool PGate::elaborate_sig(Design*, NetScope*) const { return true; } -bool PGBuiltin::elaborate_sig(Design*des, NetScope*scope) const +bool PGBuiltin::elaborate_sig(Design*, NetScope*) const { return true; } -bool PGAssign::elaborate_sig(Design*des, NetScope*scope) const +bool PGAssign::elaborate_sig(Design*, NetScope*) const { return true; } @@ -314,10 +313,13 @@ bool PGModule::elaborate_sig_mod_(Design*des, NetScope*scope, return flag; } + // Not currently used. +#if 0 bool PGModule::elaborate_sig_udp_(Design*des, NetScope*scope, PUdp*udp) const { return true; } +#endif bool PGenerate::elaborate_sig(Design*des, NetScope*container) const { @@ -338,7 +340,7 @@ bool PGenerate::elaborate_sig(Design*des, NetScope*container) const typedef list::const_iterator generate_it_t; for (generate_it_t cur = generate_schemes.begin() - ; cur != generate_schemes.end() ; cur ++) { + ; cur != generate_schemes.end() ; ++ cur ) { PGenerate*item = *cur; if (item->direct_nested_ || !item->scope_list_.empty()) { flag &= item->elaborate_sig(des, container); @@ -349,7 +351,7 @@ bool PGenerate::elaborate_sig(Design*des, NetScope*container) const typedef list::const_iterator scope_list_it_t; for (scope_list_it_t cur = scope_list_.begin() - ; cur != scope_list_.end() ; cur ++ ) { + ; cur != scope_list_.end() ; ++ cur ) { NetScope*scope = *cur; @@ -382,7 +384,7 @@ bool PGenerate::elaborate_sig_direct_(Design*des, NetScope*container) const bool flag = true; typedef list::const_iterator generate_it_t; for (generate_it_t cur = generate_schemes.begin() - ; cur != generate_schemes.end() ; cur ++) { + ; cur != generate_schemes.end() ; ++ cur ) { PGenerate*item = *cur; if (item->direct_nested_ || !item->scope_list_.empty()) { // Found the item, and it is direct nested. @@ -398,7 +400,7 @@ bool PGenerate::elaborate_sig_(Design*des, NetScope*scope) const // in the current scope. typedef map::const_iterator wires_it_t; for (wires_it_t wt = wires.begin() - ; wt != wires.end() ; wt ++ ) { + ; wt != wires.end() ; ++ wt ) { PWire*cur = (*wt).second; @@ -414,19 +416,19 @@ bool PGenerate::elaborate_sig_(Design*des, NetScope*scope) const typedef list::const_iterator generate_it_t; for (generate_it_t cur = generate_schemes.begin() - ; cur != generate_schemes.end() ; cur ++ ) { + ; cur != generate_schemes.end() ; ++ cur ) { (*cur) -> elaborate_sig(des, scope); } typedef list::const_iterator pgate_list_it_t; for (pgate_list_it_t cur = gates.begin() - ; cur != gates.end() ; cur ++) { + ; cur != gates.end() ; ++ cur ) { (*cur) ->elaborate_sig(des, scope); } typedef list::const_iterator proc_it_t; for (proc_it_t cur = behaviors.begin() - ; cur != behaviors.end() ; cur ++ ) { + ; cur != behaviors.end() ; ++ cur ) { (*cur) -> statement() -> elaborate_sig(des, scope); } @@ -1047,6 +1049,17 @@ NetNet* PWire::elaborate_sig(Design*des, NetScope*scope) const array_dimensions = 1; } + if (data_type_ == IVL_VT_REAL && (msb != 0 || lsb != 0)) { + cerr << get_fileline() << ": error: real "; + if (wtype == NetNet::REG) cerr << "variable"; + else cerr << "net"; + cerr << " '" << name_ + << "' cannot be declared as a vector, found a range [" + << msb << ":" << lsb << "]." << endl; + des->errors += 1; + return 0; + } + /* If the net type is supply0 or supply1, replace it with a simple wire with a pulldown/pullup with supply strength. In other words, transform: @@ -1076,8 +1089,10 @@ NetNet* PWire::elaborate_sig(Design*des, NetScope*scope) const if (debug_elaborate) { cerr << get_fileline() << ": debug: " - << "Generate a SUPPLY pulldown for the " - << "supply0 net." << endl; + << "Generate a SUPPLY pull for the "; + if (wtype == NetNet::SUPPLY0) cerr << "supply0"; + else cerr << "supply1"; + cerr << " net." << endl; } } diff --git a/elaborate.cc b/elaborate.cc index 9ec2591a4..14b476c87 100644 --- a/elaborate.cc +++ b/elaborate.cc @@ -42,7 +42,7 @@ # include "ivl_assert.h" -void PGate::elaborate(Design*des, NetScope*scope) const +void PGate::elaborate(Design*, NetScope*) const { cerr << "internal error: what kind of gate? " << typeid(*this).name() << endl; @@ -1903,9 +1903,13 @@ bool PGModule::elaborate_sig(Design*des, NetScope*scope) const if (mod != pform_modules.end()) return elaborate_sig_mod_(des, scope, (*mod).second); + // elaborate_sig_udp_ currently always returns true so skip all this + // for now. +#if 0 map::const_iterator udp = pform_primitives.find(type_); if (udp != pform_primitives.end()) return elaborate_sig_udp_(des, scope, (*udp).second); +#endif return true; } @@ -4077,7 +4081,7 @@ void PSpecPath::elaborate(Design*des, NetScope*scope) const /* Create all the various paths from the path specifier. */ typedef std::vector::const_iterator str_vector_iter; for (str_vector_iter cur = dst.begin() - ; cur != dst.end() ; cur ++) { + ; cur != dst.end() ; ++ cur ) { if (debug_elaborate) { cerr << get_fileline() << ": debug: Path to " << (*cur); @@ -4145,7 +4149,7 @@ void PSpecPath::elaborate(Design*des, NetScope*scope) const unsigned idx = 0; for (str_vector_iter cur_src = src.begin() - ; cur_src != src.end() ; cur_src ++) { + ; cur_src != src.end() ; ++ cur_src ) { NetNet*src_sig = scope->find_signal(*cur_src); assert(src_sig); @@ -4183,7 +4187,7 @@ static void elaborate_functions(Design*des, NetScope*scope, { typedef map::const_iterator mfunc_it_t; for (mfunc_it_t cur = funcs.begin() - ; cur != funcs.end() ; cur ++) { + ; cur != funcs.end() ; ++ cur ) { hname_t use_name ( (*cur).first ); NetScope*fscope = scope->child(use_name); @@ -4197,7 +4201,7 @@ static void elaborate_tasks(Design*des, NetScope*scope, { typedef map::const_iterator mtask_it_t; for (mtask_it_t cur = tasks.begin() - ; cur != tasks.end() ; cur ++) { + ; cur != tasks.end() ; ++ cur ) { hname_t use_name ( (*cur).first ); NetScope*tscope = scope->child(use_name); @@ -4218,7 +4222,7 @@ bool Module::elaborate(Design*des, NetScope*scope) const // Elaborate specparams typedef map::const_iterator specparam_it_t; for (specparam_it_t cur = specparams.begin() - ; cur != specparams.end() ; cur ++ ) { + ; cur != specparams.end() ; ++ cur ) { probe_expr_width(des, scope, (*cur).second); need_constant_expr = true; @@ -4263,7 +4267,7 @@ bool Module::elaborate(Design*des, NetScope*scope) const // Elaborate within the generate blocks. typedef list::const_iterator generate_it_t; for (generate_it_t cur = generate_schemes.begin() - ; cur != generate_schemes.end() ; cur ++ ) { + ; cur != generate_schemes.end() ; ++ cur ) { (*cur)->elaborate(des, scope); } @@ -4281,8 +4285,7 @@ bool Module::elaborate(Design*des, NetScope*scope) const const list&gl = get_gates(); for (list::const_iterator gt = gl.begin() - ; gt != gl.end() - ; gt ++ ) { + ; gt != gl.end() ; ++ gt ) { (*gt)->elaborate(des, scope); } @@ -4295,7 +4298,7 @@ bool Module::elaborate(Design*des, NetScope*scope) const // Elaborate the specify paths of the module. for (list::const_iterator sp = specify_paths.begin() - ; sp != specify_paths.end() ; sp ++) { + ; sp != specify_paths.end() ; ++ sp ) { (*sp)->elaborate(des, scope); } @@ -4322,7 +4325,7 @@ bool PGenerate::elaborate(Design*des, NetScope*container) const typedef list::const_iterator generate_it_t; for (generate_it_t cur = generate_schemes.begin() - ; cur != generate_schemes.end() ; cur ++) { + ; cur != generate_schemes.end() ; ++ cur ) { PGenerate*item = *cur; if (item->direct_nested_ || !item->scope_list_.empty()) { flag &= item->elaborate(des, container); @@ -4333,7 +4336,7 @@ bool PGenerate::elaborate(Design*des, NetScope*container) const typedef list::const_iterator scope_list_it_t; for (scope_list_it_t cur = scope_list_.begin() - ; cur != scope_list_.end() ; cur ++ ) { + ; cur != scope_list_.end() ; ++ cur ) { NetScope*scope = *cur; // Check that this scope is one that is contained in the @@ -4376,7 +4379,7 @@ bool PGenerate::elaborate_direct_(Design*des, NetScope*container) const bool flag = true; typedef list::const_iterator generate_it_t; for (generate_it_t cur = generate_schemes.begin() - ; cur != generate_schemes.end() ; cur ++) { + ; cur != generate_schemes.end() ; ++ cur ) { PGenerate*item = *cur; if (item->direct_nested_ || !item->scope_list_.empty()) { // Found the item, and it is direct nested. @@ -4392,16 +4395,16 @@ bool PGenerate::elaborate_(Design*des, NetScope*scope) const elaborate_tasks(des, scope, tasks); typedef list::const_iterator gates_it_t; - for (gates_it_t cur = gates.begin() ; cur != gates.end() ; cur ++ ) + for (gates_it_t cur = gates.begin() ; cur != gates.end() ; ++ cur ) (*cur)->elaborate(des, scope); typedef list::const_iterator proc_it_t; - for (proc_it_t cur = behaviors.begin(); cur != behaviors.end(); cur++) + for (proc_it_t cur = behaviors.begin(); cur != behaviors.end(); ++ cur ) (*cur)->elaborate(des, scope); typedef list::const_iterator generate_it_t; for (generate_it_t cur = generate_schemes.begin() - ; cur != generate_schemes.end() ; cur ++ ) { + ; cur != generate_schemes.end() ; ++ cur ) { (*cur)->elaborate(des, scope); } @@ -4416,13 +4419,13 @@ bool PScope::elaborate_behaviors_(Design*des, NetScope*scope) const // involves scanning the PProcess* list, creating a NetProcTop // for each process. for (list::const_iterator st = behaviors.begin() - ; st != behaviors.end() ; st ++ ) { + ; st != behaviors.end() ; ++ st ) { result_flag &= (*st)->elaborate(des, scope); } for (list::const_iterator st = analog_behaviors.begin() - ; st != analog_behaviors.end() ; st ++ ) { + ; st != analog_behaviors.end() ; ++ st ) { result_flag &= (*st)->elaborate(des, scope); } @@ -4447,7 +4450,7 @@ class elaborate_root_scope_t : public elaborator_work_item_t { { Module::replace_t root_repl; for (list::iterator cur = Module::user_defparms.begin() - ; cur != Module::user_defparms.end() ; cur++) { + ; cur != Module::user_defparms.end() ; ++ cur ) { pform_name_t tmp_name = cur->first; if (peek_head_name(tmp_name) != scope_->basename()) @@ -4506,7 +4509,7 @@ class later_defparams : public elaborator_work_item_t { { listtmp_list; for (set::iterator cur = des->defparams_later.begin() - ; cur != des->defparams_later.end() ; cur ++ ) + ; cur != des->defparams_later.end() ; ++ cur ) tmp_list.push_back(*cur); des->defparams_later.clear(); @@ -4569,8 +4572,7 @@ Design* elaborate(listroots) // Scan the root modules by name, and elaborate their scopes. for (list::const_iterator root = roots.begin() - ; root != roots.end() - ; root++) { + ; root != roots.end() ; ++ root ) { // Look for the root module in the list. map::const_iterator mod = pform_modules.find(*root); diff --git a/emit.cc b/emit.cc index 1f0ea7f23..21f0b5eef 100644 --- a/emit.cc +++ b/emit.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998-2008 Stephen Williams (steve@icarus.com) + * Copyright (c) 1998-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 @@ -31,7 +31,7 @@ # include # include -bool NetNode::emit_node(struct target_t*tgt) const +bool NetNode::emit_node(struct target_t*) const { cerr << "EMIT: Gate type? " << typeid(*this).name() << endl; return false; @@ -200,7 +200,7 @@ bool NetAnalogTop::emit(struct target_t*tgt) const return tgt->process(this); } -bool NetProc::emit_proc(struct target_t*tgt) const +bool NetProc::emit_proc(struct target_t*) const { cerr << "EMIT: Proc type? " << typeid(*this).name() << endl; return false; @@ -390,11 +390,11 @@ void NetScope::emit_scope(struct target_t*tgt) const tgt->enumeration(this, *cur); for (map::const_iterator cur = children_.begin() - ; cur != children_.end() ; cur ++) + ; cur != children_.end() ; ++ cur ) cur->second->emit_scope(tgt); for (signals_map_iter_t cur = signals_map_.begin() - ; cur != signals_map_.end() ; cur ++) { + ; cur != signals_map_.end() ; ++ cur ) { tgt->signal(cur->second); } @@ -418,7 +418,7 @@ bool NetScope::emit_defs(struct target_t*tgt) const switch (type_) { case MODULE: for (map::const_iterator cur = children_.begin() - ; cur != children_.end() ; cur ++) + ; cur != children_.end() ; ++ cur ) flag &= cur->second->emit_defs(tgt); break; @@ -430,7 +430,7 @@ bool NetScope::emit_defs(struct target_t*tgt) const break; default: /* BEGIN_END and FORK_JOIN, GENERATE... */ for (map::const_iterator cur = children_.begin() - ; cur != children_.end() ; cur ++) + ; cur != children_.end() ; ++ cur ) flag &= cur->second->emit_defs(tgt); break; } @@ -452,7 +452,7 @@ int Design::emit(struct target_t*tgt) const // enumerate the scopes for (list::const_iterator scope = root_scopes_.begin(); - scope != root_scopes_.end(); scope++) + scope != root_scopes_.end(); ++ scope ) (*scope)->emit_scope(tgt); @@ -475,7 +475,7 @@ int Design::emit(struct target_t*tgt) const // emit task and function definitions bool tasks_rc = true; for (list::const_iterator scope = root_scopes_.begin(); - scope != root_scopes_.end(); scope++) + scope != root_scopes_.end(); ++ scope ) tasks_rc &= (*scope)->emit_defs(tgt); @@ -540,7 +540,7 @@ void NetECRealParam::expr_scan(struct expr_scan_t*tgt) const tgt->expr_rparam(this); } -void NetEParam::expr_scan(struct expr_scan_t*tgt) const +void NetEParam::expr_scan(struct expr_scan_t*) const { cerr << get_fileline() << ":internal error: unexpected NetEParam." << endl; diff --git a/eval_attrib.cc b/eval_attrib.cc index 7544292cc..a293fb14c 100644 --- a/eval_attrib.cc +++ b/eval_attrib.cc @@ -43,7 +43,7 @@ attrib_list_t* evaluate_attributes(const map&att, unsigned idx = 0; typedef map::const_iterator iter_t; - for (iter_t cur = att.begin() ; cur != att.end() ; cur ++, idx++) { + for (iter_t cur = att.begin() ; cur != att.end() ; ++ cur , idx += 1) { table[idx].key = (*cur).first; PExpr*exp = (*cur).second; diff --git a/eval_tree.cc b/eval_tree.cc index 993025568..182f60dd3 100644 --- a/eval_tree.cc +++ b/eval_tree.cc @@ -29,7 +29,7 @@ # include "ivl_assert.h" # include "netmisc.h" -NetExpr* NetExpr::eval_tree(int prune_to_width) +NetExpr* NetExpr::eval_tree(int) { return 0; } @@ -60,6 +60,20 @@ static bool get_real_arg_(NetExpr*expr, verireal&val) return true; } +static bool get_real_arguments(NetExpr*le, NetExpr*re, + double&lval, double&rval) +{ + verireal val; + + if (!get_real_arg_(le, val)) return false; + lval = val.as_double(); + + if (!get_real_arg_(re, val)) return false; + rval = val.as_double(); + + return true; +} + bool NetEBinary::get_real_arguments_(verireal&lval, verireal&rval) { if (!get_real_arg_(left_, lval)) return false; @@ -68,6 +82,38 @@ bool NetEBinary::get_real_arguments_(verireal&lval, verireal&rval) return true; } +NetECReal* NetEBAdd::eval_tree_real_() +{ + verireal lval; + verireal rval; + + bool flag = get_real_arguments_(lval, rval); + if (!flag) return 0; + + verireal res_val; + + switch (op()) { + case '+': + res_val = lval + rval; + break; + case '-': + res_val = lval - rval; + break; + default: + ivl_assert(*this, 0); + } + + NetECReal*res = new NetECReal( res_val ); + ivl_assert(*this, res); + res->set_line(*this); + + if (debug_eval_tree) + cerr << get_fileline() << ": debug: Evaluated (real): " << *this + << " --> " << *res << endl; + + return res; +} + NetExpr* NetEBAdd::eval_tree(int prune_to_width) { eval_expr(left_, prune_to_width); @@ -97,12 +143,6 @@ NetExpr* NetEBAdd::eval_tree(int prune_to_width) return 0; } - if (debug_eval_tree) { - cerr << get_fileline() << ": debug: Evaluate expr=" << *this - << " --- prune=" << prune_to_width - << " has_width=" << (has_width()? "true" : "false") << endl; - } - /* Result might have known width. */ if (has_width()) { unsigned lwid = lc->expr_width(); @@ -118,7 +158,15 @@ NetExpr* NetEBAdd::eval_tree(int prune_to_width) val = val2; } - return new NetEConst(val); + NetEConst *res = new NetEConst(val); + ivl_assert(*this, res); + res->set_line(*this); + + if (debug_eval_tree) + cerr << get_fileline() << ": debug: Evaluated: " << *this + << " --> " << *res << endl; + + return res; } /* Try to combine a right constant value with the right @@ -188,35 +236,15 @@ NetExpr* NetEBAdd::eval_tree(int prune_to_width) return 0; } -NetECReal* NetEBAdd::eval_tree_real_() -{ - verireal lval; - verireal rval; - bool flag = get_real_arguments_(lval, rval); - if (!flag) return 0; - - verireal res_val; - - switch (op()) { - case '+': - res_val = lval + rval; - break; - case '-': - res_val = lval - rval; - break; - default: - ivl_assert(*this, 0); - } - - NetECReal*res = new NetECReal( res_val ); - res->set_line(*this); - return res; -} - NetEConst* NetEBBits::eval_tree(int prune_to_width) { - eval_expr(left_); - eval_expr(right_); + if (debug_eval_tree) { + cerr << get_fileline() << ": debug: Evaluating expression:" + << *this << ", prune_to_width=" << prune_to_width << endl; + } + + eval_expr(left_, prune_to_width); + eval_expr(right_, prune_to_width); NetEConst*lc = dynamic_cast(left_); NetEConst*rc = dynamic_cast(right_); @@ -321,21 +349,20 @@ NetEConst* NetEBBits::eval_tree(int prune_to_width) return new NetEConst(res); } - NetEConst* NetEBComp::eval_less_() { - if (right_->expr_type() == IVL_VT_REAL) - return eval_leeq_real_(left_, right_, false); - if (left_->expr_type() == IVL_VT_REAL) + if (right_->expr_type() == IVL_VT_REAL || + left_->expr_type() == IVL_VT_REAL) return eval_leeq_real_(left_, right_, false); - NetEConst*r = dynamic_cast(right_); - if (r == 0) return 0; + NetEConst*rc = dynamic_cast(right_); + if (rc == 0) return 0; - verinum rv = r->value(); + verinum rv = rc->value(); if (! rv.is_defined()) { - verinum result(verinum::Vx, 1); - return new NetEConst(result); + NetEConst*res = new NetEConst(verinum(verinum::Vx, 1)); + ivl_assert(*this, res); + return res; } if (NetEConst*tmp = must_be_leeq_(left_, rv, false)) { @@ -343,82 +370,27 @@ NetEConst* NetEBComp::eval_less_() } /* Now go on to the normal test of the values. */ - NetEConst*l = dynamic_cast(left_); - if (l == 0) return 0; - verinum lv = l->value(); + NetEConst*lc = dynamic_cast(left_); + if (lc == 0) return 0; + + verinum lv = lc->value(); if (! lv.is_defined()) { - verinum result(verinum::Vx, 1); - return new NetEConst(result); + NetEConst*res = new NetEConst(verinum(verinum::Vx, 1)); + ivl_assert(*this, res); + return res; } if (lv < rv) { - verinum result(verinum::V1, 1); - return new NetEConst(result); + NetEConst*res = new NetEConst(verinum(verinum::V1, 1)); + ivl_assert(*this, res); + return res; } else { - verinum result(verinum::V0, 1); - return new NetEConst(result); + NetEConst*res = new NetEConst(verinum(verinum::V0, 1)); + ivl_assert(*this, res); + return res; } } -NetEConst* NetEBComp::eval_leeq_real_(NetExpr*le, NetExpr*ri, bool eq_flag) -{ - NetEConst*vtmp; - NetECReal*rtmp; - double lv, rv; - - switch (le->expr_type()) { - case IVL_VT_REAL: - rtmp = dynamic_cast (le); - if (rtmp == 0) return 0; - lv = rtmp->value().as_double(); - break; - - case IVL_VT_LOGIC: - case IVL_VT_BOOL: - vtmp = dynamic_cast (le); - if (vtmp == 0) return 0; - lv = vtmp->value().as_double(); - break; - - default: - lv = 0.0; - cerr << get_fileline() << ": internal error: " - << "Unexpected expression type? " << le->expr_type() << endl; - assert(0); - } - - switch (ri->expr_type()) { - case IVL_VT_REAL: - rtmp = dynamic_cast (ri); - if (rtmp == 0) return 0; - rv = rtmp->value().as_double(); - break; - - case IVL_VT_LOGIC: - case IVL_VT_BOOL: - vtmp = dynamic_cast (ri); - if (vtmp == 0) return 0; - rv = vtmp->value().as_double(); - break; - - default: - rv = 0.0; - cerr << get_fileline() << ": internal error: " - << "Unexpected expression type? " << ri->expr_type() << endl; - assert(0); - } - - bool test = false; - if (lv < rv) test = true; - if (test == false && eq_flag && lv == rv) test = true; - - verinum result(test? verinum::V1 : verinum::V0, 1); - vtmp = new NetEConst(result); - vtmp->set_line(*this); - - return vtmp; -} - NetEConst* NetEBComp::must_be_leeq_(NetExpr*le, const verinum&rv, bool eq_flag) { assert(le->expr_width() > 0); @@ -432,27 +404,49 @@ NetEConst* NetEBComp::must_be_leeq_(NetExpr*le, const verinum&rv, bool eq_flag) } if (lv < rv || (eq_flag && (lv == rv))) { - verinum result(verinum::V1, 1); - return new NetEConst(result); + NetEConst*res = new NetEConst(verinum(verinum::V1, 1)); + ivl_assert(*this, res); + return res; } return 0; } +NetEConst* NetEBComp::eval_leeq_real_(NetExpr*le, NetExpr*re, bool eq_flag) +{ + double lval; + double rval; + + bool flag = get_real_arguments(le, re, lval, rval); + if (! flag) return 0; + + bool tmp = false; + if (lval < rval) tmp = true; + if (tmp == false && eq_flag && lval == rval) tmp = true; + + verinum result(tmp ? verinum::V1 : verinum::V0, 1); + NetEConst*res = new NetEConst(result); + ivl_assert(*this, res); + + return res; +} + NetEConst* NetEBComp::eval_leeq_() { - if (right_->expr_type() == IVL_VT_REAL) - return eval_leeq_real_(left_, right_, true); - if (left_->expr_type() == IVL_VT_REAL) + if (right_->expr_type() == IVL_VT_REAL || + left_->expr_type() == IVL_VT_REAL) return eval_leeq_real_(left_, right_, true); +// assert(expr_type() == IVL_VT_LOGIC); +// HERE NetEConst*r = dynamic_cast(right_); if (r == 0) return 0; verinum rv = r->value(); if (! rv.is_defined()) { - verinum result(verinum::Vx, 1); - return new NetEConst(result); + NetEConst*res = new NetEConst(verinum(verinum::Vx, 1)); + ivl_assert(*this, res); + return res; } if (left_->expr_width() == 0) { @@ -468,26 +462,29 @@ NetEConst* NetEBComp::eval_leeq_() /* Now go on to the normal test of the values. */ NetEConst*l = dynamic_cast(left_); if (l == 0) return 0; + verinum lv = l->value(); if (! lv.is_defined()) { - verinum result(verinum::Vx, 1); - return new NetEConst(result); + NetEConst*res = new NetEConst(verinum(verinum::Vx, 1)); + ivl_assert(*this, res); + return res; } if (lv <= rv) { - verinum result(verinum::V1, 1); - return new NetEConst(result); + NetEConst*res = new NetEConst(verinum(verinum::V1, 1)); + ivl_assert(*this, res); + return res; } else { - verinum result(verinum::V0, 1); - return new NetEConst(result); + NetEConst*res = new NetEConst(verinum(verinum::V0, 1)); + ivl_assert(*this, res); + return res; } } NetEConst* NetEBComp::eval_gt_() { - if (right_->expr_type() == IVL_VT_REAL) - return eval_leeq_real_(right_, left_, false); - if (left_->expr_type() == IVL_VT_REAL) + if (right_->expr_type() == IVL_VT_REAL || + left_->expr_type() == IVL_VT_REAL) return eval_leeq_real_(right_, left_, false); NetEConst*l = dynamic_cast(left_); @@ -495,8 +492,9 @@ NetEConst* NetEBComp::eval_gt_() verinum lv = l->value(); if (! lv.is_defined()) { - verinum result(verinum::Vx, 1); - return new NetEConst(result); + NetEConst*res = new NetEConst(verinum(verinum::Vx, 1)); + ivl_assert(*this, res); + return res; } if (NetEConst*tmp = must_be_leeq_(right_, lv, false)) { @@ -506,26 +504,29 @@ NetEConst* NetEBComp::eval_gt_() /* Now go on to the normal test of the values. */ NetEConst*r = dynamic_cast(right_); if (r == 0) return 0; + verinum rv = r->value(); if (! rv.is_defined()) { - verinum result(verinum::Vx, 1); - return new NetEConst(result); + NetEConst*res = new NetEConst(verinum(verinum::Vx, 1)); + ivl_assert(*this, res); + return res; } if (lv > rv) { - verinum result(verinum::V1, 1); - return new NetEConst(result); + NetEConst*res = new NetEConst(verinum(verinum::V1, 1)); + ivl_assert(*this, res); + return res; } else { - verinum result(verinum::V0, 1); - return new NetEConst(result); + NetEConst*res = new NetEConst(verinum(verinum::V0, 1)); + ivl_assert(*this, res); + return res; } } NetEConst* NetEBComp::eval_gteq_() { - if (right_->expr_type() == IVL_VT_REAL) - return eval_leeq_real_(right_, left_, true); - if (left_->expr_type() == IVL_VT_REAL) + if (right_->expr_type() == IVL_VT_REAL || + left_->expr_type() == IVL_VT_REAL) return eval_leeq_real_(right_, left_, true); NetEConst*l = dynamic_cast(left_); @@ -533,8 +534,9 @@ NetEConst* NetEBComp::eval_gteq_() verinum lv = l->value(); if (! lv.is_defined()) { - verinum result(verinum::Vx, 1); - return new NetEConst(result); + NetEConst*res = new NetEConst(verinum(verinum::Vx, 1)); + ivl_assert(*this, res); + return res; } if (NetEConst*tmp = must_be_leeq_(right_, lv, true)) { @@ -544,18 +546,22 @@ NetEConst* NetEBComp::eval_gteq_() /* Now go on to the normal test of the values. */ NetEConst*r = dynamic_cast(right_); if (r == 0) return 0; + verinum rv = r->value(); if (! rv.is_defined()) { - verinum result(verinum::Vx, 1); - return new NetEConst(result); + NetEConst*res = new NetEConst(verinum(verinum::Vx, 1)); + ivl_assert(*this, res); + return res; } if (lv >= rv) { - verinum result(verinum::V1, 1); - return new NetEConst(result); + NetEConst*res = new NetEConst(verinum(verinum::V1, 1)); + ivl_assert(*this, res); + return res; } else { - verinum result(verinum::V0, 1); - return new NetEConst(result); + NetEConst*res = new NetEConst(verinum(verinum::V0, 1)); + ivl_assert(*this, res); + return res; } } @@ -566,75 +572,34 @@ NetEConst* NetEBComp::eval_gteq_() * are equal, but there are are x/z bits, then the situation is * ambiguous so the result is x. */ -NetEConst* NetEBComp::eval_eqeq_real_(NetExpr*le, NetExpr*ri, bool ne_flag) +NetEConst* NetEBComp::eval_eqeq_real_(bool ne_flag) { - NetEConst*vtmp; - NetECReal*rtmp; - double lv, rv; + verireal lval; + verireal rval; - switch (le->expr_type()) { - case IVL_VT_REAL: - rtmp = dynamic_cast (le); - if (rtmp == 0) return 0; - lv = rtmp->value().as_double(); - break; + bool flag = get_real_arguments_(lval, rval); + if (! flag) return 0; - case IVL_VT_LOGIC: - case IVL_VT_BOOL: - vtmp = dynamic_cast (le); - if (vtmp == 0) return 0; - lv = vtmp->value().as_double(); - break; + verinum result(((lval.as_double() == rval.as_double()) ^ ne_flag) ? + verinum::V1 : verinum::V0, 1); + NetEConst*res = new NetEConst(result); + ivl_assert(*this, res); - default: - lv = 0.0; - cerr << get_fileline() << ": internal error: " - << "Unexpected expression type? " << le->expr_type() << endl; - assert(0); - } - - switch (ri->expr_type()) { - case IVL_VT_REAL: - rtmp = dynamic_cast (ri); - if (rtmp == 0) return 0; - rv = rtmp->value().as_double(); - break; - - case IVL_VT_LOGIC: - case IVL_VT_BOOL: - vtmp = dynamic_cast (ri); - if (vtmp == 0) return 0; - rv = vtmp->value().as_double(); - break; - - default: - rv = 0.0; - cerr << get_fileline() << ": internal error: " - << "Unexpected expression type? " << ri->expr_type() << endl; - assert(0); - } - - verinum result(((lv == rv) ^ ne_flag) ? verinum::V1 : verinum::V0, 1); - vtmp = new NetEConst(result); - vtmp->set_line(*this); - - return vtmp; + return res; } NetEConst* NetEBComp::eval_eqeq_(bool ne_flag) { - if (right_->expr_type() == IVL_VT_REAL) - return eval_eqeq_real_(right_, left_, ne_flag); - if (left_->expr_type() == IVL_VT_REAL) - return eval_eqeq_real_(right_, left_, ne_flag); + if (left_->expr_type() == IVL_VT_REAL || + right_->expr_type() == IVL_VT_REAL) + return eval_eqeq_real_(ne_flag); - NetEConst*l = dynamic_cast(left_); - if (l == 0) return 0; - NetEConst*r = dynamic_cast(right_); - if (r == 0) return 0; + NetEConst*lc = dynamic_cast(left_); + NetEConst*rc = dynamic_cast(right_); + if (lc == 0 || rc == 0) return 0; - const verinum&lv = l->value(); - const verinum&rv = r->value(); + const verinum&lv = lc->value(); + const verinum&rv = rc->value(); const verinum::V eq_res = ne_flag? verinum::V0 : verinum::V1; const verinum::V ne_res = ne_flag? verinum::V1 : verinum::V0; @@ -735,91 +700,119 @@ NetEConst* NetEBComp::eval_eqeq_(bool ne_flag) } } - return new NetEConst(verinum(res)); + NetEConst*result = new NetEConst(verinum(res, 1)); + ivl_assert(*this, result); + return result; } -NetEConst* NetEBComp::eval_eqeqeq_() +NetEConst* NetEBComp::eval_eqeqeq_(bool ne_flag) { - NetEConst*l = dynamic_cast(left_); - if (l == 0) return 0; - NetEConst*r = dynamic_cast(right_); - if (r == 0) return 0; + NetEConst*lc = dynamic_cast(left_); + NetEConst*rc = dynamic_cast(right_); + if (lc == 0 || rc == 0) return 0; - const verinum&lv = l->value(); - const verinum&rv = r->value(); + const verinum&lv = lc->value(); + const verinum&rv = rc->value(); verinum::V res = verinum::V1; + // Find the smallest argument length. unsigned cnt = lv.len(); - if (cnt > rv.len()) - cnt = rv.len(); + if (cnt > rv.len()) cnt = rv.len(); + // Check the common bits. for (unsigned idx = 0 ; idx < cnt ; idx += 1) - if (lv.get(idx) != rv.get(idx)) + if (lv.get(idx) != rv.get(idx)) { res = verinum::V0; + break; + } - for (unsigned idx = cnt ; idx < lv.len() ; idx += 1) - if (lv.get(idx) != verinum::V0) - res = verinum::V0; + bool is_signed = lv.has_sign() && rv.has_sign(); - for (unsigned idx = cnt ; idx < rv.len() ; idx += 1) - if (rv.get(idx) != verinum::V0) - res = verinum::V0; + // If the left value is longer check it against the pad bit. + if (res == verinum::V1) { + verinum::V pad = verinum::V0; + if (is_signed) pad = rv.get(rv.len()-1); + for (unsigned idx = cnt ; idx < lv.len() ; idx += 1) + if (lv.get(idx) != pad) { + res = verinum::V0; + break; + } + } - return new NetEConst(verinum(res, 1)); + // If the right value is longer check it against the pad bit. + if (res == verinum::V1) { + verinum::V pad = verinum::V0; + if (is_signed) pad = lv.get(lv.len()-1); + for (unsigned idx = cnt ; idx < rv.len() ; idx += 1) { + if (rv.get(idx) != pad) + res = verinum::V0; + break; + } + } + + if (ne_flag) { + if (res == verinum::V0) res = verinum::V1; + else res = verinum::V0; + } + + NetEConst*result = new NetEConst(verinum(res, 1)); + ivl_assert(*this, result); + return result; } -NetEConst* NetEBComp::eval_neeqeq_() -{ - NetEConst*tmp = eval_eqeqeq_(); - if (tmp == 0) - return 0; - - NetEConst*res; - - if (tmp->value().get(0) == verinum::V0) - res = new NetEConst(verinum(verinum::V1,1)); - else - res = new NetEConst(verinum(verinum::V0,1)); - - delete tmp; - res->set_line(*this); - return res; -} - -NetEConst* NetEBComp::eval_tree(int prune_to_width) +NetEConst* NetEBComp::eval_tree(int) { eval_expr(left_); eval_expr(right_); + NetEConst*res = 0; + switch (op_) { case 'E': // Case equality (===) - return eval_eqeqeq_(); + res = eval_eqeqeq_(false); + break; case 'e': // Equality (==) - return eval_eqeq_(false); + res = eval_eqeq_(false); + break; case 'G': // >= - return eval_gteq_(); + res = eval_gteq_(); + break; case 'L': // <= - return eval_leeq_(); + res = eval_leeq_(); + break; case 'N': // Case inequality (!==) - return eval_neeqeq_(); + res = eval_eqeqeq_(true); + break; case 'n': // not-equal (!=) - return eval_eqeq_(true); + res = eval_eqeq_(true); + break; case '<': // Less than - return eval_less_(); + res = eval_less_(); + break; case '>': // Greater than - return eval_gt_(); + res = eval_gt_(); + break; - default: - return 0; } + if (res == 0) return 0; + res->set_line(*this); + + if (debug_eval_tree) { + cerr << get_fileline() << ": debug: Evaluated"; + if (left_->expr_type() == IVL_VT_REAL || + right_->expr_type() == IVL_VT_REAL) + cerr << " (real)"; + cerr << ": " << *this << " --> " << *res << endl; + } + return res; } NetExpr* NetEBDiv::eval_tree_real_() @@ -845,6 +838,11 @@ NetExpr* NetEBDiv::eval_tree_real_() } ivl_assert(*this, res); res->set_line(*this); + + if (debug_eval_tree) + cerr << get_fileline() << ": debug: Evaluated (real): " << *this + << " --> " << *res << endl; + return res; } @@ -854,11 +852,13 @@ NetExpr* NetEBDiv::eval_tree_real_() */ NetExpr* NetEBDiv::eval_tree(int prune_to_width) { +// assert(prune_to_width <= 0); +// HERE + eval_expr(left_); eval_expr(right_); if (expr_type() == IVL_VT_REAL) return eval_tree_real_(); - assert(expr_type() == IVL_VT_LOGIC); NetEConst*lc = dynamic_cast(left_); @@ -881,14 +881,63 @@ NetExpr* NetEBDiv::eval_tree(int prune_to_width) } ivl_assert(*this, tmp); tmp->set_line(*this); + + if (debug_eval_tree) + cerr << get_fileline() << ": debug: Evaluated: " << *this + << " --> " << *tmp << endl; + return tmp; } -NetEConst* NetEBLogic::eval_tree(int prune_to_width) +NetEConst* NetEBLogic::eval_tree_real_() +{ + verireal lval; + verireal rval; + + bool flag = get_real_arguments_(lval, rval); + if (! flag) return 0; + + verinum::V res; + switch (op_) { + case 'a': // Logical AND (&&) + if ((lval.as_double() != 0.0) && (rval.as_double() != 0.0)) + res = verinum::V1; + else + res = verinum::V0; + break; + + case 'o': // Logical OR (||) + if ((lval.as_double() != 0.0) || (rval.as_double() != 0.0)) + res = verinum::V1; + else + res = verinum::V0; + break; + + default: + return 0; + } + + NetEConst*tmp = new NetEConst(verinum(res, 1)); + ivl_assert(*this, tmp); + tmp->set_line(*this); + + if (debug_eval_tree) + cerr << get_fileline() << ": debug: Evaluated (real): " << *this + << " --> " << *tmp << endl; + + return tmp; +} + +NetEConst* NetEBLogic::eval_tree(int) { eval_expr(left_); eval_expr(right_); + if (left_->expr_type() == IVL_VT_REAL || + right_->expr_type() == IVL_VT_REAL) + return eval_tree_real_(); + assert(expr_type() == IVL_VT_LOGIC); + NetEConst*lc = dynamic_cast(left_); NetEConst*rc = dynamic_cast(right_); if (lc == 0 || rc == 0) return 0; @@ -898,57 +947,61 @@ NetEConst* NetEBLogic::eval_tree(int prune_to_width) verinum v = lc->value(); for (unsigned idx = 0 ; idx < v.len() ; idx += 1) - if (v.get(idx) == verinum::V1) + if (v.get(idx) == verinum::V1) { lv = verinum::V1; + break; + } - if (lv == verinum::V0) - for (unsigned idx = 0 ; idx < v.len() ; idx += 1) - if (v.get(idx) != verinum::V0) - lv = verinum::Vx; + if (lv == verinum::V0 && ! v.is_defined()) lv = verinum::Vx; v = rc->value(); for (unsigned idx = 0 ; idx < v.len() ; idx += 1) - if (v.get(idx) == verinum::V1) + if (v.get(idx) == verinum::V1) { rv = verinum::V1; + break; + } - if (rv == verinum::V0) - for (unsigned idx = 0 ; idx < v.len() ; idx += 1) - if (v.get(idx) != verinum::V0) - rv = verinum::Vx; + if (rv == verinum::V0 && ! v.is_defined()) rv = verinum::Vx; verinum::V res; switch (op_) { - case 'a': { // Logical AND (&&) - if ((lv == verinum::V0) || (rv == verinum::V0)) - res = verinum::V0; + case 'a': // Logical AND (&&) + if ((lv == verinum::V0) || (rv == verinum::V0)) + res = verinum::V0; - else if ((lv == verinum::V1) && (rv == verinum::V1)) - res = verinum::V1; + else if ((lv == verinum::V1) && (rv == verinum::V1)) + res = verinum::V1; - else - res = verinum::Vx; + else + res = verinum::Vx; - break; - } + break; - case 'o': { // Logical OR (||) - if ((lv == verinum::V1) || (rv == verinum::V1)) - res = verinum::V1; + case 'o': // Logical OR (||) + if ((lv == verinum::V1) || (rv == verinum::V1)) + res = verinum::V1; - else if ((lv == verinum::V0) && (rv == verinum::V0)) - res = verinum::V0; + else if ((lv == verinum::V0) && (rv == verinum::V0)) + res = verinum::V0; - else - res = verinum::Vx; + else + res = verinum::Vx; - break; - } + break; default: return 0; } - return new NetEConst(verinum(res, 1)); + NetEConst*tmp = new NetEConst(verinum(res, 1)); + ivl_assert(*this, tmp); + tmp->set_line(*this); + + if (debug_eval_tree) + cerr << get_fileline() << ": debug: Evaluated: " << *this + << " --> " << *tmp << endl; + + return tmp; } @@ -961,17 +1014,25 @@ NetExpr* NetEBMult::eval_tree_real_() if (! flag) return 0; NetECReal*res = new NetECReal(lval * rval); + ivl_assert(*this, res); res->set_line(*this); + + if (debug_eval_tree) + cerr << get_fileline() << ": debug: Evaluated (real): " << *this + << " --> " << *res << endl; + return res; } NetExpr* NetEBMult::eval_tree(int prune_to_width) { +// assert(prune_to_width <= 0); +// HERE + eval_expr(left_); eval_expr(right_); if (expr_type() == IVL_VT_REAL) return eval_tree_real_(); - assert(expr_type() == IVL_VT_LOGIC); NetEConst*lc = dynamic_cast(left_); @@ -982,10 +1043,12 @@ NetExpr* NetEBMult::eval_tree(int prune_to_width) verinum rval = rc->value(); NetEConst*tmp = new NetEConst(lval * rval); + ivl_assert(*this, tmp); + tmp->set_line(*this); if (debug_eval_tree) - cerr << get_fileline() << ": debug: Evaluate " - << lval << " * " << rval << " --> " << *tmp << endl; + cerr << get_fileline() << ": debug: Evaluated: " << *this + << " --> " << *tmp << endl; return tmp; } @@ -999,23 +1062,25 @@ NetExpr* NetEBPow::eval_tree_real_() if (! flag) return 0; NetECReal*res = new NetECReal( pow(lval,rval) ); + ivl_assert(*this, res); res->set_line(*this); if (debug_eval_tree) - cerr << get_fileline() << ": debug: Evaluate (real) " - << lval << " ** " << rval << " --> " << *res << endl; + cerr << get_fileline() << ": debug: Evaluated (real): " << *this + << " --> " << *res << endl; return res; } NetExpr* NetEBPow::eval_tree(int prune_to_width) { +// assert(prune_to_width <= 0); +// HERE + eval_expr(left_); eval_expr(right_); - if (expr_type() == IVL_VT_REAL) - return eval_tree_real_(); - + if (expr_type() == IVL_VT_REAL) return eval_tree_real_(); assert(expr_type() == IVL_VT_LOGIC); NetEConst*lc = dynamic_cast(left_); @@ -1026,11 +1091,12 @@ NetExpr* NetEBPow::eval_tree(int prune_to_width) verinum rval = rc->value(); NetEConst*res = new NetEConst( pow(lval,rval) ); + ivl_assert(*this, res); res->set_line(*this); if (debug_eval_tree) - cerr << get_fileline() << ": debug: Evaluate " - << lval << " ** " << rval << " --> " << *res << endl; + cerr << get_fileline() << ": debug: Evaluated: " << *this + << " --> " << *res << endl; return res; } @@ -1081,7 +1147,7 @@ NetEConst* NetEBShift::eval_tree(int prune_to_width) if (prune_to_width > 0 && wid > (unsigned)prune_to_width) wid = prune_to_width; - assert(wid); + assert(wid > 0); verinum::V pad = verinum::V0; if (op() == 'R' && has_sign()) { pad = lv[lv.len()-1]; @@ -1117,21 +1183,28 @@ NetEConst* NetEBShift::eval_tree(int prune_to_width) } else { if (wid == 0) wid = left_->expr_width(); + if (prune_to_width > 0 && wid > (unsigned)prune_to_width) + wid = prune_to_width; + + assert(wid > 0); verinum nv (verinum::Vx, wid); res = new NetEConst(nv); } + res->set_line(*this); + return res; } NetEConst* NetEConcat::eval_tree(int prune_to_width) { +// HERE unsigned repeat_val = repeat(); unsigned local_errors = 0; if (debug_eval_tree) { - cerr << get_fileline() << ": debug: Evaluate expr=" << *this - << ", prune_to_width=" << prune_to_width << endl; + cerr << get_fileline() << ": debug: Evaluating expression:" + << *this << ", prune_to_width=" << prune_to_width << endl; } unsigned gap = 0; @@ -1218,16 +1291,18 @@ NetEConst* NetEConcat::eval_tree(int prune_to_width) NetExpr* NetEParam::eval_tree(int prune_to_width) { +// HERE if (des_ == 0) { assert(scope_ == 0); return 0; } if (debug_eval_tree) { - cerr << get_fileline() << ": debug: evaluating expression: " - << *this << endl; + cerr << get_fileline() << ": debug: Evaluating expression:" + << *this << ", prune_to_width=" << prune_to_width << endl; } + if (solving()) { cerr << get_fileline() << ": warning: Recursive parameter " "reference found involving " << *this << "." << endl; @@ -1336,6 +1411,12 @@ NetExpr* NetEParam::eval_tree(int prune_to_width) NetEConst* NetESelect::eval_tree(int prune_to_width) { +// HERE + if (debug_eval_tree) { + cerr << get_fileline() << ": debug: Evaluating expression:" + << *this << ", prune_to_width=" << prune_to_width << endl; + } + eval_expr(expr_); NetEConst*expr = dynamic_cast(expr_); @@ -1409,7 +1490,7 @@ NetExpr* NetETernary::eval_tree(int prune_to_width) eval_expr(cond_); switch (const_logical(cond_)) { case C_0: - eval_expr(false_val_); + eval_expr(false_val_, prune_to_width); if (debug_eval_tree) { cerr << get_fileline() << ": debug: Evaluate ternary with " @@ -1432,7 +1513,7 @@ NetExpr* NetETernary::eval_tree(int prune_to_width) return false_val_->dup_expr(); case C_1: - eval_expr(true_val_); + eval_expr(true_val_, prune_to_width); if (debug_eval_tree) { cerr << get_fileline() << ": debug: Evaluate ternary with " << "constant condition value: "; @@ -1464,8 +1545,8 @@ NetExpr* NetETernary::eval_tree(int prune_to_width) expressions down to constants then compare the values to build up a constant result. */ - eval_expr(true_val_); - eval_expr(false_val_); + eval_expr(true_val_, prune_to_width); + eval_expr(false_val_, prune_to_width); NetEConst*t = dynamic_cast(true_val_); NetEConst*f = dynamic_cast(false_val_); @@ -1527,17 +1608,25 @@ NetExpr* NetEUnary::eval_tree_real_() switch (op_) { case '+': res = new NetECReal(val->value()); - res->set_line(*this); - return res; + ivl_assert(*this, res); + break; case '-': res = new NetECReal(-(val->value())); - res->set_line(*this); - return res; + ivl_assert(*this, res); + break; default: return 0; } + + res->set_line(*this); + + if (debug_eval_tree) + cerr << get_fileline() << ": debug: Evaluated (real): " << *this + << " --> " << *res << endl; + + return res; } NetExpr* NetEUnary::eval_tree(int prune_to_width) @@ -1554,47 +1643,52 @@ NetExpr* NetEUnary::eval_tree(int prune_to_width) case '+': /* Unary + is a no-op. */ - return new NetEConst(val); + break; - case '-': { - if (val.is_defined()) { + case '-': + if (val.is_defined()) { + verinum tmp (verinum::V0, val.len()); + tmp.has_sign(val.has_sign()); + val = tmp - val; + } else { + for (unsigned idx = 0 ; idx < val.len() ; idx += 1) + val.set(idx, verinum::Vx); + } + break; - verinum tmp (verinum::V0, val.len()); - tmp.has_sign(val.has_sign()); - val = tmp - val; + case '~': + /* Bitwise not is even simpler then logical + not. Just invert all the bits of the operand and + make the new value with the same dimensions. */ + for (unsigned idx = 0 ; idx < val.len() ; idx += 1) + switch (val.get(idx)) { + case verinum::V0: + val.set(idx, verinum::V1); + break; + case verinum::V1: + val.set(idx, verinum::V0); + break; + default: + val.set(idx, verinum::Vx); + } - } else { - for (unsigned idx = 0 ; idx < val.len() ; idx += 1) - val.set(idx, verinum::Vx); - } - - return new NetEConst(val); - } - - case '~': { - /* Bitwise not is even simpler then logical - not. Just invert all the bits of the operand and - make the new value with the same dimensions. */ - for (unsigned idx = 0 ; idx < val.len() ; idx += 1) - switch (val.get(idx)) { - case verinum::V0: - val.set(idx, verinum::V1); - break; - case verinum::V1: - val.set(idx, verinum::V0); - break; - default: - val.set(idx, verinum::Vx); - } - - return new NetEConst(val); - } + break; case '!': assert(0); default: return 0; } + + NetEConst *res = new NetEConst(val); + ivl_assert(*this, res); + res->set_line(*this); + + if (debug_eval_tree) + cerr << get_fileline() << ": debug: Evaluated: " << *this + << " --> " << *res << endl; + + return res; } @@ -1603,13 +1697,37 @@ NetExpr* NetEUBits::eval_tree(int prune_to_width) return NetEUnary::eval_tree(prune_to_width); } -NetEConst* NetEUReduce::eval_tree(int prune_to_width) +NetEConst* NetEUReduce::eval_tree_real_() +{ + ivl_assert(*this, op_ == '!'); + + NetECReal*val= dynamic_cast (expr_); + if (val == 0) return 0; + + verinum::V res = val->value().as_double() == 0.0 ? verinum::V1 : + verinum::V0; + + NetEConst*tmp = new NetEConst(verinum(res, 1)); + ivl_assert(*this, tmp); + tmp->set_line(*this); + + if (debug_eval_tree) + cerr << get_fileline() << ": debug: Evaluated (real): " << *this + << " --> " << *tmp << endl; + + return tmp; +} + +NetEConst* NetEUReduce::eval_tree(int) { eval_expr(expr_); + if (expr_type() == IVL_VT_REAL) return eval_tree_real_(); + NetEConst*rval = dynamic_cast(expr_); if (rval == 0) return 0; verinum val = rval->value(); + verinum::V res; bool invert = false; @@ -1622,16 +1740,16 @@ NetEConst* NetEUReduce::eval_tree(int prune_to_width) the result of ! is V0. If there are no V1 bits but there are some Vx/Vz bits, the result is unknown. Otherwise, the result is V1. */ - unsigned v1 = 0, vx = 0; - for (unsigned idx = 0 ; idx < val.len() ; idx += 1) { + bool v1 = false, vx = false; + for (unsigned idx = 0 ; idx < val.len() && !v1 ; idx += 1) { switch (val.get(idx)) { case verinum::V0: break; case verinum::V1: - v1 += 1; + v1 = true; break; default: - vx += 1; + vx = true; break; } } @@ -1686,32 +1804,47 @@ NetEConst* NetEUReduce::eval_tree(int prune_to_width) } if (invert) res = ~res; - return new NetEConst(verinum(res, 1)); + + NetEConst*tmp = new NetEConst(verinum(res, 1)); + ivl_assert(*this, tmp); + tmp->set_line(*this); + + if (debug_eval_tree) + cerr << get_fileline() << ": debug: Evaluated: " << *this + << " --> " << *tmp << endl; + + return tmp; } -NetExpr* evaluate_clog2(NetExpr*&arg_) +static NetEConst* evaluate_clog2(NetExpr*&arg_) { eval_expr(arg_); + NetEConst*tmpi = dynamic_cast(arg_); NetECReal*tmpr = dynamic_cast(arg_); - if (tmpi || tmpr) { - verinum arg; - if (tmpi) { - arg = tmpi->value(); - } else { - arg = verinum(tmpr->value().as_double(), true); - } - /* If we have an x in the verinum we return 'bx. */ - if (!arg.is_defined()) { - verinum tmp (verinum::Vx, integer_width); - tmp.has_sign(true); - NetEConst*rtn = new NetEConst(tmp); - return rtn; - } + if (tmpi == 0 && tmpr == 0) return 0; + verinum arg; + if (tmpi) { + arg = tmpi->value(); + } else { + arg = verinum(tmpr->value().as_double(), true); + } + + NetEConst*rtn; + + /* If we have an x in the verinum we return 'bx. */ + if (!arg.is_defined()) { + verinum tmp (verinum::Vx, integer_width); + tmp.has_sign(true); + + rtn = new NetEConst(tmp); + ivl_assert(*arg_, rtn); + } else { bool is_neg = false; uint64_t res = 0; + if (arg.is_negative()) { is_neg = true; // If the length is not defined, then work with @@ -1734,18 +1867,23 @@ NetExpr* evaluate_clog2(NetExpr*&arg_) verinum tmp (res, integer_width); tmp.has_sign(true); - NetEConst*rtn = new NetEConst(tmp); - return rtn; + + rtn = new NetEConst(tmp); + ivl_assert(*arg_, rtn); } - return 0; + return rtn; } -NetExpr* evaluate_math_one_arg(NetExpr*&arg_, const char*name) +static NetECReal* evaluate_math_one_arg(NetExpr*&arg_, const char*name) { eval_expr(arg_); + NetEConst*tmpi = dynamic_cast(arg_); NetECReal*tmpr = dynamic_cast(arg_); + + NetECReal*res = 0; + if (tmpi || tmpr) { double arg; if (tmpi) { @@ -1755,55 +1893,81 @@ NetExpr* evaluate_math_one_arg(NetExpr*&arg_, const char*name) } if (strcmp(name, "$ln") == 0) { - return new NetECReal(verireal(log(arg))); + res = new NetECReal(verireal(log(arg))); + ivl_assert(*arg_, res); } else if (strcmp(name, "$log10") == 0) { - return new NetECReal(verireal(log10(arg))); + res = new NetECReal(verireal(log10(arg))); + ivl_assert(*arg_, res); } else if (strcmp(name, "$exp") == 0) { - return new NetECReal(verireal(exp(arg))); + res = new NetECReal(verireal(exp(arg))); + ivl_assert(*arg_, res); } else if (strcmp(name, "$sqrt") == 0) { - return new NetECReal(verireal(sqrt(arg))); + res = new NetECReal(verireal(sqrt(arg))); + ivl_assert(*arg_, res); } else if (strcmp(name, "$floor") == 0) { - return new NetECReal(verireal(floor(arg))); + res = new NetECReal(verireal(floor(arg))); + ivl_assert(*arg_, res); } else if (strcmp(name, "$ceil") == 0) { - return new NetECReal(verireal(ceil(arg))); + res = new NetECReal(verireal(ceil(arg))); + ivl_assert(*arg_, res); } else if (strcmp(name, "$sin") == 0) { - return new NetECReal(verireal(sin(arg))); + res = new NetECReal(verireal(sin(arg))); + ivl_assert(*arg_, res); } else if (strcmp(name, "$cos") == 0) { - return new NetECReal(verireal(cos(arg))); + res = new NetECReal(verireal(cos(arg))); + ivl_assert(*arg_, res); } else if (strcmp(name, "$tan") == 0) { - return new NetECReal(verireal(tan(arg))); + res = new NetECReal(verireal(tan(arg))); + ivl_assert(*arg_, res); } else if (strcmp(name, "$asin") == 0) { - return new NetECReal(verireal(asin(arg))); + res = new NetECReal(verireal(asin(arg))); + ivl_assert(*arg_, res); } else if (strcmp(name, "$acos") == 0) { - return new NetECReal(verireal(acos(arg))); + res = new NetECReal(verireal(acos(arg))); + ivl_assert(*arg_, res); } else if (strcmp(name, "$atan") == 0) { - return new NetECReal(verireal(atan(arg))); + res = new NetECReal(verireal(atan(arg))); + ivl_assert(*arg_, res); } else if (strcmp(name, "$sinh") == 0) { - return new NetECReal(verireal(sinh(arg))); + res = new NetECReal(verireal(sinh(arg))); + ivl_assert(*arg_, res); } else if (strcmp(name, "$cosh") == 0) { - return new NetECReal(verireal(cosh(arg))); + res = new NetECReal(verireal(cosh(arg))); + ivl_assert(*arg_, res); } else if (strcmp(name, "$tanh") == 0) { - return new NetECReal(verireal(tanh(arg))); + res = new NetECReal(verireal(tanh(arg))); + ivl_assert(*arg_, res); } else if (strcmp(name, "$asinh") == 0) { - return new NetECReal(verireal(asinh(arg))); + res = new NetECReal(verireal(asinh(arg))); + ivl_assert(*arg_, res); } else if (strcmp(name, "$acosh") == 0) { - return new NetECReal(verireal(acosh(arg))); + res = new NetECReal(verireal(acosh(arg))); + ivl_assert(*arg_, res); } else if (strcmp(name, "$atanh") == 0) { - return new NetECReal(verireal(atanh(arg))); + res = new NetECReal(verireal(atanh(arg))); + ivl_assert(*arg_, res); + } else { + cerr << arg_->get_fileline() << ": warning: Unhandled" + "constant system function " << name << "." << endl; } } - return 0; + return res; } -NetExpr* evaluate_math_two_args(NetExpr*&arg0_, NetExpr*&arg1_, const char*name) +static NetECReal* evaluate_math_two_args(NetExpr*&arg0_, NetExpr*&arg1_, + const char*name) { eval_expr(arg0_); eval_expr(arg1_); + NetEConst*tmpi0 = dynamic_cast(arg0_); NetECReal*tmpr0 = dynamic_cast(arg0_); NetEConst*tmpi1 = dynamic_cast(arg1_); NetECReal*tmpr1 = dynamic_cast(arg1_); + + NetECReal*res = 0; + if ((tmpi0 || tmpr0) && (tmpi1 || tmpr1)) { double arg0, arg1; if (tmpi0) { @@ -1818,57 +1982,73 @@ NetExpr* evaluate_math_two_args(NetExpr*&arg0_, NetExpr*&arg1_, const char*name) } if (strcmp(name, "$pow") == 0) { - return new NetECReal(verireal(pow(arg0, arg1))); + res = new NetECReal(verireal(pow(arg0, arg1))); + ivl_assert(*arg0_, res); } else if (strcmp(name, "$atan2") == 0) { - return new NetECReal(verireal(atan2(arg0, arg1))); + res = new NetECReal(verireal(atan2(arg0, arg1))); + ivl_assert(*arg0_, res); } else if (strcmp(name, "$hypot") == 0) { - return new NetECReal(verireal(hypot(arg0, arg1))); + res = new NetECReal(verireal(hypot(arg0, arg1))); + ivl_assert(*arg0_, res); + } else { + cerr << arg0_->get_fileline() << ": warning: Unhandled" + "constant system function " << name << "." << endl; } } - return 0; + return res; } -NetExpr* evaluate_abs(NetExpr*&arg_) +static NetExpr* evaluate_abs(NetExpr*&arg_) { eval_expr(arg_); + + NetExpr*res = 0; + NetEConst*tmpi = dynamic_cast(arg_); if (tmpi) { verinum arg = tmpi->value(); if (arg.is_negative()) { arg = v_not(arg) + verinum(1); } - return new NetEConst(arg); + res = new NetEConst(arg); + ivl_assert(*arg_, res); } NetECReal*tmpr = dynamic_cast(arg_); if (tmpr) { double arg = tmpr->value().as_double(); - return new NetECReal(verireal(fabs(arg))); + res = new NetECReal(verireal(fabs(arg))); + ivl_assert(*arg_, res); } - return 0; + return res; } -NetExpr* evaluate_min_max(NetExpr*&arg0_, NetExpr*&arg1_, const char*name) +static NetExpr* evaluate_min_max(NetExpr*&arg0_, NetExpr*&arg1_, + const char*name) { eval_expr(arg0_); eval_expr(arg1_); + NetEConst*tmpi0 = dynamic_cast(arg0_); NetECReal*tmpr0 = dynamic_cast(arg0_); NetEConst*tmpi1 = dynamic_cast(arg1_); NetECReal*tmpr1 = dynamic_cast(arg1_); + + NetExpr*res = 0; + if (tmpi0 && tmpi1) { verinum arg0 = tmpi0->value(); verinum arg1 = tmpi1->value(); if (strcmp(name, "$min") == 0) { - return new NetEConst( arg0 < arg1 ? arg0 : arg1); + res = new NetEConst( arg0 < arg1 ? arg0 : arg1); + ivl_assert(*arg0_, res); } else if (strcmp(name, "$max") == 0) { - return new NetEConst( arg0 < arg1 ? arg1 : arg0); + res = new NetEConst( arg0 < arg1 ? arg1 : arg0); + ivl_assert(*arg0_, res); } - } - - if ((tmpi0 || tmpr0) && (tmpi1 || tmpr1)) { + } else if ((tmpi0 || tmpr0) && (tmpi1 || tmpr1)) { double arg0, arg1; if (tmpi0) { arg0 = tmpi0->value().as_double(); @@ -1881,17 +2061,24 @@ NetExpr* evaluate_min_max(NetExpr*&arg0_, NetExpr*&arg1_, const char*name) arg1 = tmpr1->value().as_double(); } if (strcmp(name, "$min") == 0) { - return new NetECReal(verireal(arg0 < arg1 ? arg0 : arg1)); + res = new NetECReal(verireal(arg0 < arg1 ? arg0 : arg1)); + ivl_assert(*arg0_, res); } else if (strcmp(name, "$max") == 0) { - return new NetECReal(verireal(arg0 < arg1 ? arg1 : arg0)); + res = new NetECReal(verireal(arg0 < arg1 ? arg1 : arg0)); + ivl_assert(*arg0_, res); + } else { + cerr << arg0_->get_fileline() << ": warning: Unhandled" + "constant system function " << name << "." << endl; } } - return 0; + return res; } NetExpr* NetESFunc::eval_tree(int prune_to_width) { +// assert(prune_to_width <= 0); +// HERE /* If we are not targeting at least Verilog-2005, Verilog-AMS * or using the Icarus misc flag then we do not support these * functions as constant. */ @@ -1980,16 +2167,16 @@ NetExpr* NetESFunc::eval_tree(int prune_to_width) if (rtn != 0) { rtn->set_line(*this); - if (debug_eval_tree) { - cerr << get_fileline() << ": debug: Evaluate constant " - << nm << "." << endl; - } + + if (debug_eval_tree) + cerr << get_fileline() << ": debug: Evaluated: " << *this + << " --> " << *rtn << endl; } return rtn; } -NetExpr* NetEUFunc::eval_tree(int prune_to_width) +NetExpr* NetEUFunc::eval_tree(int) { if (need_constant_expr) { cerr << get_fileline() << ": sorry: constant user " diff --git a/expr_synth.cc b/expr_synth.cc index 86f75e9fa..5e4d02894 100644 --- a/expr_synth.cc +++ b/expr_synth.cc @@ -39,8 +39,7 @@ static NetNet* convert_to_real_const(Design*des, NetScope*scope, NetEConst*expr) /* Note that lsig, rsig and real_args are references. */ static bool process_binary_args(Design*des, NetScope*scope, NetExpr*root, NetExpr*left, NetExpr*right, - NetNet*&lsig, NetNet*&rsig, bool&real_args, - NetExpr*obj) + NetNet*&lsig, NetNet*&rsig, bool&real_args) { if (left->expr_type() == IVL_VT_REAL || right->expr_type() == IVL_VT_REAL) { @@ -77,7 +76,7 @@ static bool process_binary_args(Design*des, NetScope*scope, NetExpr*root, else return false; } -NetNet* NetExpr::synthesize(Design*des, NetScope*scope, NetExpr*root) +NetNet* NetExpr::synthesize(Design*des, NetScope*, NetExpr*) { cerr << get_fileline() << ": internal error: cannot synthesize expression: " << *this << endl; @@ -95,7 +94,7 @@ NetNet* NetEBAdd::synthesize(Design*des, NetScope*scope, NetExpr*root) NetNet *lsig=0, *rsig=0; bool real_args=false; if (process_binary_args(des, scope, root, left_, right_, lsig, rsig, - real_args, this)) { + real_args)) { return 0; } @@ -221,7 +220,7 @@ NetNet* NetEBComp::synthesize(Design*des, NetScope*scope, NetExpr*root) unsigned width; bool real_args=false; if (process_binary_args(des, scope, root, left_, right_, lsig, rsig, - real_args, this)) { + real_args)) { return 0; } @@ -370,7 +369,7 @@ NetNet* NetEBPow::synthesize(Design*des, NetScope*scope, NetExpr*root) unsigned width; bool real_args=false; if (process_binary_args(des, scope, root, left_, right_, lsig, rsig, - real_args, this)) { + real_args)) { return 0; } @@ -406,7 +405,7 @@ NetNet* NetEBMult::synthesize(Design*des, NetScope*scope, NetExpr*root) unsigned width; bool real_args=false; if (process_binary_args(des, scope, root, left_, right_, lsig, rsig, - real_args, this)) { + real_args)) { return 0; } @@ -443,7 +442,7 @@ NetNet* NetEBDiv::synthesize(Design*des, NetScope*scope, NetExpr*root) unsigned width; bool real_args=false; if (process_binary_args(des, scope, root, left_, right_, lsig, rsig, - real_args, this)) { + real_args)) { return 0; } diff --git a/functor.cc b/functor.cc index 4accea7c2..b9351c4ac 100644 --- a/functor.cc +++ b/functor.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 @@ -100,7 +100,7 @@ void functor_t::lpm_ureduce(class Design*, class NetUReduce*) void NetScope::run_functor(Design*des, functor_t*fun) { for (map::const_iterator cur = children_.begin() - ; cur != children_.end() ; cur ++) + ; cur != children_.end() ; ++ cur ) cur->second->run_functor(des, fun); for (NetEvent*cur = events_ ; cur ; /* */) { @@ -124,7 +124,7 @@ void Design::functor(functor_t*fun) { // Scan the scopes for (list::const_iterator scope = root_scopes_.begin(); - scope != root_scopes_.end(); scope++) + scope != root_scopes_.end(); ++ scope ) (*scope)->run_functor(this, fun); // apply to processes @@ -244,7 +244,7 @@ proc_match_t::~proc_match_t() { } -int NetProc::match_proc(proc_match_t*that) +int NetProc::match_proc(proc_match_t*) { return 0; } diff --git a/iverilog-vpi.sh b/iverilog-vpi.sh index d2cdfb440..c280733bd 100644 --- a/iverilog-vpi.sh +++ b/iverilog-vpi.sh @@ -22,6 +22,7 @@ CC="@IVCC@" CXX=@IVCXX@ CFLAGS="@PIC@ @IVCFLAGS@ -I@INCLUDEDIR@" +CXXFLAGS="@PIC@ @IVCXXFLAGS@ -I@INCLUDEDIR@" SUFFIX=@SUFFIX@ @@ -136,7 +137,7 @@ do obj=$base".o" echo "Compiling $src..." - $CXX -c -o $obj $DEFS $CFLAGS $INCOPT $src || compile_errors=`expr $compile_errors + 1` + $CXX -c -o $obj $DEFS $CXXFLAGS $INCOPT $src || compile_errors=`expr $compile_errors + 1` OBJ="$OBJ $obj" done diff --git a/ivl_assert.h b/ivl_assert.h index 1a1aa8a16..ebf473754 100644 --- a/ivl_assert.h +++ b/ivl_assert.h @@ -20,21 +20,16 @@ #ifndef __ivl_assert_h #define __ivl_assert_h -# include +# include #define ivl_assert(tok, expression) \ - do { \ - if (! (expression)) \ - __ivl_assert(#expression, tok, __FILE__, __LINE__); \ - } while(0) - -#define __ivl_assert(expression, tok, file, line) \ do { \ - cerr << (tok).get_fileline() << ": assert: " \ - << file << ":" << line \ - << ": failed assertion " << (expression) << endl; \ - abort(); \ - } while(0) - + if (! (expression)) { \ + cerr << (tok).get_fileline() << ": assert: " \ + << __FILE__ << ":" << __LINE__ \ + << ": failed assertion " << #expression << endl; \ + abort(); \ + } \ + } while (0) #endif diff --git a/ivlpp/lexor.lex b/ivlpp/lexor.lex index 3c1a630c2..fab69db65 100644 --- a/ivlpp/lexor.lex +++ b/ivlpp/lexor.lex @@ -20,7 +20,6 @@ # include "config.h" -# include "ivl_alloc.h" # include # include # include @@ -28,6 +27,7 @@ # include # include "globals.h" +# include "ivl_alloc.h" static void output_init(); #define YY_USER_INIT output_init() diff --git a/ivlpp/main.c b/ivlpp/main.c index 7e9a260a5..3b8d1857d 100644 --- a/ivlpp/main.c +++ b/ivlpp/main.c @@ -37,7 +37,6 @@ const char NOTICE[] = " 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.\n" ; -# include "ivl_alloc.h" # include # include # include @@ -47,6 +46,7 @@ const char NOTICE[] = # include #endif # include "globals.h" +# include "ivl_alloc.h" #if defined(__MINGW32__) && !defined(HAVE_GETOPT_H) extern int getopt(int argc, char*argv[], const char*fmt); diff --git a/lexor_keyword.gperf b/lexor_keyword.gperf index ff4169136..723c4b2af 100644 --- a/lexor_keyword.gperf +++ b/lexor_keyword.gperf @@ -1,3 +1,9 @@ +/* + * We need this to prevent -Wextra (-W) from complaining that the mask and + * tokenType values are not initialized for the empty table entries. + */ +%define initializer-suffix ,0,0 + %{ /* Command-line: gperf -o -i 1 -C -k 1-3,$ -L C -H keyword_hash -N check_identifier -tT lexor_keyword.gperf */ diff --git a/libveriuser/a_vcl.c b/libveriuser/a_vcl.c index 855a8bc2d..aa2c96df4 100644 --- a/libveriuser/a_vcl.c +++ b/libveriuser/a_vcl.c @@ -17,12 +17,12 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ -#include "ivl_alloc.h" #include #include #include #include "priv.h" #include +#include "ivl_alloc.h" /* * This is the structure of a record that I use locally to hold the diff --git a/libveriuser/veriusertfs.c b/libveriuser/veriusertfs.c index 7f16cfe4f..740b80fd2 100644 --- a/libveriuser/veriusertfs.c +++ b/libveriuser/veriusertfs.c @@ -23,7 +23,6 @@ * via VPI. This is extremely ugly, so don't look after eating dinner. */ -# include "ivl_alloc.h" # include # include # include @@ -32,6 +31,7 @@ # include "priv.h" # include "vpi_user.h" # include "veriuser.h" +# include "ivl_alloc.h" /* * local structure used to hold the persistent veriusertfs data diff --git a/libveriuser/workarea.c b/libveriuser/workarea.c index c42125881..4be46d70a 100644 --- a/libveriuser/workarea.c +++ b/libveriuser/workarea.c @@ -17,10 +17,10 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ -# include "ivl_alloc.h" # include # include # include +# include "ivl_alloc.h" /* * Keep a list of sys handle to work area bindings. diff --git a/load_module.cc b/load_module.cc index c5b32efd8..91d9241fb 100644 --- a/load_module.cc +++ b/load_module.cc @@ -21,7 +21,6 @@ # include "util.h" # include "parse_api.h" # include "compiler.h" -# include "ivl_alloc.h" # include # include # include @@ -31,6 +30,7 @@ # include # include # include +# include "ivl_alloc.h" /* * The module library items are maps of key names to file name within @@ -149,8 +149,7 @@ int build_library_index(const char*path, bool key_case_sensitive) char*key = 0; for (list::iterator suf = library_suff.begin() - ; suf != library_suff.end() - ; suf ++ ) { + ; suf != library_suff.end() ; ++ suf ) { const char*sufptr = *suf; unsigned sufsiz = strlen(sufptr); diff --git a/main.cc b/main.cc index 08ea09651..d584b1f7b 100644 --- a/main.cc +++ b/main.cc @@ -38,7 +38,6 @@ const char NOTICE[] = " 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.\n" ; -# include "ivl_alloc.h" # include # include # include @@ -89,6 +88,8 @@ static void signals_handler(int sig) } #endif +# include "ivl_alloc.h" + /* Count errors detected in flag processing. */ unsigned flag_errors = 0; @@ -734,7 +735,7 @@ static void EOC_cleanup(void) cleanup_sys_func_table(); for (list::iterator suf = library_suff.begin() ; - suf != library_suff.end() ; suf ++ ) { + suf != library_suff.end() ; ++ suf ) { free((void *)*suf); } library_suff.clear(); @@ -744,7 +745,7 @@ static void EOC_cleanup(void) free(depfile_name); for (map::iterator flg = flags.begin() ; - flg != flags.end() ; flg ++ ) { + flg != flags.end() ; ++ flg ) { free((void *)flg->second); } flags.clear(); @@ -941,24 +942,22 @@ int main(int argc, char*argv[]) ofstream out (pf_path); out << "PFORM DUMP NATURES:" << endl; for (map::iterator cur = natures.begin() - ; cur != natures.end() ; cur ++ ) { + ; cur != natures.end() ; ++ cur ) { pform_dump(out, (*cur).second); } out << "PFORM DUMP DISCIPLINES:" << endl; for (map::iterator cur = disciplines.begin() - ; cur != disciplines.end() ; cur ++ ) { + ; cur != disciplines.end() ; ++ cur ) { pform_dump(out, (*cur).second); } out << "PFORM DUMP MODULES:" << endl; for (map::iterator mod = pform_modules.begin() - ; mod != pform_modules.end() - ; mod ++ ) { + ; mod != pform_modules.end() ; ++ mod ) { pform_dump(out, (*mod).second); } out << "PFORM DUMP PRIMITIVES:" << endl; for (map::iterator idx = pform_primitives.begin() - ; idx != pform_primitives.end() - ; idx ++ ) { + ; idx != pform_primitives.end() ; ++ idx ) { (*idx).second->dump(out); } } @@ -977,14 +976,12 @@ int main(int argc, char*argv[]) if (verbose_flag) cout << "LOCATING TOP-LEVEL MODULES" << endl << " "; for (mod = pform_modules.begin() - ; mod != pform_modules.end() - ; mod++) { + ; mod != pform_modules.end() ; ++ mod ) { find_module_mention(mentioned_p, mod->second); } for (mod = pform_modules.begin() - ; mod != pform_modules.end() - ; mod++) { + ; mod != pform_modules.end() ; ++ mod ) { /* Don't choose library modules. */ if ((*mod).second->library_flag) @@ -1064,7 +1061,7 @@ int main(int argc, char*argv[]) /* Done with all the pform data. Delete the modules. */ for (map::iterator idx = pform_modules.begin() - ; idx != pform_modules.end() ; idx ++) { + ; idx != pform_modules.end() ; ++ idx ) { delete (*idx).second; (*idx).second = 0; @@ -1161,8 +1158,7 @@ int main(int argc, char*argv[]) map::const_iterator idx; for (idx = missing_modules.begin() - ; idx != missing_modules.end() - ; idx ++) + ; idx != missing_modules.end() ; ++ idx ) cerr << " " << (*idx).first << " referenced " << (*idx).second << " times."<< endl; @@ -1177,7 +1173,7 @@ static void find_module_mention(map&check_map, Module*mod) { list gates = mod->get_gates(); list::const_iterator gate; - for (gate = gates.begin(); gate != gates.end(); gate++) { + for (gate = gates.begin(); gate != gates.end(); ++ gate ) { PGModule*tmp = dynamic_cast(*gate); if (tmp) { // Note that this module has been instantiated @@ -1187,7 +1183,7 @@ static void find_module_mention(map&check_map, Module*mod) list::const_iterator cur; for (cur = mod->generate_schemes.begin() - ; cur != mod->generate_schemes.end() ; cur ++) { + ; cur != mod->generate_schemes.end() ; ++ cur ) { find_module_mention(check_map, *cur); } } @@ -1195,7 +1191,7 @@ static void find_module_mention(map&check_map, Module*mod) static void find_module_mention(map&check_map, PGenerate*schm) { list::const_iterator gate; - for (gate = schm->gates.begin(); gate != schm->gates.end(); gate++) { + for (gate = schm->gates.begin(); gate != schm->gates.end(); ++ gate ) { PGModule*tmp = dynamic_cast(*gate); if (tmp) { // Note that this module has been instantiated @@ -1205,7 +1201,7 @@ static void find_module_mention(map&check_map, PGenerate*schm) list::const_iterator cur; for (cur = schm->generate_schemes.begin() - ; cur != schm->generate_schemes.end() ; cur ++) { + ; cur != schm->generate_schemes.end() ; ++ cur ) { find_module_mention(check_map, *cur); } } diff --git a/net_design.cc b/net_design.cc index 055e620ed..8d575ed9c 100644 --- a/net_design.cc +++ b/net_design.cc @@ -138,7 +138,7 @@ NetScope* Design::find_scope(const std::list&path) const return 0; for (list::const_iterator scope = root_scopes_.begin() - ; scope != root_scopes_.end(); scope++) { + ; scope != root_scopes_.end(); ++ scope ) { NetScope*cur = *scope; if (path.front() != cur->fullname()) @@ -213,14 +213,14 @@ NetScope* Design::find_scope(NetScope*scope, const std::list&path, void Design::run_defparams() { for (list::const_iterator scope = root_scopes_.begin(); - scope != root_scopes_.end(); scope++) + scope != root_scopes_.end(); ++ scope ) (*scope)->run_defparams(this); } void NetScope::run_defparams(Design*des) { for (map::const_iterator cur = children_.begin() - ; cur != children_.end() ; cur ++) + ; cur != children_.end() ; ++ cur ) cur->second->run_defparams(des); while (! defparams.empty()) { @@ -312,7 +312,7 @@ void NetScope::run_defparams_later(Design*des) // All the scopes that this defparam set touched should have // their parameters re-evaluated. for (set::iterator cur = target_scopes.begin() - ; cur != target_scopes.end() ; cur ++ ) + ; cur != target_scopes.end() ; ++ cur ) (*cur)->evaluate_parameters(des); // If there are some scopes that still have missing scopes, @@ -326,7 +326,7 @@ void NetScope::run_defparams_later(Design*des) void Design::evaluate_parameters() { for (list::const_iterator scope = root_scopes_.begin(); - scope != root_scopes_.end(); scope++) + scope != root_scopes_.end(); ++ scope ) (*scope)->evaluate_parameters(this); } @@ -610,7 +610,7 @@ void NetScope::evaluate_parameter_real_(Design*des, param_ref_t cur) void NetScope::evaluate_parameters(Design*des) { for (map::const_iterator cur = children_.begin() - ; cur != children_.end() ; cur ++) + ; cur != children_.end() ; ++ cur ) cur->second->evaluate_parameters(des); if (debug_scopes) @@ -659,7 +659,7 @@ void NetScope::evaluate_parameters(Design*des) void Design::residual_defparams() { for (list::const_iterator scope = root_scopes_.begin(); - scope != root_scopes_.end(); scope++) + scope != root_scopes_.end(); ++ scope ) (*scope)->residual_defparams(this); } @@ -676,7 +676,7 @@ void NetScope::residual_defparams(Design*des) } for (map::const_iterator cur = children_.begin() - ; cur != children_.end() ; cur ++) + ; cur != children_.end() ; ++ cur ) cur->second->residual_defparams(des); } diff --git a/net_event.cc b/net_event.cc index f1d501cea..b3b200398 100644 --- a/net_event.cc +++ b/net_event.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000 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 @@ -138,7 +138,7 @@ void NetEvent::find_similar_event(list&event_list) probes_->find_similar_probes(first_probes); for (list::iterator idx = first_probes.begin() - ; idx != first_probes.end() ; idx ++) { + ; idx != first_probes.end() ; ++ idx ) { candidate_events.insert( (*idx)->event() ); } @@ -158,7 +158,7 @@ void NetEvent::find_similar_event(list&event_list) set candidate_tmp; for (list::iterator idx = similar_probes.begin() - ; idx != similar_probes.end() ; idx ++) { + ; idx != similar_probes.end() ; ++ idx ) { NetEvent*tmp = (*idx)->event(); if (candidate_events.find(tmp) != candidate_events.end()) @@ -178,7 +178,7 @@ void NetEvent::find_similar_event(list&event_list) for remaining compatibility details and save the survivors in the event_list that the caller passed. */ for (set::iterator idx = candidate_events.begin() - ; idx != candidate_events.end() ; idx ++) { + ; idx != candidate_events.end() ; ++ idx ) { NetEvent*tmp = *idx; @@ -459,4 +459,3 @@ NetProc* NetEvWait::statement() { return statement_; } - diff --git a/net_link.cc b/net_link.cc index f866bdc9b..2ed0588b1 100644 --- a/net_link.cc +++ b/net_link.cc @@ -22,12 +22,12 @@ # include # include "netlist.h" -# include "ivl_alloc.h" # include # include # include # include # include +# include "ivl_alloc.h" void Nexus::connect(Link&r) { diff --git a/net_nex_input.cc b/net_nex_input.cc index 0ca9edc4d..b7da06ba9 100644 --- a/net_nex_input.cc +++ b/net_nex_input.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002-2008 Stephen Williams (steve@icarus.com) + * Copyright (c) 2002-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 @@ -27,7 +27,7 @@ # include "netlist.h" # include "netmisc.h" -NexusSet* NetExpr::nex_input(bool rem_out) +NexusSet* NetExpr::nex_input(bool) { cerr << get_fileline() << ": internal error: nex_input not implemented: " @@ -35,7 +35,7 @@ NexusSet* NetExpr::nex_input(bool rem_out) return 0; } -NexusSet* NetProc::nex_input(bool rem_out) +NexusSet* NetProc::nex_input(bool) { cerr << get_fileline() << ": internal error: NetProc::nex_input not implemented" @@ -68,7 +68,7 @@ NexusSet* NetEConcat::nex_input(bool rem_out) return result; } -NexusSet* NetEAccess::nex_input(bool rem_out) +NexusSet* NetEAccess::nex_input(bool) { return new NexusSet; } @@ -76,12 +76,12 @@ NexusSet* NetEAccess::nex_input(bool rem_out) /* * A constant has not inputs, so always return an empty set. */ -NexusSet* NetEConst::nex_input(bool rem_out) +NexusSet* NetEConst::nex_input(bool) { return new NexusSet; } -NexusSet* NetECReal::nex_input(bool rem_out) +NexusSet* NetECReal::nex_input(bool) { return new NexusSet; } @@ -90,22 +90,22 @@ NexusSet* NetECReal::nex_input(bool rem_out) * A parameter by definition has no inputs. It represents a constant * value, even if that value is a constant expression. */ -NexusSet* NetEParam::nex_input(bool rem_out) +NexusSet* NetEParam::nex_input(bool) { return new NexusSet; } -NexusSet* NetEEvent::nex_input(bool rem_out) +NexusSet* NetEEvent::nex_input(bool) { return new NexusSet; } -NexusSet* NetENetenum::nex_input(bool rem_out) +NexusSet* NetENetenum::nex_input(bool) { return new NexusSet; } -NexusSet* NetEScope::nex_input(bool rem_out) +NexusSet* NetEScope::nex_input(bool) { return new NexusSet; } @@ -128,16 +128,23 @@ NexusSet* NetESelect::nex_input(bool rem_out) return result; } +/* + * The $fread, etc. system functions can have NULL arguments. + */ NexusSet* NetESFunc::nex_input(bool rem_out) { if (parms_.size() == 0) return new NexusSet; - NexusSet*result = parms_[0]->nex_input(rem_out); + NexusSet*result; + if (parms_[0]) result = parms_[0]->nex_input(rem_out); + else result = new NexusSet; for (unsigned idx = 1 ; idx < parms_.size() ; idx += 1) { - NexusSet*tmp = parms_[idx]->nex_input(rem_out); - result->add(*tmp); - delete tmp; + if (parms_[idx]) { + NexusSet*tmp = parms_[idx]->nex_input(rem_out); + result->add(*tmp); + delete tmp; + } } return result; } @@ -329,7 +336,7 @@ NexusSet* NetCase::nex_input(bool rem_out) return result; } -NexusSet* NetCAssign::nex_input(bool rem_out) +NexusSet* NetCAssign::nex_input(bool) { cerr << get_fileline() << ": internal warning: NetCAssign::nex_input()" << " not implemented." << endl; @@ -354,7 +361,7 @@ NexusSet* NetCondit::nex_input(bool rem_out) return result; } -NexusSet* NetForce::nex_input(bool rem_out) +NexusSet* NetForce::nex_input(bool) { cerr << get_fileline() << ": internal warning: NetForce::nex_input()" << " not implemented." << endl; @@ -392,16 +399,23 @@ NexusSet* NetRepeat::nex_input(bool rem_out) return result; } +/* + * The $display, etc. system tasks can have NULL arguments. + */ NexusSet* NetSTask::nex_input(bool rem_out) { if (parms_.count() == 0) return new NexusSet; - NexusSet*result = parms_[0]->nex_input(rem_out); + NexusSet*result; + if (parms_[0]) result = parms_[0]->nex_input(rem_out); + else result = new NexusSet; for (unsigned idx = 1 ; idx < parms_.count() ; idx += 1) { - NexusSet*tmp = parms_[idx]->nex_input(rem_out); - result->add(*tmp); - delete tmp; + if (parms_[idx]) { + NexusSet*tmp = parms_[idx]->nex_input(rem_out); + result->add(*tmp); + delete tmp; + } } return result; @@ -412,7 +426,7 @@ NexusSet* NetSTask::nex_input(bool rem_out) * parameters to consider, because the compiler already removed them * and converted them to blocking assignments. */ -NexusSet* NetUTask::nex_input(bool rem_out) +NexusSet* NetUTask::nex_input(bool) { return new NexusSet; } diff --git a/net_nex_output.cc b/net_nex_output.cc index e2d025784..35d3f4b52 100644 --- a/net_nex_output.cc +++ b/net_nex_output.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002-2007 Stephen Williams (steve@icarus.com) + * Copyright (c) 2002-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 @@ -26,7 +26,7 @@ # include "netlist.h" # include "netmisc.h" -void NetProc::nex_output(NexusSet&out) +void NetProc::nex_output(NexusSet&) { cerr << get_fileline() << ": internal error: NetProc::nex_output not implemented" @@ -108,7 +108,7 @@ void NetPDelay::nex_output(NexusSet&out) * all. This is OK because most system tasks are not synthesizable in * the first place. */ -void NetSTask::nex_output(NexusSet&out) +void NetSTask::nex_output(NexusSet&) { } @@ -117,7 +117,7 @@ void NetSTask::nex_output(NexusSet&out) * right, we should be listing as outputs all the output ports, but for * the purposes that this method is used, this will do for now. */ -void NetUTask::nex_output(NexusSet&out) +void NetUTask::nex_output(NexusSet&) { } diff --git a/net_tran.cc b/net_tran.cc index 43c643989..79d9c50f0 100644 --- a/net_tran.cc +++ b/net_tran.cc @@ -161,7 +161,7 @@ void join_island(NetPins*obj) // process, and thus they will join my island. This process // will recurse until all the connected branches join this island. for (list::iterator cur = uncommitted_neighbors.begin() - ; cur != uncommitted_neighbors.end() ; cur ++ ) { + ; cur != uncommitted_neighbors.end() ; ++ cur ) { join_island(*cur); } } diff --git a/netlist.h b/netlist.h index 039697c9b..2dfbc6c7f 100644 --- a/netlist.h +++ b/netlist.h @@ -3458,14 +3458,13 @@ class NetEBComp : public NetEBinary { NetEConst* must_be_leeq_(NetExpr*le, const verinum&rv, bool eq_flag); NetEConst*eval_eqeq_(bool ne_flag); - NetEConst*eval_eqeq_real_(NetExpr*le, NetExpr*ri, bool ne_flag); + NetEConst*eval_eqeq_real_(bool ne_flag); NetEConst*eval_less_(); NetEConst*eval_leeq_(); NetEConst*eval_leeq_real_(NetExpr*le, NetExpr*ri, bool eq_flag); NetEConst*eval_gt_(); NetEConst*eval_gteq_(); - NetEConst*eval_eqeqeq_(); - NetEConst*eval_neeqeq_(); + NetEConst*eval_eqeqeq_(bool ne_flag); }; /* @@ -3487,6 +3486,7 @@ class NetEBLogic : public NetEBinary { virtual NetNet* synthesize(Design*, NetScope*scope, NetExpr*root); private: + NetEConst* eval_tree_real_(); }; /* @@ -3910,6 +3910,9 @@ class NetEUReduce : public NetEUnary { virtual NetEUReduce* dup_expr() const; virtual NetEConst* eval_tree(int prune_to_width = -1); virtual ivl_variable_type_t expr_type() const; + + private: + virtual NetEConst* eval_tree_real_(); }; class NetECast : public NetEUnary { diff --git a/netmisc.cc b/netmisc.cc index 11d042f83..2e7fbe2b0 100644 --- a/netmisc.cc +++ b/netmisc.cc @@ -27,11 +27,14 @@ # include "compiler.h" # include "ivl_assert.h" +// This routines is not currently used! +#if 0 NetNet* add_to_net(Design*des, NetNet*sig, long val) { if (val == 0) return sig; -#if 0 + cerr << sig->get_fileline() << ": XXXX: Forgot how to implement add_to_net" << endl; + return 0; NetScope*scope = sig->scope(); unsigned long abs_val = (val >= 0)? val : (-val); unsigned width = sig->pin_count(); @@ -71,11 +74,8 @@ NetNet* add_to_net(Design*des, NetNet*sig, long val) des->add_node(val_c); return res; -#else - cerr << sig->get_fileline() << ": XXXX: Forgot how to implement add_to_net" << endl; - return 0; -#endif } +#endif NetNet* sub_net_from(Design*des, NetScope*scope, long val, NetNet*sig) { @@ -587,7 +587,7 @@ std::list eval_scope_path(Design*des, NetScope*scope, typedef pform_name_t::const_iterator pform_path_it; - for (pform_path_it cur = path.begin() ; cur != path.end(); cur++) { + for (pform_path_it cur = path.begin() ; cur != path.end(); ++ cur ) { const name_component_t&comp = *cur; res.push_back( eval_path_component(des,scope,comp) ); } @@ -665,7 +665,7 @@ const_bool const_logical(const NetExpr*expr) for (unsigned idx = 0; idx < cval.len(); idx += 1) { switch (cval.get(idx)) { case verinum::V1: - res = C_1; + return C_1; break; case verinum::V0: diff --git a/netmisc.h b/netmisc.h index 5c4ae014c..dd1768861 100644 --- a/netmisc.h +++ b/netmisc.h @@ -107,8 +107,12 @@ extern NetExpr*normalize_variable_array_base(NetExpr *base, long offset, * This function takes as input a NetNet signal and adds a constant * value to it. If the val is 0, then simply return sig. Otherwise, * return a new NetNet value that is the output of an addition. + * + * Not currently used. */ +#if 0 extern NetNet*add_to_net(Design*des, NetNet*sig, long val); +#endif extern NetNet*sub_net_from(Design*des, NetScope*scope, long val, NetNet*sig); /* diff --git a/nodangle.cc b/nodangle.cc index 68c2118ee..6e01d4aba 100644 --- a/nodangle.cc +++ b/nodangle.cc @@ -40,7 +40,7 @@ class nodangle_f : public functor_t { bool scomplete, ecomplete; }; -void nodangle_f::event(Design*des, NetEvent*ev) +void nodangle_f::event(Design*, NetEvent*ev) { if (ecomplete) return; @@ -113,7 +113,7 @@ void nodangle_f::event(Design*des, NetEvent*ev) list match; ev->find_similar_event(match); for (list::iterator idx = match.begin() - ; idx != match.end() ; idx ++) { + ; idx != match.end() ; ++ idx ) { NetEvent*tmp = *idx; assert(tmp != ev); @@ -122,7 +122,7 @@ void nodangle_f::event(Design*des, NetEvent*ev) } } -void nodangle_f::signal(Design*des, NetNet*sig) +void nodangle_f::signal(Design*, NetNet*sig) { if (scomplete) return; diff --git a/parse.y b/parse.y index d5b3e784d..1537db1dc 100644 --- a/parse.y +++ b/parse.y @@ -87,8 +87,8 @@ static unsigned args_after_notifier; * These are some common strength pairs that are used as defaults when * the user is not otherwise specific. */ -const static struct str_pair_t pull_strength = { IVL_DR_PULL, IVL_DR_PULL }; -const static struct str_pair_t str_strength = { IVL_DR_STRONG, IVL_DR_STRONG }; +static const struct str_pair_t pull_strength = { IVL_DR_PULL, IVL_DR_PULL }; +static const struct str_pair_t str_strength = { IVL_DR_STRONG, IVL_DR_STRONG }; static list >* make_port_list(char*id, PExpr*expr) { @@ -2457,12 +2457,12 @@ module_item | K_output var_type unsigned_signed_opt range_opt list_of_port_identifiers ';' { list >::const_iterator pp; list*tmp = new list; - for (pp = $5->begin(); pp != $5->end(); pp++) { + for (pp = $5->begin(); pp != $5->end(); ++ pp ) { tmp->push_back((*pp).first); } pform_makewire(@1, $4, $3, tmp, $2, NetNet::POUTPUT, IVL_VT_NO_TYPE, 0, SR_BOTH); - for (pp = $5->begin(); pp != $5->end(); pp++) { + for (pp = $5->begin(); pp != $5->end(); ++ pp ) { if ((*pp).second) { pform_make_reginit(@1, (*pp).first, (*pp).second); } diff --git a/pform.cc b/pform.cc index d95523c57..ae845b25a 100644 --- a/pform.cc +++ b/pform.cc @@ -28,7 +28,6 @@ # include "PGenerate.h" # include "PSpec.h" # include "discipline.h" -# include "ivl_alloc.h" # include # include # include @@ -39,6 +38,7 @@ # include # include "ivl_assert.h" +# include "ivl_alloc.h" map pform_modules; map pform_primitives; @@ -471,7 +471,7 @@ void pform_set_timescale(int unit, int prec, /* Look to see if we have any modules without a timescale. */ bool have_no_ts = false; map::iterator mod; - for (mod = pform_modules.begin(); mod != pform_modules.end(); mod++) { + for (mod = pform_modules.begin(); mod != pform_modules.end(); ++ mod ) { const Module*mp = (*mod).second; if (mp->time_from_timescale || mp->timescale_warn_done) continue; @@ -489,7 +489,7 @@ void pform_set_timescale(int unit, int prec, << endl; for (mod = pform_modules.begin() - ; mod != pform_modules.end() ; mod++) { + ; mod != pform_modules.end() ; ++ mod ) { Module*mp = (*mod).second; if (mp->time_from_timescale || mp->timescale_warn_done) continue; @@ -1100,8 +1100,7 @@ static void process_udp_table(PUdp*udp, list*table, svector output (table->size()); { unsigned idx = 0; for (list::iterator cur = table->begin() - ; cur != table->end() - ; cur ++, idx += 1) { + ; cur != table->end() ; ++ cur , idx += 1) { string tmp = *cur; /* Pull the input values from the string. */ @@ -1455,8 +1454,7 @@ void pform_set_net_range(list*names, assert((range == 0) || (range->size() == 2)); for (list::iterator cur = names->begin() - ; cur != names->end() - ; cur ++ ) { + ; cur != names->end() ; ++ cur ) { perm_string txt = *cur; pform_set_net_range(txt, range, signed_flag, dt, rt); } @@ -1489,7 +1487,7 @@ static void pform_make_event(perm_string name, const char*fn, unsigned ln) void pform_make_events(list*names, const char*fn, unsigned ln) { list::iterator cur; - for (cur = names->begin() ; cur != names->end() ; cur++) { + for (cur = names->begin() ; cur != names->end() ; ++ cur ) { perm_string txt = *cur; pform_make_event(txt, fn, ln); } @@ -1938,8 +1936,7 @@ void pform_makewire(const vlltype&li, PWSRType rt) { for (list::iterator cur = names->begin() - ; cur != names->end() - ; cur ++ ) { + ; cur != names->end() ; ++ cur ) { perm_string txt = *cur; pform_makewire(li, txt, type, pt, dt, attr); /* This has already been done for real variables. */ @@ -2074,7 +2071,7 @@ svector*pform_make_task_ports(NetNet::PortType pt, assert(names); svector*res = new svector(0); for (list::iterator cur = names->begin() - ; cur != names->end() ; cur ++ ) { + ; cur != names->end() ; ++ cur ) { perm_string name = *cur; @@ -2367,8 +2364,7 @@ void pform_set_port_type(const struct vlltype&li, NetNet::PortType pt) { for (list::iterator cur = names->begin() - ; cur != names->end() - ; cur ++ ) { + ; cur != names->end() ; ++ cur ) { perm_string txt = *cur; pform_set_port_type(txt, pt, li.text, li.first_line); pform_set_net_range(txt, range, signed_flag, IVL_VT_NO_TYPE, @@ -2393,8 +2389,7 @@ static void pform_set_reg_integer(perm_string name) void pform_set_reg_integer(list*names) { for (list::iterator cur = names->begin() - ; cur != names->end() - ; cur ++ ) { + ; cur != names->end() ; ++ cur ) { perm_string txt = *cur; pform_set_reg_integer(txt); } @@ -2414,8 +2409,7 @@ static void pform_set_reg_time(perm_string name) void pform_set_reg_time(list*names) { for (list::iterator cur = names->begin() - ; cur != names->end() - ; cur ++ ) { + ; cur != names->end() ; ++ cur ) { perm_string txt = *cur; pform_set_reg_time(txt); } @@ -2436,8 +2430,7 @@ static void pform_set_integer_2atom(uint64_t width, bool signed_flag, perm_strin void pform_set_integer_2atom(uint64_t width, bool signed_flag, list*names) { for (list::iterator cur = names->begin() - ; cur != names->end() - ; cur ++ ) { + ; cur != names->end() ; ++ cur ) { perm_string txt = *cur; pform_set_integer_2atom(width, signed_flag, txt); } @@ -2487,8 +2480,7 @@ svector* pform_make_udp_input_ports(list*names) unsigned idx = 0; for (list::iterator cur = names->begin() - ; cur != names->end() - ; cur ++ ) { + ; cur != names->end() ; ++ cur ) { perm_string txt = *cur; PWire*pp = new PWire(txt, NetNet::IMPLICIT, diff --git a/pform_disciplines.cc b/pform_disciplines.cc index c05ff1373..91f6193fe 100644 --- a/pform_disciplines.cc +++ b/pform_disciplines.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 @@ -188,7 +188,7 @@ void pform_attach_discipline(const struct vlltype&loc, ivl_discipline_t discipline, list*names) { for (list::iterator cur = names->begin() - ; cur != names->end() ; cur ++ ) { + ; cur != names->end() ; ++ cur ) { PWire* cur_net = pform_get_wire_in_scope(*cur); if (cur_net == 0) { diff --git a/pform_dump.cc b/pform_dump.cc index b2845d129..1e2eba4a6 100644 --- a/pform_dump.cc +++ b/pform_dump.cc @@ -89,7 +89,7 @@ ostream& operator<< (ostream&out, const name_component_t&that) typedef std::list::const_iterator index_it_t; for (index_it_t idx = that.index.begin() - ; idx != that.index.end() ; idx++) { + ; idx != that.index.end() ; ++ idx ) { out << *idx; } @@ -103,10 +103,10 @@ ostream& operator<< (ostream&o, const pform_name_t&that) cur = that.begin(); o << *cur; - cur++; + ++ cur; while (cur != that.end()) { o << "." << *cur; - cur++; + ++ cur; } return o; @@ -149,7 +149,7 @@ static void dump_attributes_map(ostream&out, int ind) { for (map::const_iterator idx = attributes.begin() - ; idx != attributes.end() ; idx++ ) { + ; idx != attributes.end() ; ++ idx ) { out << setw(ind) << "" << "(* " << (*idx).first; if ((*idx).second) { @@ -1008,28 +1008,28 @@ void PGenerate::dump(ostream&out, unsigned indent) const dump_wires_(out, indent+2); for (list::const_iterator idx = gates.begin() - ; idx != gates.end() ; idx++) { + ; idx != gates.end() ; ++ idx ) { (*idx)->dump(out, indent+2); } for (list::const_iterator idx = behaviors.begin() - ; idx != behaviors.end() ; idx++) { + ; idx != behaviors.end() ; ++ idx ) { (*idx)->dump(out, indent+2); } for (list::const_iterator idx = analog_behaviors.begin() - ; idx != analog_behaviors.end() ; idx++) { + ; idx != analog_behaviors.end() ; ++ idx ) { (*idx)->dump(out, indent+2); } typedef map::const_iterator genvar_iter_t; for (genvar_iter_t cur = genvars.begin() - ; cur != genvars.end() ; cur++) { + ; cur != genvars.end() ; ++ cur ) { out << setw(indent+2) << "" << "genvar " << ((*cur).first) << ";" << endl; } for (list::const_iterator idx = generate_schemes.begin() - ; idx != generate_schemes.end() ; idx++) { + ; idx != generate_schemes.end() ; ++ idx ) { (*idx)->dump(out, indent+2); } @@ -1044,7 +1044,7 @@ void LexicalScope::dump_parameters_(ostream&out, unsigned indent) const { typedef map::const_iterator parm_iter_t; for (parm_iter_t cur = parameters.begin() - ; cur != parameters.end() ; cur ++) { + ; cur != parameters.end() ; ++ cur ) { out << setw(indent) << "" << "parameter " << (*cur).second.type << " "; if ((*cur).second.signed_flag) @@ -1093,7 +1093,7 @@ void LexicalScope::dump_localparams_(ostream&out, unsigned indent) const { typedef map::const_iterator parm_iter_t; for (parm_iter_t cur = localparams.begin() - ; cur != localparams.end() ; cur ++) { + ; cur != localparams.end() ; ++ cur ) { out << setw(indent) << "" << "localparam "; if ((*cur).second.msb) out << "[" << *(*cur).second.msb << ":" @@ -1125,7 +1125,7 @@ void LexicalScope::dump_enumerations_(ostream&out, unsigned indent) const void LexicalScope::dump_events_(ostream&out, unsigned indent) const { for (map::const_iterator cur = events.begin() - ; cur != events.end() ; cur ++ ) { + ; cur != events.end() ; ++ cur ) { PEvent*ev = (*cur).second; out << setw(indent) << "" << "event " << ev->name() << "; // " << ev->get_fileline() << endl; @@ -1136,7 +1136,7 @@ void LexicalScope::dump_wires_(ostream&out, unsigned indent) const { // Iterate through and display all the wires. for (map::const_iterator wire = wires.begin() - ; wire != wires.end() ; wire ++ ) { + ; wire != wires.end() ; ++ wire ) { (*wire).second->dump(out, indent); } @@ -1147,7 +1147,7 @@ void Module::dump(ostream&out) const if (attributes.begin() != attributes.end()) { out << "(* "; for (map::const_iterator idx = attributes.begin() - ; idx != attributes.end() ; idx++ ) { + ; idx != attributes.end() ; ++ idx ) { if (idx != attributes.begin()) { out << " , "; } @@ -1187,26 +1187,26 @@ void Module::dump(ostream&out) const typedef map::const_iterator genvar_iter_t; for (genvar_iter_t cur = genvars.begin() - ; cur != genvars.end() ; cur++) { + ; cur != genvars.end() ; ++ cur ) { out << " genvar " << ((*cur).first) << ";" << endl; } typedef list::const_iterator genscheme_iter_t; for (genscheme_iter_t cur = generate_schemes.begin() - ; cur != generate_schemes.end() ; cur++) { + ; cur != generate_schemes.end() ; ++ cur ) { (*cur)->dump(out, 4); } typedef map::const_iterator specparm_iter_t; for (specparm_iter_t cur = specparams.begin() - ; cur != specparams.end() ; cur ++) { + ; cur != specparams.end() ; ++ cur ) { out << " specparam " << (*cur).first << " = " << *(*cur).second << ";" << endl; } typedef list::const_iterator parm_hiter_t; for (parm_hiter_t cur = defparms.begin() - ; cur != defparms.end() ; cur ++) { + ; cur != defparms.end() ; ++ cur ) { out << " defparam " << (*cur).first << " = "; if ((*cur).second) out << *(*cur).second << ";" << endl; @@ -1222,7 +1222,7 @@ void Module::dump(ostream&out) const // Dump the task definitions. typedef map::const_iterator task_iter_t; for (task_iter_t cur = tasks.begin() - ; cur != tasks.end() ; cur ++) { + ; cur != tasks.end() ; ++ cur ) { out << " task " << (*cur).first << ";" << endl; (*cur).second->dump(out, 6); out << " endtask;" << endl; @@ -1231,7 +1231,7 @@ void Module::dump(ostream&out) const // Dump the function definitions. typedef map::const_iterator func_iter_t; for (func_iter_t cur = funcs.begin() - ; cur != funcs.end() ; cur ++) { + ; cur != funcs.end() ; ++ cur ) { out << " function " << (*cur).first << ";" << endl; (*cur).second->dump(out, 6); out << " endfunction;" << endl; @@ -1240,28 +1240,25 @@ void Module::dump(ostream&out) const // Iterate through and display all the gates for (list::const_iterator gate = gates_.begin() - ; gate != gates_.end() - ; gate ++ ) { + ; gate != gates_.end() ; ++ gate ) { (*gate)->dump(out); } for (list::const_iterator behav = behaviors.begin() - ; behav != behaviors.end() - ; behav ++ ) { + ; behav != behaviors.end() ; ++ behav ) { (*behav)->dump(out, 4); } for (list::const_iterator idx = analog_behaviors.begin() - ; idx != analog_behaviors.end() ; idx++) { + ; idx != analog_behaviors.end() ; ++ idx) { (*idx)->dump(out, 4); } for (list::const_iterator spec = specify_paths.begin() - ; spec != specify_paths.end() - ; spec ++ ) { + ; spec != specify_paths.end() ; ++ spec ) { (*spec)->dump(out, 4); } @@ -1304,8 +1301,7 @@ void PUdp::dump(ostream&out) const // Dump the attributes for the primitive as attribute // statements. for (map::const_iterator idx = attributes.begin() - ; idx != attributes.end() - ; idx ++) { + ; idx != attributes.end() ; ++ idx ) { out << " attribute " << (*idx).first; if ((*idx).second) out << " = " << *(*idx).second; diff --git a/set_width.cc b/set_width.cc index ebecb81be..9e47eb04c 100644 --- a/set_width.cc +++ b/set_width.cc @@ -103,7 +103,7 @@ bool NetEBAdd::set_width(unsigned w, bool) } expr_width(wid); - return wid == w; + return w == wid; } void NetEBAdd::cast_signed(bool sign_flag) @@ -168,7 +168,7 @@ bool NetEBBits::set_width(unsigned w, bool) */ bool NetEBComp::set_width(unsigned w, bool) { - return (w == 1); + return w == 1; } /* @@ -199,7 +199,7 @@ bool NetEBLogic::set_width(unsigned w, bool) flag = left_->set_width(right_->expr_width()); if (!flag) flag = right_->set_width(left_->expr_width()); - return (w == 1); + return w == 1; } /* @@ -230,7 +230,7 @@ void NetEBMult::cast_signed(bool sign_flag) cast_signed_base_(sign_flag); } -bool NetEBPow::set_width(unsigned w, bool last_chance) +bool NetEBPow::set_width(unsigned w, bool) { return w == expr_width(); } @@ -242,8 +242,6 @@ bool NetEBPow::set_width(unsigned w, bool last_chance) */ bool NetEBShift::set_width(unsigned w, bool) { - bool flag = true; - switch (op()) { case 'l': @@ -263,9 +261,8 @@ bool NetEBShift::set_width(unsigned w, bool) } expr_width(left_->expr_width()); - flag = expr_width() == w; - return flag; + return w == expr_width(); } /* @@ -287,8 +284,7 @@ bool NetEConcat::set_width(unsigned w, bool) sum *= repeat(); expr_width(sum); - if (sum != w) return false; - return true; + return w == sum; } bool NetEConst::set_width(unsigned w, bool last_chance) @@ -365,7 +361,7 @@ bool NetEConst::set_width(unsigned w, bool last_chance) tmp.has_sign(value_.has_sign()); value_ = tmp; expr_width(use_w); - return use_w == w; + return w == use_w; } } @@ -414,12 +410,9 @@ bool NetEParam::set_width(unsigned, bool) return false; } -bool NetESelect::set_width(unsigned w, bool) +bool NetESelect::set_width(unsigned, bool) { - if (expr_width() == 1) - return true; - else - return false; + return expr_width() == 1; } bool NetESFunc::set_width(unsigned w, bool) @@ -433,10 +426,7 @@ bool NetESFunc::set_width(unsigned w, bool) */ bool NetESignal::set_width(unsigned w, bool) { - if (w != vector_width()) - return false; - - return true; + return w == vector_width(); } bool NetETernary::set_width(unsigned w, bool last_chance) @@ -465,12 +455,9 @@ bool NetETernary::set_width(unsigned w, bool last_chance) * width. What I really need to do is note the width of the output * parameter of the function definition and take that into account. */ -bool NetEUFunc::set_width(unsigned wid, bool) +bool NetEUFunc::set_width(unsigned w, bool) { - if (result_sig_->expr_width() == wid) - return true; - else - return false; + return w == result_sig_->expr_width(); } bool NetEUnary::set_width(unsigned w, bool) diff --git a/syn-rules.y b/syn-rules.y index 3fa089106..ebd3aa50b 100644 --- a/syn-rules.y +++ b/syn-rules.y @@ -1,7 +1,7 @@ %{ /* - * 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 @@ -53,7 +53,7 @@ static int yylex(); static void yyerror(const char*); static Design*des_; -static void make_DFF_CE(Design*des, NetProcTop*top, NetEvWait*wclk, +static void make_DFF_CE(Design*des, NetProcTop*top, NetEvent*eclk, NetExpr*cexp, NetAssignBase*asn); %} @@ -80,13 +80,11 @@ start flip-flops. */ : S_ALWAYS '@' '(' S_EVENT ')' S_ASSIGN ';' - { make_DFF_CE(des_, $1->top, $2->evwait, $4->event, - 0, $6->assign); + { make_DFF_CE(des_, $1->top, $4->event, 0, $6->assign); } | S_ALWAYS '@' '(' S_EVENT ')' S_IF S_EXPR S_ASSIGN ';' ';' - { make_DFF_CE(des_, $1->top, $2->evwait, $4->event, - $7->expr, $8->assign); + { make_DFF_CE(des_, $1->top, $4->event, $7->expr, $8->assign); } /* Unconditional assignments in initial blocks should be made into @@ -102,6 +100,7 @@ static void hookup_DFF_CE(NetFF*ff, NetESignal*d, NetEvProbe*pclk, NetNet*ce, NetAssign_*a, unsigned rval_pinoffset) { + assert(rval_pinoffset == 0); // a->sig() is a *NetNet, which doesn't have the loff_ and // lwid_ context. Add the correction for loff_ ourselves. @@ -129,7 +128,7 @@ static void hookup_DFF_CE(NetFF*ff, NetESignal*d, NetEvProbe*pclk, a->turn_sig_to_wire_on_release(); } -static void make_DFF_CE(Design*des, NetProcTop*top, NetEvWait*wclk, +static void make_DFF_CE(Design*des, NetProcTop*top, NetEvent*eclk, NetExpr*cexp, NetAssignBase*asn) { assert(asn); @@ -335,7 +334,7 @@ static int yylex() struct syn_rules_f : public functor_t { ~syn_rules_f() { } - void process(class Design*des, class NetProcTop*top) + void process(class Design*, class NetProcTop*top) { /* If the scope that contains this process as a cell attribute attached to it, then skip synthesis. */ diff --git a/synth2.cc b/synth2.cc index 4b48450f1..69d9a5943 100644 --- a/synth2.cc +++ b/synth2.cc @@ -26,13 +26,12 @@ # include -bool NetProc::synth_async(Design*des, NetScope*scope, - const NetBus&nex_map, NetBus&nex_out) +bool NetProc::synth_async(Design*, NetScope*, const NetBus&, NetBus&) { return false; } -bool NetProc::synth_sync(Design*des, NetScope*scope, NetFF*ff, +bool NetProc::synth_sync(Design*des, NetScope*scope, NetFF* /*ff*/, const NetBus&nex_map, NetBus&nex_out, const svector&events) { @@ -58,7 +57,7 @@ bool NetProc::synth_sync(Design*des, NetScope*scope, NetFF*ff, * r-value. */ bool NetAssignBase::synth_async(Design*des, NetScope*scope, - const NetBus&nex_map, NetBus&nex_out) + const NetBus& /*nex_map*/, NetBus&nex_out) { NetNet*rsig = rval_->synthesize(des, scope, rval_); assert(rsig); @@ -152,7 +151,7 @@ bool NetBlock::synth_async(Design*des, NetScope*scope, } bool NetCase::synth_async(Design*des, NetScope*scope, - const NetBus&nex_map, NetBus&nex_out) + const NetBus& /*nex_map*/, NetBus&nex_out) { /* Synthesize the select expression. */ NetNet*esig = expr_->synthesize(des, scope, expr_); @@ -237,9 +236,13 @@ bool NetCase::synth_async(Design*des, NetScope*scope, return true; } -bool NetCondit::synth_async(Design*des, NetScope*scope, - const NetBus&nex_map, NetBus&nex_out) +bool NetCondit::synth_async(Design*des, NetScope* /*scope*/, + const NetBus& /*nex_map*/, NetBus& /*nex_out*/) { + cerr << get_fileline() << ": sorry: " + << "Forgot to implement NetCondit::synth_async" << endl; + des->errors += 1; + return false; #if 0 NetNet*ssig = expr_->synthesize(des); assert(ssig); @@ -295,11 +298,6 @@ bool NetCondit::synth_async(Design*des, NetScope*scope, DEBUG_SYNTH2_EXIT("NetCondit",true) return true; -#else - cerr << get_fileline() << ": sorry: " - << "Forgot to implement NetCondit::synth_async" << endl; - des->errors += 1; - return false; #endif } @@ -351,13 +349,17 @@ bool NetProcTop::synth_async(Design*des) * This needs to be split into a DFF bank for each statement, because * the statements may each infer different reset and enable signals. */ -bool NetBlock::synth_sync(Design*des, NetScope*scope, NetFF*ff, - const NetBus&nex_map, NetBus&nex_out, - const svector&events_in) +bool NetBlock::synth_sync(Design*des, NetScope* /*scope*/, NetFF* /*ff*/, + const NetBus& /*nex_map*/, NetBus& /*nex_out*/, + const svector& /*events_in*/) { if (last_ == 0) { return true; } + cerr << get_fileline() << ": sorry: " + << "Forgot to implement NetBlock::synth_sync" << endl; + des->errors += 1; + return false; #if 0 bool flag = true; @@ -503,12 +505,6 @@ bool NetBlock::synth_sync(Design*des, NetScope*scope, NetFF*ff, return flag; -#else - cerr << get_fileline() << ": sorry: " - << "Forgot to implement NetBlock::synth_sync" - << endl; - des->errors += 1; - return false; #endif } @@ -518,10 +514,14 @@ bool NetBlock::synth_sync(Design*des, NetScope*scope, NetFF*ff, * asynchronous set/reset, depending on whether the pin of the * expression is connected to an event, or not. */ -bool NetCondit::synth_sync(Design*des, NetScope*scope, NetFF*ff, - const NetBus&nex_map, NetBus&nex_out, - const svector&events_in) +bool NetCondit::synth_sync(Design*des, NetScope* /*scope*/, NetFF* /*ff*/, + const NetBus& /*nex_map*/, NetBus& /*nex_out*/, + const svector& /*events_in*/) { + cerr << get_fileline() << ": sorry: " + << "Forgot to implement NetCondit::synth_sync" << endl; + des->errors += 1; + return false; #if 0 /* First try to turn the condition expression into an asynchronous set/reset. If the condition expression has @@ -726,11 +726,6 @@ bool NetCondit::synth_sync(Design*des, NetScope*scope, NetFF*ff, return flag; -#else - cerr << get_fileline() << ": sorry: " - << "Forgot to implement NetCondit::synth_sync" << endl; - des->errors += 1; - return false; #endif } diff --git a/t-dll-analog.cc b/t-dll-analog.cc index f5861500b..26f21abe0 100644 --- a/t-dll-analog.cc +++ b/t-dll-analog.cc @@ -22,13 +22,13 @@ # include -# include "ivl_alloc.h" # include # include "target.h" # include "ivl_target.h" # include "compiler.h" # include "t-dll.h" # include +# include "ivl_alloc.h" bool dll_target::process(const NetAnalogTop*net) { diff --git a/t-dll-api.cc b/t-dll-api.cc index 9c319115a..c98f9b919 100644 --- a/t-dll-api.cc +++ b/t-dll-api.cc @@ -22,10 +22,10 @@ # include "t-dll.h" # include "discipline.h" # include "netenum.h" -# include "ivl_alloc.h" # include # include # include +# include "ivl_alloc.h" static StringHeap api_strings; @@ -1683,7 +1683,7 @@ extern "C" int ivl_scope_children(ivl_scope_t net, void*cd) { for (map::iterator cur = net->children.begin() - ; cur != net->children.end() ; cur ++) { + ; cur != net->children.end() ; ++ cur ) { int rc = func(cur->second, cd); if (rc != 0) return rc; diff --git a/t-dll-expr.cc b/t-dll-expr.cc index f53aa4c95..ef8b106a9 100644 --- a/t-dll-expr.cc +++ b/t-dll-expr.cc @@ -19,7 +19,6 @@ # include "config.h" -# include "ivl_alloc.h" # include # include @@ -27,6 +26,7 @@ # include "netlist.h" # include # include +# include "ivl_alloc.h" /* * This is a little convenience function for converting a NetExpr diff --git a/t-dll-proc.cc b/t-dll-proc.cc index 32f33e767..e446f9653 100644 --- a/t-dll-proc.cc +++ b/t-dll-proc.cc @@ -22,13 +22,13 @@ # include -# include "ivl_alloc.h" # include # include "target.h" # include "ivl_target.h" # include "compiler.h" # include "t-dll.h" # include +# include "ivl_alloc.h" bool dll_target::process(const NetProcTop*net) { diff --git a/t-dll.cc b/t-dll.cc index 033b7a846..b02964bf7 100644 --- a/t-dll.cc +++ b/t-dll.cc @@ -21,7 +21,6 @@ # include -# include "ivl_alloc.h" # include # include // sprintf() # include "compiler.h" @@ -30,6 +29,7 @@ # include "discipline.h" # include # include "ivl_assert.h" +# include "ivl_alloc.h" struct dll_target dll_target_obj; @@ -363,7 +363,7 @@ static void nexus_lpm_add(ivl_nexus_t nex, ivl_lpm_t net, unsigned pin, nex->ptrs_[top].type_= __NEXUS_PTR_LPM; nex->ptrs_[top].drive0 = drive0; - nex->ptrs_[top].drive1 = drive0; + nex->ptrs_[top].drive1 = drive1; nex->ptrs_[top].pin_ = pin; nex->ptrs_[top].l.lpm= net; } @@ -473,7 +473,7 @@ void dll_target::make_scope_parameters(ivl_scope_t scop, const NetScope*net) typedef map::const_iterator pit_t; for (pit_t cur_pit = net->parameters.begin() - ; cur_pit != net->parameters.end() ; cur_pit ++) { + ; cur_pit != net->parameters.end() ; ++ cur_pit ) { assert(idx < scop->nparam_); ivl_parameter_t cur_par = scop->param_ + idx; @@ -487,7 +487,7 @@ void dll_target::make_scope_parameters(ivl_scope_t scop, const NetScope*net) idx += 1; } for (pit_t cur_pit = net->localparams.begin() - ; cur_pit != net->localparams.end() ; cur_pit ++) { + ; cur_pit != net->localparams.end() ; ++ cur_pit ) { assert(idx < scop->nparam_); ivl_parameter_t cur_par = scop->param_ + idx; @@ -608,7 +608,7 @@ bool dll_target::start_design(const Design*des) des_.disciplines.resize(disciplines.size()); unsigned idx = 0; for (map::const_iterator cur = disciplines.begin() - ; cur != disciplines.end() ; cur ++) { + ; cur != disciplines.end() ; ++ cur ) { des_.disciplines[idx] = cur->second; idx += 1; } @@ -616,7 +616,7 @@ bool dll_target::start_design(const Design*des) root_scopes = des->find_root_scopes(); for (list::const_iterator scop = root_scopes.begin(); - scop != root_scopes.end(); scop++) + scop != root_scopes.end(); ++ scop ) add_root(des_, *scop); @@ -2222,7 +2222,7 @@ bool dll_target::net_literal(const NetLiteral*net) return true; } -void dll_target::net_probe(const NetEvProbe*net) +void dll_target::net_probe(const NetEvProbe*) { } diff --git a/target.cc b/target.cc index 26469dfbb..3df7a9c1b 100644 --- a/target.cc +++ b/target.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998-2008 Stephen Williams + * Copyright (c) 1998-2010 Stephen Williams * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -224,14 +224,14 @@ bool target_t::net_const(const NetConst*) return false; } -bool target_t::net_sysfunction(const NetSysFunc*net) +bool target_t::net_sysfunction(const NetSysFunc*) { cerr << "target (" << typeid(*this).name() << "): " "Unhandled NetSysFunc node." << endl; return false; } -bool target_t::net_function(const NetUserFunc*net) +bool target_t::net_function(const NetUserFunc*) { cerr << "target (" << typeid(*this).name() << "): " "Unhandled NetUserFunc node." << endl; @@ -252,21 +252,21 @@ void target_t::net_probe(const NetEvProbe*net) net->dump_node(cerr, 4); } -bool target_t::sign_extend(const NetSignExtend*net) +bool target_t::sign_extend(const NetSignExtend*) { cerr << "target (" << typeid(*this).name() << "): " "Unhandled NetSignExtend node." << endl; return false; } -bool target_t::process(const NetProcTop*top) +bool target_t::process(const NetProcTop*) { cerr << "target (" << typeid(*this).name() << "): " "Unhandled process(NetProcTop)." << endl; return false; } -bool target_t::process(const NetAnalogTop*top) +bool target_t::process(const NetAnalogTop*) { cerr << "target (" << typeid(*this).name() << "): " "Unhandled process(NetAnalogTop)." << endl; @@ -353,7 +353,7 @@ bool target_t::proc_disable(const NetDisable*obj) return false; } -bool target_t::proc_force(const NetForce*dev) +bool target_t::proc_force(const NetForce*) { cerr << "target (" << typeid(*this).name() << "): " "Unhandled proc_force." << endl; diff --git a/tgt-fpga/d-generic-edif.c b/tgt-fpga/d-generic-edif.c index 71740d0c1..5831306ff 100644 --- a/tgt-fpga/d-generic-edif.c +++ b/tgt-fpga/d-generic-edif.c @@ -19,10 +19,10 @@ # include "device.h" # include "fpga_priv.h" -# include "ivl_alloc.h" # include # include # include +# include "ivl_alloc.h" struct nexus_recall { struct nexus_recall*next; diff --git a/tgt-fpga/edif.c b/tgt-fpga/edif.c index 0739f5a61..9e8d97930 100644 --- a/tgt-fpga/edif.c +++ b/tgt-fpga/edif.c @@ -18,10 +18,10 @@ */ # include "edif.h" -# include "ivl_alloc.h" # include # include # include +# include "ivl_alloc.h" typedef enum property_e { PRP_NONE = 0, diff --git a/tgt-fpga/mangle.c b/tgt-fpga/mangle.c index 0138f82d3..5b98e73e6 100644 --- a/tgt-fpga/mangle.c +++ b/tgt-fpga/mangle.c @@ -18,9 +18,9 @@ */ # include "fpga_priv.h" -# include "ivl_alloc.h" # include # include +# include "ivl_alloc.h" static size_t xnf_mangle_scope_name(ivl_scope_t net, char*buf, size_t nbuf) { diff --git a/tgt-fpga/xilinx.c b/tgt-fpga/xilinx.c index 9d9d9dd08..f64ab491f 100644 --- a/tgt-fpga/xilinx.c +++ b/tgt-fpga/xilinx.c @@ -21,10 +21,10 @@ # include "generic.h" # include "xilinx.h" # include "fpga_priv.h" -# include "ivl_alloc.h" # include # include # include +# include "ivl_alloc.h" edif_cell_t xilinx_cell_buf(edif_xlibrary_t xlib) { diff --git a/tgt-pal/emit_jed.c b/tgt-pal/emit_jed.c index ae9ad5bbc..de0672b8c 100644 --- a/tgt-pal/emit_jed.c +++ b/tgt-pal/emit_jed.c @@ -20,10 +20,10 @@ # include "config.h" # include "priv.h" -# include "ivl_alloc.h" # include # include # include +# include "ivl_alloc.h" static void draw_macrocell_modes(FILE*jfd) { diff --git a/tgt-pal/fit_log.c b/tgt-pal/fit_log.c index 469cebad6..3f5efed3e 100644 --- a/tgt-pal/fit_log.c +++ b/tgt-pal/fit_log.c @@ -20,11 +20,11 @@ # include "config.h" # include "ivl_target.h" -# include "ivl_alloc.h" # include # include # include # include "priv.h" +# include "ivl_alloc.h" /* * By the time we get here, all the flip-flops have been placed in diff --git a/tgt-pal/imain.c b/tgt-pal/imain.c index 00e2937ca..4f262753e 100644 --- a/tgt-pal/imain.c +++ b/tgt-pal/imain.c @@ -25,10 +25,10 @@ # include "priv.h" -# include "ivl_alloc.h" # include # include # include +# include "ivl_alloc.h" extern void dump_final_design(FILE*out); diff --git a/tgt-stub/stub.c b/tgt-stub/stub.c index a940e97db..2587454e1 100644 --- a/tgt-stub/stub.c +++ b/tgt-stub/stub.c @@ -28,11 +28,11 @@ # include "version_tag.h" # include "config.h" # include "priv.h" -# include "ivl_alloc.h" # include # include # include # include +# include "ivl_alloc.h" static const char*version_string = "Icarus Verilog STUB Code Generator " VERSION " (" VERSION_TAG ")\n\n" diff --git a/tgt-vvp/draw_net_input.c b/tgt-vvp/draw_net_input.c index 4eb6ec311..628210ad9 100644 --- a/tgt-vvp/draw_net_input.c +++ b/tgt-vvp/draw_net_input.c @@ -18,12 +18,12 @@ */ # include "vvp_priv.h" -# include "ivl_alloc.h" # include # include # include # include # include +# include "ivl_alloc.h" #ifdef __MINGW32__ /* MinGW has inconsistent %p output. */ #define snprintf _snprintf @@ -58,16 +58,30 @@ static ivl_signal_type_t signal_type_of_nexus(ivl_nexus_t nex) static ivl_variable_type_t signal_data_type_of_nexus(ivl_nexus_t nex) { unsigned idx; + ivl_variable_type_t out = IVL_VT_NO_TYPE; for (idx = 0 ; idx < ivl_nexus_ptrs(nex) ; idx += 1) { + ivl_variable_type_t vtype; ivl_nexus_ptr_t ptr = ivl_nexus_ptr(nex, idx); ivl_signal_t sig = ivl_nexus_ptr_sig(ptr); if (sig == 0) continue; - return ivl_signal_data_type(sig); + vtype = ivl_signal_data_type(sig); + if (out == IVL_VT_NO_TYPE && vtype == IVL_VT_BOOL) { + out = vtype; + continue; + } + if (out != IVL_VT_LOGIC && vtype == IVL_VT_LOGIC) { + out = vtype; + continue; + } + if (vtype == IVL_VT_REAL) { + out = vtype; + break; + } } - return IVL_VT_NO_TYPE; + return out; } static void draw_C4_repeated_constant(char bit_char, unsigned width) @@ -537,6 +551,70 @@ static char* draw_island_port(ivl_island_t island, int island_input_flag, } } +/* + * This routine is called to display an error message when a uwire or + * wire real has multiple drivers. + */ +typedef enum mdriver_type_e { + MDRV_UWIRE = 0, + MDRV_REAL = 1 +} mdriver_type_t; + +static void display_multi_driver_error(ivl_nexus_t nex, unsigned ndrivers, + mdriver_type_t type) +{ + unsigned idx; + unsigned scope_len = -1; + ivl_signal_t sig = 0; + /* Find the signal. */ + for (idx = 0 ; idx < ivl_nexus_ptrs(nex) ; idx += 1) { + ivl_nexus_ptr_t ptr = ivl_nexus_ptr(nex, idx); + ivl_signal_t tsig = ivl_nexus_ptr_sig(ptr); + if (tsig != 0) { + ivl_scope_t scope; + unsigned len; + if (ivl_signal_local(tsig)) continue; + + /* If this is not a local signal then find the signal + * that has the shortest scope (is the furthest up + * the hierarchy). */ + scope = ivl_signal_scope(tsig); + assert(scope); + len = strlen(ivl_scope_name(scope)); + if (len < scope_len) { + scope_len = len; + sig = tsig; + } + } + } + assert(sig); + + fprintf(stderr, "%s:%u: vvp.tgt error: ", + ivl_signal_file(sig), ivl_signal_lineno(sig)); + switch (type) { + case MDRV_UWIRE: + if (ivl_signal_type(sig) != IVL_SIT_UWIRE) { + fprintf(stderr, "(implicit) "); + } + fprintf(stderr, "uwire"); + break; + + case MDRV_REAL: + assert(ivl_signal_type(sig) == IVL_SIT_TRI); + if (ivl_signal_data_type(sig) != IVL_VT_REAL) { + fprintf(stderr, "(implicit) "); + } + fprintf(stderr, "wire real"); + break; + + default: + assert(0);; + } + fprintf(stderr, " \"%s\" must have a single driver, found (%u).\n", + ivl_signal_basename(sig), ndrivers); + vvp_errors += 1; +} + /* * This function draws the input to a net into a string. What that * means is that it returns a static string that can be used to @@ -711,22 +789,7 @@ static void draw_net_input_x(ivl_nexus_t nex, /* A uwire is a tri with only one driver. */ if (res == IVL_SIT_UWIRE) { if (ndrivers > 1) { - unsigned uidx; - ivl_signal_t usig = 0; - /* Find the uwire signal. */ - for (uidx = 0 ; uidx < ivl_nexus_ptrs(nex) ; uidx += 1) { - ivl_nexus_ptr_t ptr = ivl_nexus_ptr(nex, uidx); - usig = ivl_nexus_ptr_sig(ptr); - if (usig != 0) break; - } - assert(usig); - - fprintf(stderr, "%s:%u: vvp.tgt error: uwire \"%s\" must " - "have a single driver, found (%u).\n", - ivl_signal_file(usig), - ivl_signal_lineno(usig), - ivl_signal_basename(usig), ndrivers); - vvp_errors += 1; + display_multi_driver_error(nex, ndrivers, MDRV_UWIRE); } res = IVL_SIT_TRI; } @@ -757,6 +820,11 @@ static void draw_net_input_x(ivl_nexus_t nex, return; } + /* We currently only support one driver on real nets. */ + if (ndrivers > 1 && signal_data_type_of_nexus(nex) == IVL_VT_REAL) { + display_multi_driver_error(nex, ndrivers, MDRV_REAL); + } + level = 0; while (ndrivers) { unsigned int inst; diff --git a/tgt-vvp/draw_vpi.c b/tgt-vvp/draw_vpi.c index af6932f9d..86279578d 100644 --- a/tgt-vvp/draw_vpi.c +++ b/tgt-vvp/draw_vpi.c @@ -18,10 +18,10 @@ */ # include "vvp_priv.h" -# include "ivl_alloc.h" # include # include # include +# include "ivl_alloc.h" #ifdef __MINGW32__ /* MinGW has inconsistent %p output. */ #define snprintf _snprintf diff --git a/tgt-vvp/eval_expr.c b/tgt-vvp/eval_expr.c index cb2ff47be..90709ec6c 100644 --- a/tgt-vvp/eval_expr.c +++ b/tgt-vvp/eval_expr.c @@ -18,10 +18,10 @@ */ # include "vvp_priv.h" -# include "ivl_alloc.h" # include # include # include +# include "ivl_alloc.h" static void draw_eval_expr_dest(ivl_expr_t expr, struct vector_info dest, int ok_flags); diff --git a/tgt-vvp/eval_real.c b/tgt-vvp/eval_real.c index eeb8abfc1..3007dc5a6 100644 --- a/tgt-vvp/eval_real.c +++ b/tgt-vvp/eval_real.c @@ -160,7 +160,7 @@ static int draw_number_real(ivl_expr_t expr) int res = allocate_word(); const char*bits = ivl_expr_bits(expr); unsigned wid = ivl_expr_width(expr); - unsigned long mant = 0, mask = -1UL; + unsigned long mant = 0; int vexp = 0x1000; /* If this is a negative number, then arrange for the 2's @@ -176,7 +176,6 @@ static int draw_number_real(ivl_expr_t expr) } for (idx = 0 ; idx < wid && idx < IMM_WID ; idx += 1) { - mask <<= 1; int cur_bit = bits[idx] == '1'? 1 : 0; if (negate) { diff --git a/tgt-vvp/modpath.c b/tgt-vvp/modpath.c index ed97e5b99..89f316fdc 100644 --- a/tgt-vvp/modpath.c +++ b/tgt-vvp/modpath.c @@ -18,10 +18,10 @@ */ # include "vvp_priv.h" -# include "ivl_alloc.h" # include # include # include +# include "ivl_alloc.h" #ifdef __MINGW32__ /* MinGW has inconsistent %p output. */ #define snprintf _snprintf diff --git a/tgt-vvp/vvp_scope.c b/tgt-vvp/vvp_scope.c index cb5ad12c5..5528e32ea 100644 --- a/tgt-vvp/vvp_scope.c +++ b/tgt-vvp/vvp_scope.c @@ -18,12 +18,12 @@ */ # include "vvp_priv.h" -# include "ivl_alloc.h" # include # include # include # include # include +# include "ivl_alloc.h" /* * Escape non-symbol characters in ids, and quotes in strings. @@ -371,7 +371,7 @@ char* draw_Cr_to_string(double value) } sign = 0; - if (value < 0) { + if (value < 0.0 || (value == 0.0 && 1.0/value < 0.0)) { sign = 0x4000; value *= -1; } diff --git a/verinum.cc b/verinum.cc index 4e7be7668..733e76915 100644 --- a/verinum.cc +++ b/verinum.cc @@ -170,7 +170,7 @@ verinum::verinum(uint64_t val, unsigned n) /* The second argument is not used! It is there to make this * constructor unique. */ -verinum::verinum(double val, bool dummy) +verinum::verinum(double val, bool) : has_len_(false), has_sign_(true), string_flag_(false) { bool is_neg = false; diff --git a/verinum.h b/verinum.h index 5142883ee..d44941291 100644 --- a/verinum.h +++ b/verinum.h @@ -1,7 +1,7 @@ #ifndef __verinum_H #define __verinum_H /* - * Copyright (c) 1998-2008 Stephen Williams (steve@icarus.com) + * Copyright (c) 1998-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 @@ -46,7 +46,7 @@ class verinum { verinum(const V*v, unsigned nbits, bool has_len =true); verinum(V, unsigned nbits =1, bool has_len =true); verinum(uint64_t val, unsigned bits); - verinum(double val, bool dummy); + verinum(double val, bool); verinum(const verinum&); // Create a signed number, with an unspecified number of bits. diff --git a/vpi/Makefile.in b/vpi/Makefile.in index 93fd42b84..f51cbf9dc 100644 --- a/vpi/Makefile.in +++ b/vpi/Makefile.in @@ -89,7 +89,8 @@ distclean: clean rm -f vpi_config.h stamp-vpi_config-h cppcheck: $(O:.o=.c) $(OPP:.o=.cc) $(M:.o=.c) $(V:.o=.c) - cppcheck --enable=all -f $(INCLUDE_PATH) $^ + cppcheck --enable=all -f --suppressions $(srcdir)/cppcheck.sup \ + $(INCLUDE_PATH) $^ Makefile: $(srcdir)/Makefile.in ../config.status cd ..; ./config.status --file=vpi/$@ diff --git a/vpi/cppcheck.sup b/vpi/cppcheck.sup new file mode 100644 index 000000000..429de910c --- /dev/null +++ b/vpi/cppcheck.sup @@ -0,0 +1,41 @@ +// The following three files are copied directly from GTKWave and we do not +// have control over them. Tony has a specific programming style so these +// problems will not be fixed. + +// fstapi.c from GTKWave +variableScope:fstapi.c:1497 +variableScope:fstapi.c:1614 +variableScope:fstapi.c:1663 +variableScope:fstapi.c:1664 +variableScope:fstapi.c:2355 +variableScope:fstapi.c:2670 +variableScope:fstapi.c:2674 +variableScope:fstapi.c:2675 + +// lxt2_write.c from GTKWave +variableScope:lxt2_write.c:63 +variableScope:lxt2_write.c:523 +variableScope:lxt2_write.c:581 +variableScope:lxt2_write.c:587 +variableScope:lxt2_write.c:1602 +variableScope:lxt2_write.c:2049 + +// lxt_write.c from GTKWave +variableScope:lxt_write.c:31 +variableScope:lxt_write.c:587 +variableScope:lxt_write.c:640 +variableScope:lxt_write.c:1056 +variableScope:lxt_write.c:1057 +variableScope:lxt_write.c:1058 +variableScope:lxt_write.c:1841 +variableScope:lxt_write.c:2586 +variableScope:lxt_write.c:2587 +variableScope:lxt_write.c:2588 +variableScope:lxt_write.c:2589 + +// The routines in sys_random.c are exact copies from IEEE1364-2005 and +// they have scope warnings that we need to ignore. +variableScope:sys_random.c:46 +variableScope:sys_random.c:69 +variableScope:sys_random.c:92 +variableScope:sys_random.c:147 diff --git a/vpi/fstapi.c b/vpi/fstapi.c index 59211b772..c20a3ecb6 100644 --- a/vpi/fstapi.c +++ b/vpi/fstapi.c @@ -20,12 +20,17 @@ * DEALINGS IN THE SOFTWARE. */ +#ifdef _WAVE_USE_CONFIG_HDR +#include +#endif + #include "fstapi.h" #include "fastlz.h" #undef FST_DEBUG -#define FST_BREAK_SIZE (32 * 1024 * 1024) +#define FST_BREAK_SIZE (128 * 1024 * 1024) +#define FST_BREAK_ADD_SIZE (4 * 1024 * 1024) #define FST_WRITER_STR "fstWriter" #define FST_ID_NAM_SIZ (512) #define FST_DOUBLE_ENDTEST (2.7182818284590452354) @@ -33,7 +38,6 @@ #define FST_HDR_DATE_SIZE (128) #define FST_GZIO_LEN (32768) - #if defined(__i386__) || defined(__x86_64__) || defined(_AIX) #define FST_DO_MISALIGNED_OPS #endif @@ -42,10 +46,6 @@ #define FST_MACOSX #endif -#if defined(__CYGWIN__) && defined(__GNUC__) -#define FST_USE_FWRITE_COMBINING -#endif - /***********************/ /*** ***/ @@ -218,6 +218,19 @@ return(rc); } +static uint32_t fstGetVarint32Length(unsigned char *mem) +{ +unsigned char *mem_orig = mem; + +while(*mem & 0x80) + { + mem++; + } + +return(mem - mem_orig + 1); +} + + static uint32_t fstGetVarint32NoSkip(unsigned char *mem) { unsigned char *mem_orig = mem; @@ -395,50 +408,6 @@ fstFwrite(buf, len, 1, handle); return(len); } -#ifndef FST_USE_FWRITE_COMBINING -static int fstWriterUint32WithVarint(FILE *handle, uint32_t *u, uint64_t v) -{ -uint64_t nxt; -unsigned char buf[10 + sizeof(uint32_t)]; -unsigned char *pnt = buf + sizeof(uint32_t); -int len; - -memcpy(buf, u, sizeof(uint32_t)); - -while((nxt = v>>7)) - { - *(pnt++) = (v&0x7f) | 0x80; - v = nxt; - } -*(pnt++) = (v&0x7f); - -len = pnt-buf; -fstFwrite(buf, len, 1, handle); -return(len); -} -#else -static int fstWriterUint32WithVarint(FILE *handle, uint32_t *u, uint64_t v, const void *dbuf, size_t siz) -{ -uint64_t nxt; -unsigned char buf[10 + sizeof(uint32_t) + siz]; /* gcc extension ok for cygwin */ -unsigned char *pnt = buf + sizeof(uint32_t); -int len; - -memcpy(buf, u, sizeof(uint32_t)); - -while((nxt = v>>7)) - { - *(pnt++) = (v&0x7f) | 0x80; - v = nxt; - } -*(pnt++) = (v&0x7f); -memcpy(pnt, dbuf, siz); - -len = pnt-buf + siz; -fstFwrite(buf, len, 1, handle); -return(len); -} -#endif /***********************/ /*** ***/ @@ -464,9 +433,10 @@ FILE *hier_handle; FILE *geom_handle; FILE *valpos_handle; FILE *curval_handle; -FILE *vchn_handle; FILE *tchn_handle; +unsigned char *vchg_mem; + off_t hier_file_len; uint32_t *valpos_mem; @@ -486,7 +456,9 @@ off_t section_header_truncpos; uint32_t tchn_cnt, tchn_idx; uint64_t curtime; uint64_t firsttime; -off_t vchn_siz; +uint32_t vchg_siz; +uint32_t vchg_alloc_siz; + uint32_t secnum; off_t section_start; @@ -504,6 +476,7 @@ unsigned compress_hier : 1; unsigned repack_on_close : 1; unsigned skip_writing_section_hdr : 1; unsigned size_limit_locked : 1; +unsigned section_header_only : 1; /* should really be semaphores, but are bytes to cut down on read-modify-write window size */ unsigned char already_in_flush; /* in case control-c handlers interrupt */ @@ -511,6 +484,33 @@ unsigned char already_in_close; /* in case control-c handlers interrupt */ }; +static int fstWriterUint32WithVarint32(struct fstWriterContext *xc, uint32_t *u, uint32_t v, const void *dbuf, int siz) +{ +unsigned char *buf = xc->vchg_mem + xc->vchg_siz; +unsigned char *pnt = buf; +uint32_t nxt; +int len; + +#ifdef FST_DO_MISALIGNED_OPS +(*(uint32_t *)(pnt)) = (*(uint32_t *)(u)); +#else +memcpy(pnt, u, sizeof(uint32_t)); +#endif +pnt += 4; + +while((nxt = v>>7)) + { + *(pnt++) = (v&0x7f) | 0x80; + v = nxt; + } +*(pnt++) = (v&0x7f); +memcpy(pnt, dbuf, siz); + +len = pnt-buf + siz; +return(len); +} + + /* * header bytes, write here so defines are set up before anything else * that needs to use them @@ -664,11 +664,12 @@ if((!nam)||(!(xc->handle=fopen(nam, "w+b")))) xc->geom_handle = tmpfile(); /* .geom */ xc->valpos_handle = tmpfile(); /* .offs */ xc->curval_handle = tmpfile(); /* .bits */ - xc->vchn_handle = tmpfile(); /* .vchn */ xc->tchn_handle = tmpfile(); /* .tchn */ + xc->vchg_alloc_siz = FST_BREAK_SIZE + FST_BREAK_ADD_SIZE; + xc->vchg_mem = malloc(xc->vchg_alloc_siz); free(hf); - if(xc->hier_handle && xc->geom_handle && xc->valpos_handle && xc->curval_handle && xc->vchn_handle && xc->tchn_handle) + if(xc->hier_handle && xc->geom_handle && xc->valpos_handle && xc->curval_handle && xc->vchg_mem && xc->tchn_handle) { xc->filename = strdup(nam); xc->is_initial_time = 1; @@ -682,8 +683,8 @@ if((!nam)||(!(xc->handle=fopen(nam, "w+b")))) if(xc->geom_handle) fclose(xc->geom_handle); if(xc->valpos_handle) fclose(xc->valpos_handle); if(xc->curval_handle) fclose(xc->curval_handle); - if(xc->vchn_handle) fclose(xc->vchn_handle); if(xc->tchn_handle) fclose(xc->tchn_handle); + free(xc->vchg_mem); free(xc); xc=NULL; } @@ -703,20 +704,29 @@ if(xc && !xc->already_in_close && !xc->already_in_flush) xc->already_in_close = 1; /* never need to zero this out as it is freed at bottom */ - xc->skip_writing_section_hdr = 1; - if(!xc->size_limit_locked) + if(xc->section_header_only && xc->section_header_truncpos && (xc->vchg_siz <= 1) && (!xc->is_initial_time)) { - if(xc->is_initial_time) /* simulation time never advanced so mock up the changes as time zero ones */ + fstFtruncate(fileno(xc->handle), xc->section_header_truncpos); + fseeko(xc->handle, xc->section_header_truncpos, SEEK_SET); + xc->section_header_only = 0; + } + else + { + xc->skip_writing_section_hdr = 1; + if(!xc->size_limit_locked) { - fstHandle dupe_idx; - - fstWriterEmitTimeChange(xc, 0); /* emit some time change just to have one */ - for(dupe_idx = 0; dupe_idx < xc->maxhandle; dupe_idx++) /* now clone the values */ + if(xc->is_initial_time) /* simulation time never advanced so mock up the changes as time zero ones */ { - fstWriterEmitValueChange(xc, dupe_idx+1, xc->curval_mem + xc->valpos_mem[4*dupe_idx]); + fstHandle dupe_idx; + + fstWriterEmitTimeChange(xc, 0); /* emit some time change just to have one */ + for(dupe_idx = 0; dupe_idx < xc->maxhandle; dupe_idx++) /* now clone the values */ + { + fstWriterEmitValueChange(xc, dupe_idx+1, xc->curval_mem + xc->valpos_mem[4*dupe_idx]); + } } + fstWriterFlushContext(xc); } - fstWriterFlushContext(xc); } fstDestroyMmaps(xc, 1); @@ -855,7 +865,7 @@ if(xc && !xc->already_in_close && !xc->already_in_flush) fflush(xc->handle); if(xc->tchn_handle) { fclose(xc->tchn_handle); xc->tchn_handle = NULL; } - if(xc->vchn_handle) { fclose(xc->vchn_handle); xc->vchn_handle = NULL; } + free(xc->vchg_mem); xc->vchg_mem = NULL; if(xc->curval_handle) { fclose(xc->curval_handle); xc->curval_handle = NULL; } if(xc->valpos_handle) { fclose(xc->valpos_handle); xc->valpos_handle = NULL; } if(xc->geom_handle) { fclose(xc->geom_handle); xc->geom_handle = NULL; } @@ -969,6 +979,7 @@ if(xc) fputc(FST_BL_SKIP, xc->handle); /* temporarily tag the section, use FST_BL_VCDATA on finalize */ xc->section_start = ftello(xc->handle); + xc->section_header_only = 1; /* indicates truncate might be needed */ fstWriterUint64(xc->handle, 0); /* placeholder = section length */ fstWriterUint64(xc->handle, xc->is_initial_time ? xc->firsttime : xc->curtime); /* begin time of section */ fstWriterUint64(xc->handle, xc->curtime); /* end time of section (placeholder) */ @@ -1021,13 +1032,13 @@ uint32_t *vm4ip; struct fstWriterContext *xc = (struct fstWriterContext *)ctx; -if((!xc)||(xc->vchn_siz <= 1)||(xc->already_in_flush)) return; +if((!xc)||(xc->vchg_siz <= 1)||(xc->already_in_flush)) return; xc->already_in_flush = 1; /* should really do this with a semaphore */ -scratchpad = malloc(xc->vchn_siz); +xc->section_header_only = 0; +scratchpad = malloc(xc->vchg_siz); -fflush(xc->vchn_handle); -vchg_mem = fstMmap(NULL, xc->vchn_siz, PROT_READ|PROT_WRITE, MAP_SHARED, fileno(xc->vchn_handle), 0); +vchg_mem = xc->vchg_mem; f = xc->handle; fstWriterVarint(f, xc->maxhandle); /* emit current number of handles */ @@ -1049,9 +1060,12 @@ for(i=0;imaxhandle;i++) vm4ip[2] = fpos; - scratchpnt = scratchpad + xc->vchn_siz; /* build this buffer backwards */ + scratchpnt = scratchpad + xc->vchg_siz; /* build this buffer backwards */ if(vm4ip[1] == 1) { + wrlen = fstGetVarint32Length(vchg_mem + offs + 4); /* used to advance and determine wrlen */ + xc->curval_mem[vm4ip[0]] = vchg_mem[offs + 4 + wrlen]; /* checkpoint variable */ + while(offs) { unsigned char val; @@ -1083,6 +1097,9 @@ for(i=0;imaxhandle;i++) } else { + wrlen = fstGetVarint32Length(vchg_mem + offs + 4); /* used to advance and determine wrlen */ + memcpy(xc->curval_mem + vm4ip[0], vchg_mem + offs + 4 + wrlen, vm4ip[1]); /* checkpoint variable */ + while(offs) { int idx; @@ -1139,7 +1156,7 @@ for(i=0;imaxhandle;i++) } } - wrlen = scratchpad + xc->vchn_siz - scratchpnt; + wrlen = scratchpad + xc->vchg_siz - scratchpnt; unc_memreq += wrlen; if(wrlen > 32) { @@ -1252,12 +1269,8 @@ if(zerocnt) printf("value chains: %d\n", cnt); #endif -fstMunmap(vchg_mem, xc->vchn_siz); - -fseeko(xc->vchn_handle, 0, SEEK_SET); -fstFtruncate(fileno(xc->vchn_handle), 0); -fputc('!', xc->vchn_handle); -xc->vchn_siz = 1; +xc->vchg_mem[0] = '!'; +xc->vchg_siz = 1; endpos = ftello(xc->handle); fstWriterUint64(xc->handle, endpos-indxpos); /* write delta index position at very end of block */ @@ -1323,7 +1336,6 @@ if(xc->dump_size_limit) } } - if(!xc->skip_writing_section_hdr) { fstWriterEmitSectionHeader(xc); /* emit next section header */ @@ -1594,12 +1606,12 @@ if(xc) /* * value and time change emission */ -void fstWriterEmitValueChange(void *ctx, fstHandle handle, void *val) +void fstWriterEmitValueChange(void *ctx, fstHandle handle, const void *val) { struct fstWriterContext *xc = (struct fstWriterContext *)ctx; -unsigned char *buf = (unsigned char *)val; +const unsigned char *buf = (const unsigned char *)val; uint32_t offs; -size_t len; +int len; if((xc) && (handle <= xc->maxhandle)) { @@ -1614,24 +1626,33 @@ if((xc) && (handle <= xc->maxhandle)) handle--; /* move starting at 1 index to starting at 0 */ vm4ip = &(xc->valpos_mem[4*handle]); - offs = vm4ip[0]; + len = vm4ip[1]; - memcpy(xc->curval_mem + offs, buf, len); if(!xc->is_initial_time) { - fpos = xc->vchn_siz; - /* cygwin runs faster if these writes are combined, so the new fstWriterUint32WithVarint function, but should help with regular */ -#ifndef FST_USE_FWRITE_COMBINING - xc->vchn_siz += fstWriterUint32WithVarint(xc->vchn_handle, &vm4ip[2], xc->tchn_idx - vm4ip[3]); /* prev_chg is vm4ip[2] */ - fstFwrite(buf, len, 1, xc->vchn_handle); - xc->vchn_siz += len; -#else - xc->vchn_siz += fstWriterUint32WithVarint(xc->vchn_handle, &vm4ip[2], xc->tchn_idx - vm4ip[3], buf, len); /* do one fwrite op only */ -#endif + fpos = xc->vchg_siz; + + if((fpos + len + 10) > xc->vchg_alloc_siz) + { + xc->vchg_alloc_siz += FST_BREAK_ADD_SIZE; + xc->vchg_mem = realloc(xc->vchg_mem, xc->vchg_alloc_siz); + if(!xc->vchg_mem) + { + fprintf(stderr, "FATAL ERROR, could not realloc() in fstWriterEmitValueChange, exiting.\n"); + exit(255); + } + } + + xc->vchg_siz += fstWriterUint32WithVarint32(xc, &vm4ip[2], xc->tchn_idx - vm4ip[3], buf, len); /* do one fwrite op only */ vm4ip[3] = xc->tchn_idx; vm4ip[2] = fpos; } + else + { + offs = vm4ip[0]; + memcpy(xc->curval_mem + offs, buf, len); + } } } @@ -1659,10 +1680,8 @@ if(xc) xc->firsttime = (xc->vc_emitted) ? 0: tim; xc->curtime = 0; - fseeko(xc->vchn_handle, 0, SEEK_SET); - fstFtruncate(fileno(xc->vchn_handle), 0); - fputc('!', xc->vchn_handle); - xc->vchn_siz = 1; + xc->vchg_mem[0] = '!'; + xc->vchg_siz = 1; fstWriterEmitSectionHeader(xc); for(i=0;imaxhandle;i++) { @@ -1673,7 +1692,7 @@ if(xc) } else { - if(xc->vchn_siz >= FST_BREAK_SIZE) + if(xc->vchg_siz >= FST_BREAK_SIZE) { fstWriterFlushContext(xc); xc->tchn_cnt++; @@ -3403,6 +3422,7 @@ for(;;) printf("\tindx_pos: %d (%d bytes)\n", (int)indx_pos, (int)chain_clen); #endif chain_cmem = malloc(chain_clen); + if(!chain_cmem) goto block_err; fseeko(xc->f, indx_pos, SEEK_SET); fstFread(chain_cmem, chain_clen, 1, xc->f); @@ -3416,6 +3436,8 @@ for(;;) chain_table_lengths = malloc((vc_maxhandle+1) * sizeof(uint32_t)); } + if(!chain_table || !chain_table_lengths) goto block_err; + pnt = chain_cmem; idx = 0; pval = 0; @@ -3783,6 +3805,7 @@ for(;;) } } +block_err: free(tc_head); free(chain_cmem); free(mem_for_traversal); diff --git a/vpi/fstapi.h b/vpi/fstapi.h index 0fa158dd0..f7bfb3bae 100644 --- a/vpi/fstapi.h +++ b/vpi/fstapi.h @@ -126,7 +126,7 @@ union { /* if htyp == FST_HT_VAR */ struct fstHierVar { - unsigned char typ; /* FST_VT_VCD_EVENT ... FST_VT_VCD_WOR */ + unsigned char typ; /* FST_VT_VCD_EVENT ... FST_VT_VCD_REALTIME */ unsigned char direction; /* FST_VD_IMPLICIT ... FST_VD_INOUT */ const char *name; uint32_t length; @@ -157,7 +157,7 @@ void fstWriterSetTimescaleFromString(void *ctx, const char *s); void fstWriterSetScope(void *ctx, enum fstScopeType scopetype, const char *scopename, const char *scopecomp); void fstWriterSetUpscope(void *ctx); -void fstWriterEmitValueChange(void *ctx, fstHandle handle, void *val); +void fstWriterEmitValueChange(void *ctx, fstHandle handle, const void *val); void fstWriterEmitDumpActive(void *ctx, int enable); void fstWriterEmitTimeChange(void *ctx, uint64_t tim); void fstWriterFlushContext(void *ctx); diff --git a/vpi/lxt_write.c b/vpi/lxt_write.c index 9731363e9..3ed778cc5 100644 --- a/vpi/lxt_write.c +++ b/vpi/lxt_write.c @@ -996,8 +996,8 @@ if(rgh) lt_recurse_dictionary_free(lt, rgh); static int lt_dictval_compare(const void *v1, const void *v2) { -const dslxt_Tree *s1 = *(const dslxt_Tree * const *)v1; -const dslxt_Tree *s2 = *(const dslxt_Tree * const *)v2; +dslxt_Tree *s1 = *(dslxt_Tree **)v1; +dslxt_Tree *s2 = *(dslxt_Tree **)v2; if(s1->val > s2->val) return(1); else return(-1); /* they're *never* equal */ } diff --git a/vpi/sdf_lexor.lex b/vpi/sdf_lexor.lex index 47932b7c2..8c9c5b591 100644 --- a/vpi/sdf_lexor.lex +++ b/vpi/sdf_lexor.lex @@ -45,6 +45,7 @@ static int yywrap(void) %} %x CCOMMENT +%x COND_EDGE_ID %x EDGE_ID %% @@ -64,14 +65,15 @@ static int yywrap(void) \n { sdflloc.first_line += 1; } /* The other edge identifiers. */ -"01" {return K_01; } -"10" {return K_10; } -"0"[zZ] {return K_0Z; } -[zZ]"1" {return K_Z1; } -"1"[zZ] {return K_1Z; } -[zZ]"0" {return K_Z0; } -[pP][oO][sS][eE][dD][gG][eE] {return K_POSEDGE; } -[nN][eE][gG][eE][dD][gG][eE] {return K_NEGEDGE; } +"01" {return K_01; } +"10" {return K_10; } +"0"[zZ] {return K_0Z; } +[zZ]"1" {return K_Z1; } +"1"[zZ] {return K_1Z; } +[zZ]"0" {return K_Z0; } +[pP][oO][sS][eE][dD][gG][eE] {return K_POSEDGE; } +[nN][eE][gG][eE][dD][gG][eE] {return K_NEGEDGE; } +[cC][oO][nN][dD] {return K_COND; } /* Integer values */ [0-9]+ { @@ -85,7 +87,7 @@ static int yywrap(void) return REAL_NUMBER; } -[a-zA-Z_][a-zA-Z0-9$_]* { +([a-zA-Z_]|(\\[^ \t\b\f\r\n]))([a-zA-Z0-9$_]|(\\[^ \t\b\f\r\n]))* { return lookup_keyword(yytext); } @@ -94,6 +96,17 @@ static int yywrap(void) return QSTRING; } + /* Scalar constants. */ +("1"?"'"[bB])?"0" { return K_LOGICAL_ZERO; } +("1"?"'"[bB])?"1" { return K_LOGICAL_ONE; } + + /* Equality operators. */ + +"==" { return K_EQ; } +"!=" { return K_NE; } +"===" { return K_CEQ; } +"!==" { return K_CNE; } + /* The HCHAR (hierarchy separator) is set by the SDF file itself. We recognize here the HCHAR. */ [./] { @@ -142,9 +155,10 @@ static struct { { 0, IDENTIFIER } }; -void start_edge_id(void) +void start_edge_id(unsigned cond) { - BEGIN(EDGE_ID); + if (cond) BEGIN(COND_EDGE_ID); + else BEGIN(EDGE_ID); } void stop_edge_id(void) @@ -154,12 +168,24 @@ void stop_edge_id(void) static int lookup_keyword(const char*text) { - int idx; + unsigned idx, len, skip; for (idx = 0 ; keywords[idx].name ; idx += 1) { if (strcasecmp(text, keywords[idx].name) == 0) return keywords[idx].code; } + /* Process any escaped characters. */ + skip = 0; + len = strlen(yytext); + for (idx = 0; idx < len; idx += 1) { + if (yytext[idx] == '\\') { + skip += 1; + idx += 1; + } + yytext[idx-skip] = yytext[idx]; + } + yytext[idx-skip] = 0; + yylval.string_val = strdup(yytext); return IDENTIFIER; } diff --git a/vpi/sdf_parse.y b/vpi/sdf_parse.y index 397b66847..8901f241d 100644 --- a/vpi/sdf_parse.y +++ b/vpi/sdf_parse.y @@ -24,10 +24,10 @@ static void yyerror(const char*msg); # include "vpi_user.h" # include "sdf_parse_priv.h" # include "sdf_priv.h" -# include "ivl_alloc.h" # include # include # include +# include "ivl_alloc.h" /* This is the hierarchy separator to use. */ char sdf_use_hchar = '.'; @@ -44,12 +44,13 @@ char sdf_use_hchar = '.'; struct sdf_delval_list_s delval_list; }; -%token K_ABSOLUTE K_CELL K_CELLTYPE K_DATE K_DELAYFILE K_DELAY K_DESIGN +%token K_ABSOLUTE K_CELL K_CELLTYPE K_COND K_DATE K_DELAYFILE K_DELAY K_DESIGN %token K_DIVIDER K_HOLD K_INCREMENT K_INSTANCE K_INTERCONNECT K_IOPATH %token K_NEGEDGE K_POSEDGE K_PROCESS K_PROGRAM K_RECREM K_RECOVERY %token K_REMOVAL K_SDFVERSION K_SETUP K_SETUPHOLD K_TEMPERATURE %token K_TIMESCALE K_TIMINGCHECK K_VENDOR K_VERSION K_VOLTAGE K_WIDTH %token K_01 K_10 K_0Z K_Z1 K_1Z K_Z0 +%token K_EQ K_NE K_CEQ K_CNE K_LOGICAL_ONE K_LOGICAL_ZERO %token HCHAR %token QSTRING IDENTIFIER @@ -284,14 +285,53 @@ tchk_def | '(' K_HOLD port_tchk port_tchk rvalue ')' | '(' K_SETUPHOLD port_tchk port_tchk rvalue rvalue ')' | '(' K_RECOVERY port_tchk port_tchk rvalue ')' - | '(' K_REMOVAL port_tchk port_tchk rvalue ')' | '(' K_RECREM port_tchk port_tchk rvalue rvalue ')' + | '(' K_REMOVAL port_tchk port_tchk rvalue ')' | '(' K_WIDTH port_tchk rvalue ')' ; port_tchk - : port_spec - /* | '(' K_COND qstring_opt timing_check_condition port_spec ')' */ + : port_instance + /* This must only be an edge. For now we just accept everything. */ + | cond_edge_start port_instance ')' + /* These must only be a cond. For now we just accept everything. */ + | cond_edge_start timing_check_condition port_spec ')' + | cond_edge_start QSTRING timing_check_condition port_spec ')' + ; + +cond_edge_start + : '(' { start_edge_id(1); } cond_edge_identifier { stop_edge_id(); } + ; + +cond_edge_identifier + : K_POSEDGE + | K_NEGEDGE + | K_01 + | K_10 + | K_0Z + | K_Z1 + | K_1Z + | K_Z0 + | K_COND + ; + +timing_check_condition + : port_interconnect + | '~' port_interconnect + | '!' port_interconnect + | port_interconnect equality_operator scalar_constant + ; + +equality_operator + : K_EQ + | K_NE + | K_CEQ + | K_CNE + ; + +scalar_constant + : K_LOGICAL_ONE + | K_LOGICAL_ZERO ; port_spec @@ -318,7 +358,7 @@ port_interconnect ; port_edge - : '(' {start_edge_id();} edge_identifier {stop_edge_id();} port_instance ')' + : '(' {start_edge_id(0);} edge_identifier {stop_edge_id();} port_instance ')' { $$.vpi_edge = $3; $$.string_val = $5; } ; @@ -420,6 +460,7 @@ signed_real_number_opt { $$.value = $1; $$.defined = 1; } + ; signed_real_number : REAL_NUMBER { $$ = $1; } diff --git a/vpi/sdf_parse_priv.h b/vpi/sdf_parse_priv.h index 3483a81f9..bc2751ce1 100644 --- a/vpi/sdf_parse_priv.h +++ b/vpi/sdf_parse_priv.h @@ -1,7 +1,7 @@ #ifndef _sdf_parse_priv_h #define _sdf_parse_priv_h /* - * Copyright (c) 2007-2009 Stephen Williams (steve@icarus.com) + * Copyright (c) 2007-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 @@ -35,7 +35,7 @@ extern const char*sdf_parse_path; /* Hierarchy separator character to use. */ extern char sdf_use_hchar; -extern void start_edge_id(void); +extern void start_edge_id(unsigned cond); extern void stop_edge_id(void); #endif diff --git a/vpi/stringheap.c b/vpi/stringheap.c index 819fdfac1..2b419965a 100644 --- a/vpi/stringheap.c +++ b/vpi/stringheap.c @@ -19,10 +19,10 @@ # include "sys_priv.h" # include "stringheap.h" -# include "ivl_alloc.h" # include # include # include +# include "ivl_alloc.h" struct stringheap_cell { struct stringheap_cell*next; diff --git a/vpi/sys_display.c b/vpi/sys_display.c index 386338b7f..18729c4f1 100644 --- a/vpi/sys_display.c +++ b/vpi/sys_display.c @@ -18,7 +18,6 @@ */ # include "sys_priv.h" -# include "ivl_alloc.h" # include # include # include @@ -26,6 +25,7 @@ # include # include # include +# include "ivl_alloc.h" #define IS_MCD(mcd) !((mcd)>>31&1) diff --git a/vpi/sys_fileio.c b/vpi/sys_fileio.c index 4d0107cd7..305775390 100644 --- a/vpi/sys_fileio.c +++ b/vpi/sys_fileio.c @@ -18,13 +18,13 @@ */ # include "sys_priv.h" -# include "ivl_alloc.h" # include # include # include # include # include # include +# include "ivl_alloc.h" #define IS_MCD(mcd) !((mcd)>>31&1) diff --git a/vpi/sys_fst.c b/vpi/sys_fst.c index de02f00b8..b70eaf4c9 100644 --- a/vpi/sys_fst.c +++ b/vpi/sys_fst.c @@ -25,12 +25,12 @@ * This file contains the implementations of the FST related functions. */ -# include "ivl_alloc.h" # include # include # include # include # include +# include "ivl_alloc.h" static char *dump_path = NULL; static struct fstContext *dump_file = NULL; diff --git a/vpi/sys_lxt.c b/vpi/sys_lxt.c index de86501be..0cc02aaba 100644 --- a/vpi/sys_lxt.c +++ b/vpi/sys_lxt.c @@ -26,13 +26,13 @@ * This file contains the implementations of the LXT related functions. */ -# include "ivl_alloc.h" # include # include # include # include # include # include "stringheap.h" +# include "ivl_alloc.h" static char *dump_path = NULL; diff --git a/vpi/sys_lxt2.c b/vpi/sys_lxt2.c index e0228272e..b50011ca2 100644 --- a/vpi/sys_lxt2.c +++ b/vpi/sys_lxt2.c @@ -26,13 +26,13 @@ * This file contains the implementations of the LXT2 related functions. */ -# include "ivl_alloc.h" # include # include # include # include # include "stringheap.h" # include +# include "ivl_alloc.h" static char *dump_path = NULL; diff --git a/vpi/sys_priv.c b/vpi/sys_priv.c index 1f66d2b00..cf3713b18 100644 --- a/vpi/sys_priv.c +++ b/vpi/sys_priv.c @@ -18,11 +18,11 @@ */ #include "sys_priv.h" -#include "ivl_alloc.h" #include #include #include #include +#include "ivl_alloc.h" PLI_UINT64 timerec_to_time64(const struct t_vpi_time*timerec) { diff --git a/vpi/sys_random_mti.c b/vpi/sys_random_mti.c index d4abaceaa..14f9e1f68 100644 --- a/vpi/sys_random_mti.c +++ b/vpi/sys_random_mti.c @@ -20,11 +20,11 @@ # include "sys_priv.h" # include "sys_random.h" -# include "ivl_alloc.h" # include # include # include # include +# include "ivl_alloc.h" /* * Implement the $random system function using the ``Mersenne diff --git a/vpi/sys_readmem.c b/vpi/sys_readmem.c index 8cba60b7c..d716420dd 100644 --- a/vpi/sys_readmem.c +++ b/vpi/sys_readmem.c @@ -18,7 +18,6 @@ */ # include "sys_priv.h" -# include "ivl_alloc.h" # include # include # include @@ -26,6 +25,7 @@ # include # include "sys_readmem_lex.h" # include +# include "ivl_alloc.h" char **search_list = NULL; unsigned sl_count = 0; diff --git a/vpi/sys_scanf.c b/vpi/sys_scanf.c index e76e5e7ee..896a2af0a 100644 --- a/vpi/sys_scanf.c +++ b/vpi/sys_scanf.c @@ -22,7 +22,6 @@ # define _SVID_SOURCE 1 # include "sys_priv.h" -# include "ivl_alloc.h" # include # include # include @@ -30,6 +29,7 @@ # include # include # include +# include "ivl_alloc.h" struct byte_source { const char*str; diff --git a/vpi/sys_vcd.c b/vpi/sys_vcd.c index 9be51396a..2e47ee427 100644 --- a/vpi/sys_vcd.c +++ b/vpi/sys_vcd.c @@ -24,12 +24,12 @@ * This file contains the implementations of the VCD related functions. */ -# include "ivl_alloc.h" # include # include # include # include # include +# include "ivl_alloc.h" static char *dump_path = NULL; static FILE *dump_file = NULL; @@ -76,9 +76,11 @@ static void gen_new_vcd_id(void) v /= 94; if(!v) { vcdid[i+1] = '\0'; - break; + return; } } + // This should never happen since 94**7 is a lot if identifiers! + assert(0); } static char *truncate_bitvec(char *s) diff --git a/vpi/v2005_math.c b/vpi/v2005_math.c index 631bbc810..09edc03e2 100644 --- a/vpi/v2005_math.c +++ b/vpi/v2005_math.c @@ -20,12 +20,12 @@ */ #include "vpi_config.h" -#include "ivl_alloc.h" #include #include #include #include #include "vpi_user.h" +#include "ivl_alloc.h" /* Single argument functions. */ typedef struct s_single_data { diff --git a/vpi/va_math.c b/vpi/va_math.c index 7221abd6a..1b6bb0ea1 100644 --- a/vpi/va_math.c +++ b/vpi/va_math.c @@ -20,12 +20,12 @@ */ #include "vpi_config.h" -#include "ivl_alloc.h" #include #include #include #include #include "vpi_user.h" +#include "ivl_alloc.h" /* * Compile time options: (set in the Makefile.) diff --git a/vpi_user.h b/vpi_user.h index abe25f8db..e365c029d 100644 --- a/vpi_user.h +++ b/vpi_user.h @@ -577,7 +577,7 @@ extern PLI_INT32 vpi_chk_error(p_vpi_error_info info); /* This is the table of startup routines included in each module. */ -extern DLLEXPORT void (*vlog_startup_routines[])(); +extern DLLEXPORT void (*vlog_startup_routines[])(void); /* diff --git a/vvp/array.cc b/vvp/array.cc index a5c07bdcd..0dd77eb64 100644 --- a/vvp/array.cc +++ b/vvp/array.cc @@ -26,13 +26,13 @@ #ifdef CHECK_WITH_VALGRIND #include "vvp_cleanup.h" #endif -# include "ivl_alloc.h" # include # include # include # include # include "compile.h" # include +# include "ivl_alloc.h" unsigned long count_net_arrays = 0; unsigned long count_net_array_words = 0; diff --git a/vvp/compile.cc b/vvp/compile.cc index 6adc7a1ad..c913deb33 100644 --- a/vvp/compile.cc +++ b/vvp/compile.cc @@ -28,7 +28,6 @@ # include "vpi_priv.h" # include "parse_misc.h" # include "statistics.h" -# include "ivl_alloc.h" # include # include # include @@ -39,6 +38,8 @@ #include #endif +# include "ivl_alloc.h" + unsigned compile_errors = 0; /* @@ -76,7 +77,7 @@ struct opcode_table_s { enum operand_e argt[OPERAND_MAX]; }; -const static struct opcode_table_s opcode_table[] = { +static const struct opcode_table_s opcode_table[] = { { "%abs/wr", of_ABS_WR, 2, {OA_BIT1, OA_BIT2, OA_NONE} }, { "%add", of_ADD, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} }, { "%add/wr", of_ADD_WR, 2, {OA_BIT1, OA_BIT2, OA_NONE} }, diff --git a/vvp/delay.cc b/vvp/delay.cc index ab91b9fab..03cd6b506 100644 --- a/vvp/delay.cc +++ b/vvp/delay.cc @@ -24,12 +24,12 @@ #ifdef CHECK_WITH_VALGRIND #include "vvp_cleanup.h" #endif -#include "ivl_alloc.h" #include #include #include #include #include +#include "ivl_alloc.h" void vvp_delay_t::calculate_min_delay_() { @@ -526,7 +526,7 @@ static vvp_time64_t delay_from_edge(vvp_bit4_t a, vvp_bit4_t b, vvp_time64_t array[12]) { typedef delay_edge_t bit4_table4[4]; - const static bit4_table4 edge_table[4] = { + static const bit4_table4 edge_table[4] = { { DELAY_EDGE_01, DELAY_EDGE_01, DELAY_EDGE_0x, DELAY_EDGE_0z }, { DELAY_EDGE_10, DELAY_EDGE_10, DELAY_EDGE_1x, DELAY_EDGE_1z }, { DELAY_EDGE_x0, DELAY_EDGE_x1, DELAY_EDGE_x0, DELAY_EDGE_xz }, @@ -617,7 +617,7 @@ void vvp_fun_modpath::recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit, out_at[idx] -= now; } - for (cur ++ ; cur != candidate_list.end() ; cur ++) { + for (cur ++ ; cur != candidate_list.end() ; ++ cur ) { src = *cur; for (unsigned idx = 0 ; idx < 12 ; idx += 1) { vvp_time64_t tmp = src->wake_time_ + src->delay_[idx]; diff --git a/vvp/island_tran.cc b/vvp/island_tran.cc index 091e648e1..072f2cac2 100644 --- a/vvp/island_tran.cc +++ b/vvp/island_tran.cc @@ -161,7 +161,7 @@ bool vvp_island_branch_tran::run_test_enabled() static void island_send_value(list&connections, const vvp_vector8_t&val) { for (list::iterator idx = connections.begin() - ; idx != connections.end() ; idx ++ ) { + ; idx != connections.end() ; ++ idx ) { vvp_island_branch*tmp_ptr = idx->ptr(); @@ -173,7 +173,7 @@ static void island_send_value(list&connections, const vvp_vect static void mark_done_flags(list&connections) { for (list::iterator idx = connections.begin() - ; idx != connections.end() ; idx ++ ) { + ; idx != connections.end() ; ++ idx ) { vvp_island_branch*tmp_ptr = idx->ptr(); vvp_island_branch_tran*cur = dynamic_cast(tmp_ptr); @@ -186,7 +186,7 @@ static void mark_done_flags(list&connections) static void mark_visited_flags(list&connections) { for (list::iterator idx = connections.begin() - ; idx != connections.end() ; idx ++ ) { + ; idx != connections.end() ; ++ idx ) { vvp_island_branch*tmp_ptr = idx->ptr(); vvp_island_branch_tran*cur = dynamic_cast(tmp_ptr); @@ -200,7 +200,7 @@ static void mark_visited_flags(list&connections) static void clear_visited_flags(list&connections) { for (list::iterator idx = connections.begin() - ; idx != connections.end() ; idx ++ ) { + ; idx != connections.end() ; ++ idx ) { vvp_island_branch_tran*tmp_ptr = BRANCH_TRAN(idx->ptr()); @@ -215,7 +215,7 @@ static void resolve_values_from_connections(vvp_vector8_t&val, list&connections) { for (list::iterator idx = connections.begin() - ; idx != connections.end() ; idx ++ ) { + ; idx != connections.end() ; ++ idx ) { vvp_vector8_t tmp = get_value_from_branch(*idx); if (val.size() == 0) val = tmp; @@ -287,7 +287,7 @@ static void push_value_through_branches(const vvp_vector8_t&val, list&connections) { for (list::iterator idx = connections.begin() - ; idx != connections.end() ; idx ++ ) { + ; idx != connections.end() ; ++ idx ) { vvp_island_branch_tran*tmp_ptr = BRANCH_TRAN(idx->ptr()); unsigned tmp_ab = idx->port(); diff --git a/vvp/lexor.lex b/vvp/lexor.lex index eba911ced..b043cf488 100644 --- a/vvp/lexor.lex +++ b/vvp/lexor.lex @@ -25,9 +25,9 @@ # include "parse_misc.h" # include "compile.h" # include "parse.h" -# include "ivl_alloc.h" # include # include +# include "ivl_alloc.h" static char* strdupnew(char const *str) { diff --git a/vvp/main.cc b/vvp/main.cc index 49df4a98c..a81664e72 100644 --- a/vvp/main.cc +++ b/vvp/main.cc @@ -203,7 +203,7 @@ static void final_cleanup() #ifdef CHECK_WITH_VALGRIND /* Clean up the file name table. */ for (vector::iterator cur = file_names.begin(); - cur != file_names.end() ; cur++) { + cur != file_names.end() ; ++ cur ) { delete[] *cur; } /* Clear the static result buffer. */ diff --git a/vvp/parse.y b/vvp/parse.y index b4f5123e8..ba2e8e4a1 100644 --- a/vvp/parse.y +++ b/vvp/parse.y @@ -22,11 +22,11 @@ # include "parse_misc.h" # include "compile.h" # include "delay.h" -# include "ivl_alloc.h" # include # include # include # include +# include "ivl_alloc.h" /* * These are bits in the lexor. diff --git a/vvp/parse_misc.cc b/vvp/parse_misc.cc index 966e74084..e811fcbca 100644 --- a/vvp/parse_misc.cc +++ b/vvp/parse_misc.cc @@ -19,9 +19,9 @@ # include "parse_misc.h" # include "compile.h" -# include "ivl_alloc.h" # include # include +# include "ivl_alloc.h" const char*yypath; unsigned yyline; diff --git a/vvp/stop.cc b/vvp/stop.cc index 140b17d85..07af64487 100644 --- a/vvp/stop.cc +++ b/vvp/stop.cc @@ -28,7 +28,6 @@ # include "vpi_priv.h" # include "vthread.h" # include "schedule.h" -# include "ivl_alloc.h" # include # include #ifdef USE_READLINE @@ -39,6 +38,7 @@ #endif # include # include +# include "ivl_alloc.h" struct __vpiScope*stop_current_scope = 0; bool stop_is_finish; /* When set, $stop acts like $finish (set in main.cc). */ diff --git a/vvp/udp.cc b/vvp/udp.cc index fc221e04b..0c45be816 100644 --- a/vvp/udp.cc +++ b/vvp/udp.cc @@ -25,15 +25,15 @@ #include "symbols.h" #include "compile.h" #include "config.h" -#ifdef CHECK_WITH_VALGRIND -#include "vvp_cleanup.h" -#include "ivl_alloc.h" -#endif #include #include #include #include #include +#ifdef CHECK_WITH_VALGRIND +#include "vvp_cleanup.h" +#include "ivl_alloc.h" +#endif // We may need these later when we build the VPI interface to // UDP definitions. diff --git a/vvp/ufunc.cc b/vvp/ufunc.cc index 5ad7c6ccd..7a9d33f2a 100644 --- a/vvp/ufunc.cc +++ b/vvp/ufunc.cc @@ -234,7 +234,7 @@ void exec_ufunc_delete(vvp_code_t euf_code) void ufunc_pool_delete(void) { map::iterator iter; - for (iter = ufunc_map.begin(); iter != ufunc_map.end(); iter++) { + for (iter = ufunc_map.begin(); iter != ufunc_map.end(); ++ iter ) { delete iter->first; } } diff --git a/vvp/vpi_const.cc b/vvp/vpi_const.cc index 2c0981693..82464b112 100644 --- a/vvp/vpi_const.cc +++ b/vvp/vpi_const.cc @@ -23,11 +23,11 @@ #ifdef CHECK_WITH_VALGRIND # include "vvp_cleanup.h" #endif -# include "ivl_alloc.h" # include # include # include # include +# include "ivl_alloc.h" static int string_get(int code, vpiHandle ref) { diff --git a/vvp/vpi_event.cc b/vvp/vpi_event.cc index 7866df871..49c01cab0 100644 --- a/vvp/vpi_event.cc +++ b/vvp/vpi_event.cc @@ -19,11 +19,11 @@ # include "compile.h" # include "vpi_priv.h" -# include "ivl_alloc.h" # include # include # include # include +# include "ivl_alloc.h" static int named_event_get(int code, vpiHandle ref) { diff --git a/vvp/vpi_iter.cc b/vvp/vpi_iter.cc index 36434a53f..f548e796a 100644 --- a/vvp/vpi_iter.cc +++ b/vvp/vpi_iter.cc @@ -22,9 +22,9 @@ */ # include "vpi_priv.h" -# include "ivl_alloc.h" # include # include +# include "ivl_alloc.h" static int iterator_free_object(vpiHandle ref) { diff --git a/vvp/vpi_mcd.cc b/vvp/vpi_mcd.cc index 177a7efe5..079ad1abe 100644 --- a/vvp/vpi_mcd.cc +++ b/vvp/vpi_mcd.cc @@ -22,12 +22,12 @@ #ifdef CHECK_WITH_VALGRIND # include "vvp_cleanup.h" #endif -# include "ivl_alloc.h" # include # include # include # include # include +# include "ivl_alloc.h" extern FILE* vpi_trace; diff --git a/vvp/vpi_modules.cc b/vvp/vpi_modules.cc index 4a944c2d8..f45055eae 100644 --- a/vvp/vpi_modules.cc +++ b/vvp/vpi_modules.cc @@ -21,11 +21,11 @@ # include "vpi_priv.h" # include "ivl_dlfcn.h" # include "vvp_cleanup.h" -# include "ivl_alloc.h" # include # include # include # include +# include "ivl_alloc.h" static ivl_dll_t*dll_list = 0; static unsigned dll_list_cnt = 0; diff --git a/vvp/vpi_priv.cc b/vvp/vpi_priv.cc index 01b4519ce..7371e6a5d 100644 --- a/vvp/vpi_priv.cc +++ b/vvp/vpi_priv.cc @@ -326,7 +326,6 @@ PLI_INT32 vpi_get(int property, vpiHandle ref) ref, vpi_type_values(ref->vpi_type->type_code)); } - struct __vpiSignal*rfp = (struct __vpiSignal*)ref; if (ref->vpi_type->type_code == vpiMemory && is_net_array(ref)) return vpiNetArray; else @@ -380,7 +379,6 @@ char* vpi_get_str(PLI_INT32 property, vpiHandle ref) ref, vpi_type_values(ref->vpi_type->type_code)); } - struct __vpiSignal*rfp = (struct __vpiSignal*)ref; PLI_INT32 type; if (ref->vpi_type->type_code == vpiMemory && is_net_array(ref)) type = vpiNetArray; diff --git a/vvp/vpi_real.cc b/vvp/vpi_real.cc index 83a40d1e3..72812ecca 100644 --- a/vvp/vpi_real.cc +++ b/vvp/vpi_real.cc @@ -24,11 +24,11 @@ #ifdef CHECK_WITH_VALGRIND # include "vvp_cleanup.h" #endif -# include "ivl_alloc.h" # include # include # include # include +# include "ivl_alloc.h" struct __vpiRealVar* vpip_realvar_from_handle(vpiHandle obj) { diff --git a/vvp/vpi_scope.cc b/vvp/vpi_scope.cc index a69dea774..e3449679c 100644 --- a/vvp/vpi_scope.cc +++ b/vvp/vpi_scope.cc @@ -25,10 +25,10 @@ #ifdef CHECK_WITH_VALGRIND # include "vvp_cleanup.h" #endif -# include "ivl_alloc.h" # include # include # include +# include "ivl_alloc.h" static vpiHandle *vpip_root_table_ptr = 0; static unsigned vpip_root_table_cnt = 0; @@ -63,8 +63,6 @@ static void delete_sub_scopes(struct __vpiScope *scope) vthreads_delete(lscope); delete (scope->intern)[idx]; break; - case vpiIntegerVar: - break; case vpiMemory: case vpiNetArray: memory_delete((scope->intern)[idx]); @@ -78,6 +76,11 @@ static void delete_sub_scopes(struct __vpiScope *scope) break; case vpiNet: case vpiReg: + case vpiIntegerVar: + case vpiLongIntVar: + case vpiShortIntVar: + case vpiIntVar: + case vpiByteVar: signal_delete((scope->intern)[idx]); break; case vpiParameter: diff --git a/vvp/vpi_signal.cc b/vvp/vpi_signal.cc index fe629ed0c..4d07c997f 100644 --- a/vvp/vpi_signal.cc +++ b/vvp/vpi_signal.cc @@ -31,7 +31,6 @@ #ifdef CHECK_WITH_VALGRIND # include "vvp_cleanup.h" #endif -# include "ivl_alloc.h" # include # include # include @@ -42,6 +41,7 @@ #ifdef CHECK_WITH_VALGRIND # include #endif +# include "ivl_alloc.h" /* * Hex digits that represent 4-value bits of Verilog are not as @@ -890,6 +890,9 @@ static const struct __vpirt vpip_integer_rt = { signal_put_value, signal_get_handle, signal_iterate, + 0, + 0, + 0, 0 }; @@ -915,6 +918,9 @@ static const struct __vpirt vpip_byte_rt = { signal_put_value, signal_get_handle, signal_iterate, + 0, + 0, + 0, 0 }; @@ -926,6 +932,9 @@ static const struct __vpirt vpip_shortint_rt = { signal_put_value, signal_get_handle, signal_iterate, + 0, + 0, + 0, 0 }; @@ -937,6 +946,9 @@ static const struct __vpirt vpip_int_rt = { signal_put_value, signal_get_handle, signal_iterate, + 0, + 0, + 0, 0 }; @@ -948,6 +960,9 @@ static const struct __vpirt vpip_longint_rt = { signal_put_value, signal_get_handle, signal_iterate, + 0, + 0, + 0, 0 }; @@ -982,6 +997,8 @@ vpiHandle vpip_make_int2(const char*name, int msb, int lsb, vvp_net_t*vec) case 63: obj->vpi_type = &vpip_longint_rt; break; + default: + assert(0); } return obj; diff --git a/vvp/vpi_tasks.cc b/vvp/vpi_tasks.cc index 8c4858136..e76789f7a 100644 --- a/vvp/vpi_tasks.cc +++ b/vvp/vpi_tasks.cc @@ -29,11 +29,11 @@ #ifdef CHECK_WITH_VALGRIND # include "vvp_cleanup.h" #endif -# include "ivl_alloc.h" # include # include # include # include +# include "ivl_alloc.h" static const struct __vpirt vpip_systf_def_rt = { vpiUserSystf, diff --git a/vvp/vpi_vthr_vector.cc b/vvp/vpi_vthr_vector.cc index 1fe98b023..785ccbbe1 100644 --- a/vvp/vpi_vthr_vector.cc +++ b/vvp/vpi_vthr_vector.cc @@ -30,10 +30,10 @@ # include "vvp_cleanup.h" # include #endif -# include "ivl_alloc.h" # include # include # include +# include "ivl_alloc.h" struct __vpiVThrVec { struct __vpiHandle base; @@ -636,7 +636,7 @@ static void thread_word_delete_real(vpiHandle item) void vpi_handle_delete() { map::iterator iter; - for (iter = handle_map.begin(); iter != handle_map.end(); iter++) { + for (iter = handle_map.begin(); iter != handle_map.end(); ++ iter ) { if (iter->second) thread_vthr_delete_real(iter->first); else thread_word_delete_real(iter->first); } diff --git a/vvp/vpip_to_dec.cc b/vvp/vpip_to_dec.cc index 4ea73f3aa..6b2a99bf3 100644 --- a/vvp/vpip_to_dec.cc +++ b/vvp/vpip_to_dec.cc @@ -23,13 +23,13 @@ #ifdef CHECK_WITH_VALGRIND # include "vvp_cleanup.h" #endif -# include "ivl_alloc.h" # include # include # include /* for CHAR_BIT */ # include # include # include +# include "ivl_alloc.h" /* If you are allergic to malloc, you can set a stack memory allocation * here. Otherwise, malloc() is used for the temporary array, so the diff --git a/vvp/vthread.cc b/vvp/vthread.cc index fe3a07ec9..af75ced8a 100644 --- a/vvp/vthread.cc +++ b/vvp/vthread.cc @@ -456,7 +456,7 @@ static void child_delete(vthread_t base) void vthreads_delete(struct __vpiScope*scope) { for (std::set::iterator cur = scope->threads.begin() - ; cur != scope->threads.end() ; cur ++) { + ; cur != scope->threads.end() ; ++ cur ) { delete *cur; } scope->threads.clear(); diff --git a/vvp/vvp_island.cc b/vvp/vvp_island.cc index 1ae39af50..49c167e75 100644 --- a/vvp/vvp_island.cc +++ b/vvp/vvp_island.cc @@ -25,12 +25,12 @@ #ifdef CHECK_WITH_VALGRIND # include "vvp_cleanup.h" #endif -# include "ivl_alloc.h" # include # include # include # include # include +# include "ivl_alloc.h" static bool at_EOS = false; diff --git a/vvp/vvp_net.cc b/vvp/vvp_net.cc index b874381b8..5680e8b92 100644 --- a/vvp/vvp_net.cc +++ b/vvp/vvp_net.cc @@ -116,14 +116,14 @@ void vvp_net_pool_delete() local_net_pool_count = 0; map::iterator iter; - for (iter = vvp_net_map.begin(); iter != vvp_net_map.end(); iter++) { + for (iter = vvp_net_map.begin(); iter != vvp_net_map.end(); ++ iter ) { vvp_nets_del += 1; VALGRIND_MEMPOOL_FREE(iter->first->pool, iter->first); } vvp_net_map.clear(); map::iterator siter; - for (siter = sfunc_map.begin(); siter != sfunc_map.end(); siter++) { + for (siter = sfunc_map.begin(); siter != sfunc_map.end(); ++ siter ) { delete siter->first; } sfunc_map.clear(); @@ -155,9 +155,6 @@ vvp_net_t::vvp_net_t() out_ = vvp_net_ptr_t(0,0); fun = 0; fil = 0; -#ifdef CHECK_WITH_VALGRIND - pool = NULL; -#endif } void vvp_net_t::link(vvp_net_ptr_t port_to_link) diff --git a/vvp/vvp_net.h b/vvp/vvp_net.h index 3a173657f..875266ffc 100644 --- a/vvp/vvp_net.h +++ b/vvp/vvp_net.h @@ -23,7 +23,6 @@ # include "vpi_user.h" # include "vvp_vpi_callback.h" # include "permaheap.h" -# include "ivl_alloc.h" # include # include # include @@ -36,6 +35,8 @@ class ostream; #endif +# include "ivl_alloc.h" + using namespace std; @@ -334,12 +335,12 @@ inline vvp_vector4_t::vvp_vector4_t(unsigned size__, vvp_bit4_t val) : size_(size__) { /* note: this relies on the bit encoding for the vvp_bit4_t. */ - const static unsigned long init_atable[4] = { + static const unsigned long init_atable[4] = { WORD_0_ABITS, WORD_1_ABITS, WORD_Z_ABITS, WORD_X_ABITS }; - const static unsigned long init_btable[4] = { + static const unsigned long init_btable[4] = { WORD_0_BBITS, WORD_1_BBITS, WORD_Z_BBITS, @@ -1651,4 +1652,12 @@ inline bool vvp_net_fil_t::test_force_mask_is_zero(void) const return false; } +/* + * Undefine the ivl_alloc.h definitions so they don't leak out of this file. + */ +#undef malloc +#undef realloc +#undef calloc +#undef __ivl_alloc_H + #endif diff --git a/vvp/vvp_net_sig.cc b/vvp/vvp_net_sig.cc index 2e1a43270..1da9edb85 100644 --- a/vvp/vvp_net_sig.cc +++ b/vvp/vvp_net_sig.cc @@ -928,7 +928,7 @@ void vvp_wire_vec8::vec4_value(vvp_vector4_t&val) const } vvp_wire_real::vvp_wire_real() -: bit_(0.0) +: bit_(0.0), force_(0.0) { }