Skip to content

Commit

Permalink
Generate vvp code for the repeat statement.
Browse files Browse the repository at this point in the history
  • Loading branch information
steve committed Apr 5, 2001
1 parent b7fb806 commit 82947a9
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 8 deletions.
10 changes: 7 additions & 3 deletions ivl_target.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand All @@ -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);


Expand All @@ -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.
*
Expand Down
7 changes: 6 additions & 1 deletion t-dll-api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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_;

Expand Down Expand Up @@ -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:
Expand All @@ -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.
*
Expand Down
29 changes: 28 additions & 1 deletion t-dll-proc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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.
*
Expand Down
8 changes: 6 additions & 2 deletions t-dll.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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*);
Expand Down Expand Up @@ -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_;
Expand All @@ -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.
*
Expand Down
33 changes: 32 additions & 1 deletion tgt-vvp/vvp_process.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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.
*
Expand Down

0 comments on commit 82947a9

Please sign in to comment.