Evaluate the logical AND operator.
This commit is contained in:
parent
2443c655f2
commit
56a4236576
|
|
@ -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.7 2001/03/31 17:36:39 steve Exp $"
|
||||
#ident "$Id: eval_expr.c,v 1.8 2001/04/01 06:49:32 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "vvp_priv.h"
|
||||
|
|
@ -145,6 +145,50 @@ static struct vector_info draw_binary_expr_eq(ivl_expr_t exp)
|
|||
return lv;
|
||||
}
|
||||
|
||||
static struct vector_info draw_binary_expr_land(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, " %%and %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_plus(ivl_expr_t exp, unsigned wid)
|
||||
{
|
||||
ivl_expr_t le = ivl_expr_oper1(exp);
|
||||
|
|
@ -171,6 +215,10 @@ static struct vector_info draw_binary_expr(ivl_expr_t exp, unsigned wid)
|
|||
struct vector_info rv;
|
||||
|
||||
switch (ivl_expr_opcode(exp)) {
|
||||
case 'a': /* && (logical and) */
|
||||
rv = draw_binary_expr_land(exp, wid);
|
||||
break;
|
||||
|
||||
case 'E': /* === */
|
||||
case 'e': /* == */
|
||||
case 'N': /* !== */
|
||||
|
|
@ -400,6 +448,9 @@ struct vector_info draw_eval_expr(ivl_expr_t exp)
|
|||
|
||||
/*
|
||||
* $Log: eval_expr.c,v $
|
||||
* Revision 1.8 2001/04/01 06:49:32 steve
|
||||
* Evaluate the logical AND operator.
|
||||
*
|
||||
* Revision 1.7 2001/03/31 17:36:39 steve
|
||||
* Generate vvp code for case statements.
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in New Issue