From 41f7ecacfc4e41d3d32d204b8038d4e102394ee1 Mon Sep 17 00:00:00 2001 From: steve Date: Sat, 3 Aug 2002 22:30:48 +0000 Subject: [PATCH] Eliminate use of ivl_signal_name for signal labels. --- tgt-vvp/eval_expr.c | 17 ++++++++++------- tgt-vvp/vvp_priv.h | 11 ++++++++++- tgt-vvp/vvp_process.c | 36 ++++++++++++++++++++---------------- tgt-vvp/vvp_scope.c | 29 ++++++++++++++++++++++------- 4 files changed, 62 insertions(+), 31 deletions(-) diff --git a/tgt-vvp/eval_expr.c b/tgt-vvp/eval_expr.c index 816068cf6..bc7e87745 100644 --- a/tgt-vvp/eval_expr.c +++ b/tgt-vvp/eval_expr.c @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) -#ident "$Id: eval_expr.c,v 1.65 2002/07/12 18:10:45 steve Exp $" +#ident "$Id: eval_expr.c,v 1.66 2002/08/03 22:30:48 steve Exp $" #endif # include "vvp_priv.h" @@ -881,7 +881,7 @@ static struct vector_info draw_bitsel_expr(ivl_expr_t exp, unsigned wid) res.wid = wid; fprintf(vvp_out, " %%load/x %u, V_%s, 0;\n", res.base, - vvp_mangle_id(ivl_signal_name(sig))); + vvp_signal_label(sig)); return res; } @@ -1092,7 +1092,7 @@ static struct vector_info draw_signal_expr(ivl_expr_t exp, unsigned wid) unsigned idx; unsigned lsi = ivl_expr_lsi(exp); unsigned swid = ivl_expr_width(exp); - const char*name = ivl_expr_name(exp); + ivl_signal_t sig = ivl_expr_signal(exp); struct vector_info res; if (swid > wid) @@ -1103,7 +1103,7 @@ static struct vector_info draw_signal_expr(ivl_expr_t exp, unsigned wid) for (idx = 0 ; idx < swid ; idx += 1) fprintf(vvp_out, " %%load %u, V_%s[%u];\n", - res.base+idx, vvp_mangle_id(name), idx+lsi); + res.base+idx, vvp_signal_label(sig), idx+lsi); /* Pad the signal value with zeros. */ if (swid < wid) @@ -1359,7 +1359,7 @@ static struct vector_info draw_sfunc_expr(ivl_expr_t exp, unsigned wid) case IVL_EX_SIGNAL: fprintf(vvp_out, ", V_%s", - vvp_mangle_id(ivl_expr_name(expr))); + vvp_signal_label(ivl_expr_signal(expr))); continue; case IVL_EX_STRING: @@ -1446,7 +1446,7 @@ static struct vector_info draw_ufunc_expr(ivl_expr_t exp, unsigned wid) assert(res.wid <= ivl_signal_pins(port)); for (pin = 0 ; pin < res.wid ; pin += 1) { fprintf(vvp_out, " %%set V_%s[%u], %u;\n", - vvp_mangle_id(ivl_signal_name(port)), + vvp_signal_label(port), pin, bit); if (bit >= 4) bit += 1; @@ -1475,7 +1475,7 @@ static struct vector_info draw_ufunc_expr(ivl_expr_t exp, unsigned wid) for (idx = 0 ; idx < load_wid ; idx += 1) fprintf(vvp_out, " %%load %u, V_%s[%u];\n", res.base+idx, - vvp_mangle_id(ivl_signal_name(retval)), idx); + vvp_signal_label(retval), idx); if (load_wid < swid) fprintf(vvp_out, " %%mov %u, 0, %u;\n", @@ -1726,6 +1726,9 @@ struct vector_info draw_eval_expr(ivl_expr_t exp) /* * $Log: eval_expr.c,v $ + * Revision 1.66 2002/08/03 22:30:48 steve + * Eliminate use of ivl_signal_name for signal labels. + * * Revision 1.65 2002/07/12 18:10:45 steve * Use all bits of ?: condit expression. * diff --git a/tgt-vvp/vvp_priv.h b/tgt-vvp/vvp_priv.h index 7eb5b6b32..7f3db6e05 100644 --- a/tgt-vvp/vvp_priv.h +++ b/tgt-vvp/vvp_priv.h @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) -#ident "$Id: vvp_priv.h,v 1.15 2002/07/08 04:04:07 steve Exp $" +#ident "$Id: vvp_priv.h,v 1.16 2002/08/03 22:30:48 steve Exp $" #endif # include "ivl_target.h" @@ -37,6 +37,12 @@ extern FILE* vvp_out; extern const char *vvp_mangle_id(const char *); extern const char *vvp_mangle_name(const char *); +/* + * This generates a string from a signal that uniquely identifies + * that signal with letters that can be used in a label. + */ +extern const char* vvp_signal_label(ivl_signal_t sig); + /* * This function draws a process (initial or always) into the output * file. It normally returns 0, but returns !0 of there is some sort @@ -97,6 +103,9 @@ extern unsigned thread_count; /* * $Log: vvp_priv.h,v $ + * Revision 1.16 2002/08/03 22:30:48 steve + * Eliminate use of ivl_signal_name for signal labels. + * * Revision 1.15 2002/07/08 04:04:07 steve * Generate code for wide muxes. * diff --git a/tgt-vvp/vvp_process.c b/tgt-vvp/vvp_process.c index ccb2dcf62..5a15c0058 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.59 2002/06/02 18:57:17 steve Exp $" +#ident "$Id: vvp_process.c,v 1.60 2002/08/03 22:30:48 steve Exp $" #endif # include "vvp_priv.h" @@ -78,10 +78,10 @@ static void set_to_lvariable(ivl_lval_t lval, unsigned idx, unsigned bit) if (ivl_lval_mux(lval)) fprintf(vvp_out, " %%set/x V_%s, %u, 0;\n", - vvp_mangle_id(ivl_signal_name(sig)), bit); + vvp_signal_label(sig), bit); else fprintf(vvp_out, " %%set V_%s[%u], %u;\n", - vvp_mangle_id(ivl_signal_name(sig)), idx+part_off, bit); + vvp_signal_label(sig), idx+part_off, bit); } static void set_to_memory(ivl_memory_t mem, unsigned idx, unsigned bit) @@ -109,12 +109,10 @@ static void assign_to_lvariable(ivl_lval_t lval, unsigned idx, if (ivl_lval_mux(lval)) fprintf(vvp_out, " %%assign/x0%s V_%s, %u, %u;\n", - delay_suffix, - vvp_mangle_id(ivl_signal_name(sig)), delay, bit); + delay_suffix, vvp_signal_label(sig), delay, bit); else fprintf(vvp_out, " %%assign%s V_%s[%u], %u, %u;\n", - delay_suffix, - vvp_mangle_id(ivl_signal_name(sig)), + delay_suffix, vvp_signal_label(sig), idx+part_off, delay, bit); } @@ -536,6 +534,7 @@ static int show_stmt_cassign(ivl_statement_t net) ivl_lval_t lval; ivl_signal_t lsig; unsigned idx; + char*tmp_label; assert(ivl_stmt_lvals(net) == 1); lval = ivl_stmt_lval(net, 0); @@ -546,11 +545,13 @@ static int show_stmt_cassign(ivl_statement_t net) assert(ivl_signal_pins(lsig) == ivl_stmt_nexus_count(net)); assert(ivl_lval_part_off(lval) == 0); + tmp_label = strdup(vvp_signal_label(lsig)); for (idx = 0 ; idx < ivl_stmt_nexus_count(net) ; idx += 1) { fprintf(vvp_out, " %%cassign V_%s[%u], %s;\n", - vvp_mangle_id(ivl_signal_name(lsig)), idx, + tmp_label, idx, draw_net_input(ivl_stmt_nexus(net, idx))); } + free(tmp_label); return 0; } @@ -571,7 +572,7 @@ static int show_stmt_deassign(ivl_statement_t net) for (idx = 0 ; idx < ivl_lval_pins(lval) ; idx += 1) { fprintf(vvp_out, " %%deassign V_%s[%u], 1;\n", - vvp_mangle_id(ivl_signal_name(lsig)), idx); + vvp_signal_label(lsig), idx); } return 0; } @@ -682,14 +683,14 @@ static int show_stmt_force(ivl_statement_t net) for (idx = 0 ; idx < ivl_lval_pins(lval) ; idx += 1) { fprintf(vvp_out, "f_%s.%u .force V_%s[%u], %s;\n", - vvp_mangle_id(ivl_signal_name(lsig)), idx, - vvp_mangle_id(ivl_signal_name(lsig)), idx, + vvp_signal_label(lsig), idx, + vvp_signal_label(lsig), idx, draw_net_input(ivl_stmt_nexus(net, idx))); } for (idx = 0 ; idx < ivl_lval_pins(lval) ; idx += 1) { fprintf(vvp_out, " %%force f_%s.%u, 1;\n", - vvp_mangle_id(ivl_signal_name(lsig)), idx); + vvp_signal_label(lsig), idx); } return 0; } @@ -772,11 +773,11 @@ static int show_stmt_release(ivl_statement_t net) for (idx = 0 ; idx < ivl_lval_pins(lval) ; idx += 1) { fprintf(vvp_out, " %%load 4, V_%s[%u];\n", - vvp_mangle_id(ivl_signal_name(lsig)), idx); + vvp_signal_label(lsig), idx); fprintf(vvp_out, " %%set V_%s[%u], 4;\n", - vvp_mangle_id(ivl_signal_name(lsig)), idx); + vvp_signal_label(lsig), idx); fprintf(vvp_out, " %%release V_%s[%u];\n", - vvp_mangle_id(ivl_signal_name(lsig)), idx); + vvp_signal_label(lsig), idx); } return 0; } @@ -974,7 +975,7 @@ static int show_system_task_call(ivl_statement_t net) break; } else { fprintf(vvp_out, ", V_%s", - vvp_mangle_id(ivl_expr_name(expr))); + vvp_signal_label(ivl_expr_signal(expr))); continue; } @@ -1220,6 +1221,9 @@ int draw_func_definition(ivl_scope_t scope) /* * $Log: vvp_process.c,v $ + * Revision 1.60 2002/08/03 22:30:48 steve + * Eliminate use of ivl_signal_name for signal labels. + * * Revision 1.59 2002/06/02 18:57:17 steve * Generate %cmpi/u where appropriate. * diff --git a/tgt-vvp/vvp_scope.c b/tgt-vvp/vvp_scope.c index ea4283006..9a3a0be56 100644 --- a/tgt-vvp/vvp_scope.c +++ b/tgt-vvp/vvp_scope.c @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) -#ident "$Id: vvp_scope.c,v 1.74 2002/07/18 02:06:37 steve Exp $" +#ident "$Id: vvp_scope.c,v 1.75 2002/08/03 22:30:48 steve Exp $" #endif # include "vvp_priv.h" @@ -126,6 +126,19 @@ const char *vvp_mangle_name(const char *id) return out; } +/* + * Given a signal, generate a string name that is suitable for use as + * a label. The only rule is that the same signal will always have the + * same label. The result is stored in static memory, so remember to + * copy it out. + */ +const char* vvp_signal_label(ivl_signal_t sig) +{ + static char buf[32]; + sprintf(buf, "$%p", sig); + return buf; +} + ivl_signal_type_t signal_type_of_nexus(ivl_nexus_t nex) { unsigned idx; @@ -274,8 +287,7 @@ static const char* draw_net_input_drive(ivl_nexus_t nex, ivl_nexus_ptr_t nptr) sptr = ivl_nexus_ptr_sig(nptr); if (sptr && (ivl_signal_type(sptr) == IVL_SIT_REG)) { - sprintf(result, "V_%s[%u]", vvp_mangle_id(ivl_signal_name(sptr)), - nptr_pin); + sprintf(result, "V_%s[%u]", vvp_signal_label(sptr), nptr_pin); return result; } @@ -534,7 +546,7 @@ static void draw_reg_in_scope(ivl_signal_t sig) ivl_signal_signed(sig)? "/s" : ""; fprintf(vvp_out, "V_%s .var%s \"%s\", %d, %d;\n", - vvp_mangle_id(ivl_signal_name(sig)), signed_flag, + vvp_signal_label(sig), signed_flag, vvp_mangle_name(ivl_signal_basename(sig)), msb, lsb); } @@ -566,7 +578,7 @@ static void draw_net_in_scope(ivl_signal_t sig) } fprintf(vvp_out, "V_%s .net%s \"%s\", %d, %d", - vvp_mangle_id(ivl_signal_name(sig)), signed_flag, + vvp_signal_label(sig), signed_flag, vvp_mangle_name(ivl_signal_basename(sig)), msb, lsb); for (idx = 0 ; idx < ivl_signal_pins(sig) ; idx += 1) { fprintf(vvp_out, ", %s", args[idx]); @@ -1308,7 +1320,7 @@ static void draw_lpm_ufunc(ivl_lpm_t net) for (bit = 0 ; bit < ivl_signal_pins(psig) ; bit += 1) { fprintf(vvp_out, "%c V_%s[%u]", comma, - vvp_mangle_id(ivl_signal_name(psig)), bit); + vvp_signal_label(psig), bit); comma = ','; } } @@ -1321,7 +1333,7 @@ static void draw_lpm_ufunc(ivl_lpm_t net) comma = ' '; for (idx = 0 ; idx < ivl_lpm_width(net) ; idx += 1) { fprintf(vvp_out, "%c V_%s[%u]", comma, - vvp_mangle_id(ivl_signal_name(psig)), + vvp_signal_label(psig), idx); comma = ','; } @@ -1466,6 +1478,9 @@ int draw_scope(ivl_scope_t net, ivl_scope_t parent) /* * $Log: vvp_scope.c,v $ + * Revision 1.75 2002/08/03 22:30:48 steve + * Eliminate use of ivl_signal_name for signal labels. + * * Revision 1.74 2002/07/18 02:06:37 steve * Need driver for sure in assign feedback and other cases. *