assertion.h File Reference

Contains functions for handling assertion coverage. More...

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

Go to the source code of this file.

Functions

void assertion_parse (const char *arg)
 Parses -A command-line option to score command.
void assertion_parse_attr (attr_param *ap, int line, const func_unit *funit, bool exclude)
 Parses an in-line attribute for assertion coverage information.
void assertion_get_stats (const func_unit *funit, unsigned int *hit, unsigned int *excluded, unsigned int *total)
 Gather statistics for assertion coverage.
void assertion_report (FILE *ofile, bool verbose)
 Generates report output for assertion coverage.
void assertion_get_funit_summary (func_unit *funit, unsigned int *hit, unsigned int *excluded, unsigned int *total)
 Retrieves the total and hit counts of assertions for the specified functional unit.
void assertion_collect (func_unit *funit, int cov, char ***inst_names, int **excludes, unsigned int *inst_size)
 Collects uncovered and covered assertion instance names for the given module.
void assertion_get_coverage (const func_unit *funit, const char *inst_name, char **assert_mod, str_link **cp_head, str_link **cp_tail)
 Gets missed coverage point descriptions for the given assertion module.

Detailed Description

Contains functions for handling assertion coverage.

Author:
Trevor Williams (phase1geo@gmail.com)
Date:
4/4/2006

Function Documentation

void assertion_collect ( func_unit funit,
int  cov,
char ***  inst_names,
int **  excludes,
unsigned int *  inst_size 
)

Collects uncovered and covered assertion instance names for the given module.

Searches the specified functional unit, collecting all uncovered or covered assertion module instance names.

Parameters:
funit Pointer to functional unit
cov Specifies if uncovered (0) or covered (1) assertions should be looked for
inst_names Pointer to array of uncovered instance names found within the specified functional unit
excludes Pointer to array of integers that contain the exclude information for the given instance names
inst_size Number of valid elements in the uncov_inst_names array

References isuppl_u::assert_ovl, ovl_collect(), isuppl_u::part, PROFILE, and PROFILE_END.

00507   { PROFILE(ASSERTION_COLLECT);
00508   
00509   /* Initialize outputs */
00510   *inst_names = NULL;
00511   *excludes   = NULL;
00512   *inst_size  = 0;
00513     
00514   /* If OVL assertion coverage is needed, get this information */
00515   if( info_suppl.part.assert_ovl == 1 ) {
00516     ovl_collect( funit, cov, inst_names, excludes, inst_size );
00517   }
00518     
00519   PROFILE_END;
00520 
00521 }

void assertion_get_coverage ( const func_unit funit,
const char *  inst_name,
char **  assert_mod,
str_link **  cp_head,
str_link **  cp_tail 
)

Gets missed coverage point descriptions for the given assertion module.

Finds all of the coverage points for the given assertion instance and stores their string descriptions and execution counts in the cp list.

Parameters:
funit Pointer to functional unit
inst_name Name of assertion module instance to retrieve
assert_mod Pointer to assertion module name and filename being retrieved
cp_head Pointer to head of list of strings/integers containing coverage point information
cp_tail Pointer to tail of list of strings/integers containing coverage point information

References isuppl_u::assert_ovl, ovl_get_coverage(), isuppl_u::part, PROFILE, and PROFILE_END.

00533   { PROFILE(ASSERTION_GET_COVERAGE);
00534 
00535   /* Find functional unit */
00536   *cp_head = *cp_tail = NULL;
00537 
00538   /* If OVL assertion coverage is needed, get this information */
00539   if( info_suppl.part.assert_ovl == 1 ) {
00540     ovl_get_coverage( funit, inst_name, assert_mod, cp_head, cp_tail );
00541   }
00542 
00543   PROFILE_END;
00544  
00545 }

void assertion_get_funit_summary ( func_unit funit,
unsigned int *  hit,
unsigned int *  excluded,
unsigned int *  total 
)

Retrieves the total and hit counts of assertions for the specified functional unit.

Counts the total number and number of hit assertions for the specified functional unit.

Parameters:
funit Pointer to functional unit
hit Pointer to the number of hit assertions in the specified functional unit
excluded Pointer to the number of excluded assertions
total Pointer to the total number of assertions in the specified functional unit

References isuppl_u::assert_ovl, ovl_get_funit_stats(), isuppl_u::part, PROFILE, and PROFILE_END.

00483   { PROFILE(ASSERTION_GET_FUNIT_SUMMARY);
00484         
00485   /* Initialize total and hit counts */
00486   *hit      = 0;
00487   *excluded = 0;
00488   *total    = 0;
00489   
00490   if( info_suppl.part.assert_ovl == 1 ) {
00491     ovl_get_funit_stats( funit, hit, excluded, total );
00492   }
00493     
00494   PROFILE_END;
00495   
00496 }

void assertion_get_stats ( const func_unit funit,
unsigned int *  hit,
unsigned int *  excluded,
unsigned int *  total 
)

Gather statistics for assertion coverage.

Gets total and hit assertion coverage statistics for the given functional unit.

Parameters:
funit Pointer to current functional unit
hit Pointer to the total number of hit assertions in this functional unit
excluded Pointer to the number of excluded assertions
total Pointer to the total number of assertions found in this functional unit

References isuppl_u::assert_ovl, ovl_get_funit_stats(), isuppl_u::part, PROFILE, and PROFILE_END.

Referenced by report_gather_funit_stats(), and report_gather_instance_stats().

00077   { PROFILE(ASSERTION_GET_STATS);
00078 
00079   assert( funit != NULL );
00080 
00081   /* Initialize total and hit values */
00082   *hit      = 0;
00083   *excluded = 0;
00084   *total    = 0;
00085 
00086   /* If OVL assertion coverage is needed, check this functional unit */
00087   if( info_suppl.part.assert_ovl == 1 ) {
00088     ovl_get_funit_stats( funit, hit, excluded, total );
00089   }
00090 
00091   PROFILE_END;
00092 
00093 }

void assertion_parse ( const char *  arg  ) 

Parses -A command-line option to score command.

Parameters:
arg Command-line argument specified in -A option to score command to parse

Parses the specified command-line argument as an assertion to consider for coverage.

References PROFILE, and PROFILE_END.

00050                                                     { PROFILE(ASSERTION_PARSE);
00051 
00052   PROFILE_END;
00053 
00054 }

void assertion_parse_attr ( attr_param ap,
int  line,
const func_unit funit,
bool  exclude 
)

Parses an in-line attribute for assertion coverage information.

Parses the specified assertion attribute for assertion coverage details.

Parameters:
ap Pointer to attribute to parse
line First line number of assertion
funit Pointer to current functional unit containing this attribute
exclude If TRUE, excludes this assertion from coverage consideration

References PROFILE, and PROFILE_END.

Referenced by attribute_parse().

00064   { PROFILE(ASSERTION_PARSE_ATTR);
00065 
00066   PROFILE_END;
00067 }

void assertion_report ( FILE *  ofile,
bool  verbose 
)

Generates report output for assertion coverage.

Outputs assertion coverage report information to the given file handle.

Parameters:
ofile File to output report contents to
verbose Specifies if verbose report output needs to be generated

References assertion_display_funit_summary(), assertion_display_instance_summary(), assertion_funit_summary(), assertion_funit_verbose(), assertion_instance_summary(), assertion_instance_verbose(), curr_db, FALSE, funit_head, inst_link_s::inst, db_s::inst_head, funit_inst_s::name_diff, inst_link_s::next, PROFILE, PROFILE_END, report_covered, report_instance, and funit_inst_s::suppl.

Referenced by report_generate().

00419   { PROFILE(ASSERTION_REPORT);
00420 
00421   bool       missed_found = FALSE;  /* If set to TRUE, lines were found to be missed */
00422   inst_link* instl;                 /* Pointer to current instance link */
00423   int        acc_hits     = 0;      /* Total number of assertions hit */
00424   int        acc_total    = 0;      /* Total number of assertions in design */
00425 
00426   fprintf( ofile, "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
00427   fprintf( ofile, "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~   ASSERTION COVERAGE RESULTS   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
00428   fprintf( ofile, "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
00429 
00430   if( report_instance ) {
00431 
00432     fprintf( ofile, "Instance                                           Hit/ Miss/Total    Percent hit\n" );
00433     fprintf( ofile, "---------------------------------------------------------------------------------------------------------------------\n" );
00434 
00435     instl = db_list[curr_db]->inst_head;
00436     while( instl != NULL ) {
00437       missed_found |= assertion_instance_summary( ofile, instl->inst, (instl->inst->suppl.name_diff ? "<NA>" : "*"), &acc_hits, &acc_total );
00438       instl = instl->next;
00439     }
00440     fprintf( ofile, "---------------------------------------------------------------------------------------------------------------------\n" );
00441     (void)assertion_display_instance_summary( ofile, "Accumulated", acc_hits, acc_total );
00442 
00443     if( verbose && (missed_found || report_covered) ) {
00444       fprintf( ofile, "---------------------------------------------------------------------------------------------------------------------\n" );
00445       instl = db_list[curr_db]->inst_head;
00446       while( instl != NULL ) {
00447         assertion_instance_verbose( ofile, instl->inst, (instl->inst->suppl.name_diff ? "<NA>" : "*") );
00448         instl = instl->next;
00449       }
00450 
00451     }
00452 
00453   } else {
00454 
00455     fprintf( ofile, "Module/Task/Function      Filename                 Hit/ Miss/Total    Percent hit\n" );
00456     fprintf( ofile, "---------------------------------------------------------------------------------------------------------------------\n" );
00457 
00458     missed_found = assertion_funit_summary( ofile, db_list[curr_db]->funit_head, &acc_hits, &acc_total );
00459     fprintf( ofile, "---------------------------------------------------------------------------------------------------------------------\n" );
00460     (void)assertion_display_funit_summary( ofile, "Accumulated", "", acc_hits, acc_total );
00461 
00462     if( verbose && (missed_found || report_covered) ) {
00463       fprintf( ofile, "---------------------------------------------------------------------------------------------------------------------\n" );
00464       assertion_funit_verbose( ofile, db_list[curr_db]->funit_head );
00465     }
00466 
00467   }
00468 
00469   fprintf( ofile, "\n\n" );
00470 
00471   PROFILE_END;
00472 
00473 }

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