Permalink
Browse files

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.
  • Loading branch information...
1 parent 57f9130 commit bb5ca97f2d3bb34540c605638cd3b858ced5412a @caryr caryr committed with steveicarus Nov 1, 2010
Showing with 574 additions and 461 deletions.
  1. +4 −2 Makefile.in
  2. +9 −8 PExpr.cc
  3. +3 −0 PGate.h
  4. +7 −7 cprop.cc
  5. +45 −32 elab_expr.cc
  6. +1 −3 elab_lval.cc
  7. +1 −1 elab_pexpr.cc
  8. +4 −6 elab_scope.cc
  9. +7 −4 elab_sig.cc
  10. +5 −1 elaborate.cc
  11. +3 −3 emit.cc
  12. +383 −283 eval_tree.cc
  13. +7 −8 expr_synth.cc
  14. +1 −1 functor.cc
  15. +2 −1 iverilog-vpi.sh
  16. +6 −0 lexor_keyword.gperf
  17. +12 −12 net_nex_input.cc
  18. +4 −4 net_nex_output.cc
  19. +3 −3 netlist.h
  20. +6 −6 netmisc.cc
  21. +4 −0 netmisc.h
  22. +2 −2 nodangle.cc
  23. +12 −25 set_width.cc
  24. +7 −8 syn-rules.y
  25. +24 −29 synth2.cc
  26. +2 −2 t-dll.cc
  27. +7 −7 target.cc
  28. +1 −1 verinum.cc
  29. +2 −2 verinum.h
View
@@ -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 $@
View
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998-2008,2010 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
@@ -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;
}
View
@@ -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,
View
@@ -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
View
@@ -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[<m> +: <l>]
*/
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[<m> -: <l>]
*/
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,22 +3379,25 @@ 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;
if (min > expr_width_)
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);
Oops, something went wrong.

0 comments on commit bb5ca97

Please sign in to comment.