From 4cc421b3b79db938505359ae1f3867e813944e6c Mon Sep 17 00:00:00 2001 From: steve Date: Fri, 17 Jun 2005 03:46:52 +0000 Subject: [PATCH] Make functors know their own width. --- tgt-vvp/draw_mux.c | 119 +++----------------------------------------- tgt-vvp/vvp_scope.c | 13 +++-- vvp/README.txt | 4 +- vvp/compile.h | 7 ++- vvp/concat.cc | 13 ++++- vvp/logic.cc | 16 ++++-- vvp/logic.h | 7 ++- vvp/parse.y | 18 ++++--- 8 files changed, 61 insertions(+), 136 deletions(-) diff --git a/tgt-vvp/draw_mux.c b/tgt-vvp/draw_mux.c index 7983ac956..3d0ed7a2b 100644 --- a/tgt-vvp/draw_mux.c +++ b/tgt-vvp/draw_mux.c @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: draw_mux.c,v 1.9 2005/04/06 05:29:09 steve Exp $" +#ident "$Id: draw_mux.c,v 1.10 2005/06/17 03:46:52 steve Exp $" #endif # include "vvp_priv.h" @@ -28,116 +28,6 @@ # include # include -#if 0 -/* - * This draws a general mux, a slice at a time. Use MUXX so that - * unknows lead to unknown output. - */ -static void draw_lpm_mux_bitslice(ivl_lpm_t net, unsigned slice) -{ - unsigned sel = ivl_lpm_selects(net); - unsigned size = ivl_lpm_size(net); - unsigned sel_from_size; - unsigned seldx, idx; - ivl_nexus_t s; - - sel_from_size = 0; - seldx = size - 1; - while (seldx > 0) { - seldx >>= 1; - sel_from_size += 1; - } - if (sel_from_size > sel) { - fprintf(stderr, "internal error: MUX size=%u, selects=%u\n", - size, sel); - } - assert(sel_from_size <= sel); - - s = ivl_lpm_select(net, 0); - - /* Draw the leaf mux devices that take inputs from the - net. These also use up the least significant bit of the - select vector. */ - for (idx = 0 ; idx < size ; idx += 2) { - - fprintf(vvp_out, "L_%s.%s/%u/%u/%u .functor MUXX, ", - vvp_mangle_id(ivl_scope_name(ivl_lpm_scope(net))), - vvp_mangle_id(ivl_lpm_basename(net)), slice, sel, idx); - - { - ivl_nexus_t a = ivl_lpm_data2(net, idx+0, slice); - draw_input_from_net(a); - fprintf(vvp_out, ", "); - } - - if ((idx+1) < size) { - ivl_nexus_t b = ivl_lpm_data2(net, idx+1, slice); - draw_input_from_net(b); - fprintf(vvp_out, ", "); - } else { - fprintf(vvp_out, "C, "); - } - - draw_input_from_net(s); - fprintf(vvp_out, ", C<1>;\n"); - } - - /* Draw the tree of MUXX devices to connect the inner tree - nodes. */ - for (seldx = 1 ; seldx < (sel-1) ; seldx += 1) { - unsigned level = sel - seldx; - unsigned span = 2 << seldx; - s = ivl_lpm_select(net, seldx); - - for (idx = 0 ; idx < size ; idx += span) { - fprintf(vvp_out, "L_%s.%s/%u/%u/%u .functor MUXX, ", - vvp_mangle_id(ivl_scope_name(ivl_lpm_scope(net))), - vvp_mangle_id(ivl_lpm_basename(net)), - slice, level, idx); - - fprintf(vvp_out, "L_%s.%s/%u/%u/%u, ", - vvp_mangle_id(ivl_scope_name(ivl_lpm_scope(net))), - vvp_mangle_id(ivl_lpm_basename(net)), - slice, level+1, idx); - - if ((idx + span/2) < size) { - fprintf(vvp_out, "L_%s.%s/%u/%u/%u, ", - vvp_mangle_id(ivl_scope_name(ivl_lpm_scope(net))), - vvp_mangle_id(ivl_lpm_basename(net)), - slice, level+1, idx+span/2); - } else { - fprintf(vvp_out, "C, "); - } - - draw_input_from_net(s); - fprintf(vvp_out, ", C<1>;\n"); - } - } - - s = ivl_lpm_select(net, sel-1); - - fprintf(vvp_out, "L_%s.%s/%u .functor MUXX, ", - vvp_mangle_id(ivl_scope_name(ivl_lpm_scope(net))), - vvp_mangle_id(ivl_lpm_basename(net)), slice); - - fprintf(vvp_out, "L_%s.%s/%u/2/0, ", - vvp_mangle_id(ivl_scope_name(ivl_lpm_scope(net))), - vvp_mangle_id(ivl_lpm_basename(net)), slice); - - - if ((2U << (sel-1))/2 < size) { - fprintf(vvp_out, "L_%s.%s/%u/2/%u, ", - vvp_mangle_id(ivl_scope_name(ivl_lpm_scope(net))), - vvp_mangle_id(ivl_lpm_basename(net)), - slice, (2U << (sel-1))/2); - } else { - fprintf(vvp_out, "C, "); - } - - draw_input_from_net(s); - fprintf(vvp_out, ", C<1>;\n"); -} -#endif /* * This draws a simple A/B mux. The mux can have any width, enough @@ -145,11 +35,13 @@ static void draw_lpm_mux_bitslice(ivl_lpm_t net, unsigned slice) */ static void draw_lpm_mux_ab(ivl_lpm_t net) { + unsigned width = ivl_lpm_width(net); + /* Only support A-B muxes in this function. */ assert(ivl_lpm_size(net) == 2); assert(ivl_lpm_selects(net) == 1); - fprintf(vvp_out, "L_%p .functor MUXZ", net); + fprintf(vvp_out, "L_%p .functor MUXZ %u", net, width); fprintf(vvp_out, ", %s", draw_net_input(ivl_lpm_data(net,0))); fprintf(vvp_out, ", %s", draw_net_input(ivl_lpm_data(net,1))); fprintf(vvp_out, ", %s", draw_net_input(ivl_lpm_select(net))); @@ -174,6 +66,9 @@ void draw_lpm_mux(ivl_lpm_t net) /* * $Log: draw_mux.c,v $ + * Revision 1.10 2005/06/17 03:46:52 steve + * Make functors know their own width. + * * Revision 1.9 2005/04/06 05:29:09 steve * Rework NetRamDq and IVL_LPM_RAM nodes. * diff --git a/tgt-vvp/vvp_scope.c b/tgt-vvp/vvp_scope.c index 121c67369..b41d31d77 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 */ #ifdef HAVE_CVS_IDENT -#ident "$Id: vvp_scope.c,v 1.128 2005/05/24 01:44:28 steve Exp $" +#ident "$Id: vvp_scope.c,v 1.129 2005/06/17 03:46:52 steve Exp $" #endif # include "vvp_priv.h" @@ -1068,11 +1068,11 @@ static void draw_logic_in_scope(ivl_net_logic_t lptr) int inst; for (inst = 0; inst < ninp; inst += 4) { if (ninp > 4) - fprintf(vvp_out, "L_%p/%d/%d .functor %s", - lptr, level, inst, lcasc); + fprintf(vvp_out, "L_%p/%d/%d .functor %s %u", + lptr, level, inst, lcasc, vector_width); else { - fprintf(vvp_out, "L_%p .functor %s", - lptr, ltype); + fprintf(vvp_out, "L_%p .functor %s %u", + lptr, ltype, vector_width); draw_delay(lptr); @@ -1955,6 +1955,9 @@ int draw_scope(ivl_scope_t net, ivl_scope_t parent) /* * $Log: vvp_scope.c,v $ + * Revision 1.129 2005/06/17 03:46:52 steve + * Make functors know their own width. + * * Revision 1.128 2005/05/24 01:44:28 steve * Do sign extension of structuran nets. * diff --git a/vvp/README.txt b/vvp/README.txt index 2becd6c4d..5653c634a 100644 --- a/vvp/README.txt +++ b/vvp/README.txt @@ -1,7 +1,7 @@ /* * Copyright (c) 2001 Stephen Williams (steve@icarus.com) * - * $Id: README.txt,v 1.67 2005/05/24 01:43:27 steve Exp $ + * $Id: README.txt,v 1.68 2005/06/17 03:46:52 steve Exp $ */ VVP SIMULATION ENGINE @@ -128,7 +128,7 @@ label is required for functors. The general syntax of a functor is: -