Skip to content

Commit

Permalink
Fix some -Wextra warnings and some other bug fixes/enhancements.
Browse files Browse the repository at this point in the history
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
caryr authored and steveicarus committed Nov 2, 2010
1 parent 57f9130 commit bb5ca97
Show file tree
Hide file tree
Showing 29 changed files with 574 additions and 461 deletions.
6 changes: 4 additions & 2 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -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@

Expand Down Expand Up @@ -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 $@
Expand Down
17 changes: 9 additions & 8 deletions PExpr.cc
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -38,7 +38,7 @@ PExpr::~PExpr()
{
}

void PExpr::declare_implicit_nets(LexicalScope*scope, NetNet::Type type)
void PExpr::declare_implicit_nets(LexicalScope*, NetNet::Type)
{
}

Expand All @@ -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;
}

Expand Down
3 changes: 3 additions & 0 deletions PGate.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
14 changes: 7 additions & 7 deletions cprop.cc
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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*)
{
}

Expand All @@ -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
Expand All @@ -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*)
{
}

Expand Down Expand Up @@ -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
Expand Down
77 changes: 45 additions & 32 deletions elab_expr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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_;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
{
Expand Down Expand Up @@ -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
{
Expand Down Expand Up @@ -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_);
Expand Down Expand Up @@ -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;
Expand All @@ -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_);
Expand Down Expand Up @@ -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_);
Expand All @@ -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) {
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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)
{
Expand All @@ -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);
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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_;
Expand All @@ -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;
}
Expand Down Expand Up @@ -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
{
Expand Down Expand Up @@ -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
{
Expand Down Expand Up @@ -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
{
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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_);
Expand All @@ -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);
Expand Down
Loading

0 comments on commit bb5ca97

Please sign in to comment.