Support ternary and <= operators in vvm.

This commit is contained in:
steve 1999-09-11 04:43:17 +00:00
parent 287d21f300
commit 1c238f1948
4 changed files with 85 additions and 4 deletions

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: netlist.cc,v 1.58 1999/09/08 04:05:30 steve Exp $"
#ident "$Id: netlist.cc,v 1.59 1999/09/11 04:43:17 steve Exp $"
#endif
# include <cassert>
@ -1100,6 +1100,21 @@ NetETernary::~NetETernary()
delete false_val_;
}
const NetExpr* NetETernary::cond_expr() const
{
return cond_;
}
const NetExpr* NetETernary::true_expr() const
{
return true_val_;
}
const NetExpr* NetETernary::false_expr() const
{
return false_val_;
}
NetETernary* NetETernary::dup_expr() const
{
assert(0);
@ -1747,6 +1762,9 @@ NetNet* Design::find_signal(bool (*func)(const NetNet*))
/*
* $Log: netlist.cc,v $
* Revision 1.59 1999/09/11 04:43:17 steve
* Support ternary and <= operators in vvm.
*
* Revision 1.58 1999/09/08 04:05:30 steve
* Allow assign to not match rvalue width.
*

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: netlist.h,v 1.61 1999/09/08 04:05:30 steve Exp $"
#ident "$Id: netlist.h,v 1.62 1999/09/11 04:43:17 steve Exp $"
#endif
/*
@ -1260,6 +1260,10 @@ class NetETernary : public NetExpr {
virtual bool set_width(unsigned w);
const NetExpr*cond_expr() const;
const NetExpr*true_expr() const;
const NetExpr*false_expr() const;
virtual NetETernary* dup_expr() const;
virtual void expr_scan(struct expr_scan_t*) const;
@ -1552,6 +1556,9 @@ extern ostream& operator << (ostream&, NetNet::Type);
/*
* $Log: netlist.h,v $
* Revision 1.62 1999/09/11 04:43:17 steve
* Support ternary and <= operators in vvm.
*
* Revision 1.61 1999/09/08 04:05:30 steve
* Allow assign to not match rvalue width.
*

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: t-vvm.cc,v 1.40 1999/09/08 02:24:39 steve Exp $"
#ident "$Id: t-vvm.cc,v 1.41 1999/09/11 04:43:17 steve Exp $"
#endif
# include <iostream>
@ -121,6 +121,7 @@ class vvm_proc_rval : public expr_scan_t {
}
virtual void expr_signal(const NetESignal*);
virtual void expr_subsignal(const NetESubSignal*sig);
virtual void expr_ternary(const NetETernary*);
virtual void expr_unary(const NetEUnary*);
virtual void expr_binary(const NetEBinary*);
virtual void expr_ufunc(const NetEUFunc*);
@ -209,6 +210,24 @@ void vvm_proc_rval::expr_subsignal(const NetESubSignal*sig)
result = val;
}
void vvm_proc_rval::expr_ternary(const NetETernary*expr)
{
expr->cond_expr()->expr_scan(this);
string cond_val = result;
expr->true_expr()->expr_scan(this);
string true_val = result;
expr->false_expr()->expr_scan(this);
string false_val = result;
result = make_temp();
os_ << setw(indent_) << "" << "vvm_bitset_t<" <<
expr->expr_width() << ">" << result << ";" << endl;
os_ << setw(indent_) << "" << result << " = vvm_ternary(" <<
cond_val << "[0], " << true_val << ", " << false_val << ");"
<< endl;
}
/*
* A function call is handled by assigning the parameters from the
* input expressions, then calling the function. After the function
@ -297,6 +316,10 @@ void vvm_proc_rval::expr_binary(const NetEBinary*expr)
os_ << setw(indent_) << "" << result << " = vvm_binop_eq("
<< lres << "," << rres << ");" << endl;
break;
case 'L': // <=
os_ << setw(indent_) << "" << result << " = vvm_binop_le("
<< lres << "," << rres << ");" << endl;
break;
case 'N': // !==
os_ << setw(indent_) << "" << result << " = vvm_binop_nee("
<< lres << "," << rres << ");" << endl;
@ -1418,6 +1441,9 @@ extern const struct target tgt_vvm = {
};
/*
* $Log: t-vvm.cc,v $
* Revision 1.41 1999/09/11 04:43:17 steve
* Support ternary and <= operators in vvm.
*
* Revision 1.40 1999/09/08 02:24:39 steve
* Empty conditionals (pmonta@imedia.com)
*

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: vvm_func.h,v 1.7 1999/06/24 04:20:47 steve Exp $"
#ident "$Id: vvm_func.h,v 1.8 1999/09/11 04:43:17 steve Exp $"
#endif
# include "vvm.h"
@ -308,6 +308,19 @@ vvm_bitset_t<1> vvm_binop_lt(const vvm_bitset_t<LW>&l,
return result;
}
template <unsigned LW, unsigned RW>
vvm_bitset_t<1> vvm_binop_le(const vvm_bitset_t<LW>&l,
const vvm_bitset_t<RW>&r)
{
assert(LW == RW);
vvm_bitset_t<1> result;
result[0] = V1;
for (unsigned idx = 0 ; idx < LW ; idx += 1)
result[0] = less_with_cascade(l[idx], r[idx], result[0]);
return result;
}
template <unsigned LW, unsigned RW>
vvm_bitset_t<1> vvm_binop_land(const vvm_bitset_t<LW>&l,
const vvm_bitset_t<RW>&r)
@ -328,8 +341,25 @@ vvm_bitset_t<1> vvm_binop_lor(const vvm_bitset_t<LW>&l,
return res1;
}
template <unsigned W>
vvm_bitset_t<W> vvm_ternary(vvm_bit_t c, const vvm_bitset_t<W>&t,
const vvm_bitset_t<W>&f)
{
switch (c) {
case V0:
return f;
case V1:
return t;
default:
return f;
}
}
/*
* $Log: vvm_func.h,v $
* Revision 1.8 1999/09/11 04:43:17 steve
* Support ternary and <= operators in vvm.
*
* Revision 1.7 1999/06/24 04:20:47 steve
* Add !== and === operators.
*