Write resolvers before the .functor (PR#300)

This commit is contained in:
steve 2001-10-24 03:43:45 +00:00
parent b2f6953259
commit 5a6cca33a0
1 changed files with 27 additions and 10 deletions

View File

@ -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
*/ */
#if !defined(WINNT) #if !defined(WINNT)
#ident "$Id: vvp_scope.c,v 1.54 2001/10/22 02:04:37 steve Exp $" #ident "$Id: vvp_scope.c,v 1.55 2001/10/24 03:43:45 steve Exp $"
#endif #endif
# include "vvp_priv.h" # include "vvp_priv.h"
@ -266,9 +266,8 @@ static const char* draw_net_input_drive(ivl_nexus_t nex, ivl_nexus_ptr_t nptr)
* it writes out the resolver declarations needed to perform strength * it writes out the resolver declarations needed to perform strength
* resolution. * resolution.
* *
* The string that this returns must be copied out before this * The string that this returns is bound to the nexus, so the pointer
* function is called again. Otherwise, the string memory will be * remains valid.
* overwritten.
*/ */
static const char* draw_net_input(ivl_nexus_t nex) static const char* draw_net_input(ivl_nexus_t nex)
{ {
@ -404,11 +403,12 @@ static void draw_net_in_scope(ivl_signal_t sig)
unsigned idx; unsigned idx;
int msb = ivl_signal_pins(sig) - 1; int msb = ivl_signal_pins(sig) - 1;
int lsb = 0; int lsb = 0;
char**args; typedef const char*const_charp;
const_charp* args;
const char*signed_flag = ivl_signal_signed(sig)? "/s" : ""; const char*signed_flag = ivl_signal_signed(sig)? "/s" : "";
args = (char**)calloc(ivl_signal_pins(sig), sizeof(char*)); args = (const_charp*)calloc(ivl_signal_pins(sig), sizeof(char*));
/* Connect all the pins of the signal to something. */ /* Connect all the pins of the signal to something. */
for (idx = 0 ; idx < ivl_signal_pins(sig) ; idx += 1) { for (idx = 0 ; idx < ivl_signal_pins(sig) ; idx += 1) {
@ -510,8 +510,13 @@ static void draw_logic_in_scope(ivl_net_logic_t lptr)
const char*lcasc = 0x0; const char*lcasc = 0x0;
char identity_val = '0'; char identity_val = '0';
int level; int level;
int ninp; int ninp = ivl_logic_pins(lptr) - 1;
typedef const char*const_charp;
const_charp*input_strings = calloc(ninp, sizeof(const_charp));
for (pdx = 0 ; pdx < ninp ; pdx += 1)
input_strings[pdx] = draw_net_input(ivl_logic_pin(lptr, pdx+1));
switch (ivl_logic_type(lptr)) { switch (ivl_logic_type(lptr)) {
case IVL_LO_UDP: case IVL_LO_UDP:
@ -615,6 +620,13 @@ static void draw_logic_in_scope(ivl_net_logic_t lptr)
if (!lcasc) if (!lcasc)
lcasc = ltype; lcasc = ltype;
/* Get all the input label that I will use for parameters to
the functor that I create later. */
ninp = ivl_logic_pins(lptr) - 1;
input_strings = calloc(ninp, sizeof(char*));
for (pdx = 0 ; pdx < ninp ; pdx += 1)
input_strings[pdx] = draw_net_input(ivl_logic_pin(lptr, pdx+1));
level = 0; level = 0;
ninp = ivl_logic_pins(lptr) - 1; ninp = ivl_logic_pins(lptr) - 1;
while (ninp) { while (ninp) {
@ -636,9 +648,7 @@ static void draw_logic_in_scope(ivl_net_logic_t lptr)
level - 1, level - 1,
pdx*4 ); pdx*4 );
} else { } else {
ivl_nexus_t nex = ivl_logic_pin(lptr, pdx+1); fprintf(vvp_out, ", %s", input_strings[pdx]);
fprintf(vvp_out, ", ");
draw_input_from_net(nex);
} }
} }
for ( ; pdx < inst+4 ; pdx += 1) { for ( ; pdx < inst+4 ; pdx += 1) {
@ -653,6 +663,10 @@ static void draw_logic_in_scope(ivl_net_logic_t lptr)
ninp = 0; ninp = 0;
level += 1; level += 1;
} }
/* Free the array of char*. The strings themselves are
persistent, held by the ivl_nexus_t objects. */
free(input_strings);
} }
static void draw_event_in_scope(ivl_event_t obj) static void draw_event_in_scope(ivl_event_t obj)
@ -1204,6 +1218,9 @@ int draw_scope(ivl_scope_t net, ivl_scope_t parent)
/* /*
* $Log: vvp_scope.c,v $ * $Log: vvp_scope.c,v $
* Revision 1.55 2001/10/24 03:43:45 steve
* Write resolvers before the .functor (PR#300)
*
* Revision 1.54 2001/10/22 02:04:37 steve * Revision 1.54 2001/10/22 02:04:37 steve
* unused idx warning. * unused idx warning.
* *