#include "defines.h"
Go to the source code of this file.
Functions | |
| fsm_var * | fsm_var_add (const char *funit_name, expression *in_state, expression *out_state, char *name, bool exclude) |
| Allocates, initializes and adds FSM variable to global list. | |
| void | fsm_var_bind_add (char *sig_name, expression *expr, char *funit_name) |
| Adds specified signal and expression to binding list. | |
| void | fsm_var_stmt_add (statement *stmt, char *funit_name) |
| Add specified functional unit and statement to binding list. | |
| void | fsm_var_bind () |
| Performs FSM signal/expression binding process. | |
| void | fsm_var_cleanup () |
| Cleans up the global lists used in this file. | |
|
||||||||||||||||||||||||
|
Allocates, initializes and adds FSM variable to global list.
00108 { PROFILE(FSM_VAR_ADD);
00109
00110 fsm_var* new_var = NULL; /* Pointer to newly created FSM variable */
00111 funit_link* funitl; /* Pointer to functional unit link found */
00112 fsm* table; /* Pointer to newly create FSM */
00113
00114 /* If we have not parsed design, add new FSM variable to list */
00115 if( db_list[curr_db]->funit_head == NULL ) {
00116
00117 new_var = (fsm_var*)malloc_safe( sizeof( fsm_var ) );
00118 new_var->funit = strdup_safe( funit_name );
00119 new_var->name = NULL;
00120 new_var->ivar = in_state;
00121 new_var->ovar = out_state;
00122 new_var->iexp = NULL;
00123 new_var->table = NULL;
00124 new_var->exclude = exclude;
00125 new_var->next = NULL;
00126
00127 if( fsm_var_head == NULL ) {
00128 fsm_var_head = fsm_var_tail = new_var;
00129 } else {
00130 fsm_var_tail->next = new_var;
00131 fsm_var_tail = new_var;
00132 }
00133
00134 } else {
00135
00136 if( (funitl = funit_link_find( funit_name, FUNIT_MODULE, db_list[curr_db]->funit_head )) != NULL ) {
00137 table = fsm_create( in_state, out_state, exclude );
00138 if( name != NULL ) {
00139 table->name = strdup_safe( name );
00140 }
00141 in_state->table = table;
00142 out_state->table = table;
00143 fsm_link_add( table, &(funitl->funit->fsm_head), &(funitl->funit->fsm_tail) );
00144 } else {
00145 assert( funitl != NULL );
00146 }
00147
00148 }
00149
00150 return( new_var );
00151
00152 }
|
|
|
Performs FSM signal/expression binding process.
After the signals and expressions have been bound, the FSM statement binding list is iterated through binding all statements containing FSM state expressions to the functional unit that it is a part of. If the statement contains an FSM state expression that is an output state expression, create the FSM structure for this FSM and add it to the design.
00392 { PROFILE(FSM_VAR_BIND);
00393
00394 fv_bind* curr = NULL; /* Pointer to current FSM variable */
00395 fv_bind* tmp; /* Temporary pointer to FSM bind structure */
00396
00397 Try {
00398
00399 curr = fsm_var_bind_head;
00400 while( curr != NULL ) {
00401
00402 /* Perform binding */
00403 fsm_var_bind_expr( curr->sig_name, curr->expr, curr->funit_name );
00404
00405 tmp = curr->next;
00406
00407 /* Deallocate memory for this bind structure */
00408 free_safe( curr->sig_name, (strlen( curr->sig_name ) + 1) );
00409 free_safe( curr->funit_name, (strlen( curr->funit_name ) + 1) );
00410 free_safe( curr, sizeof( fv_bind ) );
00411
00412 curr = tmp;
00413
00414 }
00415
00416 } Catch_anonymous {
00417 while( curr != NULL ) {
00418 tmp = curr->next;
00419 free_safe( curr->sig_name, (strlen( curr->sig_name ) + 1) );
00420 free_safe( curr->funit_name, (strlen( curr->funit_name ) + 1) );
00421 free_safe( curr, sizeof( fv_bind ) );
00422 curr = tmp;
00423 }
00424 curr = fsm_var_stmt_head;
00425 while( curr != NULL ) {
00426 tmp = curr->next;
00427 free_safe( curr->funit_name, (strlen( curr->funit_name ) + 1) );
00428 free_safe( curr, sizeof( fv_bind ) );
00429 curr = tmp;
00430 }
00431 Throw 0;
00432 }
00433
00434 curr = fsm_var_stmt_head;
00435 while( curr != NULL ) {
00436
00437 /* Bind statement to functional unit */
00438 (void)fsm_var_bind_stmt( curr->stmt, curr->funit_name );
00439
00440 tmp = curr->next;
00441
00442 /* Deallocate memory for this bind structure */
00443 free_safe( curr->funit_name, (strlen( curr->funit_name ) + 1) );
00444 free_safe( curr, sizeof( fv_bind ) );
00445
00446 curr = tmp;
00447
00448 }
00449
00450 PROFILE_END;
00451
00452 }
|
|
||||||||||||||||
|
Adds specified signal and expression to binding list.
00317 { PROFILE(FSM_VAR_BIND_ADD);
00318
00319 fv_bind* fvb; /* Pointer to new FSM variable binding structure */
00320
00321 /* If the functional unit list does not exist yet, we need to bind this later; otherwise, bind now */
00322 if( db_list[curr_db]->funit_head == NULL ) {
00323
00324 /* Allocate and initialize FSM variable bind structure */
00325 fvb = (fv_bind*)malloc_safe( sizeof( fv_bind ) );
00326 fvb->sig_name = strdup_safe( sig_name );
00327 fvb->expr = expr;
00328 fvb->funit_name = strdup_safe( funit_name );
00329 fvb->next = NULL;
00330
00331 /* Add new structure to the global list */
00332 if( fsm_var_bind_head == NULL ) {
00333 fsm_var_bind_head = fsm_var_bind_tail = fvb;
00334 } else {
00335 fsm_var_bind_tail->next = fvb;
00336 fsm_var_bind_tail = fvb;
00337 }
00338
00339 } else {
00340
00341 fsm_var_bind_expr( sig_name, expr, funit_name );
00342
00343 }
00344
00345 PROFILE_END;
00346
00347 }
|
|
|
Cleans up the global lists used in this file. Iterates through the various global lists in this file, deallocating all memory. This function is called when an error has occurred during the parsing stage.
00520 { PROFILE(FSM_VAR_CLEANUP);
00521
00522 fsm_var* curr_fv; /* Pointer to the current fsm_var structure */
00523 fsm_var* tmp_fv; /* Temporary pointer */
00524 fv_bind* curr_fvb = fsm_var_bind_head; /* Pointer to the current fv_bind structure */
00525 fv_bind* tmp_fvb; /* Temporary pointer */
00526
00527 /* Deallocate fsm_var list */
00528 curr_fv = fsm_var_head;
00529 while( curr_fv != NULL ) {
00530 tmp_fv = curr_fv;
00531 curr_fv = curr_fv->next;
00532
00533 free_safe( tmp_fv->funit, (strlen( curr_fv->funit ) + 1) );
00534 expression_dealloc( tmp_fv->ivar, FALSE );
00535 expression_dealloc( tmp_fv->ovar, FALSE );
00536 free_safe( tmp_fv, sizeof( fsm_var ) );
00537 }
00538 fsm_var_head = fsm_var_tail = NULL;
00539
00540 /* Deallocate fsm_var_bind list */
00541 curr_fvb = fsm_var_bind_head;
00542 while( curr_fvb != NULL ) {
00543 tmp_fvb = curr_fvb;
00544 curr_fvb = curr_fvb->next;
00545
00546 free_safe( tmp_fvb->sig_name, (strlen( tmp_fvb->sig_name ) + 1) );
00547 free_safe( tmp_fvb->funit_name, (strlen( tmp_fvb->funit_name ) + 1) );
00548 expression_dealloc( tmp_fvb->expr, FALSE );
00549 free_safe( tmp_fvb, sizeof( fv_bind ) );
00550 }
00551 fsm_var_bind_head = fsm_var_bind_tail = NULL;
00552
00553 /* Deallocate fsm_var_stmt list */
00554 curr_fvb = fsm_var_stmt_head;
00555 while( curr_fvb != NULL ) {
00556 tmp_fvb = curr_fvb;
00557 curr_fvb = curr_fvb->next;
00558
00559 free_safe( tmp_fvb->funit_name, (strlen( tmp_fvb->funit_name ) + 1) );
00560 expression_dealloc( tmp_fvb->stmt->exp, FALSE );
00561 statement_dealloc( tmp_fvb->stmt );
00562 free_safe( tmp_fvb, sizeof( fv_bind ) );
00563 }
00564 fsm_var_stmt_head = fsm_var_stmt_tail = NULL;
00565
00566 PROFILE_END;
00567
00568 }
|
|
||||||||||||
|
Add specified functional unit and statement to binding list. Allocates and initializes an FSM variable binding entry and adds it to the fsm_var_stmt list for later processing.
00356 { PROFILE(FSM_VAR_STMT_ADD);
00357
00358 fv_bind* fvb; /* Pointer to new FSM variable binding structure */
00359
00360 fvb = (fv_bind*)malloc_safe( sizeof( fv_bind ) );
00361 fvb->stmt = stmt;
00362 fvb->funit_name = strdup_safe( funit_name );
00363 fvb->next = NULL;
00364
00365 /* Add new structure to the head of the global list */
00366 if( fsm_var_stmt_head == NULL ) {
00367 fsm_var_stmt_head = fsm_var_stmt_tail = fvb;
00368 } else {
00369 fvb->next = fsm_var_stmt_head;
00370 fsm_var_stmt_head = fvb;
00371 }
00372
00373 PROFILE_END;
00374
00375 }
|
1.3.4