Implement release functionality.

This commit is contained in:
steve 2004-12-17 04:46:40 +00:00
parent 78dda42493
commit 59bac26f4f
1 changed files with 77 additions and 70 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2001-2003 Stephen Williams (steve@icarus.com) * Copyright (c) 2001-2004 Stephen Williams (steve@icarus.com)
* *
* This source code is free software; you can redistribute it * This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU * and/or modify it in source code form under the terms of the GNU
@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#ifdef HAVE_CVS_IDENT #ifdef HAVE_CVS_IDENT
#ident "$Id: vvp_process.c,v 1.95 2004/12/11 05:43:30 steve Exp $" #ident "$Id: vvp_process.c,v 1.96 2004/12/17 04:46:40 steve Exp $"
#endif #endif
# include "vvp_priv.h" # include "vvp_priv.h"
@ -819,17 +819,25 @@ static int show_stmt_case_r(ivl_statement_t net, ivl_scope_t sscope)
return 0; return 0;
} }
static int show_stmt_cassign(ivl_statement_t net) static void force_vector_to_lval(ivl_statement_t net, struct vector_info rvec)
{ {
ivl_expr_t rval; unsigned lidx;
struct vector_info rvec;
unsigned roff = 0; unsigned roff = 0;
unsigned lidx = 0;
rval = ivl_stmt_rval(net); const char*command_name;
assert(rval);
rvec = draw_eval_expr(rval, STUFF_OK_47); switch (ivl_statement_type(net)) {
case IVL_ST_CASSIGN:
command_name = "%cassign/v";
break;
case IVL_ST_FORCE:
command_name = "%force/v";
break;
default:
command_name = "ERROR";
assert(0);
break;
}
for (lidx = 0 ; lidx < ivl_stmt_lvals(net) ; lidx += 1) { for (lidx = 0 ; lidx < ivl_stmt_lvals(net) ; lidx += 1) {
ivl_lval_t lval = ivl_stmt_lval(net, lidx); ivl_lval_t lval = ivl_stmt_lval(net, lidx);
@ -843,17 +851,33 @@ static int show_stmt_cassign(ivl_statement_t net)
use_wid = ivl_signal_width(lsig); use_wid = ivl_signal_width(lsig);
assert(roff + use_wid <= rvec.wid); assert(roff + use_wid <= rvec.wid);
fprintf(vvp_out, " %%cassign/v V_%s, %u, %u;\n", fprintf(vvp_out, " %s V_%s, %u, %u;\n", command_name,
vvp_signal_label(lsig), rvec.base+roff, use_wid); vvp_signal_label(lsig), rvec.base+roff, use_wid);
if (rvec.base >= 4) if (rvec.base >= 4)
roff += use_wid; roff += use_wid;
} }
}
/* FIXME: The above assumes that the expression is a constant static int show_stmt_cassign(ivl_statement_t net)
value to be assigned to the target. If it is not, then we {
will need to generate a thread or netlist to deal with the ivl_expr_t rval;
expression and repetitively assign to the target. */ struct vector_info rvec;
rval = ivl_stmt_rval(net);
assert(rval);
rvec = draw_eval_expr(rval, STUFF_OK_47);
/* Write out initial continuous assign instructions to assign
the expression value to the l-value. */
force_vector_to_lval(net, rvec);
/* FIXME: The above, left as is, assumes that the expression
is a constant value to be assigned to the target. If it is
not, then we will need to generate a thread or netlist to
deal with the expression and repetitively assign to the
target. */
return 0; return 0;
} }
@ -998,37 +1022,24 @@ static int show_stmt_disable(ivl_statement_t net, ivl_scope_t sscope)
static int show_stmt_force(ivl_statement_t net) static int show_stmt_force(ivl_statement_t net)
{ {
ivl_lval_t lval; ivl_expr_t rval;
ivl_signal_t lsig; struct vector_info rvec;
unsigned idx;
static unsigned force_functor_label = 0;
char*tmp_label;
assert(ivl_stmt_lvals(net) == 1); rval = ivl_stmt_rval(net);
lval = ivl_stmt_lval(net, 0); assert(rval);
lsig = ivl_lval_sig(lval); rvec = draw_eval_expr(rval, STUFF_OK_47);
assert(lsig != 0);
assert(ivl_lval_mux(lval) == 0); /* Write out initial continuous assign instructions to assign
assert(ivl_lval_part_off(lval) == 0); the expression value to the l-value. */
#if 0 force_vector_to_lval(net, rvec);
force_functor_label += 1;
tmp_label = strdup(vvp_signal_label(lsig)); /* FIXME: The above, left as is, assumes that the expression
for (idx = 0 ; idx < ivl_lval_pins(lval) ; idx += 1) { is a constant value to be assigned to the target. If it is
fprintf(vvp_out, "f_%u.%u .force V_%s[%u], %s;\n", not, then we will need to generate a thread or netlist to
force_functor_label, idx, deal with the expression and repetitively assign to the
tmp_label, idx, target. */
draw_net_input(ivl_stmt_nexus(net, idx)));
}
free(tmp_label);
for (idx = 0 ; idx < ivl_lval_pins(lval) ; idx += 1) {
fprintf(vvp_out, " %%force f_%u.%u, 1;\n",
force_functor_label, idx);
}
#else
fprintf(stderr, "XXXX I forgot how to implement %%force\n");
#endif
return 0; return 0;
} }
@ -1114,39 +1125,32 @@ static int show_stmt_noop(ivl_statement_t net)
static int show_stmt_release(ivl_statement_t net) static int show_stmt_release(ivl_statement_t net)
{ {
ivl_lval_t lval; unsigned lidx;
ivl_signal_t lsig;
unsigned idx;
/* If there are no l-vals (the target signal has been elided) for (lidx = 0 ; lidx < ivl_stmt_lvals(net) ; lidx += 1) {
then turn the release into a no-op. In other words, we are ivl_lval_t lval = ivl_stmt_lval(net, lidx);
done before we start. */ ivl_signal_t lsig = ivl_lval_sig(lval);
if (ivl_stmt_lvals(net) == 0) const char*opcode = 0;
return 0;
#if 0
assert(ivl_stmt_lvals(net) == 1);
lval = ivl_stmt_lval(net, 0);
lsig = ivl_lval_sig(lval); assert(lsig != 0);
assert(lsig != 0); assert(ivl_lval_mux(lval) == 0);
assert(ivl_lval_mux(lval) == 0); assert(ivl_lval_part_off(lval) == 0);
assert(ivl_lval_part_off(lval) == 0);
/* On release, reg variables hold the value that was forced on switch (ivl_signal_type(lsig)) {
to them. */ case IVL_SIT_REG:
for (idx = 0 ; idx < ivl_lval_pins(lval) ; idx += 1) { opcode = "reg";
if (ivl_signal_type(lsig) == IVL_SIT_REG) { break;
fprintf(vvp_out, " %%load 4, V_%s[%u];\n", default:
vvp_signal_label(lsig), idx); opcode = "net";
fprintf(vvp_out, " %%set V_%s[%u], 4;\n", break;
vvp_signal_label(lsig), idx);
} }
fprintf(vvp_out, " %%release V_%s[%u];\n",
vvp_signal_label(lsig), idx); /* Generate the appropriate release statement for this
l-value. */
fprintf(vvp_out, " %%release/%s V_%s;\n",
opcode, vvp_signal_label(lsig));
} }
#else
fprintf(stderr, "XXXX I forgot how to implement %%release\n");
#endif
return 0; return 0;
} }
@ -1529,6 +1533,9 @@ int draw_func_definition(ivl_scope_t scope)
/* /*
* $Log: vvp_process.c,v $ * $Log: vvp_process.c,v $
* Revision 1.96 2004/12/17 04:46:40 steve
* Implement release functionality.
*
* Revision 1.95 2004/12/11 05:43:30 steve * Revision 1.95 2004/12/11 05:43:30 steve
* cassign and deassign handle concatenated l-values. * cassign and deassign handle concatenated l-values.
* *