Evalulate logical or (||)

This commit is contained in:
steve 2001-04-29 20:47:39 +00:00
parent a52b34cb64
commit 31291f5d8a
1 changed files with 52 additions and 1 deletions

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: eval_expr.c,v 1.19 2001/04/21 03:26:23 steve Exp $"
#ident "$Id: eval_expr.c,v 1.20 2001/04/29 20:47:39 steve Exp $"
#endif
# include "vvp_priv.h"
@ -189,6 +189,50 @@ static struct vector_info draw_binary_expr_land(ivl_expr_t exp, unsigned wid)
return lv;
}
static struct vector_info draw_binary_expr_lor(ivl_expr_t exp, unsigned wid)
{
ivl_expr_t le = ivl_expr_oper1(exp);
ivl_expr_t re = ivl_expr_oper2(exp);
struct vector_info lv;
struct vector_info rv;
/* XXXX For now, assume the operands are a single bit. */
assert(ivl_expr_width(le) == 1);
assert(ivl_expr_width(re) == 1);
lv = draw_eval_expr_wid(le, wid);
rv = draw_eval_expr_wid(re, wid);
if (lv.base < 4) {
if (rv.base < 4) {
unsigned lb = lv.base;
unsigned rb = rv.base;
if ((lb == 0) && (rb == 0)) {
lv.base = 0;
} else if ((lb == 1) || (rb == 1)) {
lv.base = 1;
} else {
lv.base = 2;
}
} else {
fprintf(vvp_out, " %%or %u, %u, 1;\n", rv.base, lv.base);
lv = rv;
}
} else {
fprintf(vvp_out, " %%and %u, %u, 1;\n", lv.base, rv.base);
clr_vector(rv);
}
assert(wid == 1);
return lv;
}
static struct vector_info draw_binary_expr_le(ivl_expr_t exp, unsigned wid)
{
ivl_expr_t le = ivl_expr_oper1(exp);
@ -491,6 +535,10 @@ static struct vector_info draw_binary_expr(ivl_expr_t exp, unsigned wid)
rv = draw_binary_expr_ls(exp, wid);
break;
case 'o': /* || (logical or) */
rv = draw_binary_expr_lor(exp, wid);
break;
case 'r': /* >> */
rv = draw_binary_expr_rs(exp, wid);
break;
@ -807,6 +855,9 @@ struct vector_info draw_eval_expr(ivl_expr_t exp)
/*
* $Log: eval_expr.c,v $
* Revision 1.20 2001/04/29 20:47:39 steve
* Evalulate logical or (||)
*
* Revision 1.19 2001/04/21 03:26:23 steve
* Right shift by constant.
*