#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include "defines.h"
#include "expr.h"
#include "func_unit.h"
#include "instance.h"
#include "link.h"
#include "obfuscate.h"
#include "param.h"
#include "static.h"
#include "util.h"
#include "vector.h"
#include "vsignal.h"
Functions | |
mod_parm * | mod_parm_find (const char *name, mod_parm *parm) |
Searches specified module parameter list for matching parameter. | |
static void | mod_parm_find_expr_and_remove (expression *exp, mod_parm *parm) |
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. | |
void | mod_parm_display (mod_parm *mparm) |
Outputs contents of module parameter list to standard output. | |
static inst_parm * | inst_parm_find (const char *name, inst_parm *iparm) |
static inst_parm * | inst_parm_add (const char *name, char *inst_name, static_expr *msb, static_expr *lsb, bool is_signed, vector *value, mod_parm *mparm, funit_inst *inst) |
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 *value) |
Adds parameter override to defparam list. | |
void | defparam_dealloc () |
Deallocates all memory associated with defparam storage from command-line. | |
static void | param_find_and_set_expr_value (expression *expr, funit_inst *inst) |
void | param_set_sig_size (vsignal *sig, inst_parm *icurr) |
Sets the specified signal size according to the specified instance parameter. | |
static void | param_size_function (funit_inst *inst, func_unit *funit) |
void | param_expr_eval (expression *expr, funit_inst *inst) |
Evaluates parameter expression for the given instance. | |
static inst_parm * | param_has_override (mod_parm *mparm, funit_inst *inst) |
static inst_parm * | param_has_defparam (mod_parm *mparm, funit_inst *inst) |
static void | param_resolve_declared (mod_parm *mparm, funit_inst *inst) |
static void | param_resolve_override (mod_parm *oparm, funit_inst *inst) |
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 *iparm, bool recursive) |
Deallocates specified instance parameter and possibly entire instance parameter list. | |
Variables | |
static funit_inst * | defparam_list = NULL |
char | user_msg [USER_MSG_LENGTH] |
db ** | db_list |
unsigned int | curr_db |
int | curr_sig_id |
void defparam_add | ( | const char * | scope, | |
vector * | value | |||
) |
Adds parameter override to defparam list.
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.
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 }
static inst_parm* inst_parm_add | ( | const char * | name, | |
char * | inst_name, | |||
static_expr * | msb, | |||
static_expr * | lsb, | |||
bool | is_signed, | |||
vector * | value, | |||
mod_parm * | mparm, | |||
funit_inst * | inst | |||
) | [static] |
anonymous | Throw param_expr_eval param_expr_eval expression_set_value |
Creates a new instance parameter with the specified information and adds it to the instance parameter list.
name | Name of parameter | |
inst_name | Name of instance containing this parameter name | |
msb | Static expression containing the MSB of this instance parameter | |
lsb | Static expression containing the LSB of this instance parameter | |
is_signed | Specifies if this instance parameter should be treated as signed or unsigned | |
value | Vector value of specified instance parameter | |
mparm | Pointer to module instance that this instance parameter is derived from | |
inst | Pointer to current functional unit instance |
References ssuppl_u::big_endian, Catch_anonymous, vsuppl_u::data_type, vsignal_s::dim, exp_link_s::exp, static_expr_s::exp, vsignal_s::exp_head, mod_parm_s::exp_head, exp_link_add(), vsignal_s::exp_tail, expression_set_value(), FALSE, funit_inst_s::funit, esuppl_u::gen_expr, inst_parm_s::inst_name, inst_parm_dealloc(), inst_parm_find(), vsuppl_u::is_signed, dim_range_s::lsb, malloc_safe, MAX_BIT_WIDTH, inst_parm_s::mparm, dim_range_s::msb, exp_link_s::next, inst_parm_s::next, static_expr_s::num, param_expr_eval(), funit_inst_s::param_head, funit_inst_s::param_tail, esuppl_u::part, ssuppl_u::part, vsuppl_u::part, vsignal_s::pdim_num, PROFILE, PROFILE_END, vector_s::r32, vector_s::r64, expression_s::sig, inst_parm_s::sig, SSUPPL_TYPE_PARAM, SSUPPL_TYPE_PARAM_REAL, strdup_safe, expression_s::suppl, vsignal_s::suppl, vector_s::suppl, Throw, Try, vector_s::ul, rv32_s::val, rv64_s::val, vector_s::value, vsignal_s::value, expression_s::value, VDATA_R32, VDATA_R64, VDATA_UL, vector_from_real64(), vector_set_value_ulong(), vector_to_int(), vsignal_create(), and vector_s::width.
Referenced by defparam_add(), param_has_defparam(), param_has_override(), param_resolve_declared(), and param_resolve_override().
00345 { PROFILE(INST_PARM_ADD); 00346 00347 inst_parm* iparm = NULL; /* Temporary pointer to instance parameter */ 00348 int sig_width; /* Width of this parameter signal */ 00349 int sig_be; /* Big endianness of this parameter signal */ 00350 int sig_type; /* Type of signal parameter to create */ 00351 int left_val = 31; /* Value of left (msb) static expression */ 00352 int right_val = 0; /* Value of right (lsb) static expression */ 00353 exp_link* expl; /* Pointer to current expression link */ 00354 00355 assert( value != NULL ); 00356 assert( ((msb == NULL) && (lsb == NULL)) || ((msb != NULL) && (lsb != NULL)) ); 00357 00358 /* Only add the instance parameter if it currently does not exist */ 00359 if( (name == NULL) || (inst_name != NULL) || (inst_parm_find( name, inst->param_head ) == NULL) ) { 00360 00361 /* Create new signal/expression binding */ 00362 iparm = (inst_parm*)malloc_safe( sizeof( inst_parm ) ); 00363 00364 if( inst_name != NULL ) { 00365 iparm->inst_name = strdup_safe( inst_name ); 00366 } else { 00367 iparm->inst_name = NULL; 00368 } 00369 00370 Try { 00371 00372 /* If the MSB/LSB was specified, calculate the LSB and width values */ 00373 if( msb != NULL ) { 00374 00375 /* Calculate left value */ 00376 if( lsb->exp != NULL ) { 00377 param_expr_eval( lsb->exp, inst ); 00378 right_val = vector_to_int( lsb->exp->value ); 00379 } else { 00380 right_val = lsb->num; 00381 } 00382 assert( right_val >= 0 ); 00383 00384 /* Calculate right value */ 00385 if( msb->exp != NULL ) { 00386 param_expr_eval( msb->exp, inst ); 00387 left_val = vector_to_int( msb->exp->value ); 00388 } else { 00389 left_val = msb->num; 00390 } 00391 assert( left_val >= 0 ); 00392 00393 /* Calculate LSB and width information */ 00394 if( right_val > left_val ) { 00395 sig_width = (right_val - left_val) + 1; 00396 sig_be = 1; 00397 } else { 00398 sig_width = (left_val - right_val) + 1; 00399 sig_be = 0; 00400 } 00401 00402 } else { 00403 00404 sig_width = value->width; 00405 sig_be = 0; 00406 00407 } 00408 00409 /* If the parameter is sized too big, panic */ 00410 assert( (sig_width <= MAX_BIT_WIDTH) && (sig_width >= 0) ); 00411 00412 /* Figure out what type of parameter this signal needs to be */ 00413 if( (value != NULL) && ((value->suppl.part.data_type == VDATA_R64) || (value->suppl.part.data_type == VDATA_R32)) ) { 00414 sig_type = SSUPPL_TYPE_PARAM_REAL; 00415 } else { 00416 sig_type = SSUPPL_TYPE_PARAM; 00417 } 00418 00419 /* Create instance parameter signal */ 00420 iparm->sig = vsignal_create( name, sig_type, sig_width, 0, 0 ); 00421 iparm->sig->pdim_num = 1; 00422 iparm->sig->dim = (dim_range*)malloc_safe( sizeof( dim_range ) * 1 ); 00423 iparm->sig->dim[0].lsb = right_val; 00424 iparm->sig->dim[0].msb = left_val; 00425 iparm->sig->suppl.part.big_endian = sig_be; 00426 00427 /* Store signed attribute for this vector */ 00428 iparm->sig->value->suppl.part.is_signed = is_signed; 00429 00430 /* Copy the contents of the specified vector value to the signal */ 00431 switch( value->suppl.part.data_type ) { 00432 case VDATA_UL : 00433 (void)vector_set_value_ulong( iparm->sig->value, value->value.ul, value->width ); 00434 break; 00435 case VDATA_R64 : 00436 (void)vector_from_real64( iparm->sig->value, value->value.r64->val ); 00437 break; 00438 case VDATA_R32 : 00439 (void)vector_from_real64( iparm->sig->value, (double)value->value.r32->val ); 00440 break; 00441 default : assert( 0 ); break; 00442 } 00443 00444 iparm->mparm = mparm; 00445 iparm->next = NULL; 00446 00447 /* Bind the module parameter expression list to this signal */ 00448 if( mparm != NULL ) { 00449 expl = mparm->exp_head; 00450 while( expl != NULL ) { 00451 expl->exp->sig = iparm->sig; 00452 /* Set the expression's vector to this signal's vector if we are part of a generate expression */ 00453 if( expl->exp->suppl.part.gen_expr == 1 ) { 00454 expression_set_value( expl->exp, iparm->sig, inst->funit ); 00455 } 00456 exp_link_add( expl->exp, &(iparm->sig->exp_head), &(iparm->sig->exp_tail) ); 00457 expl = expl->next; 00458 } 00459 } 00460 00461 /* Now add the parameter to the current expression */ 00462 if( inst->param_head == NULL ) { 00463 inst->param_head = inst->param_tail = iparm; 00464 } else { 00465 inst->param_tail->next = iparm; 00466 inst->param_tail = iparm; 00467 } 00468 00469 } Catch_anonymous { 00470 inst_parm_dealloc( iparm, FALSE ); 00471 Throw 0; 00472 } 00473 00474 } 00475 00476 PROFILE_END; 00477 00478 return( iparm ); 00479 00480 }
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.
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.
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 }
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.
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 }
Searches specified instance parameter list for an instance parameter that matches the name of the specified instance parameter. If a match is found, a pointer to the found instance parameter is returned to the calling function; otherwise, a value of NULL is returned if no match was found.
name | Name of parameter value to find | |
iparm | Pointer to head of instance parameter list to search |
References vsignal_s::name, inst_parm_s::next, PROFILE, PROFILE_END, and inst_parm_s::sig.
Referenced by defparam_add(), and inst_parm_add().
00314 { PROFILE(INST_PARM_FIND); 00315 00316 assert( name != NULL ); 00317 00318 while( (iparm != NULL) && ((iparm->sig == NULL) || (iparm->sig->name == NULL) || (strcmp( iparm->sig->name, name ) != 0)) ) { 00319 iparm = iparm->next; 00320 } 00321 00322 PROFILE_END; 00323 00324 return( iparm ); 00325 00326 }
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.
Creates a new module parameter with the specified information and adds it to the module parameter list.
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 }
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.
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.
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 }
Searches specified module parameter list for matching parameter.
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.
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 }
static void mod_parm_find_expr_and_remove | ( | expression * | exp, | |
mod_parm * | parm | |||
) | [static] |
Searches list of module parameter expression lists for specified expression. If the expression is found in one of the lists, remove the expression link.
exp | Pointer to expression to find and remove from lists | |
parm | Pointer to module parameter list to search |
References mod_parm_s::exp_head, exp_link_remove(), mod_parm_s::exp_tail, FALSE, expression_s::left, mod_parm_s::next, PROFILE, PROFILE_END, and expression_s::right.
00127 { PROFILE(MOD_PARM_FIND_EXPR_AND_REMOVE); 00128 00129 if( exp != NULL ) { 00130 00131 /* Remove left and right expressions as well */ 00132 mod_parm_find_expr_and_remove( exp->left, parm ); 00133 mod_parm_find_expr_and_remove( exp->right, parm ); 00134 00135 while( parm != NULL ) { 00136 exp_link_remove( exp, &(parm->exp_head), &(parm->exp_tail), FALSE ); 00137 parm = parm->next; 00138 } 00139 00140 } 00141 00142 PROFILE_END; 00143 00144 }
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.
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.
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.
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 }
static void param_find_and_set_expr_value | ( | expression * | expr, | |
funit_inst * | inst | |||
) | [static] |
anonymous | Throw expression_set_value param_find_and_set_expr_value |
This function is called by param_expr_eval when it encounters a parameter in its expression tree that needs to be resolved for its value. If the parameter is found, the value of that parameter is returned. If the parameter is not found, an error message is displayed to the user (the user has created a module in which a parameter value is used without being defined).
expr | Pointer to current expression to evaluate | |
inst | Pointer to current instance to search |
References vsignal_s::exp_head, mod_parm_s::exp_head, exp_link_add(), exp_link_find(), vsignal_s::exp_tail, expression_set_value(), FATAL, funit_inst_s::funit, expression_s::id, expression_s::line, inst_parm_s::mparm, inst_parm_s::next, funit_inst_s::param_head, funit_inst_s::parent, func_unit_s::parent, print_output(), PROFILE, PROFILE_END, expression_s::sig, inst_parm_s::sig, Throw, user_msg, and USER_MSG_LENGTH.
Referenced by param_expr_eval().
00637 { PROFILE(PARAM_FIND_AND_SET_EXPR_VALUE); 00638 00639 inst_parm* icurr; /* Pointer to current instance parameter being evaluated */ 00640 00641 if( inst != NULL ) { 00642 00643 icurr = inst->param_head; 00644 while( (icurr != NULL) && ((icurr->mparm == NULL) || (exp_link_find( expr->id, icurr->mparm->exp_head ) == NULL)) ) { 00645 icurr = icurr->next; 00646 } 00647 00648 /* 00649 If we were unable to find the module parameter in the current instance, check the rest of our 00650 scope for the value. 00651 */ 00652 if( icurr == NULL ) { 00653 00654 if( inst->funit->parent != NULL ) { 00655 param_find_and_set_expr_value( expr, inst->parent ); 00656 } else { 00657 unsigned int rv = snprintf( user_msg, USER_MSG_LENGTH, "Parameter used in expression but not defined in current module, line %d", expr->line ); 00658 assert( rv < USER_MSG_LENGTH ); 00659 print_output( user_msg, FATAL, __FILE__, __LINE__ ); 00660 Throw 0; 00661 } 00662 00663 } else { 00664 00665 /* Set the found instance parameter value to this expression */ 00666 expression_set_value( expr, icurr->sig, inst->funit ); 00667 00668 /* Cause expression/signal to point to each other */ 00669 expr->sig = icurr->sig; 00670 00671 exp_link_add( expr, &(icurr->sig->exp_head), &(icurr->sig->exp_tail) ); 00672 00673 } 00674 00675 } 00676 00677 PROFILE_END; 00678 00679 }
static inst_parm* param_has_defparam | ( | mod_parm * | mparm, | |
funit_inst * | inst | |||
) | [static] |
anonymous | inst_parm_add |
Looks up specified parameter in defparam list. If a match is found, a new instance parameter is created with the value of the found defparam. If a match is not found, return NULL and do nothing else.
mparm | Pointer to module parameter to attach new instance parameter to | |
inst | Pointer to current instance |
References curr_db, FALSE, inst_parm_add(), instance_gen_scope(), mod_parm_s::is_signed, mod_parm_s::lsb, mod_parm_s::msb, vsignal_s::name, mod_parm_s::name, inst_parm_s::next, funit_inst_s::param_head, PARAM_TYPE_DECLARED_LOCAL, psuppl_u::part, PROFILE, PROFILE_END, inst_parm_s::sig, mod_parm_s::suppl, psuppl_u::type, and vsignal_s::value.
Referenced by param_resolve_declared().
00882 { PROFILE(PARAM_HAS_DEFPARAM); 00883 00884 inst_parm* parm = NULL; /* Pointer newly created instance parameter (if one is created) */ 00885 inst_parm* icurr; /* Pointer to current defparam */ 00886 char parm_scope[4096]; /* Specifes full scope to parameter to find */ 00887 char scope[4096]; /* Scope of this instance */ 00888 00889 assert( mparm != NULL ); 00890 assert( inst != NULL ); 00891 00892 /* Make sure that the user specified at least one defparam */ 00893 if( defparam_list != NULL ) { 00894 00895 unsigned int rv; 00896 00897 /* Get scope of this instance */ 00898 scope[0] = '\0'; 00899 instance_gen_scope( scope, inst, FALSE ); 00900 00901 assert( db_list[curr_db]->leading_hier_num > 0 ); 00902 00903 /* Generate full hierarchy of this parameter */ 00904 rv = snprintf( parm_scope, 4096, "%s.%s", scope, mparm->name ); 00905 assert( rv < 4096 ); 00906 00907 icurr = defparam_list->param_head; 00908 while( (icurr != NULL) && 00909 !((strcmp( icurr->sig->name, parm_scope ) == 0) && 00910 (mparm->suppl.part.type != PARAM_TYPE_DECLARED_LOCAL)) ) { 00911 icurr = icurr->next; 00912 } 00913 00914 if( icurr != NULL ) { 00915 00916 /* Defparam found, use its value to create new instance parameter */ 00917 parm = inst_parm_add( mparm->name, NULL, mparm->msb, mparm->lsb, mparm->is_signed, icurr->sig->value, mparm, inst ); 00918 00919 } 00920 00921 } 00922 00923 PROFILE_END; 00924 00925 return( parm ); 00926 00927 }
static inst_parm* param_has_override | ( | mod_parm * | mparm, | |
funit_inst * | inst | |||
) | [static] |
anonymous | inst_parm_add |
Looks up in the parent instance instance parameter list for overrides. If an override is found, adds the new instance parameter using the value of the override. If no override is found, returns NULL and does nothing.
mparm | Pointer to parameter in current module to check | |
inst | Pointer to current instance |
References funit_inst_s::funit, inst_parm_s::inst_name, inst_parm_add(), mod_parm_s::is_signed, mod_parm_s::lsb, inst_parm_s::mparm, mod_parm_s::msb, funit_inst_s::name, mod_parm_s::name, vsignal_s::name, inst_parm_s::next, psuppl_u::order, funit_inst_s::param_head, PARAM_TYPE_DECLARED_LOCAL, PARAM_TYPE_OVERRIDE, funit_inst_s::parent, func_unit_s::parent, psuppl_u::part, PROFILE, PROFILE_END, inst_parm_s::sig, mod_parm_s::suppl, psuppl_u::type, and vsignal_s::value.
Referenced by param_resolve_declared().
00826 { PROFILE(PARAM_HAS_OVERRIDE); 00827 00828 inst_parm* icurr = NULL; /* Pointer to current instance parameter in parent */ 00829 inst_parm* parm = NULL; /* Pointer to newly created parameter (if one is created) */ 00830 funit_inst* mod_inst; /* Pointer to the instance that refers to the module containing this instance */ 00831 00832 assert( mparm != NULL ); 00833 assert( inst != NULL ); 00834 00835 /* Find the module instance for this instance */ 00836 mod_inst = inst; 00837 while( mod_inst->funit->parent != NULL ) { 00838 mod_inst = mod_inst->parent; 00839 } 00840 00841 /* Check to see if the parent instance contains an override in its instance list. */ 00842 if( mod_inst->parent != NULL ) { 00843 00844 icurr = mod_inst->parent->param_head; 00845 while( (icurr != NULL) && 00846 ((icurr->mparm == NULL) || 00847 !((icurr->mparm->suppl.part.type == PARAM_TYPE_OVERRIDE) && 00848 (mparm->suppl.part.type != PARAM_TYPE_DECLARED_LOCAL) && 00849 ((icurr->sig->name != NULL) ? (strcmp( icurr->sig->name, mparm->name ) == 0) : (mparm->suppl.part.order == icurr->mparm->suppl.part.order )) && 00850 (strcmp( mod_inst->name, icurr->inst_name ) == 0))) ) { 00851 icurr = icurr->next; 00852 } 00853 00854 } 00855 00856 /* If an override has been found, use this value instead of the mparm expression value */ 00857 if( icurr != NULL ) { 00858 00859 /* Add new instance parameter to current instance */ 00860 parm = inst_parm_add( mparm->name, NULL, mparm->msb, mparm->lsb, mparm->is_signed, icurr->sig->value, mparm, inst ); 00861 00862 } 00863 00864 PROFILE_END; 00865 00866 return( parm ); 00867 00868 }
void param_resolve | ( | funit_inst * | inst | ) |
Resolves all parameters for the specified instance tree.
anonymous | param_resolve_override param_resolve param_resolve_declared |
Called after binding has occurred. Recursively resolves all parameters for the given instance tree.
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 }
static void param_resolve_declared | ( | mod_parm * | mparm, | |
funit_inst * | inst | |||
) | [static] |
anonymous | inst_parm_add param_expr_eval |
Performs declared module parameter resolution and stores the appropriate instance parameter into the current instance's instance parameter list. This procedure is accomplished by checking the following in the specified order:
mparm | Pointer to parameter in current module to check | |
inst | Pointer to current instance |
References mod_parm_s::expr, inst_parm_add(), mod_parm_s::is_signed, mod_parm_s::lsb, mod_parm_s::msb, mod_parm_s::name, param_expr_eval(), param_has_defparam(), param_has_override(), PROFILE, PROFILE_END, and expression_s::value.
Referenced by param_resolve_inst().
00945 { PROFILE(PARAM_RESOLVE_DECLARED); 00946 00947 assert( mparm != NULL ); 00948 00949 if( param_has_override( mparm, inst ) != NULL ) { 00950 00951 /* Parameter override was found in parent module, do nothing more */ 00952 00953 } else if( param_has_defparam( mparm, inst ) != NULL ) { 00954 00955 /* Parameter defparam override was found, do nothing more */ 00956 00957 } else { 00958 00959 assert( mparm->expr != NULL ); 00960 00961 /* First evaluate the current module expression */ 00962 param_expr_eval( mparm->expr, inst ); 00963 00964 /* Now add the new instance parameter */ 00965 (void)inst_parm_add( mparm->name, NULL, mparm->msb, mparm->lsb, mparm->is_signed, mparm->expr->value, mparm, inst ); 00966 00967 } 00968 00969 PROFILE_END; 00970 00971 }
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.
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 }
static void param_resolve_override | ( | mod_parm * | oparm, | |
funit_inst * | inst | |||
) | [static] |
anonymous | inst_parm_add param_expr_eval |
Evaluates the current module parameter expression tree and adds a new instance parameter to the specified instance parameter list, preserving the order and type of the override parameter.
oparm | Pointer to override module parameter | |
inst | Pointer to instance to add new instance parameter to |
References mod_parm_s::expr, mod_parm_s::inst_name, inst_parm_add(), mod_parm_s::is_signed, mod_parm_s::lsb, mod_parm_s::msb, mod_parm_s::name, param_expr_eval(), PROFILE, PROFILE_END, and expression_s::value.
Referenced by param_resolve_inst().
00985 { PROFILE(PARAM_RESOLVE_OVERRIDE); 00986 00987 assert( oparm != NULL ); 00988 00989 /* If this is a NULL parameter, don't attempt an expression evaluation */ 00990 if( oparm->expr != NULL ) { 00991 00992 /* Evaluate module override parameter */ 00993 param_expr_eval( oparm->expr, inst ); 00994 00995 /* Add the new instance override parameter */ 00996 (void)inst_parm_add( oparm->name, oparm->inst_name, oparm->msb, oparm->lsb, oparm->is_signed, oparm->expr->value, oparm, inst ); 00997 00998 } 00999 01000 PROFILE_END; 01001 01002 }
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.
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 }
static void param_size_function | ( | funit_inst * | inst, | |
func_unit * | funit | |||
) | [static] |
anonymous | funit_size_elements param_size_function param_resolve |
Recursively iterates through all functional units of given function, sizing them as appropriate for the purposes of static function allocation and execution.
inst | Pointer to instance pointing to given functional unit | |
funit | Pointer to functional unit to size |
References funit_inst_s::child_head, FALSE, funit_inst_s::funit, funit_size_elements(), funit_inst_s::next, param_resolve(), PROFILE, PROFILE_END, and TRUE.
Referenced by param_expr_eval().
00717 { PROFILE(PARAM_SIZE_FUNCTION); 00718 00719 funit_inst* child; /* Pointer to current child instance */ 00720 00721 /* Resolve all parameters for this instance */ 00722 param_resolve( inst ); 00723 00724 /* Resize the current functional unit */ 00725 funit_size_elements( funit, inst, FALSE, TRUE ); 00726 00727 /* Recursively iterate through list of children instances */ 00728 child = inst->child_head; 00729 while( child != NULL ) { 00730 param_size_function( child, child->funit ); 00731 child = child->next; 00732 } 00733 00734 PROFILE_END; 00735 00736 }
unsigned int curr_db |
Index of current database in db_list array that is being handled.
int curr_sig_id |
Signal ID that is used for identification purposes (each signal will receive a unique ID).
funit_inst* defparam_list = NULL [static] |
This may seem to be odd to store the defparams in a functional unit instance; however, the inst_parm_add function has been modified to send in a functional unit instance so we need to pass the defparam head/tail in a functional unit instance instead of individual head and tail pointers. The defparams in this functional unit can refer to any functional unit instance, however.
char user_msg[USER_MSG_LENGTH] |
Holds some output that will be displayed via the print_output command. This is created globally so that memory does not need to be reallocated for each function that wishes to use it.