Pass parameters to system functions.

This commit is contained in:
steve 2001-07-07 20:20:10 +00:00
parent b8c5aff0cb
commit 8cc89a3a1f
5 changed files with 168 additions and 15 deletions

View File

@ -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.54 2001/07/07 03:01:37 steve Exp $"
#ident "$Id: t-dll-api.cc,v 1.55 2001/07/07 20:20:10 steve Exp $"
#endif
# include "t-dll.h"
@ -294,6 +294,10 @@ extern "C" ivl_expr_t ivl_expr_parm(ivl_expr_t net, unsigned idx)
assert(idx < net->u_.concat_.parms);
return net->u_.concat_.parm[idx];
case IVL_EX_SFUNC:
assert(idx < net->u_.sfunc_.parms);
return net->u_.sfunc_.parm[idx];
case IVL_EX_UFUNC:
assert(idx < net->u_.ufunc_.parms);
return net->u_.ufunc_.parm[idx];
@ -313,7 +317,7 @@ extern "C" unsigned ivl_expr_parms(ivl_expr_t net)
return net->u_.concat_.parms;
case IVL_EX_SFUNC:
return 0; /* XXXX not supported yet. */
return net->u_.sfunc_.parms;
case IVL_EX_UFUNC:
return net->u_.ufunc_.parms;
@ -1253,6 +1257,9 @@ extern "C" ivl_statement_t ivl_stmt_sub_stmt(ivl_statement_t net)
/*
* $Log: t-dll-api.cc,v $
* Revision 1.55 2001/07/07 20:20:10 steve
* Pass parameters to system functions.
*
* Revision 1.54 2001/07/07 03:01:37 steve
* Detect and make available to t-dll the right shift.
*

View File

@ -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-expr.cc,v 1.13 2001/05/17 04:37:02 steve Exp $"
#ident "$Id: t-dll-expr.cc,v 1.14 2001/07/07 20:20:10 steve Exp $"
#endif
# include "t-dll.h"
@ -158,12 +158,26 @@ void dll_target::expr_sfunc(const NetESFunc*net)
{
assert(expr_ == 0);
expr_ = (ivl_expr_t)calloc(1, sizeof(struct ivl_expr_s));
assert(expr_);
ivl_expr_t expr = (ivl_expr_t)calloc(1, sizeof(struct ivl_expr_s));
assert(expr);
expr_->type_ = IVL_EX_SFUNC;
expr_->width_= net->expr_width();
expr_->u_.sfunc_.name_ = strdup(net->name());
expr->type_ = IVL_EX_SFUNC;
expr->width_= net->expr_width();
expr->u_.sfunc_.name_ = strdup(net->name());
unsigned cnt = net->nparms();
expr->u_.sfunc_.parms = cnt;
expr->u_.sfunc_.parm = new ivl_expr_t[cnt];
/* make up the parameter expressions. */
for (unsigned idx = 0 ; idx < cnt ; idx += 1) {
net->parm(idx)->expr_scan(this);
assert(expr_);
expr->u_.sfunc_.parm[idx] = expr_;
expr_ = 0;
}
expr_ = expr;
}
void dll_target::expr_ternary(const NetETernary*net)
@ -254,6 +268,9 @@ void dll_target::expr_unary(const NetEUnary*net)
/*
* $Log: t-dll-expr.cc,v $
* Revision 1.14 2001/07/07 20:20:10 steve
* Pass parameters to system functions.
*
* Revision 1.13 2001/05/17 04:37:02 steve
* Behavioral ternary operators for vvp.
*

View File

@ -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.53 2001/07/04 22:59:25 steve Exp $"
#ident "$Id: t-dll.h,v 1.54 2001/07/07 20:20:10 steve Exp $"
#endif
# include "target.h"
@ -173,6 +173,8 @@ struct ivl_expr_s {
struct {
char*name_;
ivl_expr_t *parm;
unsigned short parms;
} sfunc_;
struct {
@ -550,6 +552,9 @@ struct ivl_statement_s {
/*
* $Log: t-dll.h,v $
* Revision 1.54 2001/07/07 20:20:10 steve
* Pass parameters to system functions.
*
* Revision 1.53 2001/07/04 22:59:25 steve
* handle left shifter in dll output.
*

View File

@ -17,10 +17,12 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: eval_expr.c,v 1.34 2001/06/30 21:07:26 steve Exp $"
#ident "$Id: eval_expr.c,v 1.35 2001/07/07 20:20:10 steve Exp $"
#endif
# include "vvp_priv.h"
# include <string.h>
# include <malloc.h>
# include <assert.h>
struct vector_info draw_eval_expr_wid(ivl_expr_t exp, unsigned wid);
@ -810,17 +812,132 @@ static struct vector_info draw_ternary_expr(ivl_expr_t exp, unsigned wid)
static struct vector_info draw_sfunc_expr(ivl_expr_t exp, unsigned wid)
{
unsigned idx;
struct vector_info *vec = 0x0;
unsigned int vecs= 0;
unsigned int veci= 0;
unsigned parm_count = ivl_expr_parms(exp);
struct vector_info res;
/* XXXX no parameters, for now. */
assert(ivl_expr_parms(exp) == 0);
fprintf(stderr, "XXXX %s(%u)\n", ivl_expr_name(exp), parm_count);
/* If the function has no parameters, then use this short-form
to draw the statement. */
if (parm_count == 0) {
res.base = allocate_vector(wid);
res.wid = wid;
fprintf(vvp_out, " %%vpi_func \"%s\", %u, %u;\n",
ivl_expr_name(exp), res.base, res.wid);
return res;
}
/* Evaluate any expressions that need to be evaluated by the
run-time before passed to the system task. The results are
stored in the vec array. */
for (idx = 0 ; idx < parm_count ; idx += 1) {
ivl_expr_t expr = ivl_expr_parm(exp, idx);
switch (ivl_expr_type(expr)) {
case IVL_EX_NONE:
case IVL_EX_NUMBER:
case IVL_EX_SIGNAL:
case IVL_EX_STRING:
case IVL_EX_SCOPE:
case IVL_EX_SFUNC:
continue;
case IVL_EX_MEMORY:
if (!ivl_expr_oper1(expr)) {
continue;
}
default:
break;
}
vec = (struct vector_info *)
realloc(vec, (vecs+1)*sizeof(struct vector_info));
vec[vecs] = draw_eval_expr(expr);
vecs++;
}
/* Start the complicated expression. */
res.base = allocate_vector(wid);
res.wid = wid;
fprintf(vvp_out, " %%vpi_func \"%s\", %u, %u;\n",
fprintf(vvp_out, " %%vpi_func \"%s\", %u, %u",
ivl_expr_name(exp), res.base, res.wid);
/* Now draw all the parameters to the function. */
for (idx = 0 ; idx < parm_count ; idx += 1) {
ivl_expr_t expr = ivl_expr_parm(exp, idx);
switch (ivl_expr_type(expr)) {
case IVL_EX_NONE:
fprintf(vvp_out, ", \" \"");
continue;
case IVL_EX_NUMBER: {
unsigned bit, wid = ivl_expr_width(expr);
const char*bits = ivl_expr_bits(expr);
fprintf(vvp_out, ", %u'b", wid);
for (bit = wid ; bit > 0 ; bit -= 1)
fputc(bits[bit-1], vvp_out);
continue;
}
case IVL_EX_SIGNAL:
fprintf(vvp_out, ", V_%s",
vvp_mangle_id(ivl_expr_name(expr)));
continue;
case IVL_EX_STRING:
fprintf(vvp_out, ", \"%s\"",
ivl_expr_string(expr));
continue;
case IVL_EX_SCOPE:
fprintf(vvp_out, ", S_%s",
vvp_mangle_id(ivl_scope_name(ivl_expr_scope(expr))));
continue;
case IVL_EX_SFUNC:
if (strcmp("$time", ivl_expr_name(expr)) == 0)
fprintf(vvp_out, ", $time");
else
fprintf(vvp_out, ", ?");
continue;
case IVL_EX_MEMORY:
if (!ivl_expr_oper1(expr)) {
fprintf(vvp_out, ", M_%s",
vvp_mangle_id(ivl_expr_name(expr)));
continue;
}
break;
default:
break;
}
fprintf(vvp_out, ", T<%u,%u>",
vec[veci].base,
vec[veci].wid);
veci++;
}
assert(veci == vecs);
if (vecs) {
for (idx = 0; idx < vecs; idx++)
clr_vector(vec[idx]);
free(vec);
}
fprintf(vvp_out, ";\n");
return res;
}
@ -1009,6 +1126,9 @@ struct vector_info draw_eval_expr(ivl_expr_t exp)
/*
* $Log: eval_expr.c,v $
* Revision 1.35 2001/07/07 20:20:10 steve
* Pass parameters to system functions.
*
* Revision 1.34 2001/06/30 21:07:26 steve
* Support non-const right shift (unsigned).
*

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: verireal.cc,v 1.3 2000/12/10 22:01:36 steve Exp $"
#ident "$Id: verireal.cc,v 1.4 2001/07/07 20:20:10 steve Exp $"
#endif
# include "verireal.h"
@ -119,10 +119,14 @@ long verireal::as_long(int shift) const
ostream& operator<< (ostream&out, const verireal&v)
{
out << (v.sign_? "-" : "+") << v.mant_ << "e" << v.exp10_;
return out;
}
/*
* $Log: verireal.cc,v $
* Revision 1.4 2001/07/07 20:20:10 steve
* Pass parameters to system functions.
*
* Revision 1.3 2000/12/10 22:01:36 steve
* Support decimal constants in behavioral delays.
*