Reduce the while loop expression if needed.

This commit is contained in:
steve 2002-04-22 02:41:30 +00:00
parent 4502da608d
commit d482da4803
3 changed files with 47 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: eval_expr.c,v 1.57 2002/04/14 18:41:34 steve Exp $"
#ident "$Id: eval_expr.c,v 1.58 2002/04/22 02:41:30 steve Exp $"
#endif
# include "vvp_priv.h"
@ -72,7 +72,7 @@ void clr_vector(struct vector_info vec)
clr_bit(vec.base + idx);
}
static unsigned short allocate_vector(unsigned short wid)
unsigned short allocate_vector(unsigned short wid)
{
unsigned short base = 8;
@ -1506,6 +1506,9 @@ struct vector_info draw_eval_expr(ivl_expr_t exp)
/*
* $Log: eval_expr.c,v $
* Revision 1.58 2002/04/22 02:41:30 steve
* Reduce the while loop expression if needed.
*
* Revision 1.57 2002/04/14 18:41:34 steve
* Support signed integer division.
*

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: vvp_priv.h,v 1.12 2001/11/01 04:26:57 steve Exp $"
#ident "$Id: vvp_priv.h,v 1.13 2002/04/22 02:41:30 steve Exp $"
#endif
# include "ivl_target.h"
@ -78,6 +78,7 @@ extern struct vector_info draw_eval_expr(ivl_expr_t exp);
extern struct vector_info draw_eval_expr_wid(ivl_expr_t exp, unsigned w);
extern void draw_memory_index_expr(ivl_memory_t mem, ivl_expr_t exp);
extern unsigned short allocate_vector(unsigned short wid);
extern void clr_vector(struct vector_info vec);
/*
@ -88,6 +89,9 @@ extern unsigned thread_count;
/*
* $Log: vvp_priv.h,v $
* Revision 1.13 2002/04/22 02:41:30 steve
* Reduce the while loop expression if needed.
*
* Revision 1.12 2001/11/01 04:26:57 steve
* Generate code for deassign and cassign.
*

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: vvp_process.c,v 1.56 2002/04/21 22:31:02 steve Exp $"
#ident "$Id: vvp_process.c,v 1.57 2002/04/22 02:41:30 steve Exp $"
#endif
# include "vvp_priv.h"
@ -786,6 +786,36 @@ static int show_stmt_wait(ivl_statement_t net, ivl_scope_t sscope)
return show_statement(ivl_stmt_sub_stmt(net), sscope);
}
static struct vector_info reduction_or(struct vector_info cvec)
{
struct vector_info result;
switch (cvec.base) {
case 0:
result.base = 0;
result.wid = 1;
break;
case 1:
result.base = 1;
result.wid = 1;
break;
case 2:
case 3:
result.base = 0;
result.wid = 1;
break;
default:
clr_vector(cvec);
result.base = allocate_vector(1);
result.wid = 1;
fprintf(vvp_out, " %%or/r %u, %u, %u;\n", result.base,
cvec.base, cvec.wid);
break;
}
return result;
}
static int show_stmt_while(ivl_statement_t net, ivl_scope_t sscope)
{
int rc = 0;
@ -800,6 +830,9 @@ static int show_stmt_while(ivl_statement_t net, ivl_scope_t sscope)
the result. If the expression evaluates to false, then
branch to the out label. */
cvec = draw_eval_expr(ivl_stmt_cond_expr(net));
if (cvec.wid > 1)
cvec = reduction_or(cvec);
fprintf(vvp_out, " %%jmp/0xz T_%d.%d, %u;\n",
thread_count, out_label, cvec.base);
clr_vector(cvec);
@ -1135,6 +1168,9 @@ int draw_func_definition(ivl_scope_t scope)
/*
* $Log: vvp_process.c,v $
* Revision 1.57 2002/04/22 02:41:30 steve
* Reduce the while loop expression if needed.
*
* Revision 1.56 2002/04/21 22:31:02 steve
* Redo handling of assignment internal delays.
* Leave it possible for them to be calculated