From 2b5560957ad1fef684dd19d1e4f7a22dc3cfe427 Mon Sep 17 00:00:00 2001 From: Cary R Date: Wed, 13 Feb 2008 14:02:35 -0800 Subject: [PATCH] Force the L-value and R-value to match for real values. Check that if either the L-value or the R-value are real then both must be real. This prevents a runtime crash. --- elaborate.cc | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/elaborate.cc b/elaborate.cc index 50481b044..df139cf63 100644 --- a/elaborate.cc +++ b/elaborate.cc @@ -124,6 +124,16 @@ void PGAssign::elaborate(Design*des, NetScope*scope) const return; } + /* If either lval or rid are real then both must be real. */ + if ((lval->data_type() == IVL_VT_REAL || + rid->data_type() == IVL_VT_REAL) && + lval->data_type() != rid->data_type()) { + cerr << get_fileline() << ": sorry: Both the r-value and " + "the l-value must be real in this context." << endl; + des->errors += 1; + return; + } + ivl_assert(*this, rid); if (rid->pin_count() != 1) { cerr << get_fileline() << ": internal error: " @@ -288,6 +298,16 @@ void PGAssign::elaborate(Design*des, NetScope*scope) const assert(lval && rval); assert(rval->pin_count() == 1); + /* If either lval or rval are real then both must be real. */ + if ((lval->data_type() == IVL_VT_REAL || + rval->data_type() == IVL_VT_REAL) && + lval->data_type() != rval->data_type()) { + cerr << get_fileline() << ": sorry: Both the r-value and " + "the l-value must be real in this context." << endl; + des->errors += 1; + return; + } + /* If the r-value insists on being smaller then the l-value (perhaps it is explicitly sized) the pad it out to be the right width so that something is connected to all the bits