diff --git a/ivl_target.h b/ivl_target.h index 7f99ea38e..8287f951f 100644 --- a/ivl_target.h +++ b/ivl_target.h @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: ivl_target.h,v 1.117 2003/04/22 04:48:29 steve Exp $" +#ident "$Id: ivl_target.h,v 1.118 2003/05/14 05:26:41 steve Exp $" #endif #ifdef __cplusplus @@ -283,30 +283,31 @@ typedef enum ivl_signal_type_e { /* This is the type code for ivl_statement_t objects. */ typedef enum ivl_statement_type_e { - IVL_ST_NONE = 0, - IVL_ST_NOOP = 1, - IVL_ST_ASSIGN, - IVL_ST_ASSIGN_NB, - IVL_ST_BLOCK, - IVL_ST_CASE, - IVL_ST_CASEX, - IVL_ST_CASEZ, - IVL_ST_CASSIGN, - IVL_ST_CONDIT, - IVL_ST_DEASSIGN, - IVL_ST_DELAY, - IVL_ST_DELAYX, - IVL_ST_DISABLE, - IVL_ST_FORCE, - IVL_ST_FOREVER, - IVL_ST_FORK, - IVL_ST_RELEASE, - IVL_ST_REPEAT, - IVL_ST_STASK, - IVL_ST_TRIGGER, - IVL_ST_UTASK, - IVL_ST_WAIT, - IVL_ST_WHILE + IVL_ST_NONE = 0, + IVL_ST_NOOP = 1, + IVL_ST_ASSIGN = 2, + IVL_ST_ASSIGN_NB = 3, + IVL_ST_BLOCK = 4, + IVL_ST_CASE = 5, + IVL_ST_CASER = 24, /* Case statement with real expressions. */ + IVL_ST_CASEX = 6, + IVL_ST_CASEZ = 7, + IVL_ST_CASSIGN = 8, + IVL_ST_CONDIT = 9, + IVL_ST_DEASSIGN = 10, + IVL_ST_DELAY = 11, + IVL_ST_DELAYX = 12, + IVL_ST_DISABLE = 13, + IVL_ST_FORCE = 14, + IVL_ST_FOREVER = 15, + IVL_ST_FORK = 16, + IVL_ST_RELEASE = 17, + IVL_ST_REPEAT = 18, + IVL_ST_STASK = 19, + IVL_ST_TRIGGER = 20, + IVL_ST_UTASK = 21, + IVL_ST_WAIT = 22, + IVL_ST_WHILE = 23 } ivl_statement_type_t; /* This is the type of a variable, and also used as the type for an @@ -1134,11 +1135,11 @@ extern ivl_scope_t ivl_stmt_block_scope(ivl_statement_t net); extern ivl_statement_t ivl_stmt_block_stmt(ivl_statement_t net, unsigned i); /* IVL_ST_UTASK IVL_ST_DISABLE */ extern ivl_scope_t ivl_stmt_call(ivl_statement_t net); - /* IVL_ST_CASE */ + /* IVL_ST_CASE,IVL_ST_CASER,IVL_ST_CASEX,IVL_ST_CASEZ */ extern unsigned ivl_stmt_case_count(ivl_statement_t net); - /* IVL_ST_CASE */ + /* IVL_ST_CASE,IVL_ST_CASER,IVL_ST_CASEX,IVL_ST_CASEZ */ extern ivl_expr_t ivl_stmt_case_expr(ivl_statement_t net, unsigned i); - /* IVL_ST_CASE */ + /* IVL_ST_CASE,IVL_ST_CASER,IVL_ST_CASEX,IVL_ST_CASEZ */ extern ivl_statement_t ivl_stmt_case_stmt(ivl_statement_t net, unsigned i); /* IVL_ST_CONDIT IVL_ST_CASE IVL_ST_REPEAT IVL_ST_WHILE */ extern ivl_expr_t ivl_stmt_cond_expr(ivl_statement_t net); @@ -1214,6 +1215,9 @@ _END_DECL /* * $Log: ivl_target.h,v $ + * Revision 1.118 2003/05/14 05:26:41 steve + * Support real expressions in case statements. + * * Revision 1.117 2003/04/22 04:48:29 steve * Support event names as expressions elements. * diff --git a/t-dll-api.cc b/t-dll-api.cc index 0a9d89056..6eb360090 100644 --- a/t-dll-api.cc +++ b/t-dll-api.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: t-dll-api.cc,v 1.98 2003/04/22 04:48:30 steve Exp $" +#ident "$Id: t-dll-api.cc,v 1.99 2003/05/14 05:26:41 steve Exp $" #endif # include "config.h" @@ -1540,6 +1540,7 @@ extern "C" unsigned ivl_stmt_case_count(ivl_statement_t net) { switch (net->type_) { case IVL_ST_CASE: + case IVL_ST_CASER: case IVL_ST_CASEX: case IVL_ST_CASEZ: return net->u_.case_.ncase; @@ -1553,6 +1554,7 @@ extern "C" ivl_expr_t ivl_stmt_case_expr(ivl_statement_t net, unsigned idx) { switch (net->type_) { case IVL_ST_CASE: + case IVL_ST_CASER: case IVL_ST_CASEX: case IVL_ST_CASEZ: assert(idx < net->u_.case_.ncase); @@ -1568,6 +1570,7 @@ extern "C" ivl_statement_t ivl_stmt_case_stmt(ivl_statement_t net, unsigned idx) { switch (net->type_) { case IVL_ST_CASE: + case IVL_ST_CASER: case IVL_ST_CASEX: case IVL_ST_CASEZ: assert(idx < net->u_.case_.ncase); @@ -1586,6 +1589,7 @@ extern "C" ivl_expr_t ivl_stmt_cond_expr(ivl_statement_t net) return net->u_.condit_.cond_; case IVL_ST_CASE: + case IVL_ST_CASER: case IVL_ST_CASEX: case IVL_ST_CASEZ: return net->u_.case_.cond; @@ -1833,6 +1837,9 @@ extern "C" ivl_variable_type_t ivl_variable_type(ivl_variable_t net) /* * $Log: t-dll-api.cc,v $ + * Revision 1.99 2003/05/14 05:26:41 steve + * Support real expressions in case statements. + * * Revision 1.98 2003/04/22 04:48:30 steve * Support event names as expressions elements. * diff --git a/t-dll-proc.cc b/t-dll-proc.cc index ff1489185..53b30f741 100644 --- a/t-dll-proc.cc +++ b/t-dll-proc.cc @@ -18,7 +18,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: t-dll-proc.cc,v 1.58 2003/05/07 19:56:20 steve Exp $" +#ident "$Id: t-dll-proc.cc,v 1.59 2003/05/14 05:26:41 steve Exp $" #endif # include "config.h" @@ -356,6 +356,11 @@ void dll_target::proc_case(const NetCase*net) stmt_cur_->u_.case_.cond = expr_; expr_ = 0; + /* If the condition expression is a real valued expression, + then change the case statement to a CASER statement. */ + if (stmt_cur_->u_.case_.cond->value_ == IVL_VT_REAL) + stmt_cur_->type_ = IVL_ST_CASER; + unsigned ncase = net->nitems(); stmt_cur_->u_.case_.ncase = ncase; @@ -829,6 +834,9 @@ void dll_target::proc_while(const NetWhile*net) /* * $Log: t-dll-proc.cc,v $ + * Revision 1.59 2003/05/14 05:26:41 steve + * Support real expressions in case statements. + * * Revision 1.58 2003/05/07 19:56:20 steve * Improve internal error message. * diff --git a/tgt-stub/stub.c b/tgt-stub/stub.c index f0855fb83..84330f5c1 100644 --- a/tgt-stub/stub.c +++ b/tgt-stub/stub.c @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: stub.c,v 1.78 2003/05/13 01:56:15 steve Exp $" +#ident "$Id: stub.c,v 1.79 2003/05/14 05:26:41 steve Exp $" #endif # include "config.h" @@ -395,6 +395,7 @@ static void show_statement(ivl_statement_t net, unsigned ind) case IVL_ST_CASEX: case IVL_ST_CASEZ: + case IVL_ST_CASER: case IVL_ST_CASE: { unsigned cnt = ivl_stmt_case_count(net); unsigned idx; @@ -852,6 +853,9 @@ int target_design(ivl_design_t des) /* * $Log: stub.c,v $ + * Revision 1.79 2003/05/14 05:26:41 steve + * Support real expressions in case statements. + * * Revision 1.78 2003/05/13 01:56:15 steve * Allow primitives to hvae unconnected input ports. * diff --git a/tgt-vvp/vvp_process.c b/tgt-vvp/vvp_process.c index 7629e7917..483a3b5f8 100644 --- a/tgt-vvp/vvp_process.c +++ b/tgt-vvp/vvp_process.c @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: vvp_process.c,v 1.84 2003/03/25 02:15:48 steve Exp $" +#ident "$Id: vvp_process.c,v 1.85 2003/05/14 05:26:41 steve Exp $" #endif # include "vvp_priv.h" @@ -799,6 +799,79 @@ static int show_stmt_case(ivl_statement_t net, ivl_scope_t sscope) return 0; } +static int show_stmt_case_r(ivl_statement_t net, ivl_scope_t sscope) +{ + ivl_expr_t exp = ivl_stmt_cond_expr(net); + int cond = draw_eval_real(exp); + unsigned count = ivl_stmt_case_count(net); + + unsigned local_base = local_count; + + unsigned idx, default_case; + + local_count += count + 1; + + + /* First draw the branch table. All the non-default cases + generate a branch out of here, to the code that implements + the case. The default will fall through all the tests. */ + default_case = count; + + for (idx = 0 ; idx < count ; idx += 1) { + ivl_expr_t cex = ivl_stmt_case_expr(net, idx); + int cvec; + + if (cex == 0) { + default_case = idx; + continue; + } + + cvec = draw_eval_real(cex); + + fprintf(vvp_out, " %%cmp/wr %d, %d;\n", cond, cvec); + fprintf(vvp_out, " %%jmp/1 T_%d.%d, 4;\n", + thread_count, local_base+idx); + + /* Done with the guard expression value. */ + clr_word(cvec); + } + + /* Done with the case expression. */ + clr_word(cond); + + /* Emit code for the case default. The above jump table will + fall through to this statement. */ + if (default_case < count) { + ivl_statement_t cst = ivl_stmt_case_stmt(net, default_case); + show_statement(cst, sscope); + } + + /* Jump to the out of the case. */ + fprintf(vvp_out, " %%jmp T_%d.%d;\n", thread_count, + local_base+count); + + for (idx = 0 ; idx < count ; idx += 1) { + ivl_statement_t cst = ivl_stmt_case_stmt(net, idx); + + if (idx == default_case) + continue; + + fprintf(vvp_out, "T_%d.%d ;\n", thread_count, local_base+idx); + clear_expression_lookaside(); + show_statement(cst, sscope); + + fprintf(vvp_out, " %%jmp T_%d.%d;\n", thread_count, + local_base+count); + + } + + + /* The out of the case. */ + fprintf(vvp_out, "T_%d.%d ;\n", thread_count, local_base+count); + + return 0; +} + static int show_stmt_cassign(ivl_statement_t net) { ivl_lval_t lval; @@ -1269,6 +1342,10 @@ static int show_statement(ivl_statement_t net, ivl_scope_t sscope) rc += show_stmt_case(net, sscope); break; + case IVL_ST_CASER: + rc += show_stmt_case_r(net, sscope); + break; + case IVL_ST_CASSIGN: rc += show_stmt_cassign(net); break; @@ -1431,6 +1508,9 @@ int draw_func_definition(ivl_scope_t scope) /* * $Log: vvp_process.c,v $ + * Revision 1.85 2003/05/14 05:26:41 steve + * Support real expressions in case statements. + * * Revision 1.84 2003/03/25 02:15:48 steve * Use hash code for scope labels. *