#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include "defines.h"
#include "fsm_arg.h"
#include "util.h"
#include "fsm.h"
#include "fsm_var.h"
#include "vsignal.h"
#include "expr.h"
#include "vector.h"
#include "statement.h"
#include "link.h"
#include "param.h"
#include "obfuscate.h"
Functions | |
| expression * | fsm_arg_parse_state (char **arg, char *funit_name) |
| void | fsm_arg_parse (const char *arg) |
| Parses specified -F argument for FSM information. | |
| expression * | fsm_arg_parse_value (char **str, const func_unit *funit) |
| void | fsm_arg_parse_trans (expression *expr, fsm *table, const func_unit *funit) |
| void | fsm_arg_parse_attr (attr_param *ap, const func_unit *funit, bool exclude) |
| Parses specified attribute argument for FSM information. | |
Variables | |
| int | curr_expr_id |
| char | user_msg [USER_MSG_LENGTH] |
|
|
Parses specified -F argument for FSM information.
00247 { PROFILE(FSM_ARG_PARSE);
00248
00249 char* tmp = strdup_safe( arg ); /* Temporary copy of given argument */
00250 char* ptr = tmp; /* Pointer to current character in arg */
00251 expression* in_state; /* Pointer to input state expression */
00252 expression* out_state; /* Pointer to output state expression */
00253
00254 Try {
00255
00256 while( (*ptr != '\0') && (*ptr != '=') ) {
00257 ptr++;
00258 }
00259
00260 if( *ptr == '\0' ) {
00261
00262 print_output( "Option -F must specify a module/task/function/named block and one or two variables. See \"covered score -h\" for more information.",
00263 FATAL, __FILE__, __LINE__ );
00264 Throw 0;
00265
00266 } else {
00267
00268 *ptr = '\0';
00269 ptr++;
00270
00271 if( (in_state = fsm_arg_parse_state( &ptr, tmp )) != NULL ) {
00272
00273 if( *ptr == ',' ) {
00274
00275 ptr++;
00276
00277 if( (out_state = fsm_arg_parse_state( &ptr, tmp )) != NULL ) {
00278 (void)fsm_var_add( arg, in_state, out_state, NULL, FALSE );
00279 } else {
00280 print_output( "Illegal FSM command-line output state", FATAL, __FILE__, __LINE__ );
00281 Throw 0;
00282 }
00283
00284 } else {
00285
00286 /* Copy the current expression */
00287 (void)fsm_var_add( arg, in_state, in_state, NULL, FALSE );
00288
00289 }
00290
00291 } else {
00292
00293 print_output( "Illegal FSM command-line input state", FATAL, __FILE__, __LINE__ );
00294 Throw 0;
00295
00296 }
00297
00298 }
00299
00300 } Catch_anonymous {
00301 free_safe( tmp, (strlen( arg ) + 1) );
00302 Throw 0;
00303 }
00304
00305 /* Deallocate temporary memory */
00306 free_safe( tmp, (strlen( arg ) + 1) );
00307
00308 PROFILE_END;
00309
00310 }
|
|
||||||||||||||||
|
Parses specified attribute argument for FSM information.
00596 { PROFILE(FSM_ARG_PARSE_ATTR);
00597
00598 attr_param* curr; /* Pointer to current attribute parameter in list */
00599 fsm_link* fsml = NULL; /* Pointer to found FSM structure */
00600 int index = 1; /* Current index number in list */
00601 bool ignore = FALSE; /* Set to TRUE if we should ignore this attribute */
00602 expression* in_state = NULL; /* Pointer to input state */
00603 expression* out_state = NULL; /* Pointer to output state */
00604 char* str; /* Temporary holder for string value */
00605 char* tmp; /* Temporary holder for string value */
00606
00607 curr = ap;
00608 while( (curr != NULL) && !ignore ) {
00609
00610 /* This name is the name of the FSM structure to update */
00611 if( index == 1 ) {
00612 if( curr->expr != NULL ) {
00613 ignore = TRUE;
00614 } else {
00615 fsml = fsm_link_find( curr->name, funit->fsm_head );
00616 }
00617 } else if( (index == 2) && (strcmp( curr->name, "is" ) == 0) && (curr->expr != NULL) ) {
00618 if( fsml == NULL ) {
00619 int slen;
00620 tmp = str = vector_to_string( curr->expr->value, ESUPPL_STATIC_BASE( curr->expr->suppl ), FALSE );
00621 slen = strlen( tmp );
00622 Try {
00623 if( (in_state = fsm_arg_parse_state( &str, funit->name )) == NULL ) {
00624 unsigned int rv = snprintf( user_msg, USER_MSG_LENGTH, "Illegal input state expression (%s), file: %s", str, obf_file( funit->filename ) );
00625 assert( rv < USER_MSG_LENGTH );
00626 print_output( user_msg, FATAL, __FILE__, __LINE__ );
00627 Throw 0;
00628 }
00629 } Catch_anonymous {
00630 free_safe( tmp, (slen + 1) );
00631 Throw 0;
00632 }
00633 free_safe( tmp, (slen + 1) );
00634 } else {
00635 unsigned int rv = snprintf( user_msg, USER_MSG_LENGTH, "Input state specified after output state for this FSM has already been specified, file: %s",
00636 obf_file( funit->filename ) );
00637 assert( rv < USER_MSG_LENGTH );
00638 print_output( user_msg, FATAL, __FILE__, __LINE__ );
00639 Throw 0;
00640 }
00641 } else if( (index == 2) && (strcmp( curr->name, "os" ) == 0) && (curr->expr != NULL) ) {
00642 if( fsml == NULL ) {
00643 int slen;
00644 tmp = str = vector_to_string( curr->expr->value, ESUPPL_STATIC_BASE( curr->expr->suppl ), FALSE );
00645 slen = strlen( tmp );
00646 Try {
00647 if( (out_state = fsm_arg_parse_state( &str, funit->name )) == NULL ) {
00648 unsigned int rv = snprintf( user_msg, USER_MSG_LENGTH, "Illegal output state expression (%s), file: %s", str, obf_file( funit->filename ) );
00649 assert( rv < USER_MSG_LENGTH );
00650 print_output( user_msg, FATAL, __FILE__, __LINE__ );
00651 Throw 0;
00652 } else {
00653 (void)fsm_var_add( funit->name, out_state, out_state, curr->name, exclude );
00654 fsml = fsm_link_find( curr->name, funit->fsm_head );
00655 }
00656 } Catch_anonymous {
00657 free_safe( tmp, (slen + 1) );
00658 Throw 0;
00659 }
00660 free_safe( tmp, (slen + 1) );
00661 } else {
00662 unsigned int rv = snprintf( user_msg, USER_MSG_LENGTH, "Output state specified after output state for this FSM has already been specified, file: %s",
00663 obf_file( funit->filename ) );
00664 assert( rv < USER_MSG_LENGTH );
00665 print_output( user_msg, FATAL, __FILE__, __LINE__ );
00666 Throw 0;
00667 }
00668 } else if( (index == 3) && (strcmp( curr->name, "os" ) == 0) && (out_state == NULL) &&
00669 (in_state != NULL) && (curr->expr != NULL) ) {
00670 if( fsml == NULL ) {
00671 int slen;
00672 tmp = str = vector_to_string( curr->expr->value, ESUPPL_STATIC_BASE( curr->expr->suppl ), FALSE );
00673 slen = strlen( tmp );
00674 Try {
00675 if( (out_state = fsm_arg_parse_state( &str, funit->name )) == NULL ) {
00676 unsigned int rv = snprintf( user_msg, USER_MSG_LENGTH, "Illegal output state expression (%s), file: %s", str, obf_file( funit->filename ) );
00677 assert( rv < USER_MSG_LENGTH );
00678 print_output( user_msg, FATAL, __FILE__, __LINE__ );
00679 Throw 0;
00680 } else {
00681 (void)fsm_var_add( funit->name, in_state, out_state, curr->name, exclude );
00682 fsml = fsm_link_find( curr->name, funit->fsm_head );
00683 }
00684 } Catch_anonymous {
00685 free_safe( tmp, (slen + 1) );
00686 Throw 0;
00687 }
00688 free_safe( tmp, (slen + 1) );
00689 } else {
00690 unsigned int rv = snprintf( user_msg, USER_MSG_LENGTH, "Output state specified after output state for this FSM has already been specified, file: %s",
00691 obf_file( funit->filename ) );
00692 assert( rv < USER_MSG_LENGTH );
00693 print_output( user_msg, FATAL, __FILE__, __LINE__ );
00694 Throw 0;
00695 }
00696 } else if( (index > 1) && (strcmp( curr->name, "trans" ) == 0) && (curr->expr != NULL) ) {
00697 if( fsml == NULL ) {
00698 unsigned int rv = snprintf( user_msg, USER_MSG_LENGTH, "Attribute FSM name (%s) has not been previously created, file: %s",
00699 obf_sig( curr->name ), obf_file( funit->filename ) );
00700 assert( rv < USER_MSG_LENGTH );
00701 print_output( user_msg, FATAL, __FILE__, __LINE__ );
00702 Throw 0;
00703 } else {
00704 fsm_arg_parse_trans( curr->expr, fsml->table, funit );
00705 }
00706 } else {
00707 unsigned int rv;
00708 tmp = vector_to_string( curr->expr->value, ESUPPL_STATIC_BASE( curr->expr->suppl ), FALSE );
00709 rv = snprintf( user_msg, USER_MSG_LENGTH, "Invalid covered_fsm attribute parameter (%s=%s), file: %s",
00710 curr->name, tmp, obf_file( funit->filename ) );
00711 assert( rv < USER_MSG_LENGTH );
00712 print_output( user_msg, FATAL, __FILE__, __LINE__ );
00713 free_safe( tmp, (strlen( tmp ) + 1) );
00714 Throw 0;
00715 }
00716
00717 /* We need to work backwards in attribute parameter lists */
00718 curr = curr->prev;
00719 index++;
00720
00721 }
00722
00723 PROFILE_END;
00724
00725 }
|
|
||||||||||||
|
00057 { PROFILE(FSM_ARG_PARSE_STATE);
00058
00059 bool error = FALSE; /* Specifies if a parsing error has been found */
00060 vsignal* sig; /* Pointer to read-in signal */
00061 expression* expl = NULL; /* Pointer to left expression */
00062 expression* expr = NULL; /* Pointer to right expression */
00063 expression* expt = NULL; /* Pointer to temporary expression */
00064 statement* stmt; /* Pointer to statement containing top expression */
00065 exp_op_type op; /* Type of operation to decode for this signal */
00066
00067 /*
00068 If we are a concatenation, parse arguments of concatenation as signal names
00069 in a comma-separated list.
00070 */
00071 if( **arg == '{' ) {
00072
00073 /* Get first state */
00074 while( (**arg != '}') && !error ) {
00075 if( ((expl != NULL) && (**arg == ',')) || (**arg == '{') ) {
00076 (*arg)++;
00077 }
00078 if( (sig = vsignal_from_string( arg )) != NULL ) {
00079
00080 Try {
00081
00082 if( sig->value->width == 0 ) {
00083
00084 expr = expression_create( NULL, NULL, EXP_OP_SIG, FALSE, curr_expr_id, 0, 0, 0, FALSE );
00085 curr_expr_id++;
00086 fsm_var_bind_add( sig->name, expr, funit_name );
00087
00088 } else if( sig->value->width == 1 ) {
00089
00090 expr = expression_create( NULL, NULL, EXP_OP_STATIC, FALSE, curr_expr_id, 0, 0, 0, FALSE );
00091 curr_expr_id++;
00092 vector_dealloc( expr->value );
00093 expr->value = vector_create( 32, VTYPE_VAL, VDATA_UL, TRUE );
00094 (void)vector_from_int( expr->value, sig->dim[0].lsb );
00095
00096 expr = expression_create( NULL, expr, EXP_OP_SBIT_SEL, FALSE, curr_expr_id, 0, 0, 0, FALSE );
00097 curr_expr_id++;
00098 fsm_var_bind_add( sig->name, expr, funit_name );
00099
00100 } else {
00101
00102 expt = expression_create( NULL, NULL, EXP_OP_STATIC, FALSE, curr_expr_id, 0, 0, 0, FALSE );
00103 curr_expr_id++;
00104 vector_dealloc( expt->value );
00105 expt->value = vector_create( 32, VTYPE_VAL, VDATA_UL, TRUE );
00106 (void)vector_from_int( expt->value, sig->dim[0].lsb );
00107
00108 expr = expression_create( NULL, NULL, EXP_OP_STATIC, FALSE, curr_expr_id, 0, 0, 0, FALSE );
00109 curr_expr_id++;
00110 vector_dealloc( expr->value );
00111 expr->value = vector_create( 32, VTYPE_VAL, VDATA_UL, TRUE );
00112 (void)vector_from_int( expr->value, ((sig->value->width - 1) + sig->dim[0].lsb) );
00113
00114 switch( sig->suppl.part.type ) {
00115 case SSUPPL_TYPE_IMPLICIT : op = EXP_OP_MBIT_SEL; break;
00116 case SSUPPL_TYPE_IMPLICIT_POS : op = EXP_OP_MBIT_POS; break;
00117 case SSUPPL_TYPE_IMPLICIT_NEG : op = EXP_OP_MBIT_NEG; break;
00118 default : assert( 0 ); break;
00119 }
00120 expr = expression_create( expt, expr, op, FALSE, curr_expr_id, 0, 0, 0, FALSE );
00121 curr_expr_id++;
00122 fsm_var_bind_add( sig->name, expr, funit_name );
00123
00124 }
00125
00126 if( expl != NULL ) {
00127 expl = expression_create( expr, expl, EXP_OP_LIST, FALSE, curr_expr_id, 0, 0, 0, FALSE );
00128 curr_expr_id++;
00129 } else {
00130 expl = expr;
00131 }
00132
00133 } Catch_anonymous {
00134 vsignal_dealloc( sig );
00135 expression_dealloc( expr, FALSE );
00136 Throw 0;
00137 }
00138
00139 /* Deallocate signal */
00140 vsignal_dealloc( sig );
00141
00142 } else {
00143 expression_dealloc( expl, FALSE );
00144 error = TRUE;
00145 }
00146 }
00147 if( !error ) {
00148 (*arg)++;
00149 expl = expression_create( expl, NULL, EXP_OP_CONCAT, FALSE, curr_expr_id, 0, 0, 0, FALSE );
00150 curr_expr_id++;
00151 }
00152
00153 } else {
00154
00155 if( (sig = vsignal_from_string( arg )) != NULL ) {
00156
00157 Try {
00158
00159 if( sig->value->width == 0 ) {
00160
00161 expl = expression_create( NULL, NULL, EXP_OP_SIG, FALSE, curr_expr_id, 0, 0, 0, FALSE );
00162 curr_expr_id++;
00163
00164 } else if( sig->value->width == 1 ) {
00165
00166 expr = expression_create( NULL, NULL, EXP_OP_STATIC, FALSE, curr_expr_id, 0, 0, 0, FALSE );
00167 curr_expr_id++;
00168 vector_dealloc( expr->value );
00169 expr->value = vector_create( 32, VTYPE_VAL, VDATA_UL, TRUE );
00170 (void)vector_from_int( expr->value, sig->dim[0].lsb );
00171
00172 expl = expression_create( NULL, expr, EXP_OP_SBIT_SEL, FALSE, curr_expr_id, 0, 0, 0, FALSE );
00173 curr_expr_id++;
00174
00175 } else {
00176
00177 expt = expression_create( NULL, NULL, EXP_OP_STATIC, FALSE, curr_expr_id, 0, 0, 0, FALSE );
00178 curr_expr_id++;
00179 vector_dealloc( expt->value );
00180 expt->value = vector_create( 32, VTYPE_VAL, VDATA_UL, TRUE );
00181 (void)vector_from_int( expt->value, sig->dim[0].lsb );
00182
00183 expr = expression_create( NULL, NULL, EXP_OP_STATIC, FALSE, curr_expr_id, 0, 0, 0, FALSE );
00184 curr_expr_id++;
00185 vector_dealloc( expr->value );
00186 expr->value = vector_create( 32, VTYPE_VAL, VDATA_UL, TRUE );
00187 (void)vector_from_int( expr->value, ((sig->value->width - 1) + sig->dim[0].lsb) );
00188
00189 switch( sig->suppl.part.type ) {
00190 case SSUPPL_TYPE_IMPLICIT : op = EXP_OP_MBIT_SEL; break;
00191 case SSUPPL_TYPE_IMPLICIT_POS : op = EXP_OP_MBIT_POS; break;
00192 case SSUPPL_TYPE_IMPLICIT_NEG : op = EXP_OP_MBIT_NEG; break;
00193 default : assert( 0 ); break;
00194 }
00195
00196 expl = expression_create( expt, expr, op, FALSE, curr_expr_id, 0, 0, 0, FALSE );
00197 curr_expr_id++;
00198
00199 }
00200
00201 /* Add signal name and expression to FSM var binding list */
00202 fsm_var_bind_add( sig->name, expl, funit_name );
00203
00204 } Catch_anonymous {
00205 vsignal_dealloc( sig );
00206 expression_dealloc( expl, FALSE );
00207 Throw 0;
00208 }
00209
00210 /* Deallocate signal */
00211 vsignal_dealloc( sig );
00212
00213 } else {
00214 error = TRUE;
00215 }
00216
00217 }
00218
00219 /* Create statement for top-level expression, this statement will work like a continuous assignment */
00220 if( !error ) {
00221 stmt = statement_create( expl, NULL, 0 );
00222 stmt->suppl.part.head = 1;
00223 stmt->suppl.part.stop_true = 1;
00224 stmt->suppl.part.stop_false = 1;
00225 stmt->suppl.part.cont = 1;
00226 stmt->next_true = stmt;
00227 stmt->next_false = stmt;
00228 fsm_var_stmt_add( stmt, funit_name );
00229 } else {
00230 expl = NULL;
00231 }
00232
00233 PROFILE_END;
00234
00235 return( expl );
00236
00237 }
|
|
||||||||||||||||
|
00527 { PROFILE(FSM_ARG_PARSE_TRANS);
00528
00529 expression* from_state; /* Pointer to from_state value of transition */
00530 expression* to_state; /* Pointer to to_state value of transition */
00531 char* str; /* String version of expression value */
00532 char* tmp; /* Temporary pointer to string */
00533
00534 assert( expr != NULL );
00535
00536 /* Convert expression value to a string */
00537 tmp = str = vector_to_string( expr->value, ESUPPL_STATIC_BASE( expr->suppl ), FALSE );
00538
00539 Try {
00540
00541 if( (from_state = fsm_arg_parse_value( &str, funit )) == NULL ) {
00542 unsigned int rv = snprintf( user_msg, USER_MSG_LENGTH, "Left-hand side FSM transition value must be a constant value or parameter, line: %d, file: %s",
00543 expr->line, obf_file( funit->filename ) );
00544 assert( rv < USER_MSG_LENGTH );
00545 print_output( user_msg, FATAL, __FILE__, __LINE__ );
00546 Throw 0;
00547 } else {
00548
00549 if( (str[0] != '-') || (str[1] != '>') ) {
00550 unsigned int rv = snprintf( user_msg, USER_MSG_LENGTH, "FSM transition values must contain the string '->' between them, line: %d, file: %s",
00551 expr->line, obf_file( funit->filename ) );
00552 assert( rv < USER_MSG_LENGTH );
00553 print_output( user_msg, FATAL, __FILE__, __LINE__ );
00554 Throw 0;
00555 } else {
00556 str += 2;
00557 }
00558
00559 if( (to_state = fsm_arg_parse_value( &str, funit )) == NULL ) {
00560 unsigned int rv = snprintf( user_msg, USER_MSG_LENGTH, "Right-hand side FSM transition value must be a constant value or parameter, line: %d, file: %s",
00561 expr->line, obf_file( funit->filename ) );
00562 assert( rv < USER_MSG_LENGTH );
00563 print_output( user_msg, FATAL, __FILE__, __LINE__ );
00564 Throw 0;
00565 } else {
00566
00567 /* Add both expressions to FSM arc list */
00568 fsm_add_arc( table, from_state, to_state );
00569
00570 }
00571
00572 }
00573
00574 } Catch_anonymous {
00575 free_safe( tmp, (strlen( tmp ) + 1) );
00576 Throw 0;
00577 }
00578
00579 /* Deallocate string */
00580 free_safe( tmp, (strlen( tmp ) + 1) );
00581
00582 PROFILE_END;
00583
00584 }
|
|
||||||||||||
|
00328 { PROFILE(FSM_ARG_PARSE_VALUE);
00329
00330 expression* expr = NULL; /* Pointer to expression containing state value */
00331 expression* left; /* Left child expression */
00332 expression* right = NULL; /* Right child expression */
00333 vector* vec; /* Pointer to newly allocated vector value */
00334 int base; /* Base of parsed string value */
00335 char str_val[256]; /* String version of value parsed */
00336 int msb; /* Most-significant bit position of parameter */
00337 int lsb; /* Least-significant bit position of parameter */
00338 int chars_read; /* Number of characters read from sscanf() */
00339 mod_parm* mparm; /* Pointer to module parameter found */
00340
00341 vector_from_string( str, FALSE, &vec, &base );
00342
00343 if( vec != NULL ) {
00344
00345 /* This value represents a static value, handle as such */
00346 Try {
00347 expr = expression_create( NULL, NULL, EXP_OP_STATIC, FALSE, curr_expr_id, 0, 0, 0, FALSE );
00348 } Catch_anonymous {
00349 vector_dealloc( vec );
00350 Throw 0;
00351 }
00352 curr_expr_id++;
00353
00354 vector_dealloc( expr->value );
00355 expr->value = vec;
00356
00357 } else {
00358
00359 /* This value should be a parameter value, parse it */
00360 if( sscanf( *str, "%[a-zA-Z0-9_]\[%d:%d]%n", str_val, &msb, &lsb, &chars_read ) == 3 ) {
00361 *str = *str + chars_read;
00362 if( (mparm = mod_parm_find( str_val, funit->param_head )) != NULL ) {
00363
00364 /* Generate left child expression */
00365 left = expression_create( NULL, NULL, EXP_OP_STATIC, FALSE, curr_expr_id, 0, 0, 0, FALSE );
00366 curr_expr_id++;
00367 vector_dealloc( left->value );
00368 left->value = vector_create( 32, VTYPE_VAL, VDATA_UL, TRUE );
00369 (void)vector_from_int( left->value, msb );
00370
00371 /* Generate right child expression */
00372 Try {
00373 right = expression_create( NULL, NULL, EXP_OP_STATIC, FALSE, curr_expr_id, 0, 0, 0, FALSE );
00374 } Catch_anonymous {
00375 expression_dealloc( left, FALSE );
00376 Throw 0;
00377 }
00378 curr_expr_id++;
00379 vector_dealloc( right->value );
00380 right->value = vector_create( 32, VTYPE_VAL, VDATA_UL, TRUE );
00381 (void)vector_from_int( right->value, lsb );
00382
00383 /* Generate multi-bit parameter expression */
00384 Try {
00385 expr = expression_create( right, left, EXP_OP_PARAM_MBIT, FALSE, curr_expr_id, 0, 0, 0, FALSE );
00386 } Catch_anonymous {
00387 expression_dealloc( left, FALSE );
00388 expression_dealloc( right, FALSE );
00389 Throw 0;
00390 }
00391 curr_expr_id++;
00392 exp_link_add( expr, &(mparm->exp_head), &(mparm->exp_tail) );
00393
00394 }
00395 } else if( sscanf( *str, "%[a-zA-Z0-9_]\[%d+:%d]%n", str_val, &msb, &lsb, &chars_read ) == 3 ) {
00396 *str = *str + chars_read;
00397 if( (mparm = mod_parm_find( str_val, funit->param_head )) != NULL ) {
00398
00399 /* Generate left child expression */
00400 left = expression_create( NULL, NULL, EXP_OP_STATIC, FALSE, curr_expr_id, 0, 0, 0, FALSE );
00401 curr_expr_id++;
00402 vector_dealloc( left->value );
00403 left->value = vector_create( 32, VTYPE_VAL, VDATA_UL, TRUE );
00404 (void)vector_from_int( left->value, msb );
00405
00406 /* Generate right child expression */
00407 Try {
00408 right = expression_create( NULL, NULL, EXP_OP_STATIC, FALSE, curr_expr_id, 0, 0, 0, FALSE );
00409 } Catch_anonymous {
00410 expression_dealloc( left, FALSE );
00411 Throw 0;
00412 }
00413 curr_expr_id++;
00414 vector_dealloc( right->value );
00415 right->value = vector_create( 32, VTYPE_VAL, VDATA_UL, TRUE );
00416 (void)vector_from_int( right->value, lsb );
00417
00418 /* Generate variable positive multi-bit parameter expression */
00419 Try {
00420 expr = expression_create( right, left, EXP_OP_PARAM_MBIT_POS, FALSE, curr_expr_id, 0, 0, 0, FALSE );
00421 } Catch_anonymous {
00422 expression_dealloc( left, FALSE );
00423 expression_dealloc( right, FALSE );
00424 Throw 0;
00425 }
00426 curr_expr_id++;
00427 exp_link_add( expr, &(mparm->exp_head), &(mparm->exp_tail) );
00428
00429 }
00430 } else if( sscanf( *str, "%[a-zA-Z0-9_]\[%d-:%d]%n", str_val, &msb, &lsb, &chars_read ) == 3 ) {
00431 *str = *str + chars_read;
00432 if( (mparm = mod_parm_find( str_val, funit->param_head )) != NULL ) {
00433
00434 /* Generate left child expression */
00435 left = expression_create( NULL, NULL, EXP_OP_STATIC, FALSE, curr_expr_id, 0, 0, 0, FALSE );
00436 curr_expr_id++;
00437 vector_dealloc( left->value );
00438 left->value = vector_create( 32, VTYPE_VAL, VDATA_UL, TRUE );
00439 (void)vector_from_int( left->value, msb );
00440
00441 /* Generate right child expression */
00442 Try {
00443 right = expression_create( NULL, NULL, EXP_OP_STATIC, FALSE, curr_expr_id, 0, 0, 0, FALSE );
00444 } Catch_anonymous {
00445 expression_dealloc( left, FALSE );
00446 Throw 0;
00447 }
00448 curr_expr_id++;
00449 vector_dealloc( right->value );
00450 right->value = vector_create( 32, VTYPE_VAL, VDATA_UL, TRUE );
00451 (void)vector_from_int( right->value, lsb );
00452
00453 /* Generate variable positive multi-bit parameter expression */
00454 Try {
00455 expr = expression_create( right, left, EXP_OP_PARAM_MBIT_NEG, FALSE, curr_expr_id, 0, 0, 0, FALSE );
00456 } Catch_anonymous {
00457 expression_dealloc( left, FALSE );
00458 expression_dealloc( right, FALSE );
00459 Throw 0;
00460 }
00461 curr_expr_id++;
00462 exp_link_add( expr, &(mparm->exp_head), &(mparm->exp_tail) );
00463
00464 }
00465 } else if( sscanf( *str, "%[a-zA-Z0-9_]\[%d]%n", str_val, &lsb, &chars_read ) == 2 ) {
00466 *str = *str + chars_read;
00467 if( (mparm = mod_parm_find( str_val, funit->param_head )) != NULL ) {
00468
00469 /* Generate left child expression */
00470 left = expression_create( NULL, NULL, EXP_OP_STATIC, FALSE, curr_expr_id, 0, 0, 0, FALSE );
00471 curr_expr_id++;
00472 vector_dealloc( left->value );
00473 left->value = vector_create( 32, VTYPE_VAL, VDATA_UL, TRUE );
00474 (void)vector_from_int( left->value, lsb );
00475
00476 /* Generate single-bit parameter expression */
00477 Try {
00478 expr = expression_create( NULL, left, EXP_OP_PARAM_SBIT, FALSE, curr_expr_id, 0, 0, 0, FALSE );
00479 } Catch_anonymous {
00480 expression_dealloc( left, FALSE );
00481 Throw 0;
00482 }
00483 curr_expr_id++;
00484 exp_link_add( expr, &(mparm->exp_head), &(mparm->exp_tail) );
00485
00486 }
00487 } else if( sscanf( *str, "%[a-zA-Z0-9_]%n", str_val, &chars_read ) == 1 ) {
00488 *str = *str + chars_read;
00489 if( (mparm = mod_parm_find( str_val, funit->param_head )) != NULL ) {
00490
00491 /* Generate parameter expression */
00492 expr = expression_create( NULL, NULL, EXP_OP_PARAM, FALSE, curr_expr_id, 0, 0, 0, FALSE );
00493 curr_expr_id++;
00494 exp_link_add( expr, &(mparm->exp_head), &(mparm->exp_tail) );
00495
00496 }
00497 } else {
00498 expr = NULL;
00499 }
00500
00501 }
00502
00503 PROFILE_END;
00504
00505 return( expr );
00506
00507 }
|
|
|
This static value contains the current expression ID number to use for the next expression found, it is incremented by one when an expression is found. This allows us to have a unique expression ID for each expression (since expressions have no intrinsic names). |
|
|
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. |
1.3.4