diff --git a/ivl_target.h b/ivl_target.h index 054558222..59b3e89a0 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 */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: ivl_target.h,v 1.48 2001/04/05 01:12:27 steve Exp $" +#ident "$Id: ivl_target.h,v 1.49 2001/04/05 03:20:57 steve Exp $" #endif #ifdef __cplusplus @@ -249,6 +249,7 @@ typedef enum ivl_statement_type_e { IVL_ST_DELAYX, IVL_ST_FOREVER, IVL_ST_FORK, + IVL_ST_REPEAT, IVL_ST_STASK, IVL_ST_TRIGGER, IVL_ST_UTASK, @@ -699,7 +700,7 @@ extern unsigned ivl_stmt_case_count(ivl_statement_t net); extern ivl_expr_t ivl_stmt_case_expr(ivl_statement_t net, unsigned i); /* IVL_ST_CASE */ extern ivl_statement_t ivl_stmt_case_stmt(ivl_statement_t net, unsigned i); - /* IVL_ST_CONDIT, IVL_ST_CASE IVL_ST_WHILE */ + /* IVL_ST_CONDIT IVL_ST_CASE IVL_ST_REPEAT IVL_ST_WHILE */ extern ivl_expr_t ivl_stmt_cond_expr(ivl_statement_t net); /* IVL_ST_CONDIT */ extern ivl_statement_t ivl_stmt_cond_false(ivl_statement_t net); @@ -723,7 +724,7 @@ extern ivl_expr_t ivl_stmt_parm(ivl_statement_t net, unsigned idx); extern unsigned ivl_stmt_parm_count(ivl_statement_t net); /* IVL_ST_ASSIGN IVL_ST_ASSIGN_NB */ extern ivl_expr_t ivl_stmt_rval(ivl_statement_t net); - /* IVL_ST_DELAY, IVL_ST_FOREVER, IVL_ST_WAIT, IVL_ST_WHILE */ + /* IVL_ST_DELAY, IVL_ST_FOREVER, IVL_ST_REPEAT IVL_ST_WAIT, IVL_ST_WHILE */ extern ivl_statement_t ivl_stmt_sub_stmt(ivl_statement_t net); @@ -744,6 +745,9 @@ _END_DECL /* * $Log: ivl_target.h,v $ + * Revision 1.49 2001/04/05 03:20:57 steve + * Generate vvp code for the repeat statement. + * * Revision 1.48 2001/04/05 01:12:27 steve * Get signed compares working correctly in vvp. * diff --git a/t-dll-api.cc b/t-dll-api.cc index 0ebf2870b..0f4679c8d 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 */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: t-dll-api.cc,v 1.35 2001/04/05 01:12:28 steve Exp $" +#ident "$Id: t-dll-api.cc,v 1.36 2001/04/05 03:20:57 steve Exp $" #endif # include "t-dll.h" @@ -684,6 +684,7 @@ extern "C" ivl_expr_t ivl_stmt_cond_expr(ivl_statement_t net) case IVL_ST_CASEZ: return net->u_.case_.cond; + case IVL_ST_REPEAT: case IVL_ST_WHILE: return net->u_.while_.cond_; @@ -830,6 +831,7 @@ extern "C" ivl_statement_t ivl_stmt_sub_stmt(ivl_statement_t net) return net->u_.forever_.stmt_; case IVL_ST_WAIT: return net->u_.wait_.stmt_; + case IVL_ST_REPEAT: case IVL_ST_WHILE: return net->u_.while_.stmt_; default: @@ -841,6 +843,9 @@ extern "C" ivl_statement_t ivl_stmt_sub_stmt(ivl_statement_t net) /* * $Log: t-dll-api.cc,v $ + * Revision 1.36 2001/04/05 03:20:57 steve + * Generate vvp code for the repeat statement. + * * Revision 1.35 2001/04/05 01:12:28 steve * Get signed compares working correctly in vvp. * diff --git a/t-dll-proc.cc b/t-dll-proc.cc index 08e5cca04..e6e5a484d 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 */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: t-dll-proc.cc,v 1.22 2001/04/04 04:50:35 steve Exp $" +#ident "$Id: t-dll-proc.cc,v 1.23 2001/04/05 03:20:57 steve Exp $" #endif # include "target.h" @@ -368,6 +368,30 @@ void dll_target::proc_forever(const NetForever*net) stmt_cur_ = save_cur_; } +void dll_target::proc_repeat(const NetRepeat*net) +{ + assert(stmt_cur_); + assert(stmt_cur_->type_ == IVL_ST_NONE); + + stmt_cur_->type_ = IVL_ST_REPEAT; + + assert(expr_ == 0); + net->expr()->expr_scan(this); + stmt_cur_->u_.while_.cond_ = expr_; + expr_ = 0; + + ivl_statement_t tmp = (struct ivl_statement_s*) + calloc(1, sizeof(struct ivl_statement_s)); + + ivl_statement_t save_cur_ = stmt_cur_; + stmt_cur_ = tmp; + + net->emit_recurse(this); + + save_cur_->u_.while_.stmt_ = stmt_cur_; + stmt_cur_ = save_cur_; +} + void dll_target::proc_stask(const NetSTask*net) { unsigned nparms = net->nparms(); @@ -530,6 +554,9 @@ void dll_target::proc_while(const NetWhile*net) /* * $Log: t-dll-proc.cc,v $ + * Revision 1.23 2001/04/05 03:20:57 steve + * Generate vvp code for the repeat statement. + * * Revision 1.22 2001/04/04 04:50:35 steve * Support forever loops in the tgt-vvp target. * diff --git a/t-dll.h b/t-dll.h index b07df1ed1..b034d820c 100644 --- a/t-dll.h +++ b/t-dll.h @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: t-dll.h,v 1.34 2001/04/04 04:50:35 steve Exp $" +#ident "$Id: t-dll.h,v 1.35 2001/04/05 03:20:58 steve Exp $" #endif # include "target.h" @@ -84,6 +84,7 @@ struct dll_target : public target_t, public expr_scan_t { void proc_condit(const NetCondit*); bool proc_delay(const NetPDelay*); void proc_forever(const NetForever*); + void proc_repeat(const NetRepeat*); void proc_stask(const NetSTask*); bool proc_trigger(const NetEvTrig*); void proc_utask(const NetUTask*); @@ -406,7 +407,7 @@ struct ivl_statement_s { ivl_statement_t stmt_; } wait_; - struct { /* IVL_ST_WHILE */ + struct { /* IVL_ST_WHILE IVL_ST_REPEAT */ ivl_expr_t cond_; ivl_statement_t stmt_; } while_; @@ -415,6 +416,9 @@ struct ivl_statement_s { /* * $Log: t-dll.h,v $ + * Revision 1.35 2001/04/05 03:20:58 steve + * Generate vvp code for the repeat statement. + * * Revision 1.34 2001/04/04 04:50:35 steve * Support forever loops in the tgt-vvp target. * diff --git a/tgt-vvp/vvp_process.c b/tgt-vvp/vvp_process.c index c9649ad8d..8d4df77bc 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 */ #if !defined(WINNT) -#ident "$Id: vvp_process.c,v 1.24 2001/04/04 04:50:35 steve Exp $" +#ident "$Id: vvp_process.c,v 1.25 2001/04/05 03:20:58 steve Exp $" #endif # include "vvp_priv.h" @@ -413,6 +413,30 @@ static int show_stmt_noop(ivl_statement_t net) return 0; } +static int show_stmt_repeat(ivl_statement_t net) +{ + int rc = 0; + unsigned lab_top = local_count++, lab_out = local_count++; + ivl_expr_t exp = ivl_stmt_cond_expr(net); + struct vector_info cnt = draw_eval_expr(exp); + + /* Test that 0 < expr */ + fprintf(vvp_out, "T_%u.%u %%cmp/u 0, %u, %u;\n", thread_count, + lab_top, cnt.base, cnt.wid); + fprintf(vvp_out, " %%jmp/0xz T_%u.%u, 5;\n", thread_count, lab_out); + /* This adds -1 (all ones in 2's complement) to the count. */ + fprintf(vvp_out, " %%add %u, 1, %u;\n", cnt.base, cnt.wid); + + rc += show_statement(ivl_stmt_sub_stmt(net)); + + fprintf(vvp_out, " %%jmp T_%u.%u;\n", thread_count, lab_top); + fprintf(vvp_out, "T_%u.%u ;\n", thread_count, lab_out); + + clr_vector(cnt); + + return rc; +} + static int show_stmt_trigger(ivl_statement_t net) { ivl_event_t ev = ivl_stmt_event(net); @@ -578,6 +602,10 @@ static int show_statement(ivl_statement_t net) rc += show_stmt_noop(net); break; + case IVL_ST_REPEAT: + rc += show_stmt_repeat(net); + break; + case IVL_ST_STASK: rc += show_system_task_call(net); break; @@ -673,6 +701,9 @@ int draw_task_definition(ivl_scope_t scope) /* * $Log: vvp_process.c,v $ + * Revision 1.25 2001/04/05 03:20:58 steve + * Generate vvp code for the repeat statement. + * * Revision 1.24 2001/04/04 04:50:35 steve * Support forever loops in the tgt-vvp target. *