From bb5ca97f2d3bb34540c605638cd3b858ced5412a Mon Sep 17 00:00:00 2001 From: Cary R Date: Mon, 1 Nov 2010 14:37:06 -0700 Subject: [PATCH] Fix some -Wextra warnings and some other bug fixes/enhancements. This patch covers more than it should. It removes many of the -Wextra warnings in the main ivl directory. It also makes some minor code improvements, adds support for constant logicals in eval_tree (&&/||), adds support for correctly sign extending === and !==, it starts to standardize the eval_tree debug messages and fixes a strength bug in the target interface (found with -Wextra). The rest of the warnings and eval_tree() rework will need to come as a second patch. --- Makefile.in | 6 +- PExpr.cc | 17 +- PGate.h | 3 + cprop.cc | 14 +- elab_expr.cc | 77 ++--- elab_lval.cc | 4 +- elab_pexpr.cc | 2 +- elab_scope.cc | 10 +- elab_sig.cc | 11 +- elaborate.cc | 6 +- emit.cc | 6 +- eval_tree.cc | 672 +++++++++++++++++++++++++------------------- expr_synth.cc | 15 +- functor.cc | 2 +- iverilog-vpi.sh | 3 +- lexor_keyword.gperf | 6 + net_nex_input.cc | 24 +- net_nex_output.cc | 8 +- netlist.h | 6 +- netmisc.cc | 12 +- netmisc.h | 4 + nodangle.cc | 4 +- set_width.cc | 37 +-- syn-rules.y | 15 +- synth2.cc | 53 ++-- t-dll.cc | 4 +- target.cc | 14 +- verinum.cc | 2 +- verinum.h | 4 +- 29 files changed, 577 insertions(+), 464 deletions(-) diff --git a/Makefile.in b/Makefile.in index 4b268c883..c66f9665c 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@ @@ -211,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/PExpr.cc b/PExpr.cc index 98617deff..494e80058 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 @@ -38,7 +38,7 @@ PExpr::~PExpr() { } -void PExpr::declare_implicit_nets(LexicalScope*scope, NetNet::Type type) +void PExpr::declare_implicit_nets(LexicalScope*, NetNet::Type) { } @@ -52,18 +52,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 3f4cceaf0..ee151d9c0 100644 --- a/PGate.h +++ b/PGate.h @@ -237,7 +237,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/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/elab_expr.cc b/elab_expr.cc index 4c8ede40b..02e733357 100644 --- a/elab_expr.cc +++ b/elab_expr.cc @@ -127,8 +127,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) { @@ -226,9 +226,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_; @@ -447,7 +450,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 @@ -737,7 +740,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 { @@ -800,7 +803,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 { @@ -888,7 +891,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_); @@ -943,10 +946,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; @@ -955,7 +958,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_); @@ -1038,7 +1041,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_); @@ -1065,7 +1068,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) { @@ -1129,6 +1132,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; } @@ -1610,7 +1616,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) { @@ -1807,8 +1813,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) { @@ -1820,7 +1826,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); @@ -1953,7 +1959,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 @@ -2092,7 +2098,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_; @@ -2103,6 +2109,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; } @@ -2301,7 +2311,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 { @@ -2425,7 +2435,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 { @@ -2504,7 +2514,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 { @@ -2900,7 +2910,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; @@ -3005,7 +3015,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); @@ -3093,7 +3103,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); @@ -3177,7 +3187,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()); @@ -3345,7 +3355,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_); @@ -3369,10 +3379,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; @@ -3380,11 +3390,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 cb7bfd2fb..c2d9eb1af 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 9d3cb8d69..301c03710 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; diff --git a/elab_scope.cc b/elab_scope.cc index 7116aff88..d3b8dbb5b 100644 --- a/elab_scope.cc +++ b/elab_scope.cc @@ -247,7 +247,6 @@ static void elaborate_scope_events_(Design*des, NetScope*scope, } static void elaborate_scope_tasks(Design*des, NetScope*scope, - const LineInfo&loc, const map&tasks) { typedef map::const_iterator tasks_it_t; @@ -302,7 +301,6 @@ 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; @@ -482,14 +480,14 @@ 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. @@ -1050,8 +1048,8 @@ 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. diff --git a/elab_sig.cc b/elab_sig.cc index f4e6162f2..cb188a356 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 { } @@ -268,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; } @@ -313,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 { diff --git a/elaborate.cc b/elaborate.cc index ecac051ae..18f86ece5 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; } diff --git a/emit.cc b/emit.cc index d1e009b63..558f2f529 100644 --- a/emit.cc +++ b/emit.cc @@ -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; @@ -531,7 +531,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_tree.cc b/eval_tree.cc index 993025568..bfe4340ac 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,65 @@ 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,23 +949,21 @@ 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_) { @@ -948,7 +997,15 @@ NetEConst* NetEBLogic::eval_tree(int prune_to_width) 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 +1018,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 +1047,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 +1066,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 +1095,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 +1151,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 +1187,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 +1295,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 +1415,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 +1494,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 +1517,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 +1549,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_); @@ -1542,6 +1627,11 @@ NetExpr* NetEUnary::eval_tree_real_() NetExpr* NetEUnary::eval_tree(int prune_to_width) { + if (debug_eval_tree) { + cerr << get_fileline() << ": debug: Evaluating expression:" + << *this << ", prune_to_width=" << prune_to_width << endl; + } + eval_expr(expr_); if (expr_type() == IVL_VT_REAL) return eval_tree_real_(); @@ -1605,6 +1695,11 @@ NetExpr* NetEUBits::eval_tree(int prune_to_width) NetEConst* NetEUReduce::eval_tree(int prune_to_width) { + if (debug_eval_tree) { + cerr << get_fileline() << ": debug: Evaluating expression:" + << *this << ", prune_to_width=" << prune_to_width << endl; + } + eval_expr(expr_); NetEConst*rval = dynamic_cast(expr_); if (rval == 0) return 0; @@ -1892,6 +1987,11 @@ NetExpr* evaluate_min_max(NetExpr*&arg0_, NetExpr*&arg1_, const char*name) NetExpr* NetESFunc::eval_tree(int prune_to_width) { + if (debug_eval_tree) { + cerr << get_fileline() << ": debug: Evaluating expression:" + << *this << ", prune_to_width=" << prune_to_width << endl; + } + /* 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. */ @@ -1989,7 +2089,7 @@ NetExpr* NetESFunc::eval_tree(int prune_to_width) 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 d8dc402ee..4c8ebc628 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 7fb946def..b9351c4ac 100644 --- a/functor.cc +++ b/functor.cc @@ -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/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/net_nex_input.cc b/net_nex_input.cc index 2da521912..6c6ccd9d0 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,17 +90,17 @@ 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* NetEScope::nex_input(bool rem_out) +NexusSet* NetEScope::nex_input(bool) { return new NexusSet; } @@ -324,7 +324,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; @@ -349,7 +349,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; @@ -407,7 +407,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/netlist.h b/netlist.h index 074dfc55c..608a54dfe 100644 --- a/netlist.h +++ b/netlist.h @@ -3405,14 +3405,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); }; /* @@ -3434,6 +3433,7 @@ class NetEBLogic : public NetEBinary { virtual NetNet* synthesize(Design*, NetScope*scope, NetExpr*root); private: + NetEConst* eval_tree_real_(); }; /* diff --git a/netmisc.cc b/netmisc.cc index 08445a337..298c8c5a3 100644 --- a/netmisc.cc +++ b/netmisc.cc @@ -26,11 +26,14 @@ # include "pform_types.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(); @@ -70,11 +73,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) { @@ -657,7 +657,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 3d88ca8aa..cc8612458 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 1bd98e930..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; @@ -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/set_width.cc b/set_width.cc index cdd75b094..2170cfeba 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; } } @@ -409,12 +405,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) @@ -428,10 +421,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) @@ -460,12 +450,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.cc b/t-dll.cc index 1146fc08a..b62b38dae 100644 --- a/t-dll.cc +++ b/t-dll.cc @@ -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; } @@ -2210,7 +2210,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 a3581c878..cd9c25016 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 @@ -217,14 +217,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; @@ -245,21 +245,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; @@ -346,7 +346,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/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.