param.h File Reference

Contains functions and structures necessary to handle parameters. More...

#include <stdio.h>
#include "defines.h"

Go to the source code of this file.

Functions

mod_parmmod_parm_find (const char *name, mod_parm *parm)
 Searches specified module parameter list for matching parameter.
mod_parmmod_parm_add (char *scope, static_expr *msb, static_expr *lsb, bool is_signed, expression *expr, int type, func_unit *funit, char *inst_name)
 Creates new module parameter and adds it to the specified list.
void mod_parm_display (mod_parm *mparm)
 Outputs contents of module parameter list to standard output.
void inst_parm_add_genvar (vsignal *sig, funit_inst *inst)
 Creates a new instance parameter for a generate variable.
void inst_parm_bind (inst_parm *iparm)
 Performs bind of signal and expressions for the given instance parameter.
void defparam_add (const char *scope, vector *expr)
 Adds parameter override to defparam list.
void defparam_dealloc ()
 Deallocates all memory associated with defparam storage from command-line.
void param_set_sig_size (vsignal *sig, inst_parm *icurr)
 Sets the specified signal size according to the specified instance parameter.
void param_expr_eval (expression *expr, funit_inst *inst)
 Evaluates parameter expression for the given instance.
void param_resolve_inst (funit_inst *inst)
 Resolves all parameters for the specified instance.
void param_resolve (funit_inst *inst)
 Resolves all parameters for the specified instance tree.
void param_db_write (inst_parm *iparm, FILE *file)
 Outputs specified instance parameter to specified output stream.
void mod_parm_dealloc (mod_parm *parm, bool recursive)
 Deallocates specified module parameter and possibly entire module parameter list.
void inst_parm_dealloc (inst_parm *parm, bool recursive)
 Deallocates specified instance parameter and possibly entire instance parameter list.

Detailed Description

Contains functions and structures necessary to handle parameters.

Author:
Trevor Williams (phase1geo@gmail.com)
Date:
8/22/2002

Function Documentation

void defparam_add ( const char *  scope,
vector value 
)

Adds parameter override to defparam list.

Exceptions:
anonymous inst_parm_add Throw

Scans list of all parameters to make sure that specified parameter isn't already being set to a new value. If no match occurs, adds the new defparam to the defparam list. This function is called for each -P option to the score command.

Parameters:
scope Full hierarchical reference to specified scope to change value to
value User-specified parameter override value

References Catch_anonymous, vsuppl_u::data_type, static_expr_s::exp, FALSE, FATAL, inst_parm_add(), inst_parm_find(), malloc_safe, static_expr_s::num, obf_sig, funit_inst_s::param_head, funit_inst_s::param_tail, vsuppl_u::part, print_output(), PROFILE, PROFILE_END, vector_s::suppl, Throw, Try, user_msg, USER_MSG_LENGTH, VDATA_R32, VDATA_R64, VDATA_UL, and vector_dealloc().

Referenced by score_parse_args().

00553   { PROFILE(DEFPARAM_ADD);
00554 
00555   static_expr msb;  /* MSB of this defparam (forced to be 31) */
00556   static_expr lsb;  /* LSB of this defparam (forced to be 0) */
00557 
00558   assert( scope != NULL );
00559 
00560   /* If the defparam instance doesn't exist, create it now */
00561   if( defparam_list == NULL ) {
00562     defparam_list = (funit_inst*)malloc_safe( sizeof( funit_inst ) );
00563     defparam_list->param_head = NULL;
00564     defparam_list->param_tail = NULL;
00565   }
00566 
00567   if( inst_parm_find( scope, defparam_list->param_head ) == NULL ) {
00568 
00569     /* Generate MSB and LSB information */
00570     switch( value->suppl.part.data_type ) {
00571       case VDATA_UL  :  msb.num = 31;  break;
00572       case VDATA_R64 :  msb.num = 63;  break;
00573       case VDATA_R32 :  msb.num = 31;  break;
00574       default        :  assert( 0 );   break;
00575     }
00576     msb.exp = NULL;
00577     lsb.num = 0;
00578     lsb.exp = NULL;
00579 
00580     Try {
00581       (void)inst_parm_add( scope, NULL, &msb, &lsb, FALSE, value, NULL, defparam_list );
00582     } Catch_anonymous {
00583       vector_dealloc( value );
00584       Throw 0;
00585     }
00586 
00587     vector_dealloc( value );
00588 
00589   } else {
00590 
00591     unsigned int rv = snprintf( user_msg, USER_MSG_LENGTH, "Parameter (%s) value is assigned more than once", obf_sig( scope ) );
00592     assert( rv < USER_MSG_LENGTH );
00593     print_output( user_msg, FATAL, __FILE__, __LINE__ );
00594     Throw 0;
00595 
00596   }
00597 
00598   PROFILE_END;
00599 
00600 }

void defparam_dealloc (  ) 

Deallocates all memory associated with defparam storage from command-line.

Deallocates all memory used for storing defparam information.

References free_safe, inst_parm_dealloc(), funit_inst_s::param_head, PROFILE, PROFILE_END, and TRUE.

Referenced by command_score().

00605                         { PROFILE(DEFPARAM_DEALLOC);
00606 
00607   if( defparam_list != NULL ) {
00608 
00609     /* Deallocate the instance parameters in the defparam_list structure */
00610     inst_parm_dealloc( defparam_list->param_head, TRUE );
00611 
00612     /* Now free the defparam_list structure itself */
00613     free_safe( defparam_list, sizeof( funit_inst ) );
00614 
00615   }
00616 
00617   PROFILE_END;
00618 
00619 }

void inst_parm_add_genvar ( vsignal sig,
funit_inst inst 
)

Creates a new instance parameter for a generate variable.

Creates an instance parameter for a generate variable and adds it to the given instance parameter list.

Parameters:
sig Pointer to generate signal to copy
inst Pointer to instance to add this instance parameter to

References inst_parm_s::inst_name, malloc_safe, inst_parm_s::mparm, inst_parm_s::next, funit_inst_s::param_head, funit_inst_s::param_tail, ssuppl_u::part, PROFILE, PROFILE_END, inst_parm_s::sig, SSUPPL_TYPE_PARAM, vsignal_s::suppl, ssuppl_u::type, and vsignal_duplicate().

Referenced by gen_item_resolve().

00489   { PROFILE(INST_PARM_ADD_GENVAR);
00490 
00491   inst_parm* iparm;  /* Pointer to the newly allocated instance parameter */
00492 
00493   assert( inst != NULL );
00494 
00495   /* Allocate the new instance parameter */
00496   iparm = (inst_parm*)malloc_safe( sizeof( inst_parm ) );
00497 
00498   /* Initialize the instance parameter */
00499   iparm->inst_name            = NULL;
00500   iparm->sig                  = vsignal_duplicate( sig ); 
00501   iparm->sig->suppl.part.type = SSUPPL_TYPE_PARAM;
00502   iparm->mparm                = NULL;
00503   iparm->next                 = NULL;
00504 
00505   /* Add the instance parameter to the parameter list */
00506   if( inst->param_head == NULL ) {
00507     inst->param_head = inst->param_tail = iparm;
00508   } else {
00509     inst->param_tail->next = iparm;
00510     inst->param_tail       = iparm;
00511   }
00512 
00513   PROFILE_END;
00514 
00515 }

void inst_parm_bind ( inst_parm iparm  ) 

Performs bind of signal and expressions for the given instance parameter.

Binds the instance parameter signal to its list of expressions. This is called by funit_size_elements.

Parameters:
iparm Pointer to instance parameter to bind

References exp_link_s::exp, mod_parm_s::exp_head, inst_parm_s::mparm, exp_link_s::next, PROFILE, PROFILE_END, inst_parm_s::sig, and expression_s::sig.

Referenced by funit_size_elements().

00523   { PROFILE(INST_PARM_BIND);
00524 
00525   exp_link* expl;  /* Pointer to current expression link in list */
00526 
00527   /* Bind the module parameter expression list to this signal */
00528   if( iparm->mparm != NULL ) {
00529     expl = iparm->mparm->exp_head;
00530     while( expl != NULL ) {
00531       expl->exp->sig = iparm->sig;
00532       expl = expl->next;
00533     }
00534   }
00535 
00536   PROFILE_END;
00537 
00538 }

void inst_parm_dealloc ( inst_parm iparm,
bool  recursive 
)

Deallocates specified instance parameter and possibly entire instance parameter list.

Deallocates allocated memory from heap for the specified instance parameter. If the value of recursive is set to TRUE, perform this deallocation for the entire list of instance parameters.

Parameters:
iparm Pointer to instance parameter to remove
recursive If TRUE, removes entire instance parameter list; otherwise, just remove me

References free_safe, inst_parm_s::inst_name, inst_parm_dealloc(), inst_parm_s::next, PROFILE, PROFILE_END, inst_parm_s::sig, and vsignal_dealloc().

Referenced by defparam_dealloc(), inst_parm_add(), inst_parm_dealloc(), and instance_dealloc_single().

01142   { PROFILE(INST_PARM_DEALLOC);
01143 
01144   if( iparm != NULL ) {
01145 
01146     /* If the user wants to deallocate the entire module parameter list, do so now */
01147     if( recursive ) {
01148       inst_parm_dealloc( iparm->next, recursive );
01149     }
01150 
01151     /* Deallocate parameter signal */
01152     vsignal_dealloc( iparm->sig );
01153 
01154     /* Deallocate instance name, if specified */
01155     if( iparm->inst_name != NULL ) {
01156       free_safe( iparm->inst_name, (strlen( iparm->inst_name ) + 1) );
01157     }
01158     
01159     /* Deallocate parameter itself */
01160     free_safe( iparm, sizeof( inst_parm ) );
01161 
01162   }
01163 
01164   PROFILE_END;
01165 
01166 }

mod_parm* mod_parm_add ( char *  scope,
static_expr msb,
static_expr lsb,
bool  is_signed,
expression expr,
int  type,
func_unit funit,
char *  inst_name 
)

Creates new module parameter and adds it to the specified list.

Returns:
Returns pointer to newly created module parameter.

Creates a new module parameter with the specified information and adds it to the module parameter list.

Parameters:
scope Full hierarchical name of parameter value
msb Static expression containing the MSB of this module parameter
lsb Static expression containing the LSB of this module parameter
is_signed Specifies if this parameter needs to be handled as a signed value
expr Expression tree for current module parameter
type Specifies type of module parameter (declared/override)
funit Functional unit to add this module parameter to
inst_name Name of instance (used for parameter overridding)

References psuppl_u::all, static_expr_s::exp, mod_parm_s::exp_head, mod_parm_s::exp_tail, mod_parm_s::expr, funit_get_curr_module(), mod_parm_s::inst_name, mod_parm_s::is_signed, mod_parm_s::lsb, malloc_safe, mod_parm_s::msb, mod_parm_s::name, mod_parm_s::next, static_expr_s::num, psuppl_u::order, esuppl_u::owned, psuppl_u::owns_expr, func_unit_s::param_head, func_unit_s::param_tail, PARAM_TYPE_DECLARED, PARAM_TYPE_DECLARED_LOCAL, PARAM_TYPE_INST_LSB, PARAM_TYPE_INST_MSB, PARAM_TYPE_OVERRIDE, PARAM_TYPE_SIG_LSB, PARAM_TYPE_SIG_MSB, esuppl_u::part, psuppl_u::part, PROFILE, PROFILE_END, mod_parm_s::sig, strdup_safe, expression_s::suppl, mod_parm_s::suppl, and psuppl_u::type.

Referenced by db_add_declared_param(), db_add_instance(), db_add_override_param(), and db_add_vector_param().

00161   { PROFILE(MOD_PARM_ADD);
00162 
00163   mod_parm*  parm;       /* Temporary pointer to instance parameter */
00164   mod_parm*  curr;       /* Pointer to current module parameter for ordering purposes */
00165   int        order = 0;  /* Current order of parameter */
00166   func_unit* mod_funit;  /* Pointer to module containing this functional unit (used for ordering purposes) */
00167   
00168   assert( (type == PARAM_TYPE_OVERRIDE) || (expr != NULL) );  /* An expression can be NULL if we are an override type */
00169   assert( (type == PARAM_TYPE_DECLARED)       || 
00170           (type == PARAM_TYPE_DECLARED_LOCAL) ||
00171           (type == PARAM_TYPE_OVERRIDE)       ||
00172           (type == PARAM_TYPE_SIG_LSB)        ||
00173           (type == PARAM_TYPE_SIG_MSB)        ||
00174           (type == PARAM_TYPE_INST_LSB)       ||
00175           (type == PARAM_TYPE_INST_MSB) );
00176 
00177   /* Find module containing this functional unit */
00178   mod_funit = funit_get_curr_module( funit );
00179 
00180   /* Determine parameter order */
00181   if( type == PARAM_TYPE_DECLARED ) {
00182     curr  = mod_funit->param_head;
00183     order = 0;
00184     while( curr != NULL ) {
00185       if( curr->suppl.part.type == PARAM_TYPE_DECLARED ) {
00186         order++;
00187       }
00188       curr = curr->next;
00189     }
00190   } else if( type == PARAM_TYPE_OVERRIDE ) {
00191     curr  = mod_funit->param_head;
00192     order = 0;
00193     while( curr != NULL ) {
00194       if( (curr->suppl.part.type == PARAM_TYPE_OVERRIDE) &&
00195           (strcmp( inst_name, curr->inst_name ) == 0) ) {
00196         order++;
00197       }
00198       curr = curr->next;
00199     }
00200   }
00201 
00202   /* Create new signal/expression binding */
00203   parm = (mod_parm*)malloc_safe( sizeof( mod_parm ) );
00204   if( scope != NULL ) {
00205     parm->name = strdup_safe( scope );
00206   } else {
00207     parm->name = NULL;
00208   }
00209   if( inst_name != NULL ) {
00210     parm->inst_name = strdup_safe( inst_name );
00211   } else {
00212     parm->inst_name = NULL;
00213   }
00214   if( msb != NULL ) {
00215     parm->msb      = (static_expr*)malloc_safe( sizeof( static_expr ) );
00216     parm->msb->num = msb->num;
00217     parm->msb->exp = msb->exp;
00218   } else {
00219     parm->msb = NULL;
00220   }
00221   if( lsb != NULL ) {
00222     parm->lsb      = (static_expr*)malloc_safe( sizeof( static_expr ) );
00223     parm->lsb->num = lsb->num;
00224     parm->lsb->exp = lsb->exp;
00225   } else {
00226     parm->lsb = NULL;
00227   }
00228   parm->is_signed             = is_signed;
00229   parm->expr                  = expr;
00230   parm->suppl.all             = 0;
00231   parm->suppl.part.type       = type;
00232   parm->suppl.part.order      = order;
00233   if( expr != NULL ) {
00234     if( expr->suppl.part.owned == 0 ) {
00235       parm->suppl.part.owns_expr = 1;
00236       expr->suppl.part.owned = 1;
00237     }
00238   }
00239   parm->exp_head              = NULL;
00240   parm->exp_tail              = NULL;
00241   parm->sig                   = NULL;
00242   parm->next                  = NULL;
00243 
00244   /* Now add the parameter to the current expression */
00245   if( funit->param_head == NULL ) {
00246     funit->param_head = funit->param_tail = parm;
00247   } else {
00248     funit->param_tail->next = parm;
00249     funit->param_tail       = parm;
00250   }
00251 
00252   PROFILE_END;
00253 
00254   return( parm );
00255 
00256 }

void mod_parm_dealloc ( mod_parm parm,
bool  recursive 
)

Deallocates specified module parameter and possibly entire module parameter list.

Deallocates allocated memory from heap for the specified module parameter. If the value of recursive is set to TRUE, perform this deallocation for the entire list of module parameters.

Parameters:
parm Pointer to module parameter to remove
recursive If TRUE, removes entire module parameter list; otherwise, just remove me

References mod_parm_s::exp_head, exp_link_delete_list(), mod_parm_s::expr, expression_dealloc(), FALSE, free_safe, mod_parm_s::inst_name, mod_parm_s::lsb, mod_parm_dealloc(), mod_parm_s::msb, mod_parm_s::name, mod_parm_s::next, psuppl_u::owns_expr, psuppl_u::part, PROFILE, PROFILE_END, static_expr_dealloc(), mod_parm_s::suppl, and TRUE.

Referenced by funit_clean(), and mod_parm_dealloc().

01098   { PROFILE(MOD_PARM_DEALLOC);
01099 
01100   if( parm != NULL ) {
01101 
01102     /* If the user wants to deallocate the entire module parameter list, do so now */
01103     if( recursive ) {
01104       mod_parm_dealloc( parm->next, recursive );
01105     }
01106 
01107     /* Deallocate MSB and LSB static expressions */
01108     static_expr_dealloc( parm->msb, TRUE );
01109     static_expr_dealloc( parm->lsb, TRUE );
01110 
01111     /* Remove the attached expression tree */
01112     if( parm->suppl.part.owns_expr == 1 ) {
01113       expression_dealloc( parm->expr, FALSE );
01114     }
01115 
01116     /* Remove the expression list that this parameter is used in */
01117     exp_link_delete_list( parm->exp_head, FALSE );
01118 
01119     /* Remove the parameter name */
01120     free_safe( parm->name, (strlen( parm->name ) + 1) );
01121 
01122     /* Remove instance name, if specified */
01123     free_safe( parm->inst_name, (strlen( parm->inst_name ) + 1) );
01124 
01125     /* Remove the parameter itself */
01126     free_safe( parm, sizeof( mod_parm ) );
01127 
01128   }
01129 
01130   PROFILE_END;
01131 
01132 }

void mod_parm_display ( mod_parm mparm  ) 

Outputs contents of module parameter list to standard output.

Outputs contents of specified module parameter to standard output. For debugging purposes only.

Parameters:
mparm Pointer to module parameter list to display

References mod_parm_s::exp_head, exp_link_display(), mod_parm_s::expr, expression_s::id, mod_parm_s::name, mod_parm_s::next, obf_sig, psuppl_u::order, psuppl_u::owns_expr, PARAM_TYPE_DECLARED, PARAM_TYPE_DECLARED_LOCAL, PARAM_TYPE_INST_LSB, PARAM_TYPE_INST_MSB, PARAM_TYPE_OVERRIDE, PARAM_TYPE_SIG_LSB, PARAM_TYPE_SIG_MSB, psuppl_u::part, mod_parm_s::sig, mod_parm_s::suppl, psuppl_u::type, and vsignal_display().

00264   {
00265 
00266   char type_str[30];  /* String version of module parameter type */
00267 
00268   while( mparm != NULL ) {
00269     switch( mparm->suppl.part.type ) {
00270       case PARAM_TYPE_DECLARED       :  strcpy( type_str, "DECLARED" );        break;
00271       case PARAM_TYPE_OVERRIDE       :  strcpy( type_str, "OVERRIDE" );        break;
00272       case PARAM_TYPE_SIG_LSB        :  strcpy( type_str, "SIG_LSB"  );        break;
00273       case PARAM_TYPE_SIG_MSB        :  strcpy( type_str, "SIG_MSB"  );        break;
00274       case PARAM_TYPE_INST_LSB       :  strcpy( type_str, "INST_LSB" );        break;
00275       case PARAM_TYPE_INST_MSB       :  strcpy( type_str, "INST_MSB" );        break;
00276       case PARAM_TYPE_DECLARED_LOCAL :  strcpy( type_str, "DECLARED_LOCAL" );  break;
00277       default                        :  strcpy( type_str, "UNKNOWN" );         break;
00278     }
00279     if( mparm->name == NULL ) {
00280       printf( "  mparam => type: %s, order: %u, owns_exp: %u",
00281               type_str, mparm->suppl.part.order, mparm->suppl.part.owns_expr );
00282     } else {
00283       printf( "  mparam => name: %s, type: %s, order: %u, owns_exp: %u",
00284                obf_sig( mparm->name ), type_str, mparm->suppl.part.order, mparm->suppl.part.owns_expr );
00285     }
00286     if( mparm->expr != NULL ) {
00287       printf( ", exp_id: %d\n", mparm->expr->id );
00288     } else {
00289       printf( ", no_expr\n" );
00290     }
00291     if( mparm->sig != NULL ) {
00292       printf( "    " );  vsignal_display( mparm->sig );
00293     }
00294     printf( "    " );  exp_link_display( mparm->exp_head );
00295     mparm = mparm->next;
00296   }
00297 
00298 }

mod_parm* mod_parm_find ( const char *  name,
mod_parm parm 
)

Searches specified module parameter list for matching parameter.

Returns:
Returns pointer to found module parameter or NULL if module parameter is not found.

Searches specified module parameter list for an module parameter that matches the name of the specified module parameter. If a match is found, a pointer to the found module parameter is returned to the calling function; otherwise, a value of NULL is returned if no match was found.

Parameters:
name Name of parameter value to find
parm Pointer to head of module parameter list to search

References mod_parm_s::name, mod_parm_s::next, PARAM_TYPE_DECLARED, PARAM_TYPE_DECLARED_LOCAL, psuppl_u::part, PROFILE, PROFILE_END, mod_parm_s::suppl, and psuppl_u::type.

Referenced by db_add_declared_param(), fsm_arg_parse_value(), and funit_find_param().

00106   { PROFILE(MOD_PARM_FIND);
00107 
00108   assert( name != NULL );
00109 
00110   while( (parm != NULL) && ((parm->name == NULL) || (strcmp( parm->name, name ) != 0) || ((parm->suppl.part.type != PARAM_TYPE_DECLARED) && (parm->suppl.part.type != PARAM_TYPE_DECLARED_LOCAL))) ) {
00111     parm = parm->next;
00112   }
00113 
00114   PROFILE_END;
00115 
00116   return( parm );
00117  
00118 }

void param_db_write ( inst_parm iparm,
FILE *  file 
)

Outputs specified instance parameter to specified output stream.

Prints contents of specified instance parameter to the specified output stream. Parameters get output in the same format as signals (they type specified for parameters is DB_TYPE_SIGNAL). A leading # sign is attached to the parameter name to indicate that the current signal is a parameter and not a signal, and should therefore not be scored as a signal.

Parameters:
iparm Pointer to instance parameter to output to file
file Pointer to file handle to write parameter contents to

References curr_sig_id, vsignal_s::id, vsignal_s::name, PROFILE, PROFILE_END, inst_parm_s::sig, and vsignal_db_write().

Referenced by funit_db_write().

01068   { PROFILE(PARAM_DB_WRITE);
01069 
01070   /*
01071    If the parameter does not have a name, it will not be used in expressions;
01072    therefore, there is no reason to output this parameter to the CDD file.
01073   */
01074   if( iparm->sig->name != NULL ) {
01075 
01076     /* Assign a signal ID and increment it for the next signal -- this is okay to do because parameters only exist during parsing */
01077     iparm->sig->id = curr_sig_id++;
01078 
01079     /* Write the signal */
01080     vsignal_db_write( iparm->sig, file );
01081 
01082   }
01083 
01084   PROFILE_END;
01085 
01086 }

void param_expr_eval ( expression expr,
funit_inst inst 
)

Evaluates parameter expression for the given instance.

Exceptions:
anonymous expression_resize param_expr_eval param_expr_eval param_size_function param_find_and_set_expr_value

Recursively evaluates the specified expression tree, calculating the value of leaf nodes first. If a another parameter value is encountered, lookup the value of this parameter in the current instance instance parameter list. If the instance parameter cannot be found, we have encountered a user error; therefore, display an error message to the user indicating such.

Parameters:
expr Current expression to evaluate
inst Pointer to current instance to evaluate for

References expression_s::elem, EXP_OP_FUNC_CALL, EXP_OP_MBIT_NEG, EXP_OP_MBIT_POS, EXP_OP_MBIT_SEL, EXP_OP_PARAM, EXP_OP_PARAM_MBIT, EXP_OP_PARAM_MBIT_NEG, EXP_OP_PARAM_MBIT_POS, EXP_OP_PARAM_SBIT, EXP_OP_PASSIGN, EXP_OP_SBIT_SEL, EXP_OP_SIG, EXP_OP_STATIC, expression_operate(), expression_resize(), FALSE, funit_inst_s::funit, expression_s::funit, instance_find_by_funit(), expression_s::left, expression_s::op, param_expr_eval(), param_find_and_set_expr_value(), param_size_function(), ssuppl_u::part, PROFILE, PROFILE_END, expression_s::right, expression_s::sig, SSUPPL_TYPE_GENVAR, vsignal_s::suppl, TRUE, ssuppl_u::type, and expression_s::value.

Referenced by enumerate_resolve(), inst_parm_add(), param_expr_eval(), param_resolve_declared(), and param_resolve_override().

00750   { PROFILE(PARAM_EXPR_EVAL);
00751 
00752   funit_inst* funiti;      /* Pointer to static function instance */
00753   func_unit*  funit;       /* Pointer to constant function */
00754   int         ignore = 0;  /* Number of instances to ignore */
00755 
00756   if( expr != NULL ) {
00757 
00758     /* Initialize the current time */
00759     sim_time time = {0,0,0,FALSE};
00760 
00761     /* For constant functions, resolve parameters and resize the functional unit first */
00762     if( expr->op == EXP_OP_FUNC_CALL ) {
00763       funit = expr->elem.funit;
00764       assert( funit != NULL );
00765       funiti = instance_find_by_funit( inst, funit, &ignore );
00766       assert( funiti != NULL );
00767       param_size_function( funiti, funit );
00768     }
00769 
00770     /* Evaluate children first */
00771     param_expr_eval( expr->left,  inst );
00772     param_expr_eval( expr->right, inst );
00773 
00774     switch( expr->op ) {
00775       case EXP_OP_STATIC  :
00776       case EXP_OP_PASSIGN :
00777         break;
00778       case EXP_OP_PARAM          :
00779       case EXP_OP_PARAM_SBIT     :
00780       case EXP_OP_PARAM_MBIT     :
00781       case EXP_OP_PARAM_MBIT_POS :
00782       case EXP_OP_PARAM_MBIT_NEG :
00783         param_find_and_set_expr_value( expr, inst );
00784         break;
00785       case EXP_OP_SIG :
00786         assert( expr->sig != NULL );
00787         assert( expr->sig->suppl.part.type == SSUPPL_TYPE_GENVAR );
00788         break;
00789       default :
00790         /*
00791          Since we are not a parameter identifier, let's allocate some data for us 
00792          if we don't have some already.
00793         */
00794         assert( expr->value != NULL );
00795         assert( (expr->op != EXP_OP_SBIT_SEL) &&
00796                 (expr->op != EXP_OP_MBIT_SEL) &&
00797                 (expr->op != EXP_OP_MBIT_POS) &&
00798                 (expr->op != EXP_OP_MBIT_NEG) );
00799         expression_resize( expr, inst->funit, FALSE, TRUE );
00800         break;
00801     }
00802 
00803     /* Perform the operation */
00804     (void)expression_operate( expr, NULL, &time );
00805 
00806   }
00807 
00808   PROFILE_END;
00809   
00810 }

void param_resolve ( funit_inst inst  ) 

Resolves all parameters for the specified instance tree.

Exceptions:
anonymous param_resolve_override param_resolve param_resolve_declared

Called after binding has occurred. Recursively resolves all parameters for the given instance tree.

Parameters:
inst Pointer to functional unit instance to resolve parameter values for

References funit_inst_s::child_head, funit_inst_s::next, param_resolve(), param_resolve_inst(), PROFILE, and PROFILE_END.

Referenced by funit_size_elements(), param_resolve(), and param_size_function().

01040   { PROFILE(PARAM_RESOLVE);
01041 
01042   funit_inst* child;  /* Pointer to child instance of this instance */
01043 
01044   /* Resolve this instance */
01045   param_resolve_inst( inst );
01046 
01047   /* Resolve all child instances */
01048   child = inst->child_head;
01049   while( child != NULL ) {
01050     param_resolve( child );
01051     child = child->next;
01052   }
01053 
01054   PROFILE_END;
01055 
01056 }

void param_resolve_inst ( funit_inst inst  ) 

Resolves all parameters for the specified instance.

Called after local binding has occurred. Resolves the parameters for the given functional unit instance.

Parameters:
inst Pointer to functional unit instance to resolve parameter values for

References funit_inst_s::funit, mod_parm_s::next, func_unit_s::param_head, param_resolve_declared(), param_resolve_override(), PARAM_TYPE_DECLARED, PARAM_TYPE_DECLARED_LOCAL, psuppl_u::part, PROFILE, PROFILE_END, mod_parm_s::suppl, and psuppl_u::type.

Referenced by gen_item_resolve(), instance_resolve_helper(), and param_resolve().

01010   { PROFILE(PARAM_RESOLVE_INST);
01011 
01012   assert( inst != NULL );
01013 
01014   /* Resolve this instance */
01015   if( inst->funit != NULL ) {
01016     mod_parm* mparm = inst->funit->param_head;
01017     while( mparm != NULL ) {
01018       if( (mparm->suppl.part.type == PARAM_TYPE_DECLARED) ||
01019           (mparm->suppl.part.type == PARAM_TYPE_DECLARED_LOCAL) ) {
01020         param_resolve_declared( mparm, inst );
01021       } else {
01022         param_resolve_override( mparm, inst );
01023       }
01024       mparm = mparm->next;
01025     } 
01026   }
01027 
01028   PROFILE_END;
01029 
01030 }

void param_set_sig_size ( vsignal sig,
inst_parm icurr 
)

Sets the specified signal size according to the specified instance parameter.

Sizes the specified signal according to the value of the specified instance parameter value.

Parameters:
sig Pointer to signal to search for in instance parameter list
icurr Pointer to head of instance parameter list to search

References vsignal_s::dim, psuppl_u::dimension, dim_range_s::lsb, inst_parm_s::mparm, dim_range_s::msb, PARAM_TYPE_SIG_LSB, psuppl_u::part, PROFILE, PROFILE_END, inst_parm_s::sig, mod_parm_s::suppl, psuppl_u::type, vsignal_s::value, and vector_to_int().

Referenced by funit_size_elements().

00688   { PROFILE(PARAM_SET_SIG_SIZE);
00689 
00690   assert( sig != NULL );
00691   assert( icurr != NULL );
00692   assert( icurr->sig != NULL );
00693   assert( icurr->mparm != NULL );
00694 
00695   /* Set the LSB/MSB to the value of the given instance parameter */
00696   if( icurr->mparm->suppl.part.type == PARAM_TYPE_SIG_LSB ) {
00697     sig->dim[icurr->mparm->suppl.part.dimension].lsb = vector_to_int( icurr->sig->value );
00698   } else {
00699     sig->dim[icurr->mparm->suppl.part.dimension].msb = vector_to_int( icurr->sig->value );
00700   }
00701 
00702   PROFILE_END;
00703 
00704 }

Generated on Sun Nov 21 00:55:40 2010 for Covered by  doxygen 1.6.3