Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'master' into work2

Conflicts:
	elab_scope.cc
	net_nex_input.cc
	t-dll-api.cc
	vvp/parse.y
  • Loading branch information...
commit 16e1570737c68947c9c31790888ffc9650f30ade 2 parents 8aa2ba8 + 13b8dcc
Stephen Williams steveicarus authored
Showing with 1,479 additions and 1,028 deletions.
  1. +3 −3 HName.h
  2. +7 −4 Makefile.in
  3. +1 −2  Module.cc
  4. +9 −8 PExpr.cc
  5. +3 −0  PGate.h
  6. +1 −1  StringHeap.cc
  7. +1 −1  cadpli/cadpli.c
  8. +10 −1 configure.in
  9. +3 −0  cppcheck.sup
  10. +7 −7 cprop.cc
  11. +16 −7 design_dump.cc
  12. +5 −6 driver/main.c
  13. +1 −1  driver/substit.c
  14. +46 −33 elab_expr.cc
  15. +1 −3 elab_lval.cc
  16. +2 −1  elab_pexpr.cc
  17. +25 −27 elab_scope.cc
  18. +35 −20 elab_sig.cc
  19. +24 −22 elaborate.cc
  20. +10 −10 emit.cc
  21. +1 −1  eval_attrib.cc
  22. +590 −403 eval_tree.cc
  23. +7 −8 expr_synth.cc
  24. +4 −4 functor.cc
  25. +2 −1  iverilog-vpi.sh
  26. +8 −13 ivl_assert.h
  27. +1 −1  ivlpp/lexor.lex
  28. +1 −1  ivlpp/main.c
  29. +6 −0 lexor_keyword.gperf
  30. +1 −1  libveriuser/a_vcl.c
  31. +1 −1  libveriuser/veriusertfs.c
  32. +1 −1  libveriuser/workarea.c
  33. +2 −3 load_module.cc
  34. +16 −20 main.cc
  35. +8 −8 net_design.cc
  36. +4 −5 net_event.cc
  37. +1 −1  net_link.cc
  38. +35 −21 net_nex_input.cc
  39. +4 −4 net_nex_output.cc
  40. +1 −1  net_tran.cc
  41. +6 −3 netlist.h
  42. +7 −7 netmisc.cc
  43. +4 −0 netmisc.h
  44. +3 −3 nodangle.cc
  45. +4 −4 parse.y
  46. +13 −21 pform.cc
  47. +2 −2 pform_disciplines.cc
  48. +25 −29 pform_dump.cc
  49. +12 −25 set_width.cc
  50. +7 −8 syn-rules.y
  51. +24 −29 synth2.cc
  52. +1 −1  t-dll-analog.cc
  53. +2 −2 t-dll-api.cc
  54. +1 −1  t-dll-expr.cc
  55. +1 −1  t-dll-proc.cc
  56. +7 −7 t-dll.cc
  57. +7 −7 target.cc
  58. +1 −1  tgt-fpga/d-generic-edif.c
  59. +1 −1  tgt-fpga/edif.c
  60. +1 −1  tgt-fpga/mangle.c
  61. +1 −1  tgt-fpga/xilinx.c
  62. +1 −1  tgt-pal/emit_jed.c
  63. +1 −1  tgt-pal/fit_log.c
  64. +1 −1  tgt-pal/imain.c
  65. +1 −1  tgt-stub/stub.c
  66. +87 −19 tgt-vvp/draw_net_input.c
  67. +1 −1  tgt-vvp/draw_vpi.c
  68. +1 −1  tgt-vvp/eval_expr.c
  69. +1 −2  tgt-vvp/eval_real.c
  70. +1 −1  tgt-vvp/modpath.c
  71. +2 −2 tgt-vvp/vvp_scope.c
  72. +1 −1  verinum.cc
  73. +2 −2 verinum.h
  74. +2 −1  vpi/Makefile.in
  75. +41 −0 vpi/cppcheck.sup
  76. +120 −97 vpi/fstapi.c
  77. +2 −2 vpi/fstapi.h
  78. +2 −2 vpi/lxt_write.c
  79. +38 −12 vpi/sdf_lexor.lex
  80. +47 −6 vpi/sdf_parse.y
  81. +2 −2 vpi/sdf_parse_priv.h
  82. +1 −1  vpi/stringheap.c
  83. +1 −1  vpi/sys_display.c
  84. +1 −1  vpi/sys_fileio.c
  85. +1 −1  vpi/sys_fst.c
  86. +1 −1  vpi/sys_lxt.c
  87. +1 −1  vpi/sys_lxt2.c
  88. +1 −1  vpi/sys_priv.c
  89. +1 −1  vpi/sys_random_mti.c
  90. +1 −1  vpi/sys_readmem.c
  91. +1 −1  vpi/sys_scanf.c
  92. +4 −2 vpi/sys_vcd.c
  93. +1 −1  vpi/v2005_math.c
  94. +1 −1  vpi/va_math.c
  95. +1 −1  vpi_user.h
  96. +1 −1  vvp/array.cc
  97. +3 −2 vvp/compile.cc
  98. +3 −3 vvp/delay.cc
  99. +6 −6 vvp/island_tran.cc
  100. +1 −1  vvp/lexor.lex
  101. +1 −1  vvp/main.cc
  102. +1 −1  vvp/parse.y
  103. +1 −1  vvp/parse_misc.cc
  104. +1 −1  vvp/stop.cc
  105. +4 −4 vvp/udp.cc
  106. +1 −1  vvp/ufunc.cc
  107. +1 −1  vvp/vpi_const.cc
  108. +1 −1  vvp/vpi_event.cc
  109. +1 −1  vvp/vpi_iter.cc
  110. +1 −1  vvp/vpi_mcd.cc
  111. +1 −1  vvp/vpi_modules.cc
  112. +0 −2  vvp/vpi_priv.cc
  113. +1 −1  vvp/vpi_real.cc
  114. +6 −3 vvp/vpi_scope.cc
  115. +18 −1 vvp/vpi_signal.cc
  116. +1 −1  vvp/vpi_tasks.cc
  117. +2 −2 vvp/vpi_vthr_vector.cc
  118. +1 −1  vvp/vpip_to_dec.cc
  119. +1 −1  vvp/vthread.cc
  120. +1 −1  vvp/vvp_island.cc
  121. +2 −5 vvp/vvp_net.cc
  122. +12 −3 vvp/vvp_net.h
  123. +1 −1  vvp/vvp_net_sig.cc
6 HName.h
View
@@ -1,7 +1,7 @@
#ifndef __HName_H
#define __HName_H
/*
- * Copyright (c) 2001-2008 Stephen Williams (steve@icarus.com)
+ * Copyright (c) 2001-2010 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@@ -94,10 +94,10 @@ inline ostream& operator<< (ostream&out, const list<hname_t>&ll)
{
list<hname_t>::const_iterator cur = ll.begin();
out << *cur;
- cur ++;
+ ++ cur;
while (cur != ll.end()) {
out << "." << *cur;
- cur ++;
+ ++ cur;
}
return out;
}
11 Makefile.in
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@
@@ -157,12 +158,13 @@ endif
rm -rf autom4te.cache
cppcheck: $(O:.o=.cc) $(srcdir)/dosify.c $(srcdir)/version.c
- cppcheck --enable=all -f $(INCLUDE_PATH) $^
+ cppcheck --enable=all -f --suppressions $(srcdir)/cppcheck.sup \
+ $(INCLUDE_PATH) $^
cppcheck-all:
$(foreach dir,$(SUBDIRS),$(MAKE) -C $(dir) cppcheck && ) true
$(foreach dir,$(NOTUSED),$(MAKE) -C $(dir) cppcheck && ) true
- cppcheck
+ $(MAKE) cppcheck
Makefile: $(srcdir)/Makefile.in config.status
./config.status --file=$@
@@ -210,7 +212,8 @@ iverilog-vpi: $(srcdir)/iverilog-vpi.sh Makefile
-e 's;@SUFFIX@;$(suffix);' \
-e 's;@IVCC@;$(CC);' \
-e 's;@IVCXX@;$(CXX);' \
- -e 's;@IVCFLAGS@;$(CXXFLAGS);' \
+ -e 's;@IVCFLAGS@;$(CFLAGS);' \
+ -e 's;@IVCXXFLAGS@;$(CXXFLAGS);' \
-e 's;@INCLUDEDIR@;$(includedir);' \
-e 's;@LIBDIR@;@libdir@;' $< > $@
chmod +x $@
3  Module.cc
View
@@ -93,8 +93,7 @@ unsigned Module::find_port(const char*name) const
PGate* Module::get_gate(perm_string name)
{
for (list<PGate*>::iterator cur = gates_.begin()
- ; cur != gates_.end()
- ; cur ++ ) {
+ ; cur != gates_.end() ; ++ cur ) {
if ((*cur)->get_name() == name)
return *cur;
17 PExpr.cc
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
@@ -39,7 +39,7 @@ PExpr::~PExpr()
{
}
-void PExpr::declare_implicit_nets(LexicalScope*scope, NetNet::Type type)
+void PExpr::declare_implicit_nets(LexicalScope*, NetNet::Type)
{
}
@@ -53,18 +53,19 @@ bool PExpr::is_the_same(const PExpr*that) const
return typeid(this) == typeid(that);
}
-NetNet* PExpr::elaborate_lnet(Design*des, NetScope*) const
+NetNet* PExpr::elaborate_lnet(Design*, NetScope*) const
{
- cerr << get_fileline() << ": error: expression not valid in assign l-value: "
- << *this << endl;
+ cerr << get_fileline() << ": error: "
+ << "expression not valid in assign l-value: "
+ << *this << endl;
return 0;
}
-NetNet* PExpr::elaborate_bi_net(Design*des, NetScope*) const
+NetNet* PExpr::elaborate_bi_net(Design*, NetScope*) const
{
cerr << get_fileline() << ": error: "
- << "expression not valid as argument to inout port: "
- << *this << endl;
+ << "expression not valid as argument to inout port: "
+ << *this << endl;
return 0;
}
3  PGate.h
View
@@ -241,7 +241,10 @@ class PGModule : public PGate {
void elaborate_scope_mod_(Design*des, Module*mod, NetScope*sc) const;
void elaborate_scope_mod_instances_(Design*des, Module*mod, NetScope*sc) const;
bool elaborate_sig_mod_(Design*des, NetScope*scope, Module*mod) const;
+ // Not currently used.
+#if 0
bool elaborate_sig_udp_(Design*des, NetScope*scope, PUdp*udp) const;
+#endif
NetNet*resize_net_to_port_(Design*des, NetScope*scope,
NetNet*sig, unsigned port_wid,
2  StringHeap.cc
View
@@ -18,10 +18,10 @@
*/
# include "StringHeap.h"
-# include "ivl_alloc.h"
# include <cstdlib>
# include <cstring>
# include <cassert>
+# include "ivl_alloc.h"
#ifdef CHECK_WITH_VALGRIND
static char **string_pool = NULL;
2  cadpli/cadpli.c
View
@@ -17,7 +17,6 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
-# include "ivl_alloc.h"
# include <vpi_user.h>
# include <veriuser.h>
# include <stdlib.h>
@@ -25,6 +24,7 @@
# include <assert.h>
# include "config.h"
# include "ivl_dlfcn.h"
+# include "ivl_alloc.h"
typedef void* (*funcvp)(void);
11 configure.in
View
@@ -69,9 +69,18 @@ AC_SUBST(DEPENDENCY_FLAG, [-xMMD])
AC_SUBST(WARNING_FLAGS, [""])
AC_SUBST(WARNING_FLAGS_CXX, [""])
else
+# Check to see if -Wextra is supported.
+iverilog_temp_cflags="$CFLAGS"
+CFLAGS="-Wextra $CFLAGS"
+AC_MSG_CHECKING(if gcc supports -Wextra)
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
+ [[iverilog_wextra_flag="-Wextra";] AC_MSG_RESULT(yes)],
+ [[iverilog_wextra_flag="-W";] AC_MSG_RESULT(no)])
+CFLAGS="$iverilog_temp_cflags"
+
AC_SUBST(DEPENDENCY_FLAG, [-MD])
AC_SUBST(WARNING_FLAGS, ["-Wall -Wshadow"])
-AC_SUBST(WARNING_FLAGS_CXX, ["-Wextra"])
+AC_SUBST(WARNING_FLAGS_CXX, ["$iverilog_wextra_flag"])
fi
AC_LANG(C++)
3  cppcheck.sup
View
@@ -0,0 +1,3 @@
+// These are correct and are used to find the base (zero) pin.
+thisSubtraction:netlist.h:4119
+thisSubtraction:netlist.h:4128
14 cprop.cc
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
23 design_dump.cc
View
@@ -1115,7 +1115,7 @@ void NetScope::dump(ostream&o) const
{
map<perm_string,param_expr_t>::const_iterator pp;
for (pp = parameters.begin()
- ; pp != parameters.end() ; pp ++) {
+ ; pp != parameters.end() ; ++ pp ) {
o << " parameter ";
o << pp->second.type << " ";
@@ -1165,7 +1165,7 @@ void NetScope::dump(ostream&o) const
}
for (pp = localparams.begin()
- ; pp != localparams.end() ; pp ++) {
+ ; pp != localparams.end() ; ++ pp ) {
o << " localparam " << (*pp).first << " = " <<
*(*pp).second.expr << ";" << endl;
}
@@ -1175,7 +1175,7 @@ void NetScope::dump(ostream&o) const
{
list<pair<pform_name_t,NetExpr*> >::const_iterator pp;
for (pp = defparams.begin()
- ; pp != defparams.end() ; pp ++ ) {
+ ; pp != defparams.end() ; ++ pp ) {
o << " defparam " << (*pp).first << " = " <<
*(*pp).second << ";" << endl;
}
@@ -1184,7 +1184,7 @@ void NetScope::dump(ostream&o) const
{
list<pair<list<hname_t>,NetExpr*> >::const_iterator pp;
for (pp = defparams_later.begin()
- ; pp != defparams_later.end() ; pp ++ ) {
+ ; pp != defparams_later.end() ; ++ pp ) {
o << " defparam(later) " << pp->first << " = " <<
*(pp->second) << ";" << endl;
}
@@ -1223,7 +1223,7 @@ void NetScope::dump(ostream&o) const
// Dump specparams
typedef map<perm_string,spec_val_t>::const_iterator specparam_it_t;
for (specparam_it_t cur = specparams.begin()
- ; cur != specparams.end() ; cur ++ ) {
+ ; cur != specparams.end() ; ++ cur ) {
o << " specparam " << (*cur).first
<< " = ";
spec_val_t value = (*cur).second;
@@ -1260,7 +1260,7 @@ void NetScope::dump(ostream&o) const
/* Dump any sub-scopes. */
for (map<hname_t,NetScope*>::const_iterator cur = children_.begin()
- ; cur != children_.end() ; cur ++)
+ ; cur != children_.end() ; ++ cur )
cur->second->dump(o);
}
@@ -1345,6 +1345,9 @@ void NetEBinary::dump(ostream&o) const
case 'a':
o << "&&";
break;
+ case 'A':
+ o << "~&";
+ break;
case 'E':
o << "===";
break;
@@ -1530,12 +1533,18 @@ void NetEUFunc::dump(ostream&o) const
void NetEUnary::dump(ostream&o) const
{
switch (op_) {
+ case 'A':
+ o << "~&";
+ break;
case 'm':
o << "abs";
break;
case 'N':
o << "~|";
break;
+ case 'X':
+ o << "~^";
+ break;
default:
o << op_;
break;
@@ -1550,7 +1559,7 @@ void Design::dump(ostream&o) const
o << "DESIGN TIME PRECISION: 10e" << get_precision() << endl;
o << "SCOPES:" << endl;
for (list<NetScope*>::const_iterator scope = root_scopes_.begin();
- scope != root_scopes_.end(); scope++)
+ scope != root_scopes_.end(); ++ scope )
(*scope)->dump(o);
o << "ELABORATED NODES:" << endl;
11 driver/main.c
View
@@ -50,7 +50,6 @@ const char HELP[] =
#define MAXSIZE 4096
-#include "ivl_alloc.h"
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
@@ -64,11 +63,13 @@ const char HELP[] =
#endif
#ifdef __MINGW32__
-#include <windows.h>
+# include <windows.h>
+# include <io.h>
#ifdef HAVE_LIBIBERTY_H
-#include <libiberty.h>
+# include <libiberty.h>
#endif
#endif
+#include <fcntl.h>
#if HAVE_GETOPT_H
#include <getopt.h>
@@ -94,6 +95,7 @@ extern const char*optarg;
# include "globals.h"
#include "cfparse_misc.h" /* cfparse() */
+#include "ivl_alloc.h"
#ifdef __MINGW32__
const char sep = '\\';
@@ -211,8 +213,6 @@ char *get_cmd_file()
}
#ifdef __MINGW32__
-# include <io.h>
-# include <fcntl.h>
static FILE*fopen_safe(const char*path)
{
FILE*file = 0;
@@ -225,7 +225,6 @@ static FILE*fopen_safe(const char*path)
return file;
}
#else
-# include <fcntl.h>
static FILE*fopen_safe(const char*path)
{
FILE*file = 0;
2  driver/substit.c
View
@@ -17,10 +17,10 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
-# include "ivl_alloc.h"
# include <string.h>
# include <stdlib.h>
# include <stdio.h>
+# include "ivl_alloc.h"
char* substitutions(const char*str)
79 elab_expr.cc
View
@@ -129,8 +129,8 @@ NetExpr* elaborate_rval_expr(Design*des, NetScope*scope,
* The default behavior for the test_width method is to just return the
* minimum width that is passed in.
*/
-unsigned PExpr::test_width(Design*des, NetScope*scope,
- unsigned min, unsigned lval,
+unsigned PExpr::test_width(Design*, NetScope*,
+ unsigned min, unsigned,
ivl_variable_type_t&, bool&)
{
if (debug_elaborate) {
@@ -228,9 +228,12 @@ unsigned PEBinary::test_width(Design*des, NetScope*scope,
break;
}
- if (type_is_vectorable(expr_type_))
+ if (type_is_vectorable(expr_type_)) {
+ // We don't use (need?) lval so make sure the minimum width
+ // is greater than or equal to the the L-value width.
+ assert(min >= lval);
expr_width_ = min;
- else
+ } else
expr_width_ = 1;
expr_type__ = expr_type_;
@@ -449,7 +452,7 @@ NetExpr* PEBinary::elaborate_expr_base_bits_(Design*des,
NetExpr* PEBinary::elaborate_expr_base_div_(Design*des,
NetExpr*lp, NetExpr*rp,
- int expr_wid, bool is_pexpr) const
+ int expr_wid, bool) const
{
/* The % operator does not support real arguments in
baseline Verilog. But we allow it in our extended
@@ -739,7 +742,7 @@ NetExpr* PEBinary::elaborate_expr_base_rshift_(Design*des,
return tmp;
}
-NetExpr* PEBinary::elaborate_expr_base_mult_(Design*des,
+NetExpr* PEBinary::elaborate_expr_base_mult_(Design*,
NetExpr*lp, NetExpr*rp,
int expr_wid, bool is_pexpr) const
{
@@ -802,7 +805,7 @@ NetExpr* PEBinary::elaborate_expr_base_mult_(Design*des,
return tmp;
}
-NetExpr* PEBinary::elaborate_expr_base_add_(Design*des,
+NetExpr* PEBinary::elaborate_expr_base_add_(Design*,
NetExpr*lp, NetExpr*rp,
int expr_wid, bool is_pexpr) const
{
@@ -890,7 +893,7 @@ unsigned PEBComp::test_width(Design*des, NetScope*scope, unsigned, unsigned,
}
NetExpr* PEBComp::elaborate_expr(Design*des, NetScope*scope,
- int expr_width_dummy, bool sys_task_arg) const
+ int, bool) const
{
assert(left_);
assert(right_);
@@ -945,10 +948,10 @@ NetExpr* PEBComp::elaborate_expr(Design*des, NetScope*scope,
return tmp;
}
-unsigned PEBLogic::test_width(Design*des, NetScope*scope,
- unsigned min, unsigned lval,
+unsigned PEBLogic::test_width(Design*, NetScope*,
+ unsigned, unsigned,
ivl_variable_type_t&expr_type_out,
- bool&unsized_flag)
+ bool&)
{
expr_type_ = IVL_VT_LOGIC;
expr_width_ = 1;
@@ -957,7 +960,7 @@ unsigned PEBLogic::test_width(Design*des, NetScope*scope,
}
NetExpr*PEBLogic::elaborate_expr(Design*des, NetScope*scope,
- int expr_width_dummp, bool sys_task_arg) const
+ int, bool) const
{
assert(left_);
assert(right_);
@@ -1040,7 +1043,7 @@ unsigned PEBLeftWidth::test_width(Design*des, NetScope*scope,
}
NetExpr*PEBLeftWidth::elaborate_expr(Design*des, NetScope*scope,
- int expr_wid, bool sys_task_arg) const
+ int expr_wid, bool) const
{
assert(left_);
assert(right_);
@@ -1067,7 +1070,7 @@ NetExpr*PEBLeftWidth::elaborate_expr(Design*des, NetScope*scope,
return elaborate_expr_leaf(des, lp, rp, expr_wid);
}
-NetExpr*PEBPower::elaborate_expr_leaf(Design*des, NetExpr*lp, NetExpr*rp,
+NetExpr*PEBPower::elaborate_expr_leaf(Design*, NetExpr*lp, NetExpr*rp,
int expr_wid) const
{
if (debug_elaborate) {
@@ -1131,6 +1134,9 @@ unsigned PECallFunction::test_width_sfunc_(Design*des, NetScope*scope,
<< " argument width = " << expr_width_
<< ", result width = " << min << "." << endl;
+ // We don't use (need?) lval so make sure the minimum width
+ // is greater than or equal to the the L-value width.
+ assert(min >= lval);
return min;
}
@@ -1612,7 +1618,7 @@ NetExpr* PECallFunction::elaborate_expr(Design*des, NetScope*scope,
}
unsigned PEConcat::test_width(Design*des, NetScope*scope,
- unsigned min, unsigned lval,
+ unsigned, unsigned,
ivl_variable_type_t&expr_type__,
bool&unsized_flag)
{
@@ -1809,8 +1815,8 @@ NetExpr* PEConcat::elaborate_expr(Design*des, NetScope*scope,
*
* Absent any better idea, we call all real valued results a width of 1.
*/
-unsigned PEFNumber::test_width(Design*des, NetScope*scope,
- unsigned min, unsigned lval,
+unsigned PEFNumber::test_width(Design*, NetScope*,
+ unsigned, unsigned,
ivl_variable_type_t&expr_type__,
bool&unsized_flag)
{
@@ -1822,7 +1828,7 @@ unsigned PEFNumber::test_width(Design*des, NetScope*scope,
return 1;
}
-NetExpr* PEFNumber::elaborate_expr(Design*des, NetScope*scope, int, bool) const
+NetExpr* PEFNumber::elaborate_expr(Design*, NetScope*, int, bool) const
{
NetECReal*tmp = new NetECReal(*value_);
tmp->set_line(*this);
@@ -1955,7 +1961,7 @@ NetExpr* PEIdent::calculate_up_do_base_(Design*des, NetScope*scope) const
return tmp;
}
-bool PEIdent::calculate_param_range_(Design*des, NetScope*scope,
+bool PEIdent::calculate_param_range_(Design*, NetScope*,
const NetExpr*par_msb, long&par_msv,
const NetExpr*par_lsb, long&par_lsv,
long length) const
@@ -1986,7 +1992,7 @@ static void probe_index_expr_width(Design*des, NetScope*scope,
const name_component_t&name)
{
for (list<index_component_t>::const_iterator cur = name.index.begin()
- ; cur != name.index.end() ; cur ++) {
+ ; cur != name.index.end() ; ++ cur ) {
if (cur->msb)
probe_expr_width(des, scope, cur->msb);
@@ -2107,7 +2113,7 @@ unsigned PEIdent::test_width(Design*des, NetScope*scope,
// This is a parameter. If it is sized (meaning it was
// declared with range expressions) then the range
// expressions would have been caught above. So if we
- // got there there we know this is an unsized constant.
+ // got here then we know this is an unsized constant.
expr_width_ = par->expr_width();
unsized_flag = true;
return expr_width_;
@@ -2118,6 +2124,10 @@ unsigned PEIdent::test_width(Design*des, NetScope*scope,
expr_type_ = IVL_VT_NO_TYPE;
expr_width_ = min;
+ // We don't use (need?) lval so make sure the minimum width
+ // is greater than or equal to the the L-value width.
+ assert(min >= lval);
+
expr_type__ = expr_type_;
return min;
}
@@ -2387,7 +2397,7 @@ static verinum param_part_select_bits(const verinum&par_val, long wid,
NetExpr* PEIdent::elaborate_expr_param_part_(Design*des, NetScope*scope,
const NetExpr*par,
- NetScope*found_in,
+ NetScope*,
const NetExpr*par_msb,
const NetExpr*par_lsb) const
{
@@ -2511,7 +2521,7 @@ static void warn_param_ob(long par_msv, long par_lsv, bool defined,
NetExpr* PEIdent::elaborate_expr_param_idx_up_(Design*des, NetScope*scope,
const NetExpr*par,
- NetScope*found_in,
+ NetScope*,
const NetExpr*par_msb,
const NetExpr*par_lsb) const
{
@@ -2590,7 +2600,7 @@ NetExpr* PEIdent::elaborate_expr_param_idx_up_(Design*des, NetScope*scope,
NetExpr* PEIdent::elaborate_expr_param_idx_do_(Design*des, NetScope*scope,
const NetExpr*par,
- NetScope*found_in,
+ NetScope*,
const NetExpr*par_msb,
const NetExpr*par_lsb) const
{
@@ -2994,7 +3004,7 @@ NetExpr* PEIdent::elaborate_expr_net_word_(Design*des, NetScope*scope,
* Handle part selects of NetNet identifiers.
*/
NetExpr* PEIdent::elaborate_expr_net_part_(Design*des, NetScope*scope,
- NetESignal*net, NetScope*found_in) const
+ NetESignal*net, NetScope*) const
{
long msv, lsv;
bool parts_defined_flag;
@@ -3099,7 +3109,7 @@ NetExpr* PEIdent::elaborate_expr_net_part_(Design*des, NetScope*scope,
* Part select indexed up, i.e. net[<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);
@@ -3187,7 +3197,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);
@@ -3271,7 +3281,7 @@ NetExpr* PEIdent::elaborate_expr_net_idx_do_(Design*des, NetScope*scope,
}
NetExpr* PEIdent::elaborate_expr_net_bit_(Design*des, NetScope*scope,
- NetESignal*net, NetScope*found_in) const
+ NetESignal*net, NetScope*) const
{
const name_component_t&name_tail = path_.back();
ivl_assert(*this, !name_tail.index.empty());
@@ -3439,7 +3449,7 @@ unsigned PENumber::test_width(Design*, NetScope*,
return use_wid;
}
-NetEConst* PENumber::elaborate_expr(Design*des, NetScope*,
+NetEConst* PENumber::elaborate_expr(Design*, NetScope*,
int expr_width__, bool) const
{
assert(value_);
@@ -3463,10 +3473,10 @@ NetEConst* PENumber::elaborate_expr(Design*des, NetScope*,
return tmp;
}
-unsigned PEString::test_width(Design*des, NetScope*scope,
+unsigned PEString::test_width(Design*, NetScope*,
unsigned min, unsigned lval,
ivl_variable_type_t&expr_type__,
- bool&unsized_flag)
+ bool&)
{
expr_type_ = IVL_VT_BOOL;
expr_width_ = text_? 8*strlen(text_) : 0;
@@ -3474,11 +3484,14 @@ unsigned PEString::test_width(Design*des, NetScope*scope,
expr_width_ = min;
expr_type__ = expr_type_;
+ // We don't use (need?) lval so make sure the minimum width
+ // is greater than or equal to the the L-value width.
+ assert(expr_width_ >= lval);
return expr_width_;
}
-NetEConst* PEString::elaborate_expr(Design*des, NetScope*,
- int expr_width_dummy, bool) const
+NetEConst* PEString::elaborate_expr(Design*, NetScope*,
+ int, bool) const
{
NetEConst*tmp = new NetEConst(value());
tmp->set_line(*this);
4 elab_lval.cc
View
@@ -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) {
3  elab_pexpr.cc
View
@@ -28,7 +28,7 @@
# include <iostream>
# include "ivl_assert.h"
-NetExpr*PExpr::elaborate_pexpr(Design*des, NetScope*sc) const
+NetExpr*PExpr::elaborate_pexpr(Design*des, NetScope*) const
{
cerr << get_fileline() << ": error: invalid parameter expression: "
<< *this << endl;
@@ -220,6 +220,7 @@ NetExpr*PEIdent::elaborate_pexpr(Design*des, NetScope*scope) const
list<hname_t> tmp = eval_scope_path(des, scope, oldpath);
pscope = des->find_scope(scope, tmp);
}
+ ivl_assert(*this, pscope);
const NetExpr*ex_msb;
const NetExpr*ex_lsb;
52 elab_scope.cc
View
@@ -54,7 +54,7 @@ static void collect_scope_parameters_(NetScope*scope,
const map<perm_string,LexicalScope::param_expr_t>&parameters)
{
for (mparm_it_t cur = parameters.begin()
- ; cur != parameters.end() ; cur ++) {
+ ; cur != parameters.end() ; ++ cur ) {
NetEParam*tmp = new NetEParam;
tmp->set_line(*((*cur).second.expr));
@@ -69,7 +69,7 @@ static void collect_scope_localparams_(NetScope*scope,
const map<perm_string,LexicalScope::param_expr_t>&localparams)
{
for (mparm_it_t cur = localparams.begin()
- ; cur != localparams.end() ; cur ++) {
+ ; cur != localparams.end() ; ++ cur ) {
NetEParam*tmp = new NetEParam;
tmp->set_line(*((*cur).second.expr));
@@ -173,7 +173,7 @@ static void elaborate_scope_parameters_(Design*des, NetScope*scope,
const map<perm_string,LexicalScope::param_expr_t>&parameters)
{
for (mparm_it_t cur = parameters.begin()
- ; cur != parameters.end() ; cur ++) {
+ ; cur != parameters.end() ; ++ cur ) {
// A parameter can not have the same name as a genvar.
if (scope->find_genvar((*cur).first)) {
@@ -192,7 +192,7 @@ static void elaborate_scope_localparams_(Design*des, NetScope*scope,
const map<perm_string,LexicalScope::param_expr_t>&localparams)
{
for (mparm_it_t cur = localparams.begin()
- ; cur != localparams.end() ; cur ++) {
+ ; cur != localparams.end() ; ++ cur ) {
// A localparam can not have the same name as a genvar.
if (scope->find_genvar((*cur).first)) {
@@ -293,7 +293,7 @@ static void replace_scope_parameters_(NetScope*scope, const LineInfo&loc,
const Module::replace_t&replacements)
{
for (Module::replace_t::const_iterator cur = replacements.begin()
- ; cur != replacements.end() ; cur ++) {
+ ; cur != replacements.end() ; ++ cur ) {
NetExpr*val = (*cur).second;
if (val == 0) {
@@ -323,20 +323,19 @@ static void elaborate_scope_events_(Design*des, NetScope*scope,
const map<perm_string,PEvent*>&events)
{
for (map<perm_string,PEvent*>::const_iterator et = events.begin()
- ; et != events.end() ; et ++ ) {
+ ; et != events.end() ; ++ et ) {
(*et).second->elaborate_scope(des, scope);
}
}
static void elaborate_scope_tasks(Design*des, NetScope*scope,
- const LineInfo&loc,
const map<perm_string,PTask*>&tasks)
{
typedef map<perm_string,PTask*>::const_iterator tasks_it_t;
for (tasks_it_t cur = tasks.begin()
- ; cur != tasks.end() ; cur ++ ) {
+ ; cur != tasks.end() ; ++ cur ) {
hname_t use_name( (*cur).first );
// A task can not have the same name as another scope object.
@@ -385,13 +384,12 @@ static void elaborate_scope_tasks(Design*des, NetScope*scope,
}
static void elaborate_scope_funcs(Design*des, NetScope*scope,
- const LineInfo&loc,
const map<perm_string,PFunction*>&funcs)
{
typedef map<perm_string,PFunction*>::const_iterator funcs_it_t;
for (funcs_it_t cur = funcs.begin()
- ; cur != funcs.end() ; cur ++ ) {
+ ; cur != funcs.end() ; ++ cur ) {
hname_t use_name( (*cur).first );
// A function can not have the same name as another scope object.
@@ -459,7 +457,7 @@ class generate_schemes_work_item_t : public elaborator_work_item_t {
// elaboration.
typedef list<PGenerate*>::const_iterator generate_it_t;
for (generate_it_t cur = mod_->generate_schemes.begin()
- ; cur != mod_->generate_schemes.end() ; cur ++ ) {
+ ; cur != mod_->generate_schemes.end() ; ++ cur ) {
(*cur) -> generate_scope(des, scope_);
}
}
@@ -482,7 +480,7 @@ bool Module::elaborate_scope(Design*des, NetScope*scope,
// Add the genvars to the scope.
typedef map<perm_string,LineInfo*>::const_iterator genvar_it_t;
- for (genvar_it_t cur = genvars.begin(); cur != genvars.end(); cur++ ) {
+ for (genvar_it_t cur = genvars.begin(); cur != genvars.end(); ++ cur ) {
scope->add_genvar((*cur).first, (*cur).second);
}
@@ -531,7 +529,7 @@ bool Module::elaborate_scope(Design*des, NetScope*scope,
typedef list<Module::named_expr_t>::const_iterator defparms_iter_t;
for (defparms_iter_t cur = defparms.begin()
- ; cur != defparms.end() ; cur ++) {
+ ; cur != defparms.end() ; ++ cur ) {
PExpr*ex = cur->second;
assert(ex);
@@ -567,21 +565,21 @@ bool Module::elaborate_scope(Design*des, NetScope*scope,
// elaborate_scope method of the PTask for detailed
// processing.
- elaborate_scope_tasks(des, scope, *this, tasks);
+ elaborate_scope_tasks(des, scope, tasks);
// Functions are very similar to tasks, at least from the
// perspective of scopes. So handle them exactly the same
// way.
- elaborate_scope_funcs(des, scope, *this, funcs);
+ elaborate_scope_funcs(des, scope, funcs);
// Gates include modules, which might introduce new scopes, so
// scan all of them to create those scopes.
typedef list<PGate*>::const_iterator gates_it_t;
for (gates_it_t cur = gates_.begin()
- ; cur != gates_.end() ; cur ++ ) {
+ ; cur != gates_.end() ; ++ cur ) {
(*cur) -> elaborate_scope(des, scope);
}
@@ -594,7 +592,7 @@ bool Module::elaborate_scope(Design*des, NetScope*scope,
typedef list<PProcess*>::const_iterator proc_it_t;
for (proc_it_t cur = behaviors.begin()
- ; cur != behaviors.end() ; cur ++ ) {
+ ; cur != behaviors.end() ; ++ cur ) {
(*cur) -> statement() -> elaborate_scope(des, scope);
}
@@ -934,7 +932,7 @@ bool PGenerate::generate_scope_case_(Design*des, NetScope*container)
// Detect that the item is a default.
if (item->item_test.size() == 0) {
default_item = item;
- cur ++;
+ ++ cur;
continue;
}
@@ -966,7 +964,7 @@ bool PGenerate::generate_scope_case_(Design*des, NetScope*container)
if (match_flag)
break;
- cur ++;
+ ++ cur;
}
delete case_value_co;
@@ -1102,7 +1100,7 @@ void PGenerate::elaborate_subscope_direct_(Design*des, NetScope*scope)
{
typedef list<PGenerate*>::const_iterator generate_it_t;
for (generate_it_t cur = generate_schemes.begin()
- ; cur != generate_schemes.end() ; cur ++ ) {
+ ; cur != generate_schemes.end() ; ++ cur ) {
(*cur) -> generate_scope(des, scope);
}
}
@@ -1111,7 +1109,7 @@ void PGenerate::elaborate_subscope_(Design*des, NetScope*scope)
{
// Add the genvars to this scope.
typedef map<perm_string,LineInfo*>::const_iterator genvar_it_t;
- for (genvar_it_t cur = genvars.begin(); cur != genvars.end(); cur++ ) {
+ for (genvar_it_t cur = genvars.begin(); cur != genvars.end(); ++ cur ) {
scope->add_genvar((*cur).first, (*cur).second);
}
@@ -1121,7 +1119,7 @@ void PGenerate::elaborate_subscope_(Design*des, NetScope*scope)
typedef list<PGenerate*>::const_iterator generate_it_t;
for (generate_it_t cur = generate_schemes.begin()
- ; cur != generate_schemes.end() ; cur ++ ) {
+ ; cur != generate_schemes.end() ; ++ cur ) {
(*cur) -> generate_scope(des, scope);
}
@@ -1135,20 +1133,20 @@ void PGenerate::elaborate_subscope_(Design*des, NetScope*scope)
// Scan through all the task and function declarations in this
// scope.
- elaborate_scope_tasks(des, scope, *this, tasks);
- elaborate_scope_funcs(des, scope, *this, funcs);
+ elaborate_scope_tasks(des, scope, tasks);
+ elaborate_scope_funcs(des, scope, funcs);
// Scan the generated scope for gates that may create
// their own scopes.
typedef list<PGate*>::const_iterator pgate_list_it_t;
for (pgate_list_it_t cur = gates.begin()
- ; cur != gates.end() ; cur ++) {
+ ; cur != gates.end() ; ++ cur ) {
(*cur) ->elaborate_scope(des, scope);
}
typedef list<PProcess*>::const_iterator proc_it_t;
for (proc_it_t cur = behaviors.begin()
- ; cur != behaviors.end() ; cur ++ ) {
+ ; cur != behaviors.end() ; ++ cur ) {
(*cur) -> statement() -> elaborate_scope(des, scope);
}
@@ -1437,7 +1435,7 @@ void PGModule::elaborate_scope_mod_instances_(Design*des, Module*mod, NetScope*s
// parameter value with the new expression.
for (mparm_local_it_t cur = replace.begin()
- ; cur != replace.end() ; cur ++ ) {
+ ; cur != replace.end() ; ++ cur ) {
PExpr*tmp = (*cur).second;
// No expression means that the parameter is not
55 elab_sig.cc
View
@@ -78,7 +78,7 @@ static bool get_const_argument(NetExpr*exp, long&res)
return true;
}
-void Statement::elaborate_sig(Design*des, NetScope*scope) const
+void Statement::elaborate_sig(Design*, NetScope*) const
{
}
@@ -87,7 +87,7 @@ bool PScope::elaborate_sig_wires_(Design*des, NetScope*scope) const
bool flag = true;
for (map<perm_string,PWire*>::const_iterator wt = wires.begin()
- ; wt != wires.end() ; wt ++ ) {
+ ; wt != wires.end() ; ++ wt ) {
PWire*cur = (*wt).second;
NetNet*sig = cur->elaborate_sig(des, scope);
@@ -143,7 +143,7 @@ static void elaborate_sig_funcs(Design*des, NetScope*scope,
typedef map<perm_string,PFunction*>::const_iterator mfunc_it_t;
for (mfunc_it_t cur = funcs.begin()
- ; cur != funcs.end() ; cur ++) {
+ ; cur != funcs.end() ; ++ cur ) {
hname_t use_name ( (*cur).first );
NetScope*fscope = scope->child(use_name);
@@ -165,7 +165,7 @@ static void elaborate_sig_tasks(Design*des, NetScope*scope,
typedef map<perm_string,PTask*>::const_iterator mtask_it_t;
for (mtask_it_t cur = tasks.begin()
- ; cur != tasks.end() ; cur ++) {
+ ; cur != tasks.end() ; ++ cur ) {
NetScope*tscope = scope->child( hname_t((*cur).first) );
assert(tscope);
(*cur).second->elaborate_sig(des, tscope);
@@ -229,7 +229,7 @@ bool Module::elaborate_sig(Design*des, NetScope*scope) const
// scope in.
typedef list<PGenerate*>::const_iterator generate_it_t;
for (generate_it_t cur = generate_schemes.begin()
- ; cur != generate_schemes.end() ; cur ++ ) {
+ ; cur != generate_schemes.end() ; ++ cur ) {
(*cur) -> elaborate_sig(des, scope);
}
@@ -241,8 +241,7 @@ bool Module::elaborate_sig(Design*des, NetScope*scope) const
const list<PGate*>&gl = get_gates();
for (list<PGate*>::const_iterator gt = gl.begin()
- ; gt != gl.end()
- ; gt ++ ) {
+ ; gt != gl.end() ; ++ gt ) {
flag &= (*gt)->elaborate_sig(des, scope);
}
@@ -261,7 +260,7 @@ bool Module::elaborate_sig(Design*des, NetScope*scope) const
typedef list<PProcess*>::const_iterator proc_it_t;
for (proc_it_t cur = behaviors.begin()
- ; cur != behaviors.end() ; cur ++ ) {
+ ; cur != behaviors.end() ; ++ cur ) {
(*cur) -> statement() -> elaborate_sig(des, scope);
}
@@ -269,17 +268,17 @@ bool Module::elaborate_sig(Design*des, NetScope*scope) const
return flag;
}
-bool PGate::elaborate_sig(Design*des, NetScope*scope) const
+bool PGate::elaborate_sig(Design*, NetScope*) const
{
return true;
}
-bool PGBuiltin::elaborate_sig(Design*des, NetScope*scope) const
+bool PGBuiltin::elaborate_sig(Design*, NetScope*) const
{
return true;
}
-bool PGAssign::elaborate_sig(Design*des, NetScope*scope) const
+bool PGAssign::elaborate_sig(Design*, NetScope*) const
{
return true;
}
@@ -314,10 +313,13 @@ bool PGModule::elaborate_sig_mod_(Design*des, NetScope*scope,
return flag;
}
+ // Not currently used.
+#if 0
bool PGModule::elaborate_sig_udp_(Design*des, NetScope*scope, PUdp*udp) const
{
return true;
}
+#endif
bool PGenerate::elaborate_sig(Design*des, NetScope*container) const
{
@@ -338,7 +340,7 @@ bool PGenerate::elaborate_sig(Design*des, NetScope*container) const
typedef list<PGenerate*>::const_iterator generate_it_t;
for (generate_it_t cur = generate_schemes.begin()
- ; cur != generate_schemes.end() ; cur ++) {
+ ; cur != generate_schemes.end() ; ++ cur ) {
PGenerate*item = *cur;
if (item->direct_nested_ || !item->scope_list_.empty()) {
flag &= item->elaborate_sig(des, container);
@@ -349,7 +351,7 @@ bool PGenerate::elaborate_sig(Design*des, NetScope*container) const
typedef list<NetScope*>::const_iterator scope_list_it_t;
for (scope_list_it_t cur = scope_list_.begin()
- ; cur != scope_list_.end() ; cur ++ ) {
+ ; cur != scope_list_.end() ; ++ cur ) {
NetScope*scope = *cur;
@@ -382,7 +384,7 @@ bool PGenerate::elaborate_sig_direct_(Design*des, NetScope*container) const
bool flag = true;
typedef list<PGenerate*>::const_iterator generate_it_t;
for (generate_it_t cur = generate_schemes.begin()
- ; cur != generate_schemes.end() ; cur ++) {
+ ; cur != generate_schemes.end() ; ++ cur ) {
PGenerate*item = *cur;
if (item->direct_nested_ || !item->scope_list_.empty()) {
// Found the item, and it is direct nested.
@@ -398,7 +400,7 @@ bool PGenerate::elaborate_sig_(Design*des, NetScope*scope) const
// in the current scope.
typedef map<perm_string,PWire*>::const_iterator wires_it_t;
for (wires_it_t wt = wires.begin()
- ; wt != wires.end() ; wt ++ ) {
+ ; wt != wires.end() ; ++ wt ) {
PWire*cur = (*wt).second;
@@ -414,19 +416,19 @@ bool PGenerate::elaborate_sig_(Design*des, NetScope*scope) const
typedef list<PGenerate*>::const_iterator generate_it_t;
for (generate_it_t cur = generate_schemes.begin()
- ; cur != generate_schemes.end() ; cur ++ ) {
+ ; cur != generate_schemes.end() ; ++ cur ) {
(*cur) -> elaborate_sig(des, scope);
}
typedef list<PGate*>::const_iterator pgate_list_it_t;
for (pgate_list_it_t cur = gates.begin()
- ; cur != gates.end() ; cur ++) {
+ ; cur != gates.end() ; ++ cur ) {
(*cur) ->elaborate_sig(des, scope);
}
typedef list<PProcess*>::const_iterator proc_it_t;
for (proc_it_t cur = behaviors.begin()
- ; cur != behaviors.end() ; cur ++ ) {
+ ; cur != behaviors.end() ; ++ cur ) {
(*cur) -> statement() -> elaborate_sig(des, scope);
}
@@ -1047,6 +1049,17 @@ NetNet* PWire::elaborate_sig(Design*des, NetScope*scope) const
array_dimensions = 1;
}
+ if (data_type_ == IVL_VT_REAL && (msb != 0 || lsb != 0)) {
+ cerr << get_fileline() << ": error: real ";
+ if (wtype == NetNet::REG) cerr << "variable";
+ else cerr << "net";
+ cerr << " '" << name_
+ << "' cannot be declared as a vector, found a range ["
+ << msb << ":" << lsb << "]." << endl;
+ des->errors += 1;
+ return 0;
+ }
+
/* If the net type is supply0 or supply1, replace it
with a simple wire with a pulldown/pullup with supply
strength. In other words, transform:
@@ -1076,8 +1089,10 @@ NetNet* PWire::elaborate_sig(Design*des, NetScope*scope) const
if (debug_elaborate) {
cerr << get_fileline() << ": debug: "
- << "Generate a SUPPLY pulldown for the "
- << "supply0 net." << endl;
+ << "Generate a SUPPLY pull for the ";
+ if (wtype == NetNet::SUPPLY0) cerr << "supply0";
+ else cerr << "supply1";
+ cerr << " net." << endl;
}
}
46 elaborate.cc
View
@@ -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<perm_string,PUdp*>::const_iterator udp = pform_primitives.find(type_);
if (udp != pform_primitives.end())
return elaborate_sig_udp_(des, scope, (*udp).second);
+#endif
return true;
}
@@ -4077,7 +4081,7 @@ void PSpecPath::elaborate(Design*des, NetScope*scope) const
/* Create all the various paths from the path specifier. */
typedef std::vector<perm_string>::const_iterator str_vector_iter;
for (str_vector_iter cur = dst.begin()
- ; cur != dst.end() ; cur ++) {
+ ; cur != dst.end() ; ++ cur ) {
if (debug_elaborate) {
cerr << get_fileline() << ": debug: Path to " << (*cur);
@@ -4145,7 +4149,7 @@ void PSpecPath::elaborate(Design*des, NetScope*scope) const
unsigned idx = 0;
for (str_vector_iter cur_src = src.begin()
- ; cur_src != src.end() ; cur_src ++) {
+ ; cur_src != src.end() ; ++ cur_src ) {
NetNet*src_sig = scope->find_signal(*cur_src);
assert(src_sig);
@@ -4183,7 +4187,7 @@ static void elaborate_functions(Design*des, NetScope*scope,
{
typedef map<perm_string,PFunction*>::const_iterator mfunc_it_t;
for (mfunc_it_t cur = funcs.begin()
- ; cur != funcs.end() ; cur ++) {
+ ; cur != funcs.end() ; ++ cur ) {
hname_t use_name ( (*cur).first );
NetScope*fscope = scope->child(use_name);
@@ -4197,7 +4201,7 @@ static void elaborate_tasks(Design*des, NetScope*scope,
{
typedef map<perm_string,PTask*>::const_iterator mtask_it_t;
for (mtask_it_t cur = tasks.begin()
- ; cur != tasks.end() ; cur ++) {
+ ; cur != tasks.end() ; ++ cur ) {
hname_t use_name ( (*cur).first );
NetScope*tscope = scope->child(use_name);
@@ -4218,7 +4222,7 @@ bool Module::elaborate(Design*des, NetScope*scope) const
// Elaborate specparams
typedef map<perm_string,PExpr*>::const_iterator specparam_it_t;
for (specparam_it_t cur = specparams.begin()
- ; cur != specparams.end() ; cur ++ ) {
+ ; cur != specparams.end() ; ++ cur ) {
probe_expr_width(des, scope, (*cur).second);
need_constant_expr = true;
@@ -4263,7 +4267,7 @@ bool Module::elaborate(Design*des, NetScope*scope) const
// Elaborate within the generate blocks.
typedef list<PGenerate*>::const_iterator generate_it_t;
for (generate_it_t cur = generate_schemes.begin()
- ; cur != generate_schemes.end() ; cur ++ ) {
+ ; cur != generate_schemes.end() ; ++ cur ) {
(*cur)->elaborate(des, scope);
}
@@ -4281,8 +4285,7 @@ bool Module::elaborate(Design*des, NetScope*scope) const
const list<PGate*>&gl = get_gates();
for (list<PGate*>::const_iterator gt = gl.begin()
- ; gt != gl.end()
- ; gt ++ ) {
+ ; gt != gl.end() ; ++ gt ) {
(*gt)->elaborate(des, scope);
}
@@ -4295,7 +4298,7 @@ bool Module::elaborate(Design*des, NetScope*scope) const
// Elaborate the specify paths of the module.
for (list<PSpecPath*>::const_iterator sp = specify_paths.begin()
- ; sp != specify_paths.end() ; sp ++) {
+ ; sp != specify_paths.end() ; ++ sp ) {
(*sp)->elaborate(des, scope);
}
@@ -4322,7 +4325,7 @@ bool PGenerate::elaborate(Design*des, NetScope*container) const
typedef list<PGenerate*>::const_iterator generate_it_t;
for (generate_it_t cur = generate_schemes.begin()
- ; cur != generate_schemes.end() ; cur ++) {
+ ; cur != generate_schemes.end() ; ++ cur ) {
PGenerate*item = *cur;
if (item->direct_nested_ || !item->scope_list_.empty()) {
flag &= item->elaborate(des, container);
@@ -4333,7 +4336,7 @@ bool PGenerate::elaborate(Design*des, NetScope*container) const
typedef list<NetScope*>::const_iterator scope_list_it_t;
for (scope_list_it_t cur = scope_list_.begin()
- ; cur != scope_list_.end() ; cur ++ ) {
+ ; cur != scope_list_.end() ; ++ cur ) {
NetScope*scope = *cur;
// Check that this scope is one that is contained in the
@@ -4376,7 +4379,7 @@ bool PGenerate::elaborate_direct_(Design*des, NetScope*container) const
bool flag = true;
typedef list<PGenerate*>::const_iterator generate_it_t;
for (generate_it_t cur = generate_schemes.begin()
- ; cur != generate_schemes.end() ; cur ++) {
+ ; cur != generate_schemes.end() ; ++ cur ) {
PGenerate*item = *cur;
if (item->direct_nested_ || !item->scope_list_.empty()) {
// Found the item, and it is direct nested.
@@ -4392,16 +4395,16 @@ bool PGenerate::elaborate_(Design*des, NetScope*scope) const
elaborate_tasks(des, scope, tasks);
typedef list<PGate*>::const_iterator gates_it_t;
- for (gates_it_t cur = gates.begin() ; cur != gates.end() ; cur ++ )
+ for (gates_it_t cur = gates.begin() ; cur != gates.end() ; ++ cur )
(*cur)->elaborate(des, scope);
typedef list<PProcess*>::const_iterator proc_it_t;
- for (proc_it_t cur = behaviors.begin(); cur != behaviors.end(); cur++)
+ for (proc_it_t cur = behaviors.begin(); cur != behaviors.end(); ++ cur )
(*cur)->elaborate(des, scope);
typedef list<PGenerate*>::const_iterator generate_it_t;
for (generate_it_t cur = generate_schemes.begin()
- ; cur != generate_schemes.end() ; cur ++ ) {
+ ; cur != generate_schemes.end() ; ++ cur ) {
(*cur)->elaborate(des, scope);
}
@@ -4416,13 +4419,13 @@ bool PScope::elaborate_behaviors_(Design*des, NetScope*scope) const
// involves scanning the PProcess* list, creating a NetProcTop
// for each process.
for (list<PProcess*>::const_iterator st = behaviors.begin()
- ; st != behaviors.end() ; st ++ ) {
+ ; st != behaviors.end() ; ++ st ) {
result_flag &= (*st)->elaborate(des, scope);
}
for (list<AProcess*>::const_iterator st = analog_behaviors.begin()
- ; st != analog_behaviors.end() ; st ++ ) {
+ ; st != analog_behaviors.end() ; ++ st ) {
result_flag &= (*st)->elaborate(des, scope);
}
@@ -4447,7 +4450,7 @@ class elaborate_root_scope_t : public elaborator_work_item_t {
{
Module::replace_t root_repl;
for (list<Module::named_expr_t>::iterator cur = Module::user_defparms.begin()
- ; cur != Module::user_defparms.end() ; cur++) {
+ ; cur != Module::user_defparms.end() ; ++ cur ) {
pform_name_t tmp_name = cur->first;
if (peek_head_name(tmp_name) != scope_->basename())
@@ -4506,7 +4509,7 @@ class later_defparams : public elaborator_work_item_t {
{
list<NetScope*>tmp_list;
for (set<NetScope*>::iterator cur = des->defparams_later.begin()
- ; cur != des->defparams_later.end() ; cur ++ )
+ ; cur != des->defparams_later.end() ; ++ cur )
tmp_list.push_back(*cur);
des->defparams_later.clear();
@@ -4569,8 +4572,7 @@ Design* elaborate(list<perm_string>roots)
// Scan the root modules by name, and elaborate their scopes.
for (list<perm_string>::const_iterator root = roots.begin()
- ; root != roots.end()
- ; root++) {
+ ; root != roots.end() ; ++ root ) {
// Look for the root module in the list.
map<perm_string,Module*>::const_iterator mod = pform_modules.find(*root);
20 emit.cc
View
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998-2008 Stephen Williams (steve@icarus.com)
+ * Copyright (c) 1998-2010 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@@ -31,7 +31,7 @@
# include <cassert>
# include <cstring>
-bool NetNode::emit_node(struct target_t*tgt) const
+bool NetNode::emit_node(struct target_t*) const
{
cerr << "EMIT: Gate type? " << typeid(*this).name() << endl;
return false;
@@ -200,7 +200,7 @@ bool NetAnalogTop::emit(struct target_t*tgt) const
return tgt->process(this);
}
-bool NetProc::emit_proc(struct target_t*tgt) const
+bool NetProc::emit_proc(struct target_t*) const
{
cerr << "EMIT: Proc type? " << typeid(*this).name() << endl;
return false;
@@ -390,11 +390,11 @@ void NetScope::emit_scope(struct target_t*tgt) const
tgt->enumeration(this, *cur);
for (map<hname_t,NetScope*>::const_iterator cur = children_.begin()
- ; cur != children_.end() ; cur ++)
+ ; cur != children_.end() ; ++ cur )
cur->second->emit_scope(tgt);
for (signals_map_iter_t cur = signals_map_.begin()
- ; cur != signals_map_.end() ; cur ++) {
+ ; cur != signals_map_.end() ; ++ cur ) {
tgt->signal(cur->second);
}
@@ -418,7 +418,7 @@ bool NetScope::emit_defs(struct target_t*tgt) const
switch (type_) {
case MODULE:
for (map<hname_t,NetScope*>::const_iterator cur = children_.begin()
- ; cur != children_.end() ; cur ++)
+ ; cur != children_.end() ; ++ cur )
flag &= cur->second->emit_defs(tgt);
break;
@@ -430,7 +430,7 @@ bool NetScope::emit_defs(struct target_t*tgt) const
break;
default: /* BEGIN_END and FORK_JOIN, GENERATE... */
for (map<hname_t,NetScope*>::const_iterator cur = children_.begin()
- ; cur != children_.end() ; cur ++)
+ ; cur != children_.end() ; ++ cur )
flag &= cur->second->emit_defs(tgt);
break;
}
@@ -452,7 +452,7 @@ int Design::emit(struct target_t*tgt) const
// enumerate the scopes
for (list<NetScope*>::const_iterator scope = root_scopes_.begin();
- scope != root_scopes_.end(); scope++)
+ scope != root_scopes_.end(); ++ scope )
(*scope)->emit_scope(tgt);
@@ -475,7 +475,7 @@ int Design::emit(struct target_t*tgt) const
// emit task and function definitions
bool tasks_rc = true;
for (list<NetScope*>::const_iterator scope = root_scopes_.begin();
- scope != root_scopes_.end(); scope++)
+ scope != root_scopes_.end(); ++ scope )
tasks_rc &= (*scope)->emit_defs(tgt);
@@ -540,7 +540,7 @@ void NetECRealParam::expr_scan(struct expr_scan_t*tgt) const
tgt->expr_rparam(this);
}
-void NetEParam::expr_scan(struct expr_scan_t*tgt) const
+void NetEParam::expr_scan(struct expr_scan_t*) const
{
cerr << get_fileline() << ":internal error: unexpected NetEParam."
<< endl;
2  eval_attrib.cc
View
@@ -43,7 +43,7 @@ attrib_list_t* evaluate_attributes(const map<perm_string,PExpr*>&att,
unsigned idx = 0;
typedef map<perm_string,PExpr*>::const_iterator iter_t;
- for (iter_t cur = att.begin() ; cur != att.end() ; cur ++, idx++) {
+ for (iter_t cur = att.begin() ; cur != att.end() ; ++ cur , idx += 1) {
table[idx].key = (*cur).first;
PExpr*exp = (*cur).second;
993 eval_tree.cc
View
@@ -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_()
+NetEConst* NetEBBits::eval_tree(int prune_to_width)
{
- 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);
+ if (debug_eval_tree) {
+ cerr << get_fileline() << ": debug: Evaluating expression:"
+ << *this << ", prune_to_width=" << prune_to_width << endl;
}
- 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_);
+ eval_expr(left_, prune_to_width);
+ eval_expr(right_, prune_to_width);
NetEConst*lc = dynamic_cast<NetEConst*>(left_);
NetEConst*rc = dynamic_cast<NetEConst*>(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<NetEConst*>(right_);
- if (r == 0) return 0;
+ NetEConst*rc = dynamic_cast<NetEConst*>(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,80 +370,25 @@ NetEConst* NetEBComp::eval_less_()
}
/* Now go on to the normal test of the values. */
- NetEConst*l = dynamic_cast<NetEConst*>(left_);
- if (l == 0) return 0;
- verinum lv = l->value();
+ NetEConst*lc = dynamic_cast<NetEConst*>(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* 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<NetECReal*> (le);
- if (rtmp == 0) return 0;
- lv = rtmp->value().as_double();
- break;
-
- case IVL_VT_LOGIC:
- case IVL_VT_BOOL:
- vtmp = dynamic_cast<NetEConst*> (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<NetECReal*> (ri);
- if (rtmp == 0) return 0;
- rv = rtmp->value().as_double();
- break;
-
- case IVL_VT_LOGIC:
- case IVL_VT_BOOL:
- vtmp = dynamic_cast<NetEConst*> (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);
+ NetEConst*res = new NetEConst(verinum(verinum::V0, 1));
+ ivl_assert(*this, res);
+ return res;
}
-
- 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)
@@ -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<NetEConst*>(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<NetEConst*>(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<NetEConst*>(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<NetEConst*>(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<NetEConst*>(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<NetEConst*>(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;
-
- switch (le->expr_type()) {
- case IVL_VT_REAL:
- rtmp = dynamic_cast<NetECReal*> (le);
- if (rtmp == 0) return 0;
- lv = rtmp->value().as_double();
- break;
-
- case IVL_VT_LOGIC:
- case IVL_VT_BOOL:
- vtmp = dynamic_cast<NetEConst*> (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<NetECReal*> (ri);
- if (rtmp == 0) return 0;
- rv = rtmp->value().as_double();
- break;
-
- case IVL_VT_LOGIC:
- case IVL_VT_BOOL:
- vtmp = dynamic_cast<NetEConst*> (ri);
- if (vtmp == 0) return 0;
- rv = vtmp->value().as_double();
- break;
+ verireal lval;
+ verireal rval;
- default:
- rv = 0.0;
- cerr << get_fileline() << ": internal error: "
- << "Unexpected expression type? " << ri->expr_type() << endl;
- assert(0);
- }
+ bool flag = get_real_arguments_(lval, rval);
+ if (! flag) return 0;
- verinum result(((lv == rv) ^ ne_flag) ? verinum::V1 : verinum::V0, 1);
- vtmp = new NetEConst(result);
- vtmp->set_line(*this);
+ verinum result(((lval.as_double() == rval.as_double()) ^ ne_flag) ?
+ verinum::V1 : verinum::V0, 1);
+ NetEConst*res = new NetEConst(result);
+ ivl_assert(*this, res);
- 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<NetEConst*>(left_);
- if (l == 0) return 0;
- NetEConst*r = dynamic_cast<NetEConst*>(right_);
- if (r == 0) return 0;
+ NetEConst*lc = dynamic_cast<NetEConst*>(left_);
+ NetEConst*rc = dynamic_cast<NetEConst*>(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<NetEConst*>(left_);
- if (l == 0) return 0;
- NetEConst*r = dynamic_cast<NetEConst*>(right_);
- if (r == 0) return 0;
+ NetEConst*lc = dynamic_cast<NetEConst*>(left_);
+ NetEConst*rc = dynamic_cast<NetEConst*>(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))
- res = verinum::V0;
-
- for (unsigned idx = cnt ; idx < lv.len() ; idx += 1)
- if (lv.get(idx) != verinum::V0)
- res = verinum::V0;
-
- for (unsigned idx = cnt ; idx < rv.len() ; idx += 1)
- if (rv.get(idx) != verinum::V0)
+ if (lv.get(idx) != rv.get(idx)) {
res = verinum::V0;
+ break;
+ }
- return new NetEConst(verinum(res, 1<