Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Cleanup after parameter expression rework.

This patch removes some code made redundant by the rework of
parameter expression evaluation. It also documents the new
-g option.
  • Loading branch information...
commit b89ab1f2b0cfd232ab59d4b71672d5493c1cd599 1 parent 275dde7
@martinwhitaker martinwhitaker authored committed
View
2  Makefile.in
@@ -92,7 +92,7 @@ TT = t-dll.o t-dll-api.o t-dll-expr.o t-dll-proc.o t-dll-analog.o
FF = cprop.o nodangle.o synth.o synth2.o syn-rules.o
O = main.o async.o design_dump.o discipline.o dup_expr.o elaborate.o \
- elab_expr.o elaborate_analog.o elab_lval.o elab_net.o elab_pexpr.o \
+ elab_expr.o elaborate_analog.o elab_lval.o elab_net.o \
elab_scope.o elab_sig.o elab_sig_analog.o emit.o eval.o eval_attrib.o \
eval_tree.o expr_synth.o functor.o lexor.o lexor_keyword.o link_const.o \
load_module.o netlist.o netmisc.o net_analog.o net_assign.o net_design.o \
View
3  Module.h
@@ -146,9 +146,6 @@ class Module : public PScope, public LineInfo {
private:
list<PGate*> gates_;
- static void elaborate_parm_item_(perm_string name, const param_expr_t&cur,
- Design*des, NetScope*scope);
-
private: // Not implemented
Module(const Module&);
Module& operator= (const Module&);
View
36 PExpr.h
@@ -110,12 +110,6 @@ class PExpr : public LineInfo {
virtual NetExpr*elaborate_expr(Design*des, NetScope*scope,
int expr_width, bool sys_task_arg) const;
- // Elaborate expressions that are the r-value of parameter
- // assignments. This elaboration follows the restrictions of
- // constant expressions and supports later overriding and
- // evaluation of parameters.
- virtual NetExpr*elaborate_pexpr(Design*des, NetScope*sc) const;
-
// This method elaborates the expression as gates, but
// restricted for use as l-values of continuous assignments.
virtual NetNet* elaborate_lnet(Design*des, NetScope*scope) const;
@@ -179,7 +173,6 @@ class PEConcat : public PExpr {
virtual NetNet* elaborate_bi_net(Design*des, NetScope*scope) const;
virtual NetExpr*elaborate_expr(Design*des, NetScope*,
int expr_width, bool sys_task_arg) const;
- virtual NetEConcat*elaborate_pexpr(Design*des, NetScope*) const;
virtual NetAssign_* elaborate_lval(Design*des,
NetScope*scope,
bool is_force) const;
@@ -244,7 +237,6 @@ class PEFNumber : public PExpr {
bool&unsized_flag);
virtual NetExpr*elaborate_expr(Design*des, NetScope*,
int expr_width, bool sys_task_arg) const;
- virtual NetExpr*elaborate_pexpr(Design*des, NetScope*sc) const;
virtual void dump(ostream&) const;
@@ -286,7 +278,6 @@ class PEIdent : public PExpr {
virtual NetExpr*elaborate_expr(Design*des, NetScope*,
int expr_width, bool sys_task_arg) const;
- virtual NetExpr*elaborate_pexpr(Design*des, NetScope*sc) const;
// Elaborate the PEIdent as a port to a module. This method
// only applies to Ident expressions.
@@ -405,7 +396,6 @@ class PENumber : public PExpr {
virtual NetEConst*elaborate_expr(Design*des, NetScope*,
int expr_width, bool) const;
- virtual NetExpr*elaborate_pexpr(Design*des, NetScope*sc) const;
virtual NetAssign_* elaborate_lval(Design*des,
NetScope*scope,
bool is_force) const;
@@ -441,7 +431,6 @@ class PEString : public PExpr {
virtual NetEConst*elaborate_expr(Design*des, NetScope*,
int expr_width, bool) const;
- virtual NetEConst*elaborate_pexpr(Design*des, NetScope*sc) const;
verinum* eval_const(Design*, NetScope*) const;
private:
@@ -467,7 +456,6 @@ class PEUnary : public PExpr {
virtual NetExpr*elaborate_expr(Design*des, NetScope*,
int expr_width, bool sys_task_arg) const;
- virtual NetExpr*elaborate_pexpr(Design*des, NetScope*sc) const;
virtual verinum* eval_const(Design*des, NetScope*sc) const;
private:
@@ -497,7 +485,6 @@ class PEBinary : public PExpr {
virtual NetExpr*elaborate_expr(Design*des, NetScope*,
int expr_width, bool sys_task_arg) const;
- virtual NetExpr*elaborate_pexpr(Design*des, NetScope*sc) const;
virtual verinum* eval_const(Design*des, NetScope*sc) const;
protected:
@@ -506,19 +493,22 @@ class PEBinary : public PExpr {
PExpr*right_;
NetExpr*elaborate_expr_base_(Design*, NetExpr*lp, NetExpr*rp,
- int use_wid, bool is_pexpr =false) const;
+ int use_wid) const;
NetExpr*elaborate_eval_expr_base_(Design*, NetExpr*lp, NetExpr*rp,
int use_wid) const;
- NetExpr*elaborate_expr_base_bits_(Design*, NetExpr*lp, NetExpr*rp, int use_wid) const;
+ NetExpr*elaborate_expr_base_bits_(Design*, NetExpr*lp, NetExpr*rp,
+ int use_wid) const;
NetExpr*elaborate_expr_base_div_(Design*, NetExpr*lp, NetExpr*rp,
- int use_wid, bool is_pexpr) const;
- NetExpr*elaborate_expr_base_lshift_(Design*, NetExpr*lp, NetExpr*rp, int use_wid) const;
- NetExpr*elaborate_expr_base_rshift_(Design*, NetExpr*lp, NetExpr*rp, int use_wid) const;
+ int use_wid) const;
+ NetExpr*elaborate_expr_base_lshift_(Design*, NetExpr*lp, NetExpr*rp,
+ int use_wid) const;
+ NetExpr*elaborate_expr_base_rshift_(Design*, NetExpr*lp, NetExpr*rp,
+ int use_wid) const;
NetExpr*elaborate_expr_base_mult_(Design*, NetExpr*lp, NetExpr*rp,
- int use_wid, bool is_pexpr) const;
+ int use_wid) const;
NetExpr*elaborate_expr_base_add_(Design*, NetExpr*lp, NetExpr*rp,
- int use_wid, bool is_pexpr) const;
+ int use_wid) const;
};
@@ -539,7 +529,6 @@ class PEBComp : public PEBinary {
NetExpr* elaborate_expr(Design*des, NetScope*scope,
int expr_width, bool sys_task_arg) const;
- NetExpr*elaborate_pexpr(Design*des, NetScope*sc) const;
private:
int left_width_;
@@ -562,7 +551,6 @@ class PEBLogic : public PEBinary {
NetExpr* elaborate_expr(Design*des, NetScope*scope,
int expr_width, bool sys_task_arg) const;
- NetExpr*elaborate_pexpr(Design*des, NetScope*sc) const;
};
/*
@@ -588,8 +576,6 @@ class PEBLeftWidth : public PEBinary {
virtual NetExpr*elaborate_expr(Design*des, NetScope*scope,
int expr_width, bool sys_task_arg) const;
- virtual NetExpr*elaborate_pexpr(Design*des, NetScope*scope) const;
-
};
class PEBPower : public PEBLeftWidth {
@@ -635,7 +621,6 @@ class PETernary : public PExpr {
virtual NetExpr*elaborate_expr(Design*des, NetScope*,
int expr_width, bool sys_task_arg) const;
- virtual NetETernary*elaborate_pexpr(Design*des, NetScope*sc) const;
virtual verinum* eval_const(Design*des, NetScope*sc) const;
private:
@@ -674,7 +659,6 @@ class PECallFunction : public PExpr {
virtual NetExpr*elaborate_expr(Design*des, NetScope*scope,
int expr_wid, bool sys_task_arg) const;
- virtual NetExpr*elaborate_pexpr(Design*des, NetScope*sc) const;
virtual unsigned test_width(Design*des, NetScope*scope,
unsigned min, unsigned lval,
View
4 README.txt
@@ -184,8 +184,7 @@ first, followed by the structural and behavioral elaboration.
This pass scans through the pform looking for scopes and parameters. A
tree of NetScope objects is built up and placed in the Design object,
with the root module represented by the root NetScope object. The
-elab_scope.cc and elab_pexpr.cc files contain most of the code for
-handling this phase.
+elab_scope.cc file contains most of the code for handling this phase.
The tail of the elaborate_scope behavior (after the pform is
traversed) includes a scan of the NetScope tree to locate defparam
@@ -476,4 +475,3 @@ file. However, I have early on received aid in the form of fixes,
Verilog guidance, and especially testing from many people. Testers in
particular include a larger community of people interested in a GPL
Verilog for Linux.
-
View
1  compiler.h
@@ -98,7 +98,6 @@ extern bool verbose_flag;
extern bool debug_scopes;
extern bool debug_eval_tree;
extern bool debug_elaborate;
-extern bool debug_elab_pexpr;
extern bool debug_synth2;
extern bool debug_optimizer;
View
8 design_dump.cc
@@ -1504,14 +1504,6 @@ void NetESignal::dump(ostream&o) const
o << "[" << msi()<<":"<<lsi() << "]";
}
-void NetEParam::dump(ostream&o) const
-{
- if (scope_ != 0)
- o << "<" << scope_path(scope_) << "." << (*reference_).first << ">";
- else
- o << "<" << (*reference_).first << ">";
-}
-
void NetETernary::dump(ostream&o) const
{
o << "(" << *cond_ << ") ? (" << *true_val_ << ") : (" <<
View
5 driver/iverilog.man.in
@@ -121,6 +121,11 @@ has side effects, the resulting behavior will differ from that
required by the standard. Using \fI\-gstrict\-ca\-eval\fP will force
standard compliant behavior (with some loss in performance).
.TP 8
+.B -gstrict-expr-width\fI|\fP-gno-strict-expr-width
+Enable or disable (default) strict compliance with the standard rules
+for determining expression bit lengths. When disabled, the RHS of a
+parameter assignment is evaluated as a lossless expression.
+.TP 8
.B -I\fIincludedir\fP
Append directory \fIincludedir\fP to list of directories searched
for Verilog include files. The \fB\-I\fP switch may be used many times
View
21 elab_expr.cc
@@ -332,7 +332,7 @@ NetExpr* PEBinary::elaborate_eval_expr_base_(Design*des,
*/
NetExpr* PEBinary::elaborate_expr_base_(Design*des,
NetExpr*lp, NetExpr*rp,
- int expr_wid, bool is_pexpr) const
+ int expr_wid) const
{
if (debug_elaborate) {
cerr << get_fileline() << ": debug: elaborate expression "
@@ -362,12 +362,12 @@ NetExpr* PEBinary::elaborate_expr_base_(Design*des,
break;
case '*':
- tmp = elaborate_expr_base_mult_(des, lp, rp, expr_wid, is_pexpr);
+ tmp = elaborate_expr_base_mult_(des, lp, rp, expr_wid);
break;
case '%':
case '/':
- tmp = elaborate_expr_base_div_(des, lp, rp, expr_wid, is_pexpr);
+ tmp = elaborate_expr_base_div_(des, lp, rp, expr_wid);
break;
case 'l':
@@ -391,7 +391,7 @@ NetExpr* PEBinary::elaborate_expr_base_(Design*des,
case '+':
case '-':
- tmp = elaborate_expr_base_add_(des, lp, rp, expr_wid, is_pexpr);
+ tmp = elaborate_expr_base_add_(des, lp, rp, expr_wid);
break;
case 'E': /* === */
@@ -452,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) const
+ int expr_wid) const
{
/* The % operator does not support real arguments in
baseline Verilog. But we allow it in our extended
@@ -744,7 +744,7 @@ NetExpr* PEBinary::elaborate_expr_base_rshift_(Design*des,
NetExpr* PEBinary::elaborate_expr_base_mult_(Design*,
NetExpr*lp, NetExpr*rp,
- int expr_wid, bool is_pexpr) const
+ int expr_wid) const
{
// First, Make sure that signed arguments are padded to the
// width of the output. This is necessary for 2s complement
@@ -785,9 +785,7 @@ NetExpr* PEBinary::elaborate_expr_base_mult_(Design*,
// If this expression is unsigned, then make sure the
// arguments are unsigned so that the padding below doesn't
// cause any sign extension to happen.
- if (! is_pexpr)
- suppress_binary_operand_sign_if_needed(lp, rp);
-
+ suppress_binary_operand_sign_if_needed(lp, rp);
// Multiply will guess a width that is the sum of the
// widths of the operand. If that sum is too small, then
@@ -807,7 +805,7 @@ NetExpr* PEBinary::elaborate_expr_base_mult_(Design*,
NetExpr* PEBinary::elaborate_expr_base_add_(Design*,
NetExpr*lp, NetExpr*rp,
- int expr_wid, bool is_pexpr) const
+ int expr_wid) const
{
NetExpr*tmp;
bool use_lossless_flag = expr_wid == -2;
@@ -823,8 +821,7 @@ NetExpr* PEBinary::elaborate_expr_base_add_(Design*,
// If the expression is unsigned, then force the operands to
// unsigned so that the set_width below doesn't cause them to
// be sign-extended.
- if (! is_pexpr)
- suppress_binary_operand_sign_if_needed(lp, rp);
+ suppress_binary_operand_sign_if_needed(lp, rp);
tmp = new NetEBAdd(op_, lp, rp, use_lossless_flag);
if (expr_wid > 0 && type_is_vectorable(tmp->expr_type()))
View
515 elab_pexpr.cc
@@ -1,515 +0,0 @@
-/*
- * Copyright (c) 2000-2010 Stephen Williams (steve@icarus.com)
- *
- * This source code is free software; you can redistribute it
- * and/or modify it in source code form under the terms of the GNU
- * General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-# include "config.h"
-
-# include "PExpr.h"
-# include "compiler.h"
-# include "util.h"
-# include "netmisc.h"
-
-# include <cstdlib>
-# include <iostream>
-# include "ivl_assert.h"
-
-NetExpr*PExpr::elaborate_pexpr(Design*des, NetScope*) const
-{
- cerr << get_fileline() << ": error: invalid parameter expression: "
- << *this << endl;
- des->errors += 1;
-
- return 0;
-}
-
-/*
- * Binary operators have sub-expressions that must be elaborated as
- * parameter expressions. If either of them fail, then give up. Once
- * they are taken care of, make the base object just as in any other
- * expression.
- */
-NetExpr*PEBinary::elaborate_pexpr (Design*des, NetScope*scope) const
-{
- NetExpr*lp = left_->elaborate_pexpr(des, scope);
- NetExpr*rp = right_->elaborate_pexpr(des, scope);
- if ((lp == 0) || (rp == 0)) {
- delete lp;
- delete rp;
- return 0;
- }
-
- NetExpr*tmp = elaborate_expr_base_(des, lp, rp, -2, true);
- return tmp;
-}
-
-NetExpr*PEBComp::elaborate_pexpr(Design*des, NetScope*scope) const
-{
- NetExpr*lp = left_->elaborate_pexpr(des, scope);
- NetExpr*rp = right_->elaborate_pexpr(des, scope);
- if ((lp == 0) || (rp == 0)) {
- delete lp;
- delete rp;
- return 0;
- }
-
- NetEBComp*tmp = new NetEBComp(op_, lp, rp);
- tmp->set_line(*this);
- bool flag = tmp->set_width(1);
- if (flag == false) {
- cerr << get_fileline() << ": internal error: "
- "expression bit width of comparison != 1." << endl;
- des->errors += 1;
- }
-
- return tmp;
-}
-
-NetExpr*PEBLeftWidth::elaborate_pexpr (Design*des, NetScope*scope) const
-{
- NetExpr*lp = left_->elaborate_pexpr(des, scope);
- NetExpr*rp = right_->elaborate_pexpr(des, scope);
- if ((lp == 0) || (rp == 0)) {
- delete lp;
- delete rp;
- return 0;
- }
-
- NetExpr*tmp = elaborate_expr_leaf(des, lp, rp, -2);
- return tmp;
-}
-
-NetExpr*PEBLogic::elaborate_pexpr(Design*des, NetScope*scope) const
-{
- NetExpr*lp = left_->elaborate_pexpr(des, scope);
- NetExpr*rp = right_->elaborate_pexpr(des, scope);
- if ((lp == 0) || (rp == 0)) {
- delete lp;
- delete rp;
- return 0;
- }
-
- NetEBLogic*tmp = new NetEBLogic(op_, lp, rp);
- tmp->set_line(*this);
- bool flag = tmp->set_width(1);
- if (flag == false) {
- cerr << get_fileline() << ": internal error: "
- "expression bit width of comparison != 1." << endl;
- des->errors += 1;
- }
-
- return tmp;
-}
-
-/*
- * Event though parameters are not generally sized, parameter
- * expressions can include concatenation expressions. This requires
- * that the subexpressions all have well-defined size (in spite of
- * being in a parameter expression) in order to get a defined
- * value. The sub-expressions themselves must also be value parameter
- * expressions.
- */
-NetEConcat* PEConcat::elaborate_pexpr(Design*des, NetScope*scope) const
-{
- NetExpr* repeat = 0;
-
- /* If there is a repeat expression, then evaluate the constant
- value and set the repeat count. */
- if (repeat_) {
- repeat = repeat_->elaborate_pexpr(des, scope);
- if (repeat == 0) {
- cerr << get_fileline() << ": error: "
- "concatenation repeat expression cannot be evaluated."
- << endl;
- des->errors += 1;
- return 0;
- }
-
- /* continue on even if the repeat expression doesn't
- work, as we can find more errors. */
- }
-
- /* Make the empty concat expression. */
- NetEConcat*tmp = new NetEConcat(parms_.size(), repeat);
- tmp->set_line(*this);
-
- /* Elaborate all the operands and attach them to the concat
- node. Use the elaborate_pexpr method instead of the
- elaborate_expr method. */
- bool fail = false;
- for (unsigned idx = 0 ; idx < parms_.size() ; idx += 1) {
- assert(parms_[idx]);
- NetExpr*ex = parms_[idx]->elaborate_pexpr(des, scope);
- if (ex == 0) continue;
-
- if (ex->expr_type() == IVL_VT_REAL) {
- cerr << ex->get_fileline() << ": error: concatenation "
- << "operand can not be real: " << *ex << endl;
- des->errors += 1;
- fail = true;
- continue;
- }
- ex->set_line(*parms_[idx]);
-
- if (dynamic_cast<NetEParam*>(ex)) {
-
- /* If this parameter is a NetEParam, then put off
- the width check for later. */
-
- } else if (! ex->has_width()) {
- cerr << ex->get_fileline() << ": error: operand of "
- << "concatenation has indefinite width: "
- << *ex << endl;
- des->errors += 1;
- fail = true;
- continue;
- }
-
- tmp->set(idx, ex);
- }
-
- if (fail) {
- delete tmp;
- return 0;
- }
-
- return tmp;
-}
-
-NetExpr*PEFNumber::elaborate_pexpr(Design*des, NetScope*scope) const
-{
- return elaborate_expr(des, scope, -1, false);
-}
-
-/*
- * Parameter expressions may reference other parameters, but only in
- * the current scope. Preserve the parameter reference in the
- * parameter expression I'm generating, instead of evaluating it now,
- * because the referenced parameter may yet be overridden.
- */
-NetExpr*PEIdent::elaborate_pexpr(Design*des, NetScope*scope) const
-{
- pform_name_t oldpath = path_;
- name_component_t name_tail = path_.back();
- oldpath.pop_back();
-
- if (path_.size() > 1) {
- cerr << get_fileline() << ": error: parameter r-value expression "
- "does not support hierarchical references `" << path_
- << "`." << endl;
- des->errors += 1;
- return 0;
- }
-
- NetScope*pscope = scope;
- if (path_.size() > 0) {
- 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;
- const NetExpr*ex = 0;
- // Look up the parameter name in the current scope. If the
- // name is not found in the pscope, look in containing scopes,
- // but do not go outside the containing module instance.
- for (;;) {
- ex = pscope->get_parameter(des, name_tail.name, ex_msb, ex_lsb);
- if (ex != 0)
- break;
- if (pscope->type() == NetScope::MODULE)
- break;
- pscope = pscope->parent();
- ivl_assert(*this, pscope);
- }
- if (ex == 0) {
- cerr << get_fileline() << ": error: identifier `"
- << name_tail.name << "` is not a parameter in "
- << scope_path(scope)<< "." << endl;
- des->errors += 1;
- return 0;
- }
-
- NetExpr*res = new NetEParam(des, pscope, name_tail.name);
- res->set_line(*this);
- assert(res);
-
- index_component_t::ctype_t use_sel = index_component_t::SEL_NONE;
- if (!name_tail.index.empty())
- use_sel = name_tail.index.back().sel;
-
- switch (use_sel) {
- case index_component_t::SEL_NONE:
- break;
-
- default:
- case index_component_t::SEL_PART:
- cerr << get_fileline() << ": sorry: Cannot part select "
- "bits of parameters." << endl;
- des->errors += 1;
- delete res;
- return 0;
-
- case index_component_t::SEL_BIT:
-
- /* We have here a bit select. Insert a NetESelect node
- to handle it. */
- NetExpr*tmp = name_tail.index.back().msb->elaborate_pexpr(des, scope);
- if (tmp == 0) {
- delete res;
- return 0;
- }
- if (debug_elaborate)
- cerr << get_fileline() << ": debug: "
- << "Bit select [" << *tmp << "]"
- << " in parameter expression." << endl;
-
- res = new NetESelect(res, tmp, 1);
- res->set_line(*this);
- break;
- }
-
- return res;
-}
-
-/*
- * Simple numbers can be elaborated by the elaborate_expr method.
- */
-NetExpr*PENumber::elaborate_pexpr(Design*des, NetScope*sc) const
-{
- return elaborate_expr(des, sc, -1, false);
-}
-
-
-NetEConst* PEString::elaborate_pexpr(Design*des, NetScope*scope) const
-{
- return elaborate_expr(des, scope, -1, false);
-}
-
-NetETernary* PETernary::elaborate_pexpr(Design*des, NetScope*scope) const
-{
- NetExpr*c = expr_->elaborate_pexpr(des, scope);
- NetExpr*t = tru_->elaborate_pexpr(des, scope);
- NetExpr*f = fal_->elaborate_pexpr(des, scope);
- if (c == 0 || t == 0 || f == 0) return 0;
-
- NetETernary*tmp = new NetETernary(c, t, f);
- tmp->set_line(*this);
- return tmp;
-}
-
-NetExpr*PEUnary::elaborate_pexpr (Design*des, NetScope*scope) const
-{
- NetExpr*ip = expr_->elaborate_pexpr(des, scope);
- if (ip == 0) return 0;
-
- /* Should we evaluate expressions ahead of time,
- * just like in PEBinary::elaborate_expr() ?
- */
-
- NetEUnary*tmp;
- switch (op_) {
- default:
- tmp = new NetEUnary(op_, ip);
- tmp->set_line(*this);
- break;
-
- case '~':
- tmp = new NetEUBits(op_, ip);
- tmp->set_line(*this);
- break;
-
- case '!': // Logical NOT
- case '&': // Reduction AND
- case '|': // Reduction OR
- case '^': // Reduction XOR
- case 'A': // Reduction NAND (~&)
- case 'N': // Reduction NOR (~|)
- case 'X': // Reduction NXOR (~^)
- tmp = new NetEUReduce(op_, ip);
- tmp->set_line(*this);
- break;
- }
-
- return tmp;
-}
-
-NetExpr* PECallFunction::elaborate_pexpr(Design*des, NetScope*scope) const
-{
- /* Only $clog2 and the builtin mathematical functions can
- * be a constant system function. */
- perm_string nm = peek_tail_name(path_);
- if (nm[0] == '$' && (generation_flag >= GN_VER2005 ||
- gn_icarus_misc_flag || gn_verilog_ams_flag)) {
- if (nm == "$clog2" ||
- nm == "$ln" ||
- nm == "$log10" ||
- nm == "$exp" ||
- nm == "$sqrt" ||
- nm == "$floor" ||
- nm == "$ceil" ||
- nm == "$sin" ||
- nm == "$cos" ||
- nm == "$tan" ||
- nm == "$asin" ||
- nm == "$acos" ||
- nm == "$atan" ||
- nm == "$sinh" ||
- nm == "$cosh" ||
- nm == "$tanh" ||
- nm == "$asinh" ||
- nm == "$acosh" ||
- nm == "$atanh") {
- if (parms_.size() != 1 || parms_[0] == 0) {
- cerr << get_fileline() << ": error: " << nm
- << " takes a single argument." << endl;
- des->errors += 1;
- return 0;
- }
- NetExpr*arg = parms_[0]->elaborate_pexpr(des, scope);
- if (arg == 0) return 0;
- NetESFunc*rtn;
- if (nm == "$clog2") {
- rtn = new NetESFunc(nm, IVL_VT_BOOL, integer_width, 1);
- } else {
- rtn = new NetESFunc(nm, IVL_VT_REAL, 1, 1);
- }
- rtn->set_line(*this);
- rtn->cast_signed(true);
- rtn->parm(0, arg);
- return rtn;
- }
-
- if (nm == "$pow" ||
- nm == "$atan2" ||
- nm == "$hypot") {
- if (parms_.size() != 2 || parms_[0] == 0 || parms_[1] == 0) {
- cerr << get_fileline() << ": error: " << nm
- << " takes two arguments." << endl;
- des->errors += 1;
- return 0;
- }
- NetExpr*arg0 = parms_[0]->elaborate_pexpr(des, scope);
- NetExpr*arg1 = parms_[1]->elaborate_pexpr(des, scope);
- if (arg0 == 0 || arg1 == 0) return 0;
- NetESFunc*rtn = new NetESFunc(nm, IVL_VT_REAL, 1, 2);
- rtn->set_line(*this);
- rtn->cast_signed(true);
- rtn->parm(0, arg0);
- rtn->parm(1, arg1);
- return rtn;
- }
-
- /* This is only available with verilog-ams or icarus-misc. */
- if ((gn_icarus_misc_flag || gn_verilog_ams_flag) &&
- (nm == "$abs")) {
- if (parms_.size() != 1 || parms_[0] == 0) {
- cerr << get_fileline() << ": error: " << nm
- << " takes a single argument." << endl;
- des->errors += 1;
- return 0;
- }
- NetExpr*arg = parms_[0]->elaborate_pexpr(des, scope);
- if (arg == 0) return 0;
- NetESFunc*rtn;
- /* This can return either a real or an arbitrary
- * width vector, so set things to fail if this
- * does not get replaced with a constant during
- * elaboration. */
- rtn = new NetESFunc(nm, IVL_VT_NO_TYPE, 0, 1);
- rtn->set_line(*this);
- rtn->cast_signed(true);
- rtn->parm(0, arg);
- return rtn;
- }
- if ((gn_icarus_misc_flag || gn_verilog_ams_flag) &&
- (nm == "$min" || nm == "$max")) {
- if (parms_.size() != 2 || parms_[0] == 0 || parms_[1] == 0) {
- cerr << get_fileline() << ": error: " << nm
- << " takes two arguments." << endl;
- des->errors += 1;
- return 0;
- }
- NetExpr*arg0 = parms_[0]->elaborate_pexpr(des, scope);
- NetExpr*arg1 = parms_[1]->elaborate_pexpr(des, scope);
- if (arg0 == 0 || arg1 == 0) return 0;
- /* See $abs above for why this has no type or width. */
- NetESFunc*rtn = new NetESFunc(nm, IVL_VT_NO_TYPE, 0, 2);
- rtn->set_line(*this);
- rtn->cast_signed(true);
- rtn->parm(0, arg0);
- rtn->parm(1, arg1);
- return rtn;
- }
-
- cerr << get_fileline() << ": error: " << nm << "() is not a "
- "constant system function." << endl;
- des->errors += 1;
- return 0;
- }
-
- /* Constant user function code goes here. */
- cerr << get_fileline() << ": sorry: constant user functions are not "
- "currently supported: " << nm << "()." << endl;
- des->errors += 1;
- return 0;
-}
-
-void NetExpr::resolve_pexpr_type(void)
-{
-}
-
-void NetEBinary::resolve_pexpr_type(void)
-{
- if (debug_elab_pexpr) {
- cerr << get_fileline() << ": debug: "
- << "Resolve_pexpr_type for binary " << human_readable_op(op_)
- << "." << endl;
- }
-
- left_->resolve_pexpr_type();
- right_->resolve_pexpr_type();
-
- switch (op_) {
- case '+':
- case '-':
- case '*':
- case '/':
- suppress_binary_operand_sign_if_needed(left_, right_);
- cast_signed_base_(left_->has_sign() && right_->has_sign());
- break;
- default:
- break;
- }
-}
-
-void NetEParam::resolve_pexpr_type(void)
-{
- if (debug_elab_pexpr) {
- cerr << get_fileline() << ": debug: "
- << "Resolve_pexpr_type for parameter " << reference_->first
- << "." << endl;
- }
-
- if (reference_->second.signed_flag) {
- cast_signed_base_(true);
-
- } else if (reference_->second.val) {
- cast_signed_base_( reference_->second.val->has_sign() );
- }
-}
View
4 elab_scope.cc
@@ -136,8 +136,8 @@ static void elaborate_scope_enumeration(Design*des, NetScope*scope,
{
bool rc_flag;
assert(enum_type->range->size() == 2);
- NetExpr*msb_ex = enum_type->range->front()->elaborate_pexpr(des, scope);
- NetExpr*lsb_ex = enum_type->range->back() ->elaborate_pexpr(des, scope);
+ NetExpr*msb_ex = enum_type->range->front()->elaborate_expr(des, scope, -2, false);
+ NetExpr*lsb_ex = enum_type->range->back() ->elaborate_expr(des, scope, -2, false);
long msb = 0;
rc_flag = eval_as_long(msb, msb_ex);
View
6 emit.cc
@@ -540,12 +540,6 @@ void NetECRealParam::expr_scan(struct expr_scan_t*tgt) const
tgt->expr_rparam(this);
}
-void NetEParam::expr_scan(struct expr_scan_t*) const
-{
- cerr << get_fileline() << ":internal error: unexpected NetEParam."
- << endl;
-}
-
void NetEEvent::expr_scan(struct expr_scan_t*tgt) const
{
tgt->expr_event(this);
View
7 eval_tree.cc
@@ -1289,13 +1289,6 @@ NetEConst* NetEConcat::eval_tree(int prune_to_width)
return res;
}
-NetExpr* NetEParam::eval_tree(int prune_to_width)
-{
- // The NetEParam class is now redundant.
- assert(0);
- return 0;
-}
-
NetEConst* NetESelect::eval_tree(int prune_to_width)
{
// HERE
View
4 main.cc
@@ -149,7 +149,6 @@ bool warn_sens_entire_arr = false;
bool debug_scopes = false;
bool debug_eval_tree = false;
bool debug_elaborate = false;
-bool debug_elab_pexpr = false;
bool debug_synth2 = false;
bool debug_optimizer = false;
@@ -567,9 +566,6 @@ static void read_iconfig_file(const char*ipath)
} else if (strcmp(cp,"elaborate") == 0) {
debug_elaborate = true;
cerr << "debug: Enable elaborate debug" << endl;
- } else if (strcmp(cp,"elab_pexpr") == 0) {
- debug_elab_pexpr = true;
- cerr << "debug: Enable elaborate-pexpr debug" << endl;
} else if (strcmp(cp,"synth2") == 0) {
debug_synth2 = true;
cerr << "debug: Enable synth2 debug" << endl;
View
53 net_expr.cc
@@ -520,59 +520,6 @@ netenum_t* NetENetenum::netenum() const
return netenum_;
}
-
-NetEParam::NetEParam()
-: des_(0), scope_(0)
-{
- solving_ = false;
-}
-
-NetEParam::NetEParam(Design*d, NetScope*s, perm_string n)
- : des_(d), scope_(s), reference_(scope_->find_parameter(n))
-{
- cast_signed_base_(reference_->second.signed_flag);
- solving_ = false;
-}
-
-NetEParam::NetEParam(Design*d, NetScope*s, ref_t ref)
- : des_(d), scope_(s), reference_(ref)
-{
- cast_signed_base_(reference_->second.signed_flag);
- solving_ = false;
-}
-
-NetEParam::~NetEParam()
-{
-}
-
-bool NetEParam::has_width() const
-{
- return false;
-}
-
-ivl_variable_type_t NetEParam::expr_type() const
-{
- return (*reference_).second.type;
-}
-
-NetEParam* NetEParam::dup_expr() const
-{
- NetEParam*tmp = new NetEParam(des_, scope_, reference_);
- tmp->solving(solving_);
- tmp->set_line(*this);
- return tmp;
-}
-
-void NetEParam::solving(bool arg)
-{
- solving_ = arg;
-}
-
-bool NetEParam::solving() const
-{
- return solving_;
-}
-
NetESelect::NetESelect(NetExpr*exp, NetExpr*base, unsigned wid)
: expr_(exp), base_(base)
{
View
9 net_nex_input.cc
@@ -86,15 +86,6 @@ NexusSet* NetECReal::nex_input(bool)
return new NexusSet;
}
-/*
- * A parameter by definition has no inputs. It represents a constant
- * value, even if that value is a constant expression.
- */
-NexusSet* NetEParam::nex_input(bool)
-{
- return new NexusSet;
-}
-
NexusSet* NetEEvent::nex_input(bool)
{
return new NexusSet;
View
49 netlist.h
@@ -1659,15 +1659,6 @@ class NetExpr : public LineInfo {
// part of the enumeration.
virtual netenum_t*enumeration() const;
- // Expressions in parameter declarations may have encountered
- // arguments that are themselves untyped parameters. These
- // cannot be fully resolved for type when elaborated (they are
- // elaborated before all parameter overrides are complete) so
- // this virtual method needs to be called right before
- // evaluating the expression. This wraps up the evaluation of
- // the type.
- virtual void resolve_pexpr_type();
-
// This method evaluates the expression and returns an
// equivalent expression that is reduced as far as compile
// time knows how. Essentially, this is designed to fold
@@ -3348,7 +3339,6 @@ class NetEBinary : public NetExpr {
// widths.
virtual bool has_width() const;
- virtual void resolve_pexpr_type();
virtual NetEBinary* dup_expr() const;
virtual NexusSet* nex_input(bool rem_out = true);
@@ -3633,45 +3623,6 @@ class NetEConcat : public NetExpr {
/*
- * This class is a placeholder for a parameter expression. When
- * parameters are first created, an instance of this object is used to
- * hold the place where the parameter expression goes. Then, when the
- * parameters are resolved, these objects are removed.
- *
- * If the parameter object is created with a path and name, then the
- * object represents a reference to a parameter that is known to exist.
- */
-class NetEParam : public NetExpr {
- public:
- NetEParam();
- NetEParam(class Design*des, NetScope*scope, perm_string name);
- ~NetEParam();
-
- virtual NexusSet* nex_input(bool rem_out = true);
- virtual void resolve_pexpr_type();
- virtual bool set_width(unsigned w, bool last_chance);
- virtual bool has_width() const;
- virtual void expr_scan(struct expr_scan_t*) const;
- virtual ivl_variable_type_t expr_type() const;
- virtual NetExpr* eval_tree(int prune_to_width = -1);
- virtual NetEParam* dup_expr() const;
- void solving(bool arg);
- bool solving() const;
-
- virtual void dump(ostream&) const;
-
- private:
- Design*des_;
- NetScope*scope_;
- typedef map<perm_string,NetScope::param_expr_t>::iterator ref_t;
- ref_t reference_;
- bool solving_;
-
- NetEParam(class Design*des, NetScope*scope, ref_t ref);
-};
-
-
-/*
* This expression node supports bit/part selects from general
* expressions. The sub-expression is self-sized, and has bits
* selected from it. The base is the expression that identifies the
View
5 set_width.cc
@@ -405,11 +405,6 @@ bool NetEMemory::set_width(unsigned w, bool)
return true;
}
#endif
-bool NetEParam::set_width(unsigned, bool)
-{
- return false;
-}
-
bool NetESelect::set_width(unsigned, bool)
{
return expr_width() == 1;
Please sign in to comment.
Something went wrong with that request. Please try again.