Add variant of elaborate_rval_expr() that only takes a data_type_t
The `elaborate_rval_expr()` function takes a `data_type_t`, a
`ivl_variable_type_t` and a `width` parameter. In most places the
ivl_variable_type_t and width are directly derived from the data_type_t.
This slightly simplifies the code.
The only place where this is currently not possible is when assigning to a
compound expression like a concatenation, e.g. `{a,b} = c;`.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
This commit is contained in:
parent
b11da7e16f
commit
ff8a44b025
19
elab_expr.cc
19
elab_expr.cc
|
|
@ -91,6 +91,15 @@ static NetBranch* find_existing_implicit_branch(NetNet*sig, NetNet*gnd)
|
|||
return 0;
|
||||
}
|
||||
|
||||
NetExpr* elaborate_rval_expr(Design*des, NetScope*scope, ivl_type_t lv_net_type,
|
||||
PExpr*expr, bool need_const, bool force_unsigned)
|
||||
{
|
||||
return elaborate_rval_expr(des, scope, lv_net_type,
|
||||
lv_net_type->base_type(),
|
||||
lv_net_type->packed_width(),
|
||||
expr, need_const, force_unsigned);
|
||||
}
|
||||
|
||||
NetExpr* elaborate_rval_expr(Design*des, NetScope*scope, ivl_type_t lv_net_type,
|
||||
ivl_variable_type_t lv_type, unsigned lv_width,
|
||||
PExpr*expr, bool need_const, bool force_unsigned)
|
||||
|
|
@ -2009,7 +2018,7 @@ static NetExpr* check_for_enum_methods(const LineInfo*li,
|
|||
NetExpr* count = 0;
|
||||
if (args != 0 && parg) {
|
||||
count = elaborate_rval_expr(des, scope, &netvector_t::atom2u32,
|
||||
IVL_VT_BOOL, 32, parg);
|
||||
parg);
|
||||
if (count == 0) {
|
||||
cerr << li->get_fileline() << ": error: unable to elaborate "
|
||||
"enumeration method argument " << use_path << "."
|
||||
|
|
@ -2897,8 +2906,6 @@ unsigned PECallFunction::elaborate_arguments_(Design*des, NetScope*scope,
|
|||
if (tmp) {
|
||||
parms[pidx] = elaborate_rval_expr(des, scope,
|
||||
def->port(pidx)->net_type(),
|
||||
def->port(pidx)->data_type(),
|
||||
(unsigned)def->port(pidx)->vector_width(),
|
||||
tmp, need_const);
|
||||
if (parms[pidx] == 0) {
|
||||
parm_errors += 1;
|
||||
|
|
@ -3222,11 +3229,11 @@ NetExpr* PECallFunction::elaborate_expr_method_(Design*des, NetScope*scope,
|
|||
NetExpr*tmp;
|
||||
|
||||
tmp = elaborate_rval_expr(des, scope, &netvector_t::atom2u32,
|
||||
IVL_VT_BOOL, 32, parms_[0], false);
|
||||
parms_[0], false);
|
||||
sys_expr->parm(1, tmp);
|
||||
|
||||
tmp = elaborate_rval_expr(des, scope, &netvector_t::atom2u32,
|
||||
IVL_VT_BOOL, 32, parms_[1], false);
|
||||
parms_[1], false);
|
||||
sys_expr->parm(2, tmp);
|
||||
|
||||
return sys_expr;
|
||||
|
|
@ -6546,8 +6553,6 @@ NetExpr* PENewClass::elaborate_expr_constructor_(Design*des, NetScope*scope,
|
|||
PExpr*tmp = parms_[idx-1];
|
||||
parms[idx] = elaborate_rval_expr(des, scope,
|
||||
def->port(idx)->net_type(),
|
||||
def->port(idx)->data_type(),
|
||||
def->port(idx)->vector_width(),
|
||||
tmp, false);
|
||||
if (parms[idx] == 0)
|
||||
parm_errors += 1;
|
||||
|
|
|
|||
14
elaborate.cc
14
elaborate.cc
|
|
@ -140,9 +140,7 @@ void PGAssign::elaborate(Design*des, NetScope*scope) const
|
|||
<< ", pin_count=" << lval->pin_count() << endl;
|
||||
}
|
||||
|
||||
NetExpr*rval_expr = elaborate_rval_expr(des, scope, lval->net_type(),
|
||||
lval->data_type(),
|
||||
lval->vector_width(), pin(1));
|
||||
NetExpr*rval_expr = elaborate_rval_expr(des, scope, lval->net_type(), pin(1));
|
||||
|
||||
if (rval_expr == 0) {
|
||||
cerr << get_fileline() << ": error: Unable to elaborate r-value: "
|
||||
|
|
@ -3253,8 +3251,6 @@ NetProc* PChainConstructor::elaborate(Design*des, NetScope*scope) const
|
|||
PExpr*tmp = parms_[idx-1];
|
||||
parms[idx] = elaborate_rval_expr(des, scope,
|
||||
def->port(idx)->net_type(),
|
||||
def->port(idx)->data_type(),
|
||||
def->port(idx)->vector_width(),
|
||||
tmp, false);
|
||||
continue;
|
||||
}
|
||||
|
|
@ -4029,7 +4025,7 @@ NetProc* PCallTask::elaborate_build_call_(Design*des, NetScope*scope,
|
|||
|
||||
if (parms_idx < parms_.size() && parms_[parms_idx]) {
|
||||
rv = elaborate_rval_expr(des, scope, port->net_type(),
|
||||
lv_type, wid, parms_ [parms_idx]);
|
||||
parms_ [parms_idx]);
|
||||
if (NetEEvent*evt = dynamic_cast<NetEEvent*> (rv)) {
|
||||
cerr << evt->get_fileline() << ": error: An event '"
|
||||
<< evt->event()->name() << "' can not be a user "
|
||||
|
|
@ -5453,7 +5449,6 @@ NetProc* PForStatement::elaborate(Design*des, NetScope*scope) const
|
|||
/* Make the r-value of the initial assignment, and size it
|
||||
properly. Then use it to build the assignment statement. */
|
||||
initial_expr = elaborate_rval_expr(des, scope, sig->net_type(),
|
||||
sig->data_type(), sig->vector_width(),
|
||||
expr1_);
|
||||
|
||||
if (debug_elaborate && initial_expr) {
|
||||
|
|
@ -5700,12 +5695,9 @@ NetProc* PReturn::elaborate(Design*des, NetScope*scope) const
|
|||
|
||||
NetNet*res = target->find_signal(target->basename());
|
||||
ivl_assert(*this, res);
|
||||
ivl_variable_type_t lv_type = res->data_type();
|
||||
unsigned long wid = res->vector_width();
|
||||
NetAssign_*lv = new NetAssign_(res);
|
||||
|
||||
NetExpr*val = elaborate_rval_expr(des, scope, res->net_type(),
|
||||
lv_type, wid, expr_);
|
||||
NetExpr*val = elaborate_rval_expr(des, scope, res->net_type(), expr_);
|
||||
|
||||
NetBlock*proc = new NetBlock(NetBlock::SEQU, 0);
|
||||
proc->set_line( *this );
|
||||
|
|
|
|||
|
|
@ -408,6 +408,13 @@ extern NetExpr* elaborate_rval_expr(Design*des, NetScope*scope,
|
|||
unsigned lv_width, PExpr*expr,
|
||||
bool need_const =false,
|
||||
bool force_unsigned =false);
|
||||
/*
|
||||
* Same as above, but lv_width and lv_type are derived from the lv_net_type.
|
||||
*/
|
||||
extern NetExpr* elaborate_rval_expr(Design*des, NetScope*scope,
|
||||
ivl_type_t lv_net_type, PExpr*expr,
|
||||
bool need_const = false,
|
||||
bool force_unsigned = false);
|
||||
|
||||
extern bool evaluate_range(Design*des, NetScope*scope, const LineInfo*li,
|
||||
const pform_range_t&range,
|
||||
|
|
|
|||
Loading…
Reference in New Issue