Main Page | Modules | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

/Users/trevorw/projects/release/covered-0.7.4/src/fsm_var.h File Reference


Detailed Description

Contains functions for handling FSM variable structure.

Author:
Trevor Williams (phase1geo@gmail.com)
Date:
10/3/2003

#include "defines.h"

Go to the source code of this file.

Functions

fsm_varfsm_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.


Function Documentation

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.

Returns:
Returns pointer to newly allocated FSM variable.
Adds the specified Verilog hierarchical scope to a list of FSM scopes to find during the parsing phase.
Parameters:
funit_name  String containing functional unit containing FSM state variable
in_state  Pointer to expression containing input state
out_state  Pointer to expression containing output state
name  Name of this FSM (only valid for attributes
exclude  If TRUE, excludes the FSM from coverage consideration

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 }

void fsm_var_bind  ) 
 

Performs FSM signal/expression binding process.

Exceptions:
anonymous fsm_var_bind_expr Throw
After Verilog parsing has completed, this function should be called to bind all signals to their associated FSM state expressions and functional units. For each entry in the FSM binding list the signal name is looked in the functional unit specified in the binding entry. If the signal is found, the associated expression pointer is added to the signal's expression list and the expression's signal pointer is set to point at the found signal structure. If the signal was not found, an error message is reported to the user, specifying the signal did not exist in the design.

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 }

void fsm_var_bind_add char *  sig_name,
expression expr,
char *  funit_name
 

Adds specified signal and expression to binding list.

Exceptions:
anonymous fsm_var_bind_expr
Creates a new FSM binding structure and initializes it with the specified information. The FSM binding structure is then added to the global list of FSM binding structures to be bound after parsing is complete.
Parameters:
sig_name  Name of signal to bind
expr  Pointer to expression to bind
funit_name  Name of functional unit that will contain the expression and signal being bound

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 }

void fsm_var_cleanup  ) 
 

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 }

void fsm_var_stmt_add statement stmt,
char *  funit_name
 

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.

Parameters:
stmt  Pointer to statement containing FSM state expression
funit_name  Name of functional unit that will contain stmt

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 }


Generated on Wed Jun 17 22:19:22 2009 for Covered by doxygen 1.3.4