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

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


Detailed Description

Contains vector-related functions for signal vectors.

Author:
Trevor Williams (phase1geo@gmail.com)
Date:
12/1/2001

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

Go to the source code of this file.

Functions

void vector_init_ulong (vector *vec, ulong **value, ulong data_l, ulong data_h, bool owns_value, int width, int type)
 Initializes specified vector.

void vector_init_r64 (vector *vec, rv64 *value, double data, char *str, bool owns_value, int type)
 Initializes specified vector with realtime information.

void vector_init_r32 (vector *vec, rv32 *value, float data, char *str, bool owns_value, int type)
 Initializes specified vector with shortreal information.

vectorvector_create (int width, int type, int data_type, bool data)
 Creates and initializes new vector.

void vector_copy (const vector *from_vec, vector *to_vec)
 Copies contents of from_vec to to_vec.

void vector_copy_range (vector *to_vec, const vector *from_vec, int lsb)
void vector_clone (const vector *from_vec, vector **to_vec)
 Copies contents of from_vec to to_vec, allocating memory.

void vector_db_write (vector *vec, FILE *file, bool write_data, bool net)
 Displays vector information to specified database file.

void vector_db_read (vector **vec, char **line)
 Creates and parses current file line for vector information.

void vector_db_merge (vector *base, char **line, bool same)
 Reads and merges two vectors, placing the result into base vector.

void vector_merge (vector *base, vector *other)
 Merges two vectors, placing the result into the base vector.

int vector_get_eval_a (vector *vec, int index)
 Returns the value of the eval_a for the given bit index.

int vector_get_eval_b (vector *vec, int index)
 Returns the value of the eval_b for the given bit index.

int vector_get_eval_c (vector *vec, int index)
 Returns the value of the eval_c for the given bit index.

int vector_get_eval_d (vector *vec, int index)
 Returns the value of the eval_d for the given bit index.

int vector_get_eval_ab_count (vector *vec)
 Counts the number of eval_a/b bits set in the given vector.

int vector_get_eval_abc_count (vector *vec)
 Counts the number of eval_a/b/c bits set in the given vector.

int vector_get_eval_abcd_count (vector *vec)
 Counts the number of eval_a/b/c/d bits set in the given vector.

char * vector_get_toggle01_ulong (ulong **value, int width)
 Returns string containing toggle 0 -> 1 information in binary format.

char * vector_get_toggle10_ulong (ulong **value, int width)
 Returns string containing toggle 1 -> 0 information in binary format.

void vector_display_toggle01_ulong (ulong **value, int width, FILE *ofile)
 Outputs the toggle01 information from the specified nibble to the specified output stream.

void vector_display_toggle10_ulong (ulong **value, int width, FILE *ofile)
 Outputs the toggle10 information from the specified nibble to the specified output stream.

void vector_display_value_ulong (ulong **value, int width)
 Outputs the binary value of the specified nibble array to standard output.

void vector_display_ulong (ulong **value, unsigned int width, unsigned int type)
 Outputs ulong vector to standard output.

void vector_display (const vector *vec)
 Outputs vector contents to standard output.

bool vector_set_value_ulong (vector *vec, ulong **value, unsigned int width)
 Sets specified vector value to new value and maintains coverage history.

bool vector_part_select_pull (vector *tgt, vector *src, int lsb, int msb, bool set_mem_rd)
 Sets specified target vector to bit range of source vector.

bool vector_part_select_push (vector *tgt, int tgt_lsb, int tgt_msb, const vector *src, int src_lsb, int src_msb, bool sign_extend)
 Sets specified target vector to bit range of source vector.

void vector_set_unary_evals (vector *vec)
 Sets eval_a/b bits according to unary coverage.

void vector_set_and_comb_evals (vector *tgt, vector *left, vector *right)
 Sets eval_a/b/c bits according to AND combinational logic coverage.

void vector_set_or_comb_evals (vector *tgt, vector *left, vector *right)
 Sets eval_a/b/c bits according to OR combinational logic coverage.

void vector_set_other_comb_evals (vector *tgt, vector *left, vector *right)
 Sets eval_a/b/c/d bits according to other combinational logic coverage.

bool vector_sign_extend (vector *vec, int last)
 Bit fills the given vector with the appropriate value starting at the last bit.

bool vector_is_unknown (const vector *vec)
 Returns TRUE if specified vector has unknown bits set.

bool vector_is_not_zero (const vector *vec)
 Returns TRUE if specified vector is a non-zero value (does not check unknown bit).

bool vector_set_to_x (vector *vec)
 Sets entire vector value to a value of X.

int vector_to_int (const vector *vec)
 Converts vector into integer value.

uint64 vector_to_uint64 (const vector *vec)
 Converts vector into a 64-bit unsigned integer value.

real64 vector_to_real64 (const vector *vec)
 Converts vector into a 64-bit real value.

void vector_to_sim_time (const vector *vec, uint64 scale, sim_time *time)
 Converts vector into a sim_time structure.

bool vector_from_int (vector *vec, int value)
 Converts integer into vector value.

bool vector_from_uint64 (vector *vec, uint64 value)
 Converts a 64-bit integer into a vector value.

bool vector_from_real64 (vector *vec, real64 value)
 Converts a 64-bit real into a vector value.

char * vector_to_string (vector *vec, int base, bool show_all)
 Converts vector into a string value in specified format.

void vector_from_string_fixed (vector *vec, const char *str)
 Converts a string to a preallocated vector.

void vector_from_string (char **str, bool quoted, vector **vec, int *base)
 Converts character string value into vector.

bool vector_vcd_assign (vector *vec, const char *value, int msb, int lsb)
 Assigns specified VCD value to specified vector.

void vector_toggle_count (vector *vec, unsigned int *tog01_cnt, unsigned int *tog10_cnt)
 Counts toggle01 and toggle10 information from specifed vector.

void vector_mem_rw_count (vector *vec, int lsb, int msb, unsigned int *wr_cnt, unsigned int *rd_cnt)
 Counts memory write and read information from specified vector.

bool vector_set_assigned (vector *vec, int msb, int lsb)
 Sets all assigned bits in vector bit value array within specified range.

bool vector_set_coverage_and_assign_ulong (vector *vec, const ulong *scratchl, const ulong *scratchh, int lsb, int msb)
 Set coverage information for given vector and assigns values from scratch arrays to vector.

bool vector_bitwise_and_op (vector *tgt, vector *src1, vector *src2)
 Performs bitwise AND operation on two source vectors.

bool vector_bitwise_nand_op (vector *tgt, vector *src1, vector *src2)
 Performs bitwise NAND operation on two source vectors.

bool vector_bitwise_or_op (vector *tgt, vector *src1, vector *src2)
 Performs bitwise OR operation on two source vectors.

bool vector_bitwise_nor_op (vector *tgt, vector *src1, vector *src2)
 Performs bitwise NOR operation on two source vectors.

bool vector_bitwise_xor_op (vector *tgt, vector *src1, vector *src2)
 Performs bitwise XOR operation on two source vectors.

bool vector_bitwise_nxor_op (vector *tgt, vector *src1, vector *src2)
 Performs bitwise NXOR operation on two source vectors.

bool vector_op_lt (vector *tgt, const vector *left, const vector *right)
 Performs less-than comparison of two vectors.

bool vector_op_le (vector *tgt, const vector *left, const vector *right)
 Performs less-than-or-equal comparison of two vectors.

bool vector_op_gt (vector *tgt, const vector *left, const vector *right)
 Performs greater-than comparison of two vectors.

bool vector_op_ge (vector *tgt, const vector *left, const vector *right)
 Performs greater-than-or-equal comparison of two vectors.

bool vector_op_eq (vector *tgt, const vector *left, const vector *right)
 Performs equal comparison of two vectors.

bool vector_ceq_ulong (const vector *left, const vector *right)
 Performs case equal comparison of two vectors and returns result.

bool vector_op_ceq (vector *tgt, const vector *left, const vector *right)
 Performs case equal comparison of two vectors.

bool vector_op_cxeq (vector *tgt, const vector *left, const vector *right)
 Performs casex equal comparison of two vectors.

bool vector_op_czeq (vector *tgt, const vector *left, const vector *right)
 Performs casez equal comparison of two vectors.

bool vector_op_ne (vector *tgt, const vector *left, const vector *right)
 Performs not-equal comparison of two vectors.

bool vector_op_cne (vector *tgt, const vector *left, const vector *right)
 Performs case not-equal comparison of two vectors.

bool vector_op_lor (vector *tgt, const vector *left, const vector *right)
 Performs logical-OR operation of two vectors.

bool vector_op_land (vector *tgt, const vector *left, const vector *right)
 Performs logical-AND operation of two vectors.

bool vector_op_lshift (vector *tgt, const vector *left, const vector *right)
 Performs left shift operation on left expression by right expression bits.

bool vector_op_rshift (vector *tgt, const vector *left, const vector *right)
 Performs right shift operation on left expression by right expression bits.

bool vector_op_arshift (vector *tgt, const vector *left, const vector *right)
 Performs arithmetic right shift operation on left expression by right expression bits.

bool vector_op_add (vector *tgt, const vector *left, const vector *right)
 Performs addition operation on left and right expression values.

bool vector_op_negate (vector *tgt, const vector *src)
 Performs a twos complement of the src vector and stores the new vector in tgt.

bool vector_op_subtract (vector *tgt, const vector *left, const vector *right)
 Performs subtraction operation on left and right expression values.

bool vector_op_multiply (vector *tgt, const vector *left, const vector *right)
 Performs multiplication operation on left and right expression values.

bool vector_op_divide (vector *tgt, const vector *left, const vector *right)
 Performs division operation on left and right vector values.

bool vector_op_modulus (vector *tgt, const vector *left, const vector *right)
 Performs modulus operation on left and right vector values.

bool vector_op_inc (vector *tgt, vecblk *tvb)
 Performs increment operation on specified vector.

bool vector_op_dec (vector *tgt, vecblk *tvb)
 Performs increment operation on specified vector.

bool vector_unary_inv (vector *tgt, const vector *src)
 Performs unary bitwise inversion operation on specified vector value.

bool vector_unary_and (vector *tgt, const vector *src)
 Performs unary AND operation on specified vector value.

bool vector_unary_nand (vector *tgt, const vector *src)
 Performs unary NAND operation on specified vector value.

bool vector_unary_or (vector *tgt, const vector *src)
 Performs unary OR operation on specified vector value.

bool vector_unary_nor (vector *tgt, const vector *src)
 Performs unary NOR operation on specified vector value.

bool vector_unary_xor (vector *tgt, const vector *src)
 Performs unary XOR operation on specified vector value.

bool vector_unary_nxor (vector *tgt, const vector *src)
 Performs unary NXOR operation on specified vector value.

bool vector_unary_not (vector *tgt, const vector *src)
 Performs unary logical NOT operation on specified vector value.

bool vector_op_expand (vector *tgt, const vector *left, const vector *right)
 Performs expansion operation.

bool vector_op_list (vector *tgt, const vector *left, const vector *right)
 Performs list operation.

void vector_dealloc_value (vector *vec)
 Deallocates the value structure for the given vector.

void vector_dealloc (vector *vec)
 Deallocates all memory allocated for vector.


Function Documentation

bool vector_bitwise_and_op vector tgt,
vector src1,
vector src2
 

Performs bitwise AND operation on two source vectors.

Returns:
Returns TRUE if assigned value differs from original vector value; otherwise, returns FALSE.
Performs a bitwise AND operation. Vector sizes will be properly compensated by placing zeroes.
Parameters:
tgt  Target vector for operation results to be stored
src1  Source vector 1 to perform operation on
src2  Source vector 2 to perform operation on

03172   { PROFILE(VECTOR_BITWISE_AND_OP);
03173   
03174   bool retval;  /* Return value for this function */
03175 
03176   switch( tgt->suppl.part.data_type ) {
03177     case VDATA_UL :
03178       { 
03179         ulong        scratchl[UL_DIV(MAX_BIT_WIDTH)];
03180         ulong        scratchh[UL_DIV(MAX_BIT_WIDTH)];
03181         unsigned int src1_size = UL_SIZE(src1->width);
03182         unsigned int src2_size = UL_SIZE(src2->width);
03183         unsigned int i;
03184         for( i=0; i<UL_SIZE(tgt->width); i++ ) {
03185           ulong* entry1 = src1->value.ul[i];
03186           ulong* entry2 = src2->value.ul[i];
03187           ulong  val1_l = (i<src1_size) ? entry1[VTYPE_INDEX_VAL_VALL] : 0;
03188           ulong  val1_h = (i<src1_size) ? entry1[VTYPE_INDEX_VAL_VALH] : 0;
03189           ulong  val2_l = (i<src2_size) ? entry2[VTYPE_INDEX_VAL_VALL] : 0;
03190           ulong  val2_h = (i<src2_size) ? entry2[VTYPE_INDEX_VAL_VALH] : 0;
03191           scratchl[i]   = ~(val1_h | val2_h) & (val1_l & val2_l);
03192           scratchh[i]   = (val1_h & val2_h) | (val1_h & val2_l) | (val2_h & val1_l);
03193         }
03194         retval = vector_set_coverage_and_assign_ulong( tgt, scratchl, scratchh, 0, (tgt->width - 1) );
03195       }
03196       break;
03197     default :  assert( 0 );  break;
03198   }
03199 
03200   PROFILE_END;
03201 
03202   return( retval );
03203  
03204 }

bool vector_bitwise_nand_op vector tgt,
vector src1,
vector src2
 

Performs bitwise NAND operation on two source vectors.

Returns:
Returns TRUE if assigned value differs from original vector value; otherwise, returns FALSE.
Performs a bitwise NAND operation. Vector sizes will be properly compensated by placing zeroes.
Parameters:
tgt  Target vector for operation results to be stored
src1  Source vector 1 to perform operation on
src2  Source vector 2 to perform operation on

03217   { PROFILE(VECTOR_BITWISE_NAND_OP);   
03218                                       
03219   bool retval;  /* Return value for this function */
03220                                       
03221   switch( tgt->suppl.part.data_type ) {
03222     case VDATA_UL :                  
03223       {
03224         static ulong scratchl[UL_DIV(MAX_BIT_WIDTH)];
03225         static ulong scratchh[UL_DIV(MAX_BIT_WIDTH)];
03226         unsigned int src1_size = UL_SIZE(src1->width);
03227         unsigned int src2_size = UL_SIZE(src2->width);
03228         unsigned int i;
03229         for( i=0; i<UL_SIZE(tgt->width); i++ ) {
03230           ulong* entry1 = src1->value.ul[i];
03231           ulong* entry2 = src2->value.ul[i];
03232           ulong  val1_l = (i<src1_size) ? entry1[VTYPE_INDEX_VAL_VALL] : 0;
03233           ulong  val1_h = (i<src1_size) ? entry1[VTYPE_INDEX_VAL_VALH] : 0;
03234           ulong  val2_l = (i<src2_size) ? entry2[VTYPE_INDEX_VAL_VALL] : 0;
03235           ulong  val2_h = (i<src2_size) ? entry2[VTYPE_INDEX_VAL_VALH] : 0;
03236           scratchl[i] = ~(val1_h | val2_h) & ~(val1_l & val2_l);
03237           scratchh[i] = (val1_h & val2_h) | (val1_h & ~val2_l) | (val2_h & ~val1_l);
03238         }
03239         retval = vector_set_coverage_and_assign_ulong( tgt, scratchl, scratchh, 0, (tgt->width - 1) );
03240       }
03241       break;
03242     default :  assert( 0 );  break; 
03243   }
03244 
03245   PROFILE_END;
03246 
03247   return( retval );
03248  
03249 }

bool vector_bitwise_nor_op vector tgt,
vector src1,
vector src2
 

Performs bitwise NOR operation on two source vectors.

Returns:
Returns TRUE if assigned value differs from original vector value; otherwise, returns FALSE.
Performs a bitwise NOR operation. Vector sizes will be properly compensated by placing zeroes.
Parameters:
tgt  Target vector for operation results to be stored
src1  Source vector 1 to perform operation on
src2  Source vector 2 to perform operation on

03307   { PROFILE(VECTOR_BITWISE_NOR_OP);
03308 
03309   bool retval;  /* Return value for this function */
03310 
03311   switch( tgt->suppl.part.data_type ) {
03312     case VDATA_UL :
03313       {
03314         static ulong scratchl[UL_DIV(MAX_BIT_WIDTH)];
03315         static ulong scratchh[UL_DIV(MAX_BIT_WIDTH)];
03316         unsigned int src1_size = UL_SIZE(src1->width);
03317         unsigned int src2_size = UL_SIZE(src2->width);
03318         unsigned int i;
03319         for( i=0; i<UL_SIZE(tgt->width); i++ ) {
03320           ulong* entry1 = src1->value.ul[i];
03321           ulong* entry2 = src2->value.ul[i];
03322           ulong  val1_l = (i<src1_size) ? entry1[VTYPE_INDEX_VAL_VALL] : 0;
03323           ulong  val1_h = (i<src1_size) ? entry1[VTYPE_INDEX_VAL_VALH] : 0;
03324           ulong  val2_l = (i<src2_size) ? entry2[VTYPE_INDEX_VAL_VALL] : 0;
03325           ulong  val2_h = (i<src2_size) ? entry2[VTYPE_INDEX_VAL_VALH] : 0;
03326           scratchl[i] = ~(val1_h | val2_h) & ~(val1_l | val2_l);
03327           scratchh[i] =  (val1_h & val2_h) |  (val1_h & val2_l) | (val2_h & val1_l);
03328         }
03329         retval = vector_set_coverage_and_assign_ulong( tgt, scratchl, scratchh, 0, (tgt->width - 1) );
03330       }
03331       break;
03332     default :  assert( 0 );  break;
03333   }
03334 
03335   PROFILE_END;
03336 
03337   return( retval );
03338 
03339 }

bool vector_bitwise_nxor_op vector tgt,
vector src1,
vector src2
 

Performs bitwise NXOR operation on two source vectors.

Returns:
Returns TRUE if assigned value differs from original vector value; otherwise, returns FALSE.
Performs a bitwise NXOR operation. Vector sizes will be properly compensated by placing zeroes.
Parameters:
tgt  Target vector for operation results to be stored
src1  Source vector 1 to perform operation on
src2  Source vector 2 to perform operation on

03397   { PROFILE(VECTOR_BITWISE_NXOR_OP);
03398   
03399   bool retval;  /* Return value for this function */
03400 
03401   switch( tgt->suppl.part.data_type ) {
03402     case VDATA_UL :
03403       { 
03404         static ulong scratchl[UL_DIV(MAX_BIT_WIDTH)];
03405         static ulong scratchh[UL_DIV(MAX_BIT_WIDTH)];
03406         unsigned int src1_size = UL_SIZE(src1->width);
03407         unsigned int src2_size = UL_SIZE(src2->width);
03408         unsigned int i;
03409         for( i=0; i<UL_SIZE(tgt->width); i++ ) {
03410           ulong* entry1 = src1->value.ul[i];
03411           ulong* entry2 = src2->value.ul[i];
03412           ulong  val1_l = (i<src1_size) ? entry1[VTYPE_INDEX_VAL_VALL] : 0;
03413           ulong  val1_h = (i<src1_size) ? entry1[VTYPE_INDEX_VAL_VALH] : 0;
03414           ulong  val2_l = (i<src2_size) ? entry2[VTYPE_INDEX_VAL_VALL] : 0;
03415           ulong  val2_h = (i<src2_size) ? entry2[VTYPE_INDEX_VAL_VALH] : 0;
03416           scratchl[i] = ~(val1_l ^ val2_l) & ~(val1_h | val2_h);
03417           scratchh[i] =  (val1_h | val2_h);
03418         }
03419         retval = vector_set_coverage_and_assign_ulong( tgt, scratchl, scratchh, 0, (tgt->width - 1) );
03420       }
03421       break;
03422     default :  assert( 0 );  break;
03423   }
03424 
03425   PROFILE_END;
03426 
03427   return( retval );
03428  
03429 }

bool vector_bitwise_or_op vector tgt,
vector src1,
vector src2
 

Performs bitwise OR operation on two source vectors.

Returns:
Returns TRUE if assigned value differs from original vector value; otherwise, returns FALSE.
Performs a bitwise OR operation. Vector sizes will be properly compensated by placing zeroes.
Parameters:
tgt  Target vector for operation results to be stored
src1  Source vector 1 to perform operation on
src2  Source vector 2 to perform operation on

03262   { PROFILE(VECTOR_BITWISE_OR_OP);
03263 
03264   bool retval;  /* Return value for this function */
03265 
03266   switch( tgt->suppl.part.data_type ) {
03267     case VDATA_UL :
03268       {
03269         static ulong scratchl[UL_DIV(MAX_BIT_WIDTH)];
03270         static ulong scratchh[UL_DIV(MAX_BIT_WIDTH)];
03271         unsigned int src1_size = UL_SIZE(src1->width);
03272         unsigned int src2_size = UL_SIZE(src2->width);
03273         unsigned int i;
03274         for( i=0; i<UL_SIZE(tgt->width); i++ ) {
03275           ulong* entry1 = src1->value.ul[i];
03276           ulong* entry2 = src2->value.ul[i];
03277           ulong  val1_l = (i<src1_size) ? entry1[VTYPE_INDEX_VAL_VALL] : 0;
03278           ulong  val1_h = (i<src1_size) ? entry1[VTYPE_INDEX_VAL_VALH] : 0;
03279           ulong  val2_l = (i<src2_size) ? entry2[VTYPE_INDEX_VAL_VALL] : 0;
03280           ulong  val2_h = (i<src2_size) ? entry2[VTYPE_INDEX_VAL_VALH] : 0;
03281           scratchl[i] = (val1_l & ~val1_h) | (val2_l & ~val2_h);
03282           scratchh[i] = ~scratchl[i] & (val1_h | val2_h);
03283         }
03284         retval = vector_set_coverage_and_assign_ulong( tgt, scratchl, scratchh, 0, (tgt->width - 1) );
03285       }
03286       break;
03287     default :  assert( 0 );  break;
03288   }
03289 
03290   PROFILE_END;
03291 
03292   return( retval );
03293 
03294 }

bool vector_bitwise_xor_op vector tgt,
vector src1,
vector src2
 

Performs bitwise XOR operation on two source vectors.

Returns:
Returns TRUE if assigned value differs from original vector value; otherwise, returns FALSE.
Performs a bitwise XOR operation. Vector sizes will be properly compensated by placing zeroes.
Parameters:
tgt  Target vector for operation results to be stored
src1  Source vector 1 to perform operation on
src2  Source vector 2 to perform operation on

03352   { PROFILE(VECTOR_BITWISE_XOR_OP);
03353 
03354   bool retval;  /* Return value for this function */
03355 
03356   switch( tgt->suppl.part.data_type ) {
03357     case VDATA_UL :
03358       {
03359         static ulong scratchl[UL_DIV(MAX_BIT_WIDTH)];
03360         static ulong scratchh[UL_DIV(MAX_BIT_WIDTH)];
03361         unsigned int src1_size = UL_SIZE(src1->width);
03362         unsigned int src2_size = UL_SIZE(src2->width);
03363         unsigned int i;
03364         for( i=0; i<UL_SIZE(tgt->width); i++ ) {
03365           ulong* entry1 = src1->value.ul[i];
03366           ulong* entry2 = src2->value.ul[i];
03367           ulong  val1_l = (i<src1_size) ? entry1[VTYPE_INDEX_VAL_VALL] : 0;
03368           ulong  val1_h = (i<src1_size) ? entry1[VTYPE_INDEX_VAL_VALH] : 0;
03369           ulong  val2_l = (i<src2_size) ? entry2[VTYPE_INDEX_VAL_VALL] : 0;
03370           ulong  val2_h = (i<src2_size) ? entry2[VTYPE_INDEX_VAL_VALH] : 0;
03371           scratchl[i] = (val1_l ^ val2_l) & ~(val1_h | val2_h);
03372           scratchh[i] = (val1_h | val2_h);
03373         }
03374         retval = vector_set_coverage_and_assign_ulong( tgt, scratchl, scratchh, 0, (tgt->width - 1) );
03375       }
03376       break;
03377     default :  assert( 0 );  break;
03378   }
03379 
03380   PROFILE_END;
03381 
03382   return( retval );
03383 
03384 }

bool vector_ceq_ulong const vector left,
const vector right
 

Performs case equal comparison of two vectors and returns result.

Returns:
Returns TRUE if the two input vectors are four-state bitwise-equal to each other; otherwise, returns FALSE.
Parameters:
left  Pointer to left vector to compare
right  Pointer to right vector to compare

03787   { PROFILE(VECTOR_CEQ_ULONG);
03788 
03789   unsigned int lsize       = UL_SIZE(left->width);
03790   unsigned int rsize       = UL_SIZE(right->width);
03791   int          i           = ((lsize < rsize) ? rsize : lsize);
03792   unsigned int lmsb        = (left->width - 1);
03793   unsigned int rmsb        = (right->width - 1);
03794   bool         lmsb_is_one = (((left->value.ul[UL_DIV(lmsb)][VTYPE_INDEX_VAL_VALL]  >> UL_MOD(lmsb)) & 1) == 1);
03795   bool         rmsb_is_one = (((right->value.ul[UL_DIV(rmsb)][VTYPE_INDEX_VAL_VALL] >> UL_MOD(rmsb)) & 1) == 1);
03796   ulong        lvall;
03797   ulong        lvalh;
03798   ulong        rvall;
03799   ulong        rvalh;
03800 
03801   do {
03802     i--;
03803     vector_copy_val_and_sign_extend_ulong( left,  i, lmsb_is_one, &lvall, &lvalh );
03804     vector_copy_val_and_sign_extend_ulong( right, i, rmsb_is_one, &rvall, &rvalh );
03805   } while( (i > 0) && (lvall == rvall) && (lvalh == rvalh) );
03806 
03807   PROFILE_END;
03808 
03809   return( (lvall == rvall) && (lvalh == rvalh) );
03810 
03811 }

void vector_clone const vector from_vec,
vector **  to_vec
 

Copies contents of from_vec to to_vec, allocating memory.

Copies the contents of the from_vec to the to_vec, allocating new memory.

Parameters:
from_vec  Vector to copy
to_vec  Newly created vector copy

00346   { PROFILE(VECTOR_CLONE);
00347 
00348   if( from_vec == NULL ) {
00349 
00350     /* If from_vec is NULL, just assign to_vec to NULL */
00351     *to_vec = NULL;
00352 
00353   } else {
00354 
00355     /* Create vector */
00356     *to_vec = vector_create( from_vec->width, from_vec->suppl.part.type, from_vec->suppl.part.data_type, TRUE );
00357 
00358     vector_copy( from_vec, *to_vec );
00359 
00360   }
00361 
00362   PROFILE_END;
00363 
00364 }

void vector_copy const vector from_vec,
vector to_vec
 

Copies contents of from_vec to to_vec.

Copies the contents of the from_vec to the to_vec.

Parameters:
from_vec  Vector to copy
to_vec  Newly created vector copy

00257   { PROFILE(VECTOR_COPY);
00258 
00259   unsigned int i, j;  /* Loop iterators */
00260 
00261   assert( from_vec != NULL );
00262   assert( to_vec != NULL );
00263   assert( from_vec->width == to_vec->width );
00264   assert( from_vec->suppl.part.data_type == to_vec->suppl.part.data_type );
00265 
00266   switch( to_vec->suppl.part.data_type ) {
00267     case VDATA_UL :
00268       {
00269         unsigned int size      = UL_SIZE( from_vec->width );
00270         unsigned int type_size = (from_vec->suppl.part.type != to_vec->suppl.part.type) ? 2 : vector_type_sizes[to_vec->suppl.part.type];
00271         for( i=0; i<size; i++ ) {
00272           for( j=0; j<type_size; j++ ) {
00273             to_vec->value.ul[i][j] = from_vec->value.ul[i][j];
00274           }
00275         }
00276       }
00277       break;
00278     case VDATA_R64 :
00279       {
00280         to_vec->value.r64->val = from_vec->value.r64->val;
00281         to_vec->value.r64->str = (from_vec->value.r64->str != NULL) ? strdup_safe( from_vec->value.r64->str ) : NULL;
00282       }
00283       break;
00284     case VDATA_R32 :
00285       {
00286         to_vec->value.r32->val = from_vec->value.r32->val;
00287         to_vec->value.r32->str = (from_vec->value.r32->str != NULL) ? strdup_safe( from_vec->value.r32->str ) : NULL;
00288       }
00289       break;
00290     default:  assert( 0 );  break;
00291   }
00292 
00293   PROFILE_END;
00294 
00295 }

void vector_copy_range vector to_vec,
const vector from_vec,
int  lsb
 

Copies the entire contents of a bit range from from_vec to to_vec, aligning the stored value starting at bit 0.

Parameters:
to_vec  Vector to copy to
from_vec  Vector to copy from
lsb  LSB of bit range to copy

00305   { PROFILE(VECTOR_COPY_RANGE);
00306 
00307   assert( from_vec != NULL );
00308   assert( to_vec != NULL );
00309   assert( from_vec->suppl.part.type == to_vec->suppl.part.type );
00310   assert( from_vec->suppl.part.data_type == to_vec->suppl.part.data_type );
00311 
00312   switch( to_vec->suppl.part.data_type ) {
00313     case VDATA_UL :
00314       {
00315         unsigned int i, j;
00316         for( i=0; i<to_vec->width; i++ ) {
00317           unsigned int my_index     = UL_DIV(i);
00318           unsigned int their_index  = UL_DIV(i + lsb);
00319           unsigned int their_offset = UL_MOD(i + lsb);
00320           for( j=0; j<vector_type_sizes[to_vec->suppl.part.type]; j++ ) {
00321             if( UL_MOD(i) == 0 ) {
00322               to_vec->value.ul[my_index][j] = 0;
00323             }
00324             to_vec->value.ul[my_index][j] |= (((from_vec->value.ul[their_index][j] >> their_offset) & 0x1) << i);
00325           }
00326         }
00327       }
00328       break;
00329     case VDATA_R32 :
00330     case VDATA_R64 :
00331       assert( 0 );
00332       break;
00333     default :  assert( 0 );  break;
00334   }
00335 
00336   PROFILE_END;
00337 
00338 }

vector* vector_create int  width,
int  type,
int  data_type,
bool  data
 

Creates and initializes new vector.

Returns:
Pointer to newly created vector.
Creates new vector from heap memory and initializes all vector contents.
Parameters:
width  Bit width of this vector
type  Type of vector to create (see Vector Types for valid values)
data_type  Data type used to store vector value information
data  If FALSE only initializes width but does not allocate a value array

00200   { PROFILE(VECTOR_CREATE);
00201 
00202   vector* new_vec;  /* Pointer to newly created vector */
00203 
00204   assert( width > 0 );
00205 
00206   new_vec = (vector*)malloc_safe( sizeof( vector ) );
00207 
00208   switch( data_type ) {
00209     case VDATA_UL :
00210       {
00211         ulong** value = NULL;
00212         if( data == TRUE ) {
00213           int          num  = vector_type_sizes[type];
00214           unsigned int size = UL_SIZE(width);
00215           unsigned int i;
00216           value = (ulong**)malloc_safe( sizeof( ulong* ) * size );
00217           for( i=0; i<size; i++ ) {
00218             value[i] = (ulong*)malloc_safe( sizeof( ulong ) * num );
00219           }
00220         }
00221         vector_init_ulong( new_vec, value, 0x0, 0x0, (value != NULL), width, type );
00222       }
00223       break;
00224     case VDATA_R64 :
00225       {
00226         rv64* value = NULL;
00227         if( data == TRUE ) {
00228           value = (rv64*)malloc_safe( sizeof( rv64 ) );
00229         }
00230         vector_init_r64( new_vec, value, 0.0, NULL, (value != NULL), type );
00231       }
00232       break;
00233     case VDATA_R32 :
00234       {
00235         rv32* value = NULL;
00236         if( data == TRUE ) {
00237           value = (rv32*)malloc_safe( sizeof( rv32 ) );
00238         }
00239         vector_init_r32( new_vec, value, 0.0, NULL, (value != NULL), type );
00240       }
00241       break;
00242     default :  assert( 0 );
00243   }
00244 
00245   PROFILE_END;
00246 
00247   return( new_vec );
00248 
00249 }

void vector_db_merge vector base,
char **  line,
bool  same
 

Reads and merges two vectors, placing the result into base vector.

Exceptions:
anonymous Throw Throw Throw
Parses current file line for vector information and performs vector merge of base vector and read vector information. If the vectors are found to be different (width is not equal), an error message is sent to the user and the program is halted. If the vectors are found to be equivalents, the merge is performed on the vector elements.
Parameters:
base  Base vector to merge data into
line  Pointer to line to parse for vector information
same  Specifies if vector to merge needs to be exactly the same as the existing vector

00670   { PROFILE(VECTOR_DB_MERGE);
00671 
00672   unsigned int width;       /* Width of read vector */
00673   vsuppl       suppl;       /* Supplemental value of vector */
00674   int          chars_read;  /* Number of characters read */
00675 
00676   assert( base != NULL );
00677 
00678   /*@-formatcode@*/
00679   if( sscanf( *line, "%u %hhu%n", &width, &(suppl.all), &chars_read ) == 2 ) {
00680   /*@=formatcode@*/
00681 
00682     *line = *line + chars_read;
00683 
00684     if( base->width != width ) {
00685 
00686       if( same ) {
00687         print_output( "Attempting to merge databases derived from different designs.  Unable to merge",
00688                       FATAL, __FILE__, __LINE__ );
00689         Throw 0;
00690       }
00691 
00692     } else if( base->suppl.part.owns_data == 1 ) {
00693 
00694       switch( base->suppl.part.data_type ) {
00695         case VDATA_UL :
00696           {
00697             unsigned int i, j;
00698             for( i=0; i<=((width-1)>>(info_suppl.part.vec_ul_size+3)); i++ ) {
00699               for( j=0; j<vector_type_sizes[suppl.part.type]; j++ ) {
00700 
00701                 /* If the CDD vector size and our size are the same, just do a direct read */
00702 #if SIZEOF_LONG == 4
00703                 if( info_suppl.part.vec_ul_size == 2 ) {
00704 #elif SIZEOF_LONG == 8
00705                 if( info_suppl.part.vec_ul_size == 3 ) {
00706 #else
00707 #error "Unsupported long size"
00708 #endif
00709                   ulong val;
00710                   if( sscanf( *line, "%lx%n", &val, &chars_read ) == 1 ) {
00711                     *line += chars_read;
00712                     if( j >= 2 ) {
00713                       base->value.ul[i][j] |= val;
00714                     }
00715                   } else {
00716                     print_output( "Unable to parse vector information in database file.  Unable to merge.", FATAL, __FILE__, __LINE__ );
00717                     Throw 0;
00718                   }
00719 
00720 #if SIZEOF_LONG == 8
00721                 /* If the CDD file size is 32-bit and we are 64-bit, store two elements to our one */
00722                 } else if( info_suppl.part.vec_ul_size == 2 ) {
00723                   uint32 val;
00724                   if( sscanf( *line, "%x%n", &val, &chars_read ) == 1 ) {
00725                     *line += chars_read;
00726                     if( j >= 2 ) {
00727                       if( i == 0 ) {
00728                         base->value.ul[i/2][j] = (ulong)val;
00729                       } else {
00730                         base->value.ul[i/2][j] |= ((ulong)val << 32);
00731                       }
00732                     }
00733                   } else {
00734                     print_output( "Unable to parse vector information in database file.  Unable to merge.", FATAL, __FILE__, __LINE__ );
00735                     Throw 0;
00736                   }
00737 
00738 #elif SIZEOF_LONG == 4
00739                 /* If the CDD file size is 64-bit and we are 32-bit, store one elements to our two */
00740                 } else if( info_suppl.part.vec_ul_size == 3 ) {
00741                   unsigned long long val;
00742                   /*@-duplicatequals +ignorequals@*/
00743                   if( sscanf( *line, "%llx%n", &val, &chars_read ) == 1 ) {
00744                   /*@=duplicatequals =ignorequals@*/
00745                     *line += chars_read;
00746                     if( j >= 2 ) {
00747                       base->value.ul[(i*2)+0][j] = (ulong)(val & 0xffffffffLL);
00748                       base->value.ul[(i*2)+1][j] = (ulong)((val >> 32) & 0xffffffffLL);
00749                     }
00750                   } else {
00751                     print_output( "Unable to parse vector information in database file.  Unable to merge.", FATAL, __FILE__, __LINE__ );
00752                     Throw 0;
00753                   }
00754 #endif
00755                 /* Otherwise, we don't know how to convert the value, so flag an error */
00756                 } else {
00757                   print_output( "Unable to parse vector information in database file.  Unable to merge.", FATAL, __FILE__, __LINE__ );
00758                   Throw 0;
00759                 }
00760               }
00761             }
00762           }
00763           break;
00764         case VDATA_R64 :
00765           {
00766             int  store_str;
00767             char value[64];
00768             if( sscanf( *line, "%d %s%n", &store_str, value, &chars_read ) == 2 ) {
00769               *line += chars_read;
00770             } else {
00771               print_output( "Unable to parse vector information in database file.  Unable to merge.", FATAL, __FILE__, __LINE__ );
00772               Throw 0;
00773             }
00774           }
00775           break;
00776         case VDATA_R32 :
00777           {
00778             int  store_str;
00779             char value[64];
00780             if( sscanf( *line, "%d %s%n", &store_str, value, &chars_read ) == 2 ) {
00781               *line += chars_read;
00782             } else {
00783               print_output( "Unable to parse vector information in database file.  Unable to merge.", FATAL, __FILE__, __LINE__ );
00784               Throw 0;
00785             }
00786           }
00787           break;
00788         default :  assert( 0 );  break;
00789       }
00790 
00791     }
00792 
00793   } else {
00794 
00795     print_output( "Unable to parse vector line from database file.  Unable to merge.", FATAL, __FILE__, __LINE__ );
00796     Throw 0;
00797 
00798   }
00799 
00800   PROFILE_END;
00801 
00802 }

void vector_db_read vector **  vec,
char **  line
 

Creates and parses current file line for vector information.

Exceptions:
anonymous Throw Throw
Creates a new vector structure, parses current file line for vector information and returns new vector structure to calling function.
Parameters:
vec  Pointer to vector to create
line  Pointer to line to parse for vector information

00472   { PROFILE(VECTOR_DB_READ);
00473 
00474   unsigned int width;       /* Vector bit width */
00475   vsuppl       suppl;       /* Temporary supplemental value */
00476   int          chars_read;  /* Number of characters read */
00477 
00478   /* Read in vector information */
00479   /*@-formatcode@*/
00480   if( sscanf( *line, "%u %hhu%n", &width, &(suppl.all), &chars_read ) == 2 ) {
00481   /*@=formatcode@*/
00482 
00483     *line = *line + chars_read;
00484 
00485     /* Create new vector */
00486     *vec              = vector_create( width, suppl.part.type, suppl.part.data_type, TRUE );
00487     (*vec)->suppl.all = suppl.all;
00488 
00489     if( suppl.part.owns_data == 1 ) {
00490 
00491       Try {
00492 
00493         switch( suppl.part.data_type ) {
00494           case VDATA_UL :
00495             {
00496               unsigned int i, j;
00497               for( i=0; i<=((width-1)>>(info_suppl.part.vec_ul_size+3)); i++ ) {
00498                 for( j=0; j<vector_type_sizes[suppl.part.type]; j++ ) {
00499                   /* If the CDD vector size and our size are the same, just do a direct read */
00500 #if SIZEOF_LONG == 4
00501                   if( info_suppl.part.vec_ul_size == 2 ) {
00502 #elif SIZEOF_LONG == 8
00503                   if( info_suppl.part.vec_ul_size == 3 ) {
00504 #else
00505 #error "Unsupported long size"
00506 #endif
00507                     if( sscanf( *line, "%lx%n", &((*vec)->value.ul[i][j]), &chars_read ) == 1 ) {
00508                       *line += chars_read;
00509                     } else {
00510                       print_output( "Unable to parse vector information in database file.  Unable to read.", FATAL, __FILE__, __LINE__ );
00511                       Throw 0;
00512                     }
00513 
00514 #if SIZEOF_LONG == 8
00515                   /* If the CDD file size is 32-bit and we are 64-bit, store two elements to our one */
00516                   } else if( info_suppl.part.vec_ul_size == 2 ) {
00517                     uint32 val;
00518                     if( sscanf( *line, "%x%n", &val, &chars_read ) == 1 ) {
00519                       *line += chars_read;
00520                       if( i == 0 ) {
00521                         (*vec)->value.ul[i/2][j] = (ulong)val;
00522                       } else {
00523                         (*vec)->value.ul[i/2][j] |= ((ulong)val << 32);
00524                       }
00525                     } else {
00526                       print_output( "Unable to parse vector information in database file.  Unable to read.", FATAL, __FILE__, __LINE__ );
00527                       Throw 0;
00528                     }
00529 
00530 #elif SIZEOF_LONG == 4
00531                   /* If the CDD file size is 64-bit and we are 32-bit, store one elements to our two */
00532                   } else if( info_suppl.part.vec_ul_size == 3 ) {
00533                     unsigned long long val;
00534                     /*@-duplicatequals +ignorequals@*/
00535                     if( sscanf( *line, "%llx%n", &val, &chars_read ) == 1 ) {
00536                     /*@=duplicatequals =ignorequals@*/
00537                       *line += chars_read;
00538                       (*vec)->value.ul[(i*2)+0][j] = (ulong)(val & 0xffffffffLL);
00539                       (*vec)->value.ul[(i*2)+1][j] = (ulong)((val >> 32) & 0xffffffffLL);
00540                     } else {
00541                       print_output( "Unable to parse vector information in database file.  Unable to read.", FATAL, __FILE__, __LINE__ );
00542                       Throw 0;
00543                     }
00544 #endif
00545                   /* Otherwise, we don't know how to convert the value, so flag an error */
00546                   } else {
00547                     print_output( "Unable to parse vector information in database file.  Unable to read.", FATAL, __FILE__, __LINE__ );
00548                     Throw 0;
00549                   }
00550                 }
00551               }
00552             }
00553             break;
00554           case VDATA_R64 :
00555             {
00556               int store_str;
00557               if( sscanf( *line, "%d%n", &store_str, &chars_read ) == 1 ) {
00558                 *line += chars_read;
00559                 if( store_str == 1 ) {
00560                   char str[4096];
00561                   if( sscanf( *line, "%s%n", str, &chars_read ) == 1 ) {
00562                     unsigned int slen;
00563                     char*        stmp;
00564                     (*vec)->value.r64->str = strdup_safe( str );
00565                     slen = strlen( *line );
00566                     stmp = strdup_safe( *line );
00567                     *line += chars_read;
00568                     if( sscanf( remove_underscores( stmp ), "%lf", &((*vec)->value.r64->val)) != 1 ) {
00569                       free_safe( stmp, (slen + 1) );
00570                       print_output( "Unable to parse vector information in database file.  Unable to read.", FATAL, __FILE__, __LINE__ );
00571                       Throw 0;
00572                     }
00573                     free_safe( stmp, (slen + 1) );
00574                   } else {
00575                     print_output( "Unable to parse vector information in database file.  Unable to read.", FATAL, __FILE__, __LINE__ );
00576                     Throw 0;
00577                   }
00578                 } else {
00579                   if( sscanf( *line, "%lf%n", &((*vec)->value.r64->val), &chars_read ) == 1 ) {
00580                     *line += chars_read;
00581                   } else {
00582                     print_output( "Unable to parse vector information in database file.  Unable to read.", FATAL, __FILE__, __LINE__ );
00583                     Throw 0;
00584                   }
00585                 }
00586               } else {
00587                 print_output( "Unable to parse vector information in database file.  Unable to read.", FATAL, __FILE__, __LINE__ );
00588                 Throw 0;
00589               }
00590             }
00591             break;
00592           case VDATA_R32 :
00593             {
00594               int store_str;
00595               if( sscanf( *line, "%d%n", &store_str, &chars_read ) == 1 ) {
00596                 *line += chars_read;
00597                 if( store_str == 1 ) {
00598                   char str[4096];
00599                   if( sscanf( *line, "%s%n", str, &chars_read ) == 1 ) {
00600                     unsigned int slen;
00601                     char*        stmp;
00602                     (*vec)->value.r32->str = strdup_safe( str );
00603                     slen = strlen( *line );
00604                     stmp = strdup_safe( *line );
00605                     *line += chars_read;
00606                     if( sscanf( remove_underscores( stmp ), "%f", &((*vec)->value.r32->val)) != 1 ) {
00607                       free_safe( stmp, (slen + 1) );
00608                       print_output( "Unable to parse vector information in database file.  Unable to read.", FATAL, __FILE__, __LINE__ );
00609                       Throw 0;
00610                     }
00611                     free_safe( stmp, (slen + 1) );
00612                   } else {
00613                     print_output( "Unable to parse vector information in database file.  Unable to read.", FATAL, __FILE__, __LINE__ );
00614                     Throw 0;
00615                   }
00616                 } else {
00617                   if( sscanf( *line, "%f%n", &((*vec)->value.r32->val), &chars_read ) == 1 ) {
00618                     *line += chars_read;
00619                   } else {
00620                     print_output( "Unable to parse vector information in database file.  Unable to read.", FATAL, __FILE__, __LINE__ );
00621                     Throw 0;
00622                   }
00623                 }
00624               } else {
00625                 print_output( "Unable to parse vector information in database file.  Unable to read.", FATAL, __FILE__, __LINE__ );
00626                 Throw 0;
00627               }
00628             }
00629             break;
00630           default :  assert( 0 );  break;
00631         }
00632 
00633       } Catch_anonymous {
00634         vector_dealloc( *vec );
00635         *vec = NULL;
00636         Throw 0;
00637       }
00638 
00639     /* Otherwise, deallocate the vector data */
00640     } else {
00641 
00642       vector_dealloc_value( *vec );
00643 
00644     }
00645 
00646   } else {
00647 
00648     print_output( "Unable to parse vector information in database file.  Unable to read.", FATAL, __FILE__, __LINE__ );
00649     Throw 0;
00650 
00651   }
00652 
00653   PROFILE_END;
00654 
00655 }

void vector_db_write vector vec,
FILE *  file,
bool  write_data,
bool  net
 

Displays vector information to specified database file.

Writes the specified vector to the specified coverage database file.

Parameters:
vec  Pointer to vector to display to database file
file  Pointer to coverage database file to display to
write_data  If set to TRUE, causes 4-state data bytes to be included
net  If set to TRUE, causes default value to be written as Z instead of X

00374   { PROFILE(VECTOR_DB_WRITE);
00375 
00376   uint8 mask;   /* Mask value for vector values */
00377 
00378   assert( vec != NULL );
00379   assert( vec->width > 0 );
00380 
00381   /* Calculate vector data mask */
00382   mask = write_data ? 0xff : 0xfc;
00383   switch( vec->suppl.part.type ) {
00384     case VTYPE_VAL :  mask = mask & 0x03;  break;
00385     case VTYPE_SIG :  mask = mask & 0x1b;  break;
00386     case VTYPE_EXP :  mask = mask & 0x3f;  break;
00387     case VTYPE_MEM :  mask = mask & 0x7b;  break;
00388     default        :  break;
00389   }
00390 
00391   /* Output vector information to specified file */
00392   /*@-formatcode@*/
00393   fprintf( file, "%u %hhu",
00394     vec->width,
00395     (vec->suppl.all & VSUPPL_MASK)
00396   );
00397   /*@=formatcode@*/
00398 
00399   /* Only write our data if we own it */
00400   if( vec->suppl.part.owns_data == 1 ) {
00401 
00402     /* Output value based on data type */
00403     switch( vec->suppl.part.data_type ) {
00404       case VDATA_UL :
00405         {
00406           ulong        dflt_l = net ? UL_SET : 0x0;
00407           ulong        dflt_h = (vec->suppl.part.is_2state == 1) ? 0x0 : UL_SET;
00408           unsigned int i, j;
00409           ulong        hmask  = UL_HMASK( vec->width - 1 );
00410           for( i=0; i<(UL_SIZE(vec->width) - 1); i++ ) {
00411             fprintf( file, " %lx", (write_data && (vec->value.ul != NULL)) ? vec->value.ul[i][VTYPE_INDEX_VAL_VALL] : dflt_l );
00412             fprintf( file, " %lx", (write_data && (vec->value.ul != NULL)) ? vec->value.ul[i][VTYPE_INDEX_VAL_VALH] : dflt_h );
00413             for( j=2; j<vector_type_sizes[vec->suppl.part.type]; j++ ) {
00414               if( ((mask >> j) & 0x1) == 1 ) {
00415                 fprintf( file, " %lx", (vec->value.ul != NULL) ? vec->value.ul[i][j] : 0 );
00416               } else {
00417                 fprintf( file, " 0" );
00418               }
00419             }
00420           }
00421           fprintf( file, " %lx", ((write_data && (vec->value.ul != NULL)) ? vec->value.ul[i][VTYPE_INDEX_VAL_VALL] : dflt_l) & hmask );
00422           fprintf( file, " %lx", ((write_data && (vec->value.ul != NULL)) ? vec->value.ul[i][VTYPE_INDEX_VAL_VALH] : dflt_h) & hmask );
00423           for( j=2; j<vector_type_sizes[vec->suppl.part.type]; j++ ) {
00424             if( ((mask >> j) & 0x1) == 1 ) {
00425               fprintf( file, " %lx", (vec->value.ul != NULL) ? (vec->value.ul[i][j] & hmask) : 0 );
00426             } else {
00427               fprintf( file, " 0" );
00428             }
00429           }
00430         }
00431         break;
00432       case VDATA_R64 :
00433         if( vec->value.r64 != NULL ) {
00434           if( vec->value.r64->str != NULL ) {
00435             fprintf( file, " 1 %s", vec->value.r64->str );
00436           } else {
00437             fprintf( file, " 0 %f", vec->value.r64->val );
00438           }
00439         } else {
00440           fprintf( file, " 0 0.0" );
00441         }
00442         break;
00443       case VDATA_R32 :
00444         if( vec->value.r32 != NULL ) {
00445           if( vec->value.r32->str != NULL ) {
00446             fprintf( file, " 1 %s", vec->value.r32->str );
00447           } else {
00448             fprintf( file, " 0 %f", vec->value.r32->val );
00449           }
00450         } else {
00451           fprintf( file, " 0 0.0" );
00452         }
00453         break;
00454       default :  assert( 0 );  break;
00455     }
00456 
00457   }
00458 
00459   PROFILE_END;
00460 
00461 }

void vector_dealloc vector vec  ) 
 

Deallocates all memory allocated for vector.

Deallocates all heap memory that was initially allocated with the malloc routine.

Parameters:
vec  Pointer to vector to deallocate memory from

05154   { PROFILE(VECTOR_DEALLOC);
05155 
05156   if( vec != NULL ) {
05157 
05158     /* Deallocate all vector values */
05159     if( (vec->value.ul != NULL) && (vec->suppl.part.owns_data == 1) ) {
05160       vector_dealloc_value( vec );
05161     }
05162 
05163     /* Deallocate vector itself */
05164     free_safe( vec, sizeof( vector ) );
05165 
05166   }
05167 
05168   PROFILE_END;
05169 
05170 }

void vector_dealloc_value vector vec  ) 
 

Deallocates the value structure for the given vector.

Deallocates the value structure for the given vector.

Parameters:
vec  Pointer to vector to deallocate value for

05118   { PROFILE(VECTOR_DEALLOC_VALUE);
05119 
05120   switch( vec->suppl.part.data_type ) {
05121     case VDATA_UL :
05122       {
05123         unsigned int i;
05124         unsigned int size = UL_SIZE( vec->width );
05125 
05126         for( i=0; i<size; i++ ) {
05127           free_safe( vec->value.ul[i], (sizeof( ulong ) * vector_type_sizes[vec->suppl.part.type]) );
05128         }
05129         free_safe( vec->value.ul, (sizeof( ulong* ) * size) );
05130         vec->value.ul = NULL;
05131       }
05132       break;
05133     case VDATA_R64 :
05134       free_safe( vec->value.r64->str, (strlen( vec->value.r64->str ) + 1) );
05135       free_safe( vec->value.r64, sizeof( rv64 ) );
05136       break;
05137     case VDATA_R32 :
05138       free_safe( vec->value.r32->str, (strlen( vec->value.r32->str ) + 1) );
05139       free_safe( vec->value.r32, sizeof( rv32 ) );
05140       break;
05141     default :  assert( 0 );  break;
05142   }
05143 
05144   PROFILE_END;
05145 
05146 }

void vector_display const vector vec  ) 
 

Outputs vector contents to standard output.

Outputs contents of vector to standard output (for debugging purposes only).

Parameters:
vec  Pointer to vector to output to standard output

01358   {
01359 
01360   assert( vec != NULL );
01361 
01362   /*@-formatcode@*/
01363   printf( "Vector (%p) => width: %u, suppl: %hhx\n", vec, vec->width, vec->suppl.all );
01364   /*@=formatcode@*/
01365 
01366   if( (vec->width > 0) && (vec->value.ul != NULL) ) {
01367     switch( vec->suppl.part.data_type ) {
01368       case VDATA_UL  :  vector_display_ulong( vec->value.ul, vec->width, vec->suppl.part.type );  break;
01369       case VDATA_R64 :  vector_display_r64( vec->value.r64 );  break;
01370       case VDATA_R32 :  vector_display_r32( vec->value.r32 );  break;
01371       default        :  assert( 0 );  break;
01372     }
01373   } else {
01374     printf( "NO DATA" );
01375   }
01376 
01377   printf( "\n" );
01378 
01379 }

void vector_display_toggle01_ulong ulong **  value,
int  width,
FILE *  ofile
 

Outputs the toggle01 information from the specified nibble to the specified output stream.

Displays the ulong toggle01 information from the specified vector to the output stream specified in ofile.

Parameters:
value  Value array to display toggle information
width  Number of bits in value array to display
ofile  Stream to output information to

01107   { PROFILE(VECTOR_DISPLAY_TOGGLE01_ULONG);
01108 
01109   unsigned int nib       = 0;
01110   int          i, j;
01111   int          bits_left = UL_MOD(width - 1);
01112 
01113   fprintf( ofile, "%d'h", width );
01114 
01115   for( i=UL_SIZE(width); i--; ) {
01116     for( j=bits_left; j>=0; j-- ) {
01117       nib |= (((value[i][VTYPE_INDEX_SIG_TOG01] >> (unsigned int)j) & 0x1) << ((unsigned int)j % 4));
01118       if( (j % 4) == 0 ) {
01119         fprintf( ofile, "%1x", nib );
01120         nib = 0;
01121       }
01122       if( ((j % 16) == 0) && ((j != 0) || (i != 0)) ) {
01123         fprintf( ofile, "_" );
01124       }
01125     }
01126     bits_left = (UL_BITS - 1);
01127   }
01128 
01129   PROFILE_END;
01130 
01131 }

void vector_display_toggle10_ulong ulong **  value,
int  width,
FILE *  ofile
 

Outputs the toggle10 information from the specified nibble to the specified output stream.

Displays the ulong toggle10 information from the specified vector to the output stream specified in ofile.

Parameters:
value  Value array to display toggle information
width  Number of bits of value array to display
ofile  Stream to output information to

01141   { PROFILE(VECTOR_DISPLAY_TOGGLE10_ULONG);
01142 
01143   unsigned int nib       = 0;
01144   int          i, j;
01145   int          bits_left = UL_MOD(width - 1);
01146   
01147   fprintf( ofile, "%d'h", width );
01148       
01149   for( i=UL_SIZE(width); i--; ) {
01150     for( j=bits_left; j>=0; j-- ) {
01151       nib |= (((value[i][VTYPE_INDEX_SIG_TOG10] >> (unsigned int)j) & 0x1) << ((unsigned int)j % 4));
01152       if( (j % 4) == 0 ) {
01153         fprintf( ofile, "%1x", nib );
01154         nib = 0;
01155       }
01156       if( ((j % 16) == 0) && ((j != 0) || (i != 0)) ) {
01157         fprintf( ofile, "_" );
01158       }
01159     } 
01160     bits_left = (UL_BITS - 1);
01161   }
01162 
01163   PROFILE_END;
01164 
01165 }

void vector_display_ulong ulong **  value,
unsigned int  width,
unsigned int  type
 

Outputs ulong vector to standard output.

Outputs the specified ulong value array to standard output as described by the width parameter.

Parameters:
value  Value array to display
width  Number of bits in array to display
type  Type of vector to display

01205   {
01206 
01207   unsigned int i, j;  /* Loop iterator */
01208 
01209   for( i=0; i<vector_type_sizes[type]; i++ ) {
01210     for( j=UL_SIZE(width); j--; ) {
01211       /*@-formatcode@*/
01212       printf( " %lx", value[j][i] );
01213       /*@=formatcode@*/
01214     }
01215   }
01216 
01217   /* Display value */
01218   printf( ", " );
01219   vector_display_value_ulong( value, width );
01220 
01221   switch( type ) {
01222 
01223     case VTYPE_SIG :
01224 
01225       /* Display toggle01 history */
01226       printf( ", 0->1: " );
01227       vector_display_toggle01_ulong( value, width, stdout );
01228 
01229       /* Display toggle10 history */
01230       printf( ", 1->0: " );
01231       vector_display_toggle10_ulong( value, width, stdout );
01232 
01233       break;
01234 
01235     case VTYPE_EXP :
01236 
01237       /* Display eval_a information */
01238       printf( ", a: %u'h", width );
01239       for( i=UL_SIZE(width); i--; ) {
01240         /*@-formatcode@*/
01241 #if SIZEOF_LONG == 4
01242         printf( "%08lx", value[i][VTYPE_INDEX_EXP_EVAL_A] );
01243 #elif SIZEOF_LONG == 8
01244         printf( "%016lx", value[i][VTYPE_INDEX_EXP_EVAL_A] );
01245 #else
01246 #error "Unsupported long size"
01247 #endif
01248         /*@=formatcode@*/
01249       }
01250 
01251       /* Display eval_b information */
01252       printf( ", b: %u'h", width );
01253       for( i=UL_SIZE(width); i--; ) {
01254         /*@-formatcode@*/
01255 #if SIZEOF_LONG == 4
01256         printf( "%08lx", value[i][VTYPE_INDEX_EXP_EVAL_B] );
01257 #elif SIZEOF_LONG == 8
01258         printf( "%016lx", value[i][VTYPE_INDEX_EXP_EVAL_B] );
01259 #endif
01260         /*@=formatcode@*/
01261       }
01262 
01263       /* Display eval_c information */
01264       printf( ", c: %u'h", width );
01265       for( i=UL_SIZE(width); i--; ) {
01266         /*@-formatcode@*/
01267 #if SIZEOF_LONG == 4
01268         printf( "%08lx", value[i][VTYPE_INDEX_EXP_EVAL_C] );
01269 #elif SIZEOF_LONG == 8
01270         printf( "%016lx", value[i][VTYPE_INDEX_EXP_EVAL_C] );
01271 #endif
01272         /*@=formatcode@*/
01273       }
01274 
01275       /* Display eval_d information */
01276       printf( ", d: %u'h", width );
01277       for( i=UL_SIZE(width); i--; ) {
01278         /*@-formatcode@*/
01279 #if SIZEOF_LONG == 4
01280         printf( "%08lx", value[i][VTYPE_INDEX_EXP_EVAL_D] );
01281 #elif SIZEOF_LONG == 8
01282         printf( "%016lx", value[i][VTYPE_INDEX_EXP_EVAL_D] );
01283 #endif
01284         /*@=formatcode@*/
01285       }
01286 
01287       break;
01288 
01289     case VTYPE_MEM :
01290   
01291       /* Display toggle01 history */
01292       printf( ", 0->1: " );
01293       vector_display_toggle01_ulong( value, width, stdout );
01294 
01295       /* Display toggle10 history */
01296       printf( ", 1->0: " );
01297       vector_display_toggle10_ulong( value, width, stdout );
01298 
01299       /* Write history */
01300       printf( ", wr: %u'h", width );
01301       for( i=UL_SIZE(width); i--; ) {
01302         /*@-formatcode@*/
01303 #if SIZEOF_LONG == 4
01304         printf( "%08lx", value[i][VTYPE_INDEX_MEM_WR] );
01305 #elif SIZEOF_LONG == 8
01306         printf( "%016lx", value[i][VTYPE_INDEX_MEM_WR] );
01307 #endif
01308         /*@=formatcode@*/
01309       }
01310 
01311       /* Read history */
01312       printf( ", rd: %u'h", width );
01313       for( i=UL_SIZE(width); i--; ) {
01314         /*@-formatcode@*/
01315 #if SIZEOF_LONG == 4
01316         printf( "%08lx", value[i][VTYPE_INDEX_MEM_RD] );
01317 #elif SIZEOF_LONG == 8
01318         printf( "%016lx", value[i][VTYPE_INDEX_MEM_RD] );
01319 #endif
01320         /*@=formatcode@*/
01321       }
01322 
01323       break;
01324 
01325     default : break;
01326 
01327   }
01328 
01329 }

void vector_display_value_ulong ulong **  value,
int  width
 

Outputs the binary value of the specified nibble array to standard output.

Displays the binary value of the specified ulong vector data array to standard output.

Parameters:
value  Pointer to vector value array
width  Number of elements in value array

01173   {
01174 
01175   int i, j;  /* Loop iterator */
01176   int bits_left = UL_MOD(width - 1);
01177 
01178   printf( "value: %d'b", width );
01179 
01180   for( i=UL_SIZE(width); i--; ) {
01181     for( j=bits_left; j>=0; j-- ) {
01182       if( ((value[i][VTYPE_INDEX_VAL_VALH] >> (unsigned int)j) & 0x1) == 0 ) {
01183         printf( "%lu", ((value[i][VTYPE_INDEX_VAL_VALL] >> (unsigned int)j) & 0x1) );
01184       } else {
01185         if( ((value[i][VTYPE_INDEX_VAL_VALL] >> (unsigned int)j) & 0x1) == 0 ) {
01186           printf( "x" );
01187         } else {
01188           printf( "z" );
01189         }
01190       }
01191     }
01192     bits_left = (UL_BITS - 1);
01193   }
01194 
01195 }

bool vector_from_int vector vec,
int  value
 

Converts integer into vector value.

Returns:
Returns TRUE if the value has changed from the last assignment to the given vector.
Converts an integer value into a vector, creating a vector value to store the new vector into. This function is used along with the vector_to_int for mathematical vector operations. We will first convert vectors into integers, perform the mathematical operation, and then revert the integers back into the vectors.
Parameters:
vec  Pointer to vector store value into
value  Integer value to convert into vector

02466   { PROFILE(VECTOR_FROM_INT);
02467 
02468   bool retval = TRUE;  /* Return value for this function */
02469 
02470   switch( vec->suppl.part.data_type ) {
02471     case VDATA_UL :
02472       {
02473         ulong        scratchl[UL_DIV(MAX_BIT_WIDTH)];
02474         ulong        scratchh[UL_DIV(MAX_BIT_WIDTH)];
02475         unsigned int i;
02476         unsigned int size        = (vec->width < (sizeof( int ) << 3)) ? UL_SIZE( vec->width ) : UL_SIZE( sizeof( int ) << 3 );
02477         bool         sign_extend = (value < 0) && (vec->width > (sizeof( int ) << 3));
02478         unsigned int shift       = (UL_BITS <= (sizeof( int ) << 3)) ? UL_BITS : (sizeof( int ) << 3);
02479         for( i=0; i<size; i++ ) {
02480           scratchl[i] = (ulong)value & UL_SET;
02481           scratchh[i] = 0;
02482           /*@-shiftimplementation@*/
02483           value >>= shift;
02484           /*@=shiftimplementation@*/
02485         }
02486         if( sign_extend ) {
02487           vector_sign_extend_ulong( scratchl, scratchh, UL_SET, UL_SET, (vec->width - 1), vec->width );
02488         } else {
02489           size = UL_SIZE( vec->width );
02490           for( ; i<size; i++ ) {
02491             scratchl[i] = scratchh[i] = 0;
02492           }
02493         }
02494         retval = vector_set_coverage_and_assign_ulong( vec, scratchl, scratchh, 0, (vec->width - 1) );
02495       }
02496       break;
02497     case VDATA_R64 :
02498       retval              = !DEQ( vec->value.r64->val, (double)value );
02499       vec->value.r64->val = (double)value;
02500       break;
02501     case VDATA_R32 :
02502       retval              = !FEQ( vec->value.r32->val, (float)value );
02503       vec->value.r32->val = (float)value;
02504       break;
02505     default :  assert( 0 );  break;
02506   }
02507 
02508   /* Because this value came from an integer, specify that the vector is signed */
02509   vec->suppl.part.is_signed = 1;
02510 
02511   PROFILE_END;
02512 
02513   return( retval );
02514 
02515 }

bool vector_from_real64 vector vec,
real64  value
 

Converts a 64-bit real into a vector value.

Returns:
Returns TRUE if the value has changed from the last assignment to the given vector.
Converts a 64-bit real value into a vector.
Parameters:
vec  Pointer to vector store value into
value  64-bit real value to convert into vector

02576   { PROFILE(VECTOR_FROM_REAL64);
02577 
02578   bool retval = TRUE;  /* Return value for this function */
02579 
02580   switch( vec->suppl.part.data_type ) {
02581     case VDATA_UL :
02582       retval = vector_from_uint64( vec, (uint64)round( value ) );
02583       break;
02584     case VDATA_R64 :
02585       retval              = !DEQ( vec->value.r64->val, value );
02586       vec->value.r64->val = value;
02587       break;
02588     case VDATA_R32 :
02589       retval              = !FEQ( vec->value.r32->val, (float)value);
02590       vec->value.r32->val = (float)value;
02591       break;
02592     default :  assert( 0 );  break;
02593   }
02594 
02595   PROFILE_END;
02596 
02597   return( retval );
02598 
02599 }

void vector_from_string char **  str,
bool  quoted,
vector **  vec,
int *  base
 

Converts character string value into vector.

Converts a string value from the lexer into a vector structure appropriately sized. If the string value size exceeds Covered's maximum bit allowance, return a value of NULL to indicate this to the calling function.

Parameters:
str  String version of value
quoted  If TRUE, treat the string as a literal
vec  Pointer to vector to allocate and populate with string information
base  Base type of string value parsed

02919   { PROFILE(VECTOR_FROM_STRING);
02920 
02921   int    bits_per_char;         /* Number of bits represented by a single character in the value string str */
02922   int    size;                  /* Specifies bit width of vector to create */
02923   char   value[MAX_BIT_WIDTH];  /* String to store string value in */
02924   char   stype[3];              /* Temporary holder for type of string being parsed */
02925   int    chars_read;            /* Number of characters read by a sscanf() function call */
02926   double real;                  /* Container for real number */
02927 
02928   if( quoted ) {
02929 
02930     size = strlen( *str ) * 8;
02931 
02932     /* If this is the empty (null) string, allocate 8-bits */
02933     if( size == 0 ) {
02934       size = 8;
02935     }
02936 
02937     /* If we have exceeded the maximum number of bits, return a value of NULL */
02938     if( size > MAX_BIT_WIDTH ) {
02939 
02940       *vec  = NULL;
02941       *base = 0;
02942 
02943     } else {
02944 
02945       unsigned int pos = 0;
02946       int          i;
02947 
02948       /* Create vector */
02949       *vec  = vector_create( size, VTYPE_VAL, VDATA_UL, TRUE );
02950       *base = QSTRING;
02951 
02952       for( i=(strlen( *str ) - 1); i>=0; i-- ) {
02953         (*vec)->value.ul[pos>>(UL_DIV_VAL-3)][VTYPE_INDEX_VAL_VALL] |= (ulong)((*str)[i]) << ((pos & (UL_MOD_VAL >> 3)) << 3);
02954         pos++;
02955       }
02956 
02957     }
02958 
02959   } else {
02960 
02961     unsigned int slen = strlen( *str );
02962     char*        stmp = strdup_safe( *str );
02963 
02964     if( ((sscanf( *str, "%[0-9_]%[.]%[0-9_]", value, value, value ) == 3) ||
02965          (sscanf( *str, "-%[0-9_]%[.]%[0-9_]", value, value, value ) == 3)) &&
02966         (sscanf( remove_underscores( stmp ), "%lf%n", &real, &chars_read ) == 1) ) {
02967 
02968       *vec                         = vector_create( 64, VTYPE_VAL, VDATA_R64, TRUE );
02969       (*vec)->value.r64->val       = real;
02970       (*vec)->value.r64->str       = strdup_safe( *str );
02971       (*vec)->suppl.part.is_signed = 1;
02972       *str                         = *str + chars_read;
02973 
02974     } else {
02975 
02976       if( sscanf( *str, "%d'%[sSdD]%[0-9]%n", &size, stype, value, &chars_read ) == 3 ) {
02977         bits_per_char = 10;
02978         *base         = DECIMAL;
02979         *str          = *str + chars_read;
02980       } else if( sscanf( *str, "%d'%[sSbB]%[01xXzZ_\?]%n", &size, stype, value, &chars_read ) == 3 ) {
02981         bits_per_char = 1;
02982         *base         = BINARY;
02983         *str          = *str + chars_read;
02984       } else if( sscanf( *str, "%d'%[sSoO]%[0-7xXzZ_\?]%n", &size, stype, value, &chars_read ) == 3 ) {
02985         bits_per_char = 3;
02986         *base         = OCTAL;
02987         *str          = *str + chars_read;
02988       } else if( sscanf( *str, "%d'%[sShH]%[0-9a-fA-FxXzZ_\?]%n", &size, stype, value, &chars_read ) == 3 ) {
02989         bits_per_char = 4;
02990         *base         = HEXIDECIMAL;
02991         *str          = *str + chars_read;
02992       } else if( sscanf( *str, "'%[sSdD]%[0-9]%n", stype, value, &chars_read ) == 2 ) {
02993         bits_per_char = 10;
02994         *base         = DECIMAL;
02995         size          = 32;
02996         *str          = *str + chars_read;
02997       } else if( sscanf( *str, "'%[sSbB]%[01xXzZ_\?]%n", stype, value, &chars_read ) == 2 ) {
02998         bits_per_char = 1;
02999         *base         = BINARY;
03000         size          = 32;
03001         *str          = *str + chars_read;
03002       } else if( sscanf( *str, "'%[sSoO]%[0-7xXzZ_\?]%n", stype, value, &chars_read ) == 2 ) {
03003         bits_per_char = 3;
03004         *base         = OCTAL;
03005         size          = 32;
03006         *str          = *str + chars_read;
03007       } else if( sscanf( *str, "'%[sShH]%[0-9a-fA-FxXzZ_\?]%n", stype, value, &chars_read ) == 2 ) {
03008         bits_per_char = 4;
03009         *base         = HEXIDECIMAL;
03010         size          = 32;
03011         *str          = *str + chars_read;
03012       } else if( sscanf( *str, "%[0-9_]%n", value, &chars_read ) == 1 ) {
03013         bits_per_char = 10;
03014         *base         = DECIMAL;
03015         stype[0]      = 's';       
03016         stype[1]      = '\0';
03017         size          = 32;
03018         *str          = *str + chars_read;
03019       } else {
03020         /* If the specified string is none of the above, return NULL */
03021         bits_per_char = 0;
03022       }
03023 
03024       /* If we have exceeded the maximum number of bits, return a value of NULL */
03025       if( (size > MAX_BIT_WIDTH) || (bits_per_char == 0) ) {
03026 
03027         *vec  = NULL;
03028         *base = 0;
03029 
03030       } else {
03031 
03032         /* Create vector */
03033         *vec = vector_create( size, VTYPE_VAL, VDATA_UL, TRUE );
03034         if( *base == DECIMAL ) {
03035           (void)vector_from_uint64( *vec, ato64( value ) );
03036         } else {
03037           vector_set_static( *vec, value, bits_per_char ); 
03038         }
03039 
03040         /* Set the signed bit to the appropriate value based on the signed indicator in the vector string */
03041         if( (stype[0] == 's') || (stype [0] == 'S') ) {
03042           (*vec)->suppl.part.is_signed = 1;
03043         } else {
03044           (*vec)->suppl.part.is_signed = 0;
03045         }
03046 
03047       }
03048 
03049     }
03050 
03051     /* Deallocate memory */
03052     free_safe( stmp, (slen + 1) );
03053 
03054   }
03055 
03056   PROFILE_END;
03057 
03058 }

void vector_from_string_fixed vector vec,
const char *  str
 

Converts a string to a preallocated vector.

Stores the specified string into the specified vector. If the entire string cannot fit in the vector, only store as many characters as is possible.

Parameters:
vec  Pointer to vector to store string value
str  Pointer to string value to store

02893   { PROFILE(VECTOR_FROM_STRING_FIXED);
02894 
02895   unsigned int width = ((vec->width >> 3) < strlen( str )) ? (vec->width >> 3) : strlen( str );
02896   unsigned int pos = 0;
02897   int          i;
02898 
02899   /* TBD - Not sure if I need to support both endianness values here */
02900   for( i=(width-1); i>=0; i-- ) {
02901     vec->value.ul[pos>>(UL_DIV_VAL-3)][VTYPE_INDEX_VAL_VALL] |= (ulong)(str[i]) << ((pos & (UL_MOD_VAL >> 3)) << 3);
02902     pos++;
02903   }
02904 
02905   PROFILE_END;
02906 
02907 }

bool vector_from_uint64 vector vec,
uint64  value
 

Converts a 64-bit integer into a vector value.

Returns:
Returns TRUE if the value has changed from the last assignment to the given vector.
Converts a 64-bit integer value into a vector. This function is used along with the vector_to_uint64 for mathematical vector operations. We will first convert vectors into 64-bit integers, perform the mathematical operation, and then revert the 64-bit integers back into the vectors.
Parameters:
vec  Pointer to vector store value into
value  64-bit integer value to convert into vector

02528   { PROFILE(VECTOR_FROM_UINT64);
02529 
02530   bool retval = TRUE;  /* Return value for this function */
02531 
02532   switch( vec->suppl.part.data_type ) {
02533     case VDATA_UL :
02534       {
02535         ulong        scratchl[UL_DIV(MAX_BIT_WIDTH)];
02536         ulong        scratchh[UL_DIV(MAX_BIT_WIDTH)];
02537         unsigned int i;
02538         unsigned int size  = (vec->width < (sizeof( uint64 ) << 3)) ? UL_SIZE( vec->width ) : UL_SIZE( sizeof( uint64 ) << 3 );
02539         unsigned int shift = (UL_BITS <= (sizeof( uint64 ) << 3)) ? UL_BITS : (sizeof( uint64 ) << 3); 
02540         for( i=0; i<size; i++ ) {
02541           scratchl[i] = (ulong)value & UL_SET;
02542           scratchh[i] = 0;
02543           value >>= shift;
02544         }
02545         retval = vector_set_coverage_and_assign_ulong( vec, scratchl, scratchh, 0, (vec->width - 1) );
02546       }
02547       break;
02548     case VDATA_R64 :
02549       retval              = !DEQ( vec->value.r64->val, (double)value );
02550       vec->value.r64->val = (double)value;
02551       break;
02552     case VDATA_R32 :
02553       retval              = !FEQ( vec->value.r32->val, (float)value );
02554       vec->value.r32->val = (float)value;
02555       break;
02556     default :  assert( 0 );  break;
02557   }
02558 
02559   /* Because this value came from an unsigned integer, specify that the vector is unsigned */
02560   vec->suppl.part.is_signed = 0;
02561 
02562   PROFILE_END;
02563 
02564   return( retval );
02565 
02566 }

int vector_get_eval_a vector vec,
int  index
 

Returns the value of the eval_a for the given bit index.

Returns:
Returns eval_a coverage information for specified vector and bit position.
Parameters:
vec  Pointer to vector to get eval_a information from
index  Index to retrieve bit from

00847   { PROFILE(VECTOR_GET_EVAL_A);
00848 
00849   int retval;  /* Return value for this function */
00850 
00851   assert( vec != NULL );
00852   assert( vec->suppl.part.type == VTYPE_EXP );
00853 
00854   switch( vec->suppl.part.data_type ) {
00855     case VDATA_UL  :  retval = (vec->value.ul[UL_DIV(index)][VTYPE_INDEX_EXP_EVAL_A] >> UL_MOD(index)) & 0x1;  break;
00856     case VDATA_R64 :  retval = 0;
00857     default        :  assert( 0 );  break;
00858   }
00859 
00860   PROFILE_END;
00861 
00862   return( retval );
00863 
00864 }

int vector_get_eval_ab_count vector vec  ) 
 

Counts the number of eval_a/b bits set in the given vector.

Returns:
Returns the number of eval_a/b bits are set in the given vector.
Parameters:
vec  Pointer to vector to count eval_a/b bits in

00946   { PROFILE(VECTOR_GET_EVAL_AB_COUNT);
00947 
00948   int          count = 0;  /* Number of EVAL_A/B bits set */
00949   unsigned int i, j;       /* Loop iterators */
00950 
00951   switch( vec->suppl.part.data_type ) {
00952     case VDATA_UL :
00953       for( i=0; i<UL_SIZE( vec->width ); i++ ) {
00954         ulong value_a = vec->value.ul[i][VTYPE_INDEX_EXP_EVAL_A];
00955         ulong value_b = vec->value.ul[i][VTYPE_INDEX_EXP_EVAL_B];
00956         for( j=0; j<UL_BITS; j++ ) {
00957           count += (value_a >> j) & 0x1;
00958           count += (value_b >> j) & 0x1;
00959         }
00960       }
00961       break;
00962     case VDATA_R64 :
00963       break;
00964     default :  assert( 0 );  break;
00965   }
00966 
00967   PROFILE_END;
00968 
00969   return( count );
00970 
00971 }

int vector_get_eval_abc_count vector vec  ) 
 

Counts the number of eval_a/b/c bits set in the given vector.

Returns:
Returns the number of eval_a/b/c bits are set in the given vector.
Parameters:
vec  Pointer to vector to count eval_a/b/c bits in

00978   { PROFILE(VECTOR_GET_EVAL_ABC_COUNT);
00979 
00980   int          count = 0;  /* Number of EVAL_A/B/C bits set */
00981   unsigned int i, j;       /* Loop iterators */
00982 
00983   switch( vec->suppl.part.data_type ) {
00984     case VDATA_UL :
00985       for( i=0; i<UL_SIZE( vec->width ); i++ ) {
00986         ulong value_a = vec->value.ul[i][VTYPE_INDEX_EXP_EVAL_A]; 
00987         ulong value_b = vec->value.ul[i][VTYPE_INDEX_EXP_EVAL_B]; 
00988         ulong value_c = vec->value.ul[i][VTYPE_INDEX_EXP_EVAL_C]; 
00989         for( j=0; j<UL_BITS; j++ ) {
00990           count += (value_a >> j) & 0x1;
00991           count += (value_b >> j) & 0x1;
00992           count += (value_c >> j) & 0x1;
00993         }
00994       }
00995       break;
00996     case VDATA_R64 :
00997       break;
00998     default :  assert( 0 );  break;
00999   }
01000   
01001   PROFILE_END;
01002 
01003   return( count );
01004 
01005 }

int vector_get_eval_abcd_count vector vec  ) 
 

Counts the number of eval_a/b/c/d bits set in the given vector.

Returns:
Returns the number of eval_a/b/c/d bits are set in the given vector.
Parameters:
vec  Pointer to vector to count eval_a/b/c/d bits in

01012   { PROFILE(VECTOR_GET_EVAL_ABCD_COUNT);
01013 
01014   int          count = 0;  /* Number of EVAL_A/B/C/D bits set */
01015   unsigned int i, j;       /* Loop iterators */
01016 
01017   switch( vec->suppl.part.data_type ) {
01018     case VDATA_UL :
01019       for( i=0; i<UL_SIZE( vec->width ); i++ ) {
01020         ulong value_a = vec->value.ul[i][VTYPE_INDEX_EXP_EVAL_A]; 
01021         ulong value_b = vec->value.ul[i][VTYPE_INDEX_EXP_EVAL_B]; 
01022         ulong value_c = vec->value.ul[i][VTYPE_INDEX_EXP_EVAL_C]; 
01023         ulong value_d = vec->value.ul[i][VTYPE_INDEX_EXP_EVAL_D]; 
01024         for( j=0; j<UL_BITS; j++ ) {
01025           count += (value_a >> j) & 0x1;
01026           count += (value_b >> j) & 0x1;
01027           count += (value_c >> j) & 0x1;
01028           count += (value_d >> j) & 0x1;
01029         }
01030       }
01031       break;
01032     case VDATA_R64 :
01033       break;
01034     default :  assert( 0 );  break;
01035   }
01036   
01037   PROFILE_END;
01038 
01039   return( count );
01040 
01041 }

int vector_get_eval_b vector vec,
int  index
 

Returns the value of the eval_b for the given bit index.

Returns:
Returns eval_b coverage information for specified vector and bit position.
Parameters:
vec  Pointer to vector to get eval_b information from
index  Index to retrieve bit from

00872   { PROFILE(VECTOR_GET_EVAL_B);
00873 
00874   int retval;  /* Return value for this function */
00875 
00876   assert( vec != NULL );
00877   assert( vec->suppl.part.type == VTYPE_EXP );
00878 
00879   switch( vec->suppl.part.data_type ) {
00880     case VDATA_UL  :  retval = (vec->value.ul[UL_DIV(index)][VTYPE_INDEX_EXP_EVAL_B] >> UL_MOD(index)) & 0x1;  break;
00881     case VDATA_R64 :  retval = 0;
00882     default        :  assert( 0 );  break;
00883   }
00884 
00885   PROFILE_END;
00886 
00887   return( retval );
00888 
00889 }

int vector_get_eval_c vector vec,
int  index
 

Returns the value of the eval_c for the given bit index.

Returns:
Returns eval_c coverage information for specified vector and bit position.
Parameters:
vec  Pointer to vector to get eval_c information from
index  Index to retrieve bit from

00897   { PROFILE(VECTOR_GET_EVAL_C);
00898 
00899   int retval;  /* Return value for this function */
00900 
00901   assert( vec != NULL );
00902   assert( vec->suppl.part.type == VTYPE_EXP );
00903 
00904   switch( vec->suppl.part.data_type ) {
00905     case VDATA_UL  :  retval = (vec->value.ul[UL_DIV(index)][VTYPE_INDEX_EXP_EVAL_C] >> UL_MOD(index)) & 0x1;  break;
00906     case VDATA_R64 :  retval = 0;
00907     default        :  assert( 0 );  break;
00908   }
00909 
00910   PROFILE_END;
00911 
00912   return( retval );
00913 
00914 }

int vector_get_eval_d vector vec,
int  index
 

Returns the value of the eval_d for the given bit index.

Returns:
Returns eval_a coverage information for specified vector and bit position.
Parameters:
vec  Pointer to vector to get eval_d information from
index  Index to retrieve bit from

00922   { PROFILE(VECTOR_GET_EVAL_D);
00923 
00924   int retval;  /* Return value for this function */
00925 
00926   assert( vec != NULL );
00927   assert( vec->suppl.part.type == VTYPE_EXP );
00928 
00929   switch( vec->suppl.part.data_type ) {
00930     case VDATA_UL  :  retval = (vec->value.ul[UL_DIV(index)][VTYPE_INDEX_EXP_EVAL_D] >> UL_MOD(index)) & 0x1;  break;
00931     case VDATA_R64 :  retval = 0;
00932     default        :  assert( 0 );  break;
00933   }
00934 
00935   PROFILE_END;
00936 
00937   return( retval );
00938 
00939 }

char* vector_get_toggle01_ulong ulong **  value,
int  width
 

Returns string containing toggle 0 -> 1 information in binary format.

Returns:
Returns a string showing the toggle 0 -> 1 information.
Parameters:
value  Pointer to vector data array to get string from
width  Width of given vector data array

01049   { PROFILE(VECTOR_GET_TOGGLE01_ULONG);
01050 
01051   char* bits = (char*)malloc_safe( width + 1 );
01052   int   i;
01053   char  tmp[2];
01054 
01055   for( i=width; i--; ) {
01056     /*@-formatcode@*/
01057     unsigned int rv = snprintf( tmp, 2, "%hhx", (unsigned char)((value[UL_DIV(i)][VTYPE_INDEX_SIG_TOG01] >> UL_MOD(i)) & 0x1) );
01058     /*@=formatcode@*/
01059     assert( rv < 2 );
01060     bits[i] = tmp[0];
01061   }
01062 
01063   bits[width] = '\0';
01064     
01065   PROFILE_END;
01066 
01067   return( bits );
01068 
01069 }

char* vector_get_toggle10_ulong ulong **  value,
int  width
 

Returns string containing toggle 1 -> 0 information in binary format.

Returns:
Returns a string showing the toggle 1 -> 0 information.
Parameters:
value  Pointer to vector data array to get string from
width  Width of given vector data array

01077   { PROFILE(VECTOR_GET_TOGGLE10_ULONG);
01078 
01079   char* bits = (char*)malloc_safe( width + 1 );
01080   int   i;
01081   char  tmp[2];
01082   
01083   for( i=width; i--; ) {
01084     /*@-formatcode@*/ 
01085     unsigned int rv = snprintf( tmp, 2, "%hhx", (unsigned char)((value[UL_DIV(i)][VTYPE_INDEX_SIG_TOG10] >> UL_MOD(i)) & 0x1) );
01086     /*@=formatcode@*/ 
01087     assert( rv < 2 );
01088     bits[i] = tmp[0];
01089   } 
01090   
01091   bits[width] = '\0';
01092 
01093   PROFILE_END;
01094 
01095   return( bits );
01096 
01097 }

void vector_init_r32 vector vec,
rv32 value,
float  data,
char *  str,
bool  owns_value,
int  type
 

Initializes specified vector with shortreal information.

Initializes the specified vector with the contents of width and value (if value != NULL). If value != NULL, initializes all contents of value array to NaN.

Parameters:
vec  Pointer to vector to initialize
value  Pointer to 32-bit real value structure for vector
data  Initial value to set the data to
str  String representation of the value
owns_value  Set to TRUE if this vector is responsible for deallocating the given value array
type  Type of vector to initialize this to

00166   { PROFILE(VECTOR_INT_R32);
00167 
00168   vec->width                = 32;
00169   vec->suppl.all            = 0;
00170   vec->suppl.part.type      = type;
00171   vec->suppl.part.data_type = VDATA_R32;
00172   vec->suppl.part.owns_data = owns_value;
00173   vec->value.r32            = value;
00174 
00175   if( value != NULL ) {
00176 
00177     vec->value.r32->val = data;
00178     vec->value.r32->str = (str != NULL) ? strdup_safe( str ) : NULL;
00179 
00180   } else {
00181 
00182     assert( !owns_value );
00183 
00184   }
00185 
00186   PROFILE_END;
00187 
00188 }

void vector_init_r64 vector vec,
rv64 value,
double  data,
char *  str,
bool  owns_value,
int  type
 

Initializes specified vector with realtime information.

Initializes the specified vector with the contents of width and value (if value != NULL). If value != NULL, initializes all contents of value array to NaN.

Parameters:
vec  Pointer to vector to initialize
value  Pointer to real value structure for vector
data  Initial value to set the data to
str  String representation of the value
owns_value  Set to TRUE if this vector is responsible for deallocating the given value array
type  Type of vector to initialize this to

00131   { PROFILE(VECTOR_INT_R64);
00132 
00133   vec->width                = 64;
00134   vec->suppl.all            = 0;
00135   vec->suppl.part.type      = type;
00136   vec->suppl.part.data_type = VDATA_R64;
00137   vec->suppl.part.owns_data = owns_value;
00138   vec->value.r64            = value;
00139 
00140   if( value != NULL ) {
00141 
00142     vec->value.r64->val = data;
00143     vec->value.r64->str = (str != NULL) ? strdup_safe( str ) : NULL;
00144 
00145   } else {
00146 
00147     assert( !owns_value );
00148 
00149   }
00150 
00151   PROFILE_END;
00152 
00153 }

void vector_init_ulong vector vec,
ulong **  value,
ulong  data_l,
ulong  data_h,
bool  owns_value,
int  width,
int  type
 

Initializes specified vector.

Initializes the specified vector with the contents of width and value (if value != NULL). If value != NULL, initializes all contents of value array to 0x2 (X-value).

Parameters:
vec  Pointer to vector to initialize
value  Pointer to vec_data array for vector
data_l  Initial value to set each lower data value to
data_h  Initial value to set each upper data value to
owns_value  Set to TRUE if this vector is responsible for deallocating the given value array
width  Bit width of specified vector
type  Type of vector to initialize this to

00078   { PROFILE(VECTOR_INIT);
00079 
00080   vec->width                = width;
00081   vec->suppl.all            = 0;
00082   vec->suppl.part.type      = type;
00083   vec->suppl.part.data_type = VDATA_UL;
00084   vec->suppl.part.owns_data = owns_value;
00085   vec->value.ul             = value;
00086 
00087   if( value != NULL ) {
00088 
00089     int    i, j;
00090     int    size  = UL_SIZE(width);
00091     int    num   = vector_type_sizes[type];
00092     ulong  lmask = UL_HMASK(width - 1);
00093 
00094     assert( width > 0 );
00095 
00096     for( i=0; i<(size - 1); i++ ) {
00097       vec->value.ul[i][VTYPE_INDEX_VAL_VALL] = data_l;
00098       vec->value.ul[i][VTYPE_INDEX_VAL_VALH] = data_h;
00099       for( j=2; j<num; j++ ) {
00100         vec->value.ul[i][j] = 0x0;
00101       }
00102     }
00103 
00104     vec->value.ul[i][VTYPE_INDEX_VAL_VALL] = data_l & lmask;
00105     vec->value.ul[i][VTYPE_INDEX_VAL_VALH] = data_h & lmask;
00106     for( j=2; j<num; j++ ) {
00107       vec->value.ul[i][j] = 0x0;
00108     }
00109 
00110   } else {
00111 
00112     assert( !owns_value );
00113 
00114   }
00115 
00116   PROFILE_END;
00117 
00118 }

bool vector_is_not_zero const vector vec  ) 
 

Returns TRUE if specified vector is a non-zero value (does not check unknown bit).

Returns:
Returns TRUE if the given vector contains at least one non-zero bit; otherwise, returns FALSE.
Parameters:
vec  Pointer to vector to check for non-zero-ness

02234   { PROFILE(VECTOR_IS_NOT_ZERO);
02235 
02236   unsigned int i = 0;  /* Loop iterator */
02237   unsigned int size;   /* Size of data array */
02238 
02239   assert( vec != NULL );
02240   assert( vec->value.ul != NULL );
02241 
02242   switch( vec->suppl.part.data_type ) {
02243     case VDATA_UL :
02244       size = UL_SIZE( vec->width );
02245       while( (i < size) && (vec->value.ul[i][VTYPE_INDEX_VAL_VALL] == 0) ) i++;
02246       break;
02247     case VDATA_R64 :
02248       size = DEQ( vec->value.r64->val, 0.0 ) ? 1 : 0;
02249       break;
02250     case VDATA_R32 :
02251       size = FEQ( vec->value.r32->val, 0.0) ? 1 : 0;
02252       break;
02253     default :  assert( 0 );  break;
02254   }
02255 
02256   PROFILE_END;
02257 
02258   return( i < size );
02259 
02260 }

bool vector_is_unknown const vector vec  ) 
 

Returns TRUE if specified vector has unknown bits set.

Returns:
Returns TRUE if the given vector contains unknown (X or Z) bits; otherwise, returns FALSE.
Parameters:
vec  Pointer to vector check for unknown-ness

02203   { PROFILE(VECTOR_IS_UKNOWN);
02204 
02205   unsigned int i = 0;  /* Loop iterator */
02206   unsigned int size;   /* Size of data array */
02207 
02208   assert( vec != NULL );
02209   assert( vec->value.ul != NULL );
02210 
02211   switch( vec->suppl.part.data_type ) {
02212     case VDATA_UL :
02213       size = UL_SIZE( vec->width );
02214       while( (i < size) && (vec->value.ul[i][VTYPE_INDEX_VAL_VALH] == 0) ) i++;
02215       break;
02216     case VDATA_R64 :
02217     case VDATA_R32 :
02218       size = 0;
02219       break;
02220     default :  assert( 0 );  break;
02221   }
02222 
02223   PROFILE_END;
02224 
02225   return( i < size );
02226 
02227 }

void vector_mem_rw_count vector vec,
int  lsb,
int  msb,
unsigned int *  wr_cnt,
unsigned int *  rd_cnt
 

Counts memory write and read information from specified vector.

Counts the number of bits that were written and read for the given memory vector.

Parameters:
vec  Pointer to vector to parse
lsb  Least-significant bit of memory element to get information for
msb  Most-significant bit of memory element to get information for
wr_cnt  Pointer to number of bits in vector that were written
rd_cnt  Pointer to number of bits in vector that were read

01426   { PROFILE(VECTOR_MEM_RW_COUNT);
01427 
01428   unsigned int i, j;  /* Loop iterator */
01429 
01430   switch( vec->suppl.part.data_type ) {
01431     case VDATA_UL :
01432       { 
01433         ulong lmask = UL_LMASK(lsb);
01434         ulong hmask = UL_HMASK(msb);
01435         if( UL_DIV(lsb) == UL_DIV(msb) ) {
01436           lmask &= hmask;
01437         }
01438         for( i=UL_DIV(lsb); i<=UL_DIV(msb); i++ ) {
01439           ulong mask = (i == UL_DIV(lsb)) ? lmask : ((i == UL_DIV(msb)) ? hmask : UL_SET);
01440           ulong wr   = vec->value.ul[i][VTYPE_INDEX_MEM_WR] & mask;
01441           ulong rd   = vec->value.ul[i][VTYPE_INDEX_MEM_RD] & mask;
01442           for( j=0; j<UL_BITS; j++ ) {
01443             *wr_cnt += (wr >> j) & 0x1;
01444             *rd_cnt += (rd >> j) & 0x1;
01445           }
01446         }
01447       }
01448       break;
01449     case VDATA_R64 :
01450       break;
01451     default :  assert( 0 );  break;
01452   }
01453 
01454   PROFILE_END;
01455 
01456 }

void vector_merge vector base,
vector other
 

Merges two vectors, placing the result into the base vector.

Merges two vectors, placing the result back into the base vector. This function is used by the GUI for calculating module coverage.

Parameters:
base  Vector which will contain the merged results
other  Vector which will merge its results into the base vector

00811   { PROFILE(VECTOR_MERGE);
00812 
00813   unsigned int i, j;  /* Loop iterator */
00814 
00815   assert( base != NULL );
00816   assert( base->width == other->width );
00817 
00818   if( base->suppl.part.owns_data == 1 ) {
00819 
00820     switch( base->suppl.part.data_type ) {
00821       case VDATA_UL :
00822         for( i=0; i<UL_SIZE(base->width); i++ ) {
00823           for( j=2; j<vector_type_sizes[base->suppl.part.type]; j++ ) {
00824             base->value.ul[i][j] |= other->value.ul[i][j];
00825           }
00826         }
00827         break;
00828       case VDATA_R64 :
00829       case VDATA_R32 :
00830         /* Nothing to do here */
00831         break;
00832       default :  assert( 0 );  break;
00833     }
00834 
00835   }
00836 
00837   PROFILE_END;
00838 
00839 }

bool vector_op_add vector tgt,
const vector left,
const vector right
 

Performs addition operation on left and right expression values.

Returns:
Returns TRUE if assigned value differs from original value; otherwise, returns FALSE.
Performs 4-state bitwise addition on left and right expression values. Carry bit is discarded (value is wrapped around).
Parameters:
tgt  Target vector for storage of results
left  Expression value on left side of + sign
right  Expression value on right side of + sign

04239   { PROFILE(VECTOR_OP_ADD);
04240 
04241   bool retval;  /* Return value for this function */
04242 
04243   /* If either the left or right vector is unknown, set the entire value to X */
04244   if( vector_is_unknown( left ) || vector_is_unknown( right ) ) {
04245 
04246     retval = vector_set_to_x( tgt );
04247 
04248   /* Otherwise, perform the addition operation */
04249   } else {
04250 
04251     switch( tgt->suppl.part.data_type ) {
04252       case VDATA_UL :
04253         {
04254           ulong        vall[UL_DIV(MAX_BIT_WIDTH)];
04255           ulong        valh[UL_DIV(MAX_BIT_WIDTH)];
04256           ulong        carry = 0;
04257           bool         lmsb_is_one = (((left->value.ul[UL_DIV(left->width-1)][VTYPE_INDEX_VAL_VALL]   >> UL_MOD(left->width  - 1)) & 1) == 1);
04258           bool         rmsb_is_one = (((right->value.ul[UL_DIV(right->width-1)][VTYPE_INDEX_VAL_VALL] >> UL_MOD(right->width - 1)) & 1) == 1);
04259           ulong        lvall, lvalh;
04260           ulong        rvall, rvalh;
04261           unsigned int i;
04262           for( i=0; i<UL_SIZE( tgt->width ); i++ ) {
04263             vector_copy_val_and_sign_extend_ulong( left,  i, lmsb_is_one, &lvall, &lvalh ); 
04264             vector_copy_val_and_sign_extend_ulong( right, i, rmsb_is_one, &rvall, &rvalh ); 
04265             vall[i] = lvall + rvall + carry;
04266             valh[i] = 0;
04267             carry   = ((lvall & rvall) | ((lvall | rvall) & ~vall[i])) >> (UL_BITS - 1);
04268           }
04269           retval = vector_set_coverage_and_assign_ulong( tgt, vall, valh, 0, (tgt->width - 1) );
04270         }
04271         break;
04272       case VDATA_R64 :
04273         {
04274           double result       = vector_to_real64( left ) + vector_to_real64( right );
04275           retval              = !DEQ( tgt->value.r64->val, result );
04276           tgt->value.r64->val = result;
04277         }
04278         break;
04279       case VDATA_R32 :
04280         {
04281           float result        = (float)(vector_to_real64( left ) + vector_to_real64( right ));
04282           retval              = !FEQ( tgt->value.r32->val, result );
04283           tgt->value.r32->val = result;
04284         }
04285         break;
04286       default :  assert( 0 );  break;
04287     }
04288 
04289   }
04290 
04291   PROFILE_END;
04292 
04293   return( retval );
04294 
04295 }    

bool vector_op_arshift vector tgt,
const vector left,
const vector right
 

Performs arithmetic right shift operation on left expression by right expression bits.

Returns:
Returns TRUE if assigned value differs from original value; otherwise, returns FALSE.
Converts right expression into an integer value and right shifts the left expression the specified number of bit locations, sign extending the MSB.
Parameters:
tgt  Target vector for storage of results
left  Expression value being shifted left
right  Expression containing number of bit positions to shift

04189   { PROFILE(VECTOR_OP_ARSHIFT);
04190 
04191   bool retval;  /* Return value for this function */
04192 
04193   if( vector_is_unknown( right ) ) {
04194   
04195     retval = vector_set_to_x( tgt );
04196     
04197   } else {
04198   
04199     int shift_val = vector_to_int( right );
04200     
04201     switch( tgt->suppl.part.data_type ) {
04202       case VDATA_UL :
04203         {
04204           ulong        vall[UL_DIV(MAX_BIT_WIDTH)];
04205           ulong        valh[UL_DIV(MAX_BIT_WIDTH)];
04206           ulong        signl, signh;
04207           unsigned int msb = left->width - 1;
04208 
04209           vector_rshift_ulong( left, vall, valh, shift_val, msb );
04210           if( left->suppl.part.is_signed ) {
04211             vector_get_sign_extend_vector_ulong( left, &signl, &signh );
04212             vector_sign_extend_ulong( vall, valh, signl, signh, (msb - shift_val), tgt->width );
04213           }
04214         
04215           retval = vector_set_coverage_and_assign_ulong( tgt, vall, valh, 0, (tgt->width - 1) );
04216         }
04217         break;
04218       default :  assert( 0 );  break;
04219     }
04220 
04221   }
04222 
04223   PROFILE_END;
04224 
04225   return( retval );
04226 
04227 }

bool vector_op_ceq vector tgt,
const vector left,
const vector right
 

Performs case equal comparison of two vectors.

Returns:
Returns TRUE if the assigned value differs from the original value; otherwise, returns FALSE.
Performs a case equal comparison of the left and right expressions.
Parameters:
tgt  Target vector for storage of results
left  Expression on left of greater-than-or-equal sign
right  Expression on right of greater-than-or-equal sign

03822   { PROFILE(VECTOR_OP_CEQ);
03823 
03824   bool retval;  /* Return value for this function */
03825 
03826   switch( tgt->suppl.part.data_type ) {
03827     case VDATA_UL :
03828       {
03829         ulong scratchl = vector_ceq_ulong( left, right );
03830         ulong scratchh = 0;
03831         retval = vector_set_coverage_and_assign_ulong( tgt, &scratchl, &scratchh, 0, 0 );
03832       }
03833       break;
03834     default :  assert( 0 );  break;
03835   }
03836 
03837   PROFILE_END;
03838 
03839   return( retval );
03840 
03841 }

bool vector_op_cne vector tgt,
const vector left,
const vector right
 

Performs case not-equal comparison of two vectors.

Returns:
Returns TRUE if the assigned value differs from the original value; otherwise, returns FALSE.
Performs an case not-equal comparison of the left and right expressions.
Parameters:
tgt  Target vector for storage of results
left  Expression on left of greater-than-or-equal sign
right  Expression on right of greater-than-or-equal sign

04010   { PROFILE(VECTOR_OP_CNE);
04011 
04012   bool retval;  /* Return value for this function */
04013   
04014   switch( tgt->suppl.part.data_type ) {
04015     case VDATA_UL :
04016       {
04017         ulong scratchl = !vector_ceq_ulong( left, right );
04018         ulong scratchh = 0;
04019         retval = vector_set_coverage_and_assign_ulong( tgt, &scratchl, &scratchh, 0, 0 );
04020       }
04021       break;
04022     default :  assert( 0 );  break;
04023   }
04024 
04025   PROFILE_END;
04026 
04027   return( retval );
04028 
04029 }

bool vector_op_cxeq vector tgt,
const vector left,
const vector right
 

Performs casex equal comparison of two vectors.

Returns:
Returns TRUE if the assigned value differs from the original value; otherwise, returns FALSE.
Performs a casex equal comparison of the left and right expressions.
Parameters:
tgt  Target vector for storage of results
left  Expression on left of greater-than-or-equal sign
right  Expression on right of greater-than-or-equal sign

03852   { PROFILE(VECTOR_OP_CXEQ);
03853 
03854   bool retval;  /* Return value for this function */
03855 
03856   switch( tgt->suppl.part.data_type ) {
03857     case VDATA_UL :
03858       {
03859         ulong        scratchl    = 0;
03860         ulong        scratchh    = 0;
03861         unsigned int lsize       = UL_SIZE(left->width);
03862         unsigned int rsize       = UL_SIZE(right->width);
03863         int          i           = ((lsize < rsize) ? rsize : lsize);
03864         unsigned int lmsb        = (left->width - 1);
03865         unsigned int rmsb        = (right->width - 1);
03866         bool         lmsb_is_one = (((left->value.ul[UL_DIV(lmsb)][VTYPE_INDEX_VAL_VALL]  >> UL_MOD(lmsb)) & 1) == 1);
03867         bool         rmsb_is_one = (((right->value.ul[UL_DIV(rmsb)][VTYPE_INDEX_VAL_VALL] >> UL_MOD(rmsb)) & 1) == 1);
03868         ulong        mask        = (left->width < right->width) ? UL_HMASK(left->width - 1) : UL_HMASK(right->width - 1);
03869         ulong        lvall;
03870         ulong        lvalh;
03871         ulong        rvall;
03872         ulong        rvalh;
03873         do {
03874           i--;
03875           vector_copy_val_and_sign_extend_ulong( left,  i, lmsb_is_one, &lvall, &lvalh );
03876           vector_copy_val_and_sign_extend_ulong( right, i, rmsb_is_one, &rvall, &rvalh );
03877         } while( (i > 0) && (((~(lvall ^ rvall) | lvalh | rvalh) & mask) == mask) );
03878         scratchl = (((~(lvall ^ rvall) | lvalh | rvalh) & mask) == mask);
03879         retval   = vector_set_coverage_and_assign_ulong( tgt, &scratchl, &scratchh, 0, 0 );
03880       }
03881       break;
03882     default :  assert( 0 );  break;
03883   }
03884 
03885   PROFILE_END;
03886 
03887   return( retval );
03888 
03889 }

bool vector_op_czeq vector tgt,
const vector left,
const vector right
 

Performs casez equal comparison of two vectors.

Returns:
Returns TRUE if the assigned value differs from the original value; otherwise, returns FALSE.
Performs a casez equal comparison of the left and right expressions.
Parameters:
tgt  Target vector for storage of results
left  Expression on left of greater-than-or-equal sign
right  Expression on right of greater-than-or-equal sign

03900   { PROFILE(VECTOR_OP_CZEQ);
03901 
03902   bool retval;  /* Return value for this function */
03903 
03904   switch( tgt->suppl.part.data_type ) {
03905     case VDATA_UL :
03906       {
03907         ulong        scratchl    = 0;
03908         ulong        scratchh    = 0;
03909         unsigned int lsize       = UL_SIZE(left->width);
03910         unsigned int rsize       = UL_SIZE(right->width);
03911         int          i           = ((lsize < rsize) ? rsize : lsize) - 1;
03912         unsigned int lmsb        = (left->width - 1);
03913         unsigned int rmsb        = (right->width - 1);
03914         bool         lmsb_is_one = (((left->value.ul[UL_DIV(lmsb)][VTYPE_INDEX_VAL_VALL]  >> UL_MOD(lmsb)) & 1) == 1);
03915         bool         rmsb_is_one = (((right->value.ul[UL_DIV(rmsb)][VTYPE_INDEX_VAL_VALL] >> UL_MOD(rmsb)) & 1) == 1);
03916         ulong        mask        = (left->width < right->width) ? UL_HMASK(left->width - 1) : UL_HMASK(right->width - 1);
03917         ulong        lvall;
03918         ulong        lvalh;
03919         ulong        rvall;
03920         ulong        rvalh;
03921         vector_copy_val_and_sign_extend_ulong( left,  i, lmsb_is_one, &lvall, &lvalh );
03922         vector_copy_val_and_sign_extend_ulong( right, i, rmsb_is_one, &rvall, &rvalh );
03923         while( (i > 0) && ((((~(lvall ^ rvall) & ~(lvalh ^ rvalh)) | (lvalh & lvall) | (rvalh & rvall)) & mask) == mask) ) {
03924           mask  = UL_SET;
03925           i--;
03926           vector_copy_val_and_sign_extend_ulong( left,  i, lmsb_is_one, &lvall, &lvalh );
03927           vector_copy_val_and_sign_extend_ulong( right, i, rmsb_is_one, &rvall, &rvalh );
03928         }
03929         scratchl = ((((~(lvall ^ rvall) & ~(lvalh ^ rvalh)) | (lvalh & lvall) | (rvalh & rvall)) & mask) == mask);
03930         retval   = vector_set_coverage_and_assign_ulong( tgt, &scratchl, &scratchh, 0, 0 );
03931       }
03932       break;
03933     default :  assert( 0 );  break;
03934   }
03935 
03936   PROFILE_END;
03937 
03938   return( retval );
03939 
03940 }

bool vector_op_dec vector tgt,
vecblk tvb
 

Performs increment operation on specified vector.

Returns:
Returns TRUE (decrements will always cause a value change)
Performs an decrement operation on the specified vector.
Parameters:
tgt  Target vector to assign data to
tvb  Pointer to vector block for temporary vectors

04650   { PROFILE(VECTOR_OP_DEC);
04651 
04652   switch( tgt->suppl.part.data_type ) {
04653     case VDATA_UL :
04654       {
04655         vector* tmp1 = &(tvb->vec[tvb->index++]);
04656         vector* tmp2 = &(tvb->vec[tvb->index++]);
04657         vector_copy( tgt, tmp1 );
04658         tmp2->value.ul[0][VTYPE_INDEX_VAL_VALL] = 1;
04659         (void)vector_op_subtract( tgt, tmp1, tmp2 );
04660       }
04661     case VDATA_R64 :
04662       tgt->value.r64->val -= 1.0;
04663       break;
04664     case VDATA_R32 :
04665       tgt->value.r32->val -= 1.0;
04666       break;
04667     default :  assert( 0 );  break;
04668   }
04669 
04670   PROFILE_END;
04671 
04672   return( TRUE );
04673 
04674 }

bool vector_op_divide vector tgt,
const vector left,
const vector right
 

Performs division operation on left and right vector values.

Returns:
Returns TRUE if value changes; otherwise, returns FALSE.
Performs vector divide operation.
Parameters:
tgt  Pointer to vector that will store divide result
left  Pointer to left vector
right  Pointer to right vector

04514   { PROFILE(VECTOR_OP_DIVIDE);
04515 
04516   bool retval;  /* Return value for this function */
04517 
04518   if( vector_is_unknown( left ) || vector_is_unknown( right ) ) {
04519 
04520     retval = vector_set_to_x( tgt );
04521 
04522   } else {
04523 
04524     switch( tgt->suppl.part.data_type ) {
04525       case VDATA_UL :
04526         {
04527           ulong vall;
04528           ulong valh = 0;
04529           ulong rval = right->value.ul[0][VTYPE_INDEX_EXP_VALL];
04530           if( rval == 0 ) {
04531             retval = vector_set_to_x( tgt );
04532           } else {
04533             vall = left->value.ul[0][VTYPE_INDEX_EXP_VALL] / rval;
04534             retval = vector_set_coverage_and_assign_ulong( tgt, &vall, &valh, 0, (UL_BITS - 1) );
04535           }
04536         }
04537         break;
04538       case VDATA_R64 :
04539         {
04540           double result       = vector_to_real64( left ) / vector_to_real64( right );
04541           retval              = !DEQ( tgt->value.r64->val, result);
04542           tgt->value.r64->val = result;
04543         }
04544         break;
04545       case VDATA_R32 :
04546         {
04547           float result        = (float)(vector_to_real64( left ) / vector_to_real64( right ));
04548           retval              = !FEQ( tgt->value.r32->val, result );
04549           tgt->value.r32->val = result;
04550         }
04551         break;
04552       default :  assert( 0 );  break;
04553     }
04554 
04555   }
04556 
04557   PROFILE_END;
04558 
04559   return( retval );
04560 
04561 }

bool vector_op_eq vector tgt,
const vector left,
const vector right
 

Performs equal comparison of two vectors.

Returns:
Returns TRUE if the assigned value differs from the original value; otherwise, returns FALSE.
Performs an equal comparison of the left and right expressions.
Parameters:
tgt  Target vector for storage of results
left  Expression on left of greater-than-or-equal sign
right  Expression on right of greater-than-or-equal sign

03726   { PROFILE(VECTOR_OP_EQ);
03727 
03728   bool retval;  /* Return value for this function */
03729 
03730   // printf( "In vector_op_eq...\n" );
03731   // printf( "  left:  " );  vector_display( left );
03732   // printf( "  right: " );  vector_display( right );
03733 
03734   if( vector_is_unknown( left ) || vector_is_unknown( right ) ) {
03735 
03736     retval = vector_set_to_x( tgt );
03737 
03738   } else {
03739 
03740     switch( tgt->suppl.part.data_type ) {
03741       case VDATA_UL :
03742         {
03743           ulong scratchl;
03744           ulong scratchh = 0;
03745           if( (left->suppl.part.data_type == VDATA_UL) && (right->suppl.part.data_type == VDATA_UL) ) {
03746             unsigned int lsize       = UL_SIZE(left->width);
03747             unsigned int rsize       = UL_SIZE(right->width);
03748             int          i           = ((lsize < rsize) ? rsize : lsize);
03749             unsigned int lmsb        = (left->width - 1);
03750             unsigned int rmsb        = (right->width - 1);
03751             bool         lmsb_is_one = (((left->value.ul[UL_DIV(lmsb)][VTYPE_INDEX_VAL_VALL]  >> UL_MOD(lmsb)) & 1) == 1);
03752             bool         rmsb_is_one = (((right->value.ul[UL_DIV(rmsb)][VTYPE_INDEX_VAL_VALL] >> UL_MOD(rmsb)) & 1) == 1);
03753             ulong        lvall;
03754             ulong        lvalh;
03755             ulong        rvall;
03756             ulong        rvalh;
03757             do {
03758               i--;
03759               vector_copy_val_and_sign_extend_ulong( left,  i, lmsb_is_one, &lvall, &lvalh );
03760               vector_copy_val_and_sign_extend_ulong( right, i, rmsb_is_one, &rvall, &rvalh );
03761             } while( (i > 0) && (lvall == rvall) );
03762             scratchl = (lvall == rvall);
03763           } else {
03764             scratchl = DEQ( vector_to_real64( left ), vector_to_real64( right )) ? 1 : 0;
03765           }
03766           retval = vector_set_coverage_and_assign_ulong( tgt, &scratchl, &scratchh, 0, 0 );
03767         }
03768         break;
03769       default :  assert( 0 );  break;
03770     }
03771 
03772   }
03773 
03774   PROFILE_END;
03775 
03776   return( retval );
03777 
03778 }

bool vector_op_expand vector tgt,
const vector left,
const vector right
 

Performs expansion operation.

Returns:
Returns TRUE if the new value differs from the old value; otherwise, returns FALSE.
Performs expansion operation.
Parameters:
tgt  Pointer to vector to store results in
left  Pointer to vector containing expansion multiplier value
right  Pointer to vector that will be multiplied

05019   { PROFILE(VECTOR_OP_EXPAND);
05020 
05021   bool retval;  /* Return value for this function */
05022 
05023   switch( tgt->suppl.part.data_type ) {
05024     case VDATA_UL :
05025       {
05026         ulong        vall[UL_DIV(MAX_BIT_WIDTH)];
05027         ulong        valh[UL_DIV(MAX_BIT_WIDTH)];
05028         unsigned int i, j;
05029         unsigned int rwidth     = right->width;
05030         unsigned int multiplier = vector_to_int( left );
05031         unsigned int pos        = 0;
05032         for( i=0; i<multiplier; i++ ) {
05033           for( j=0; j<rwidth; j++ ) {
05034             ulong*       rval     = right->value.ul[UL_DIV(j)];
05035             unsigned int my_index = UL_DIV(pos);
05036             unsigned int offset   = UL_MOD(pos);
05037             if( offset == 0 ) {
05038               vall[my_index] = 0;
05039               valh[my_index] = 0;
05040             }
05041             vall[my_index] |= ((rval[VTYPE_INDEX_VAL_VALL] >> UL_MOD(j)) & 0x1) << offset;
05042             valh[my_index] |= ((rval[VTYPE_INDEX_VAL_VALH] >> UL_MOD(j)) & 0x1) << offset;
05043             pos++;
05044           }
05045         }
05046         retval = vector_set_coverage_and_assign_ulong( tgt, vall, valh, 0, (tgt->width - 1) );
05047       }
05048       break;
05049     default :  assert( 0 );  break;
05050   }
05051 
05052   PROFILE_END;
05053 
05054   return( retval );
05055 
05056 }

bool vector_op_ge vector tgt,
const vector left,
const vector right
 

Performs greater-than-or-equal comparison of two vectors.

Returns:
Returns TRUE if the assigned value differs from the original value; otherwise, returns FALSE.
Performs a greater-than-or-equal comparison of the left and right expressions.
Parameters:
tgt  Target vector for storage of results
left  Expression on left of greater-than-or-equal sign
right  Expression on right of greater-than-or-equal sign

03667   { PROFILE(VECTOR_OP_GE);
03668 
03669   bool retval;  /* Return value for this function */
03670 
03671   if( vector_is_unknown( left ) || vector_is_unknown( right ) ) {
03672 
03673     retval = vector_set_to_x( tgt );
03674 
03675   } else {
03676 
03677     switch( tgt->suppl.part.data_type ) {
03678       case VDATA_UL :
03679         {
03680           ulong scratchl;
03681           ulong scratchh = 0;
03682           if( (left->suppl.part.data_type == VDATA_UL) && (right->suppl.part.data_type == VDATA_UL) ) {
03683             unsigned int lsize       = UL_SIZE(left->width);
03684             unsigned int rsize       = UL_SIZE(right->width);
03685             int          i           = ((lsize < rsize) ? rsize : lsize);
03686             unsigned int lmsb        = (left->width - 1);
03687             unsigned int rmsb        = (right->width - 1);
03688             bool         lmsb_is_one = (((left->value.ul[UL_DIV(lmsb)][VTYPE_INDEX_VAL_VALL]  >> UL_MOD(lmsb)) & 1) == 1);
03689             bool         rmsb_is_one = (((right->value.ul[UL_DIV(rmsb)][VTYPE_INDEX_VAL_VALL] >> UL_MOD(rmsb)) & 1) == 1);
03690             ulong        lvall;
03691             ulong        lvalh;
03692             ulong        rvall;
03693             ulong        rvalh;
03694             do {
03695               i--;
03696               vector_copy_val_and_sign_extend_ulong( left,  i, lmsb_is_one, &lvall, &lvalh );
03697               vector_copy_val_and_sign_extend_ulong( right, i, rmsb_is_one, &rvall, &rvalh );
03698             } while( (i > 0) && (lvall == rvall) );
03699             scratchl = vector_reverse_for_cmp_ulong( left, right ) ? (rvall >= lvall) : (lvall >= rvall);
03700           } else {
03701             scratchl = (vector_to_real64( left ) >= vector_to_real64( right )) ? 1 : 0;
03702           }
03703           retval = vector_set_coverage_and_assign_ulong( tgt, &scratchl, &scratchh, 0, 0 );
03704         }
03705         break;
03706       default :  assert( 0 );  break;
03707     }
03708 
03709   }
03710 
03711   PROFILE_END;
03712 
03713   return( retval );
03714 
03715 }

bool vector_op_gt vector tgt,
const vector left,
const vector right
 

Performs greater-than comparison of two vectors.

Returns:
Returns TRUE if the assigned value differs from the original value; otherwise, returns FALSE.
Performs a greater-than comparison of the left and right expressions.
Parameters:
tgt  Target vector for storage of results
left  Expression on left of greater-than sign
right  Expression on right of greater-than sign

03608   { PROFILE(VECTOR_OP_GT);
03609 
03610   bool retval;  /* Return value for this function */
03611 
03612   if( vector_is_unknown( left ) || vector_is_unknown( right ) ) {
03613  
03614     retval = vector_set_to_x( tgt );
03615 
03616   } else {
03617 
03618     switch( tgt->suppl.part.data_type ) {
03619       case VDATA_UL :
03620         {
03621           ulong scratchl;
03622           ulong scratchh = 0;
03623           if( (left->suppl.part.data_type == VDATA_UL) && (right->suppl.part.data_type == VDATA_UL) ) {
03624             unsigned int lsize       = UL_SIZE(left->width);
03625             unsigned int rsize       = UL_SIZE(right->width);
03626             int          i           = ((lsize < rsize) ? rsize : lsize);
03627             unsigned int lmsb        = (left->width - 1);
03628             unsigned int rmsb        = (right->width - 1);
03629             bool         lmsb_is_one = (((left->value.ul[UL_DIV(lmsb)][VTYPE_INDEX_VAL_VALL]  >> UL_MOD(lmsb)) & 1) == 1);
03630             bool         rmsb_is_one = (((right->value.ul[UL_DIV(rmsb)][VTYPE_INDEX_VAL_VALL] >> UL_MOD(rmsb)) & 1) == 1);
03631             ulong        lvall;
03632             ulong        lvalh;
03633             ulong        rvall;
03634             ulong        rvalh;
03635             do {
03636               i--;
03637               vector_copy_val_and_sign_extend_ulong( left,  i, lmsb_is_one, &lvall, &lvalh );
03638               vector_copy_val_and_sign_extend_ulong( right, i, rmsb_is_one, &rvall, &rvalh );
03639             } while( (i > 0) && (lvall == rvall) );
03640             scratchl = vector_reverse_for_cmp_ulong( left, right ) ? (rvall > lvall) : (lvall > rvall);
03641           } else {
03642             scratchl = (vector_to_real64( left ) > vector_to_real64( right )) ? 1 : 0;
03643           }
03644           retval = vector_set_coverage_and_assign_ulong( tgt, &scratchl, &scratchh, 0, 0 );
03645         }
03646         break;
03647       default :  assert( 0 );  break;
03648     }
03649 
03650   }
03651 
03652   PROFILE_END;
03653 
03654   return( retval );
03655 
03656 }

bool vector_op_inc vector tgt,
vecblk tvb
 

Performs increment operation on specified vector.

Returns:
Returns TRUE (increments will always cause a value change)
Performs an increment operation on the specified vector.
Parameters:
tgt  Target vector to assign data to
tvb  Pointer to vector block for temporary vectors

04615   { PROFILE(VECTOR_OP_INC);
04616 
04617   switch( tgt->suppl.part.data_type ) {
04618     case VDATA_UL :
04619       {
04620         vector* tmp1 = &(tvb->vec[tvb->index++]);
04621         vector* tmp2 = &(tvb->vec[tvb->index++]);
04622         vector_copy( tgt, tmp1 );
04623         tmp2->value.ul[0][VTYPE_INDEX_VAL_VALL] = 1;
04624         (void)vector_op_add( tgt, tmp1, tmp2 );
04625       }
04626       break;
04627     case VDATA_R64 :
04628       tgt->value.r64->val += 1.0;
04629       break;
04630     case VDATA_R32 :
04631       tgt->value.r32->val += 1.0;
04632       break;
04633     default :  assert( 0 );  break;
04634   }
04635 
04636   PROFILE_END;
04637 
04638   return( TRUE );
04639 
04640 }

bool vector_op_land vector tgt,
const vector left,
const vector right
 

Performs logical-AND operation of two vectors.

Returns:
Returns TRUE if the value of tgt changed as a result of this operation; otherwise, returns FALSE.
Performs logical-AND operation and calculates coverage information.
Parameters:
tgt  Pointer to vector to store result into
left  Pointer to left vector of expression
right  Pointer to right vector of expression

04072   { PROFILE(VECTOR_OP_LAND);
04073 
04074   bool retval;                                 /* Return value for this function */
04075   bool lunknown = vector_is_unknown( left );   /* Check for left value being unknown */
04076   bool runknown = vector_is_unknown( right );  /* Check for right value being unknown */
04077 
04078   switch( tgt->suppl.part.data_type ) {
04079     case VDATA_UL :
04080       {
04081         ulong valh = (lunknown && runknown) ? 1 : 0;
04082         ulong vall = ((!lunknown && vector_is_not_zero( left )) && (!runknown && vector_is_not_zero( right ))) ? 1 : 0;
04083         retval     = vector_set_coverage_and_assign_ulong( tgt, &vall, &valh, 0, 0 );
04084       }
04085       break;
04086     default :  assert( 0 );  break;
04087   }
04088 
04089   PROFILE_END;
04090 
04091   return( retval );
04092 
04093 }

bool vector_op_le vector tgt,
const vector left,
const vector right
 

Performs less-than-or-equal comparison of two vectors.

Returns:
Returns TRUE if the assigned value differs from the original value; otherwise, returns FALSE.
Performs a less-than-or-equal comparison of the left and right expressions.
Parameters:
tgt  Target vector for storage of results
left  Expression on left of less than sign
right  Expression on right of less than sign

03549   { PROFILE(VECTOR_OP_LE);
03550 
03551   bool retval;  /* Return value for this function */
03552 
03553   if( vector_is_unknown( left ) || vector_is_unknown( right ) ) {
03554 
03555     retval = vector_set_to_x( tgt );
03556 
03557   } else {
03558 
03559     switch( tgt->suppl.part.data_type ) {
03560       case VDATA_UL :
03561         {
03562           ulong scratchl;
03563           ulong scratchh = 0;
03564           if( (left->suppl.part.data_type == VDATA_UL) && (right->suppl.part.data_type == VDATA_UL) ) {
03565             unsigned int lsize       = UL_SIZE(left->width);
03566             unsigned int rsize       = UL_SIZE(right->width);
03567             int          i           = ((lsize < rsize) ? rsize : lsize);
03568             unsigned int lmsb        = (left->width - 1);
03569             unsigned int rmsb        = (right->width - 1);
03570             bool         lmsb_is_one = (((left->value.ul[UL_DIV(lmsb)][VTYPE_INDEX_VAL_VALL]  >> UL_MOD(lmsb)) & 1) == 1);
03571             bool         rmsb_is_one = (((right->value.ul[UL_DIV(rmsb)][VTYPE_INDEX_VAL_VALL] >> UL_MOD(rmsb)) & 1) == 1);
03572             ulong        lvall;
03573             ulong        lvalh;
03574             ulong        rvall;
03575             ulong        rvalh;
03576             do {
03577               i--;
03578               vector_copy_val_and_sign_extend_ulong( left,  i, lmsb_is_one, &lvall, &lvalh );
03579               vector_copy_val_and_sign_extend_ulong( right, i, rmsb_is_one, &rvall, &rvalh );
03580             } while( (i > 0) && (lvall == rvall) );
03581             scratchl = vector_reverse_for_cmp_ulong( left, right ) ? (rvall <= lvall) : (lvall <= rvall);
03582           } else {
03583             scratchl = (vector_to_real64( left ) <= vector_to_real64( right )) ? 1 : 0;
03584           }
03585           retval = vector_set_coverage_and_assign_ulong( tgt, &scratchl, &scratchh, 0, 0 );
03586         }
03587         break;
03588       default :  assert( 0 );  break;
03589     }
03590 
03591   }
03592 
03593   PROFILE_END;
03594 
03595   return( retval );
03596 
03597 }

bool vector_op_list vector tgt,
const vector left,
const vector right
 

Performs list operation.

Returns:
Returns TRUE if the new value differs from the old value; otherwise, returns FALSE.
Performs list operation.
Parameters:
tgt  Pointer to vector to store results in
left  Pointer to vector containing expansion multiplier value
right  Pointer to vector that will be multiplied

05067   { PROFILE(VECTOR_OP_LIST);
05068         
05069   bool retval;  /* Return value for this function */
05070           
05071   switch( tgt->suppl.part.data_type ) {
05072     case VDATA_UL :
05073       {       
05074         ulong        vall[UL_DIV(MAX_BIT_WIDTH)];
05075         ulong        valh[UL_DIV(MAX_BIT_WIDTH)];
05076         unsigned int i;
05077         unsigned int pos    = right->width;
05078         unsigned int lwidth = left->width;
05079         unsigned int rsize  = UL_SIZE( pos );
05080 
05081         /* Load right vector directly */
05082         for( i=0; i<rsize; i++ ) {
05083           ulong* rval = right->value.ul[i];
05084           vall[i] = rval[VTYPE_INDEX_VAL_VALL];
05085           valh[i] = rval[VTYPE_INDEX_VAL_VALH];
05086         }
05087 
05088         /* Load left vector a bit at at time */
05089         for( i=0; i<lwidth; i++ ) {
05090           ulong*       lval     = left->value.ul[UL_DIV(i)];
05091           unsigned int my_index = UL_DIV(pos);
05092           unsigned int offset   = UL_MOD(pos);
05093           if( offset == 0 ) {
05094             vall[my_index] = 0;
05095             valh[my_index] = 0;
05096           }
05097           vall[my_index] |= ((lval[VTYPE_INDEX_EXP_VALL] >> UL_MOD(i)) & 0x1) << offset;
05098           valh[my_index] |= ((lval[VTYPE_INDEX_EXP_VALH] >> UL_MOD(i)) & 0x1) << offset;
05099           pos++;
05100         }
05101         retval = vector_set_coverage_and_assign_ulong( tgt, vall, valh, 0, ((left->width + right->width) - 1) );
05102       }
05103       break;
05104     default :  assert( 0 );  break;
05105   }
05106 
05107   PROFILE_END;
05108 
05109   return( retval );
05110   
05111 }

bool vector_op_lor vector tgt,
const vector left,
const vector right
 

Performs logical-OR operation of two vectors.

Returns:
Returns TRUE if the value of tgt changed as a result of this operation; otherwise, returns FALSE.
Performs logical-OR operation and calculates coverage information.
Parameters:
tgt  Pointer to vector to store result into
left  Pointer to left vector of expression
right  Pointer to right vector of expression

04040   { PROFILE(VECTOR_OP_LOR);
04041 
04042   bool retval;                                 /* Return value for this function */
04043   bool lunknown = vector_is_unknown( left );   /* Check for left value being unknown */
04044   bool runknown = vector_is_unknown( right );  /* Check for right value being unknown */
04045 
04046   switch( tgt->suppl.part.data_type ) {
04047     case VDATA_UL :
04048       {
04049         ulong valh = (lunknown && runknown) ? 1 : 0;
04050         ulong vall = ((!lunknown && vector_is_not_zero( left )) || (!runknown && vector_is_not_zero( right ))) ? 1 : 0;
04051         retval     = vector_set_coverage_and_assign_ulong( tgt, &vall, &valh, 0, 0 );
04052       }
04053       break;
04054     default :  assert( 0 );  break;
04055   }
04056 
04057   PROFILE_END;
04058 
04059   return( retval );
04060 
04061 }

bool vector_op_lshift vector tgt,
const vector left,
const vector right
 

Performs left shift operation on left expression by right expression bits.

Returns:
Returns TRUE if assigned value differs from original value; otherwise, returns FALSE.
Converts right expression into an integer value and left shifts the left expression the specified number of bit locations, zero-filling the LSB.
Parameters:
tgt  Target vector for storage of results
left  Expression value being shifted left
right  Expression containing number of bit positions to shift

04105   { PROFILE(VECTOR_OP_LSHIFT);
04106 
04107   bool retval;  /* Return value for this function */
04108 
04109   if( vector_is_unknown( right ) ) {
04110 
04111     retval = vector_set_to_x( tgt );
04112 
04113   } else { 
04114 
04115     int shift_val = vector_to_int( right );
04116 
04117     switch( tgt->suppl.part.data_type ) {
04118       case VDATA_UL :
04119         {
04120           ulong vall[UL_DIV(MAX_BIT_WIDTH)];
04121           ulong valh[UL_DIV(MAX_BIT_WIDTH)];
04122           vector_lshift_ulong( left, vall, valh, shift_val, ((left->width + shift_val) - 1) );
04123           retval = vector_set_coverage_and_assign_ulong( tgt, vall, valh, 0, (tgt->width - 1) );
04124         }
04125         break;
04126       default :  assert( 0 );  break;
04127     }
04128 
04129   }
04130 
04131   PROFILE_END;
04132 
04133   return( retval );
04134     
04135 }

bool vector_op_lt vector tgt,
const vector left,
const vector right
 

Performs less-than comparison of two vectors.

Returns:
Returns TRUE if the assigned value differs from the original value; otherwise, returns FALSE.
Performs a less-than comparison of the left and right expressions.
Parameters:
tgt  Target vector for storage of results
left  Expression on left of less than sign
right  Expression on right of less than sign

03490   { PROFILE(VECTOR_OP_LT);
03491 
03492   bool retval;  /* Return value for this function */
03493 
03494   if( vector_is_unknown( left ) || vector_is_unknown( right ) ) {
03495 
03496     retval = vector_set_to_x( tgt );
03497 
03498   } else {
03499 
03500     switch( tgt->suppl.part.data_type ) {
03501       case VDATA_UL :
03502         {
03503           ulong scratchl;
03504           ulong scratchh = 0;
03505           if( (left->suppl.part.data_type == VDATA_UL) && (right->suppl.part.data_type == VDATA_UL) ) {
03506             unsigned int lsize       = UL_SIZE(left->width);
03507             unsigned int rsize       = UL_SIZE(right->width);
03508             int          i           = ((lsize < rsize) ? rsize : lsize);
03509             unsigned int lmsb        = (left->width - 1);
03510             unsigned int rmsb        = (right->width - 1);
03511             bool         lmsb_is_one = (((left->value.ul[UL_DIV(lmsb)][VTYPE_INDEX_VAL_VALL]  >> UL_MOD(lmsb)) & 1) == 1);
03512             bool         rmsb_is_one = (((right->value.ul[UL_DIV(rmsb)][VTYPE_INDEX_VAL_VALL] >> UL_MOD(rmsb)) & 1) == 1);
03513             ulong        lvall;
03514             ulong        lvalh;
03515             ulong        rvall;
03516             ulong        rvalh;
03517             do {
03518               i--;
03519               vector_copy_val_and_sign_extend_ulong( left,  i, lmsb_is_one, &lvall, &lvalh );
03520               vector_copy_val_and_sign_extend_ulong( right, i, rmsb_is_one, &rvall, &rvalh );
03521             } while( (i > 0) && (lvall == rvall) );
03522             scratchl = vector_reverse_for_cmp_ulong( left, right ) ? (rvall < lvall) : (lvall < rvall);
03523           } else {
03524             scratchl = (vector_to_real64( left ) < vector_to_real64( right )) ? 1 : 0;
03525           }
03526           retval = vector_set_coverage_and_assign_ulong( tgt, &scratchl, &scratchh, 0, 0 );
03527         }
03528         break;
03529       default :  assert( 0 );  break;
03530     }
03531 
03532   }
03533 
03534   PROFILE_END;
03535 
03536   return( retval );
03537 
03538 }

bool vector_op_modulus vector tgt,
const vector left,
const vector right
 

Performs modulus operation on left and right vector values.

Returns:
Returns TRUE if value changes; otherwise, returns FALSE.
Performs vector modulus operation.
Parameters:
tgt  Pointer to vector that will store divide result
left  Pointer to left vector
right  Pointer to right vector

04572   { PROFILE(VECTOR_OP_MODULUS);
04573 
04574   bool retval;  /* Return value for this function */
04575 
04576   if( vector_is_unknown( left ) || vector_is_unknown( right ) ) {
04577 
04578     retval = vector_set_to_x( tgt );
04579 
04580   } else {
04581 
04582     switch( tgt->suppl.part.data_type ) {
04583       case VDATA_UL :
04584         {
04585           ulong vall;
04586           ulong valh = 0;
04587           ulong rval = right->value.ul[0][VTYPE_INDEX_EXP_VALL];
04588           if( rval == 0 ) {
04589             retval = vector_set_to_x( tgt );
04590           } else {
04591             vall = left->value.ul[0][VTYPE_INDEX_EXP_VALL] % rval;
04592             retval = vector_set_coverage_and_assign_ulong( tgt, &vall, &valh, 0, (UL_BITS - 1) );
04593           }
04594         }
04595         break;
04596       default :  assert( 0 );  break;
04597     }
04598 
04599   }
04600 
04601   PROFILE_END;
04602 
04603   return( retval );
04604 
04605 }

bool vector_op_multiply vector tgt,
const vector left,
const vector right
 

Performs multiplication operation on left and right expression values.

Returns:
Returns TRUE if assigned value differs from original value; otherwise, returns FALSE.
Performs 4-state conversion multiplication. If both values are known (non-X, non-Z), vectors are converted to integers, multiplication occurs and values are converted back into vectors. If one of the values is equal to zero, the value is 0. If one of the values is equal to one, the value is that of the other vector.
Parameters:
tgt  Target vector for storage of results
left  Expression value on left side of * sign
right  Expression value on right side of * sign

04462   { PROFILE(VECTOR_OP_MULTIPLY);
04463 
04464   bool retval;  /* Return value for this function */
04465 
04466   if( vector_is_unknown( left ) || vector_is_unknown( right ) ) {
04467 
04468     retval = vector_set_to_x( tgt );
04469 
04470   } else {
04471 
04472     switch( tgt->suppl.part.data_type ) {
04473       case VDATA_UL :
04474         {
04475           ulong vall = left->value.ul[0][VTYPE_INDEX_VAL_VALL] * right->value.ul[0][VTYPE_INDEX_VAL_VALL];
04476           ulong valh = 0;
04477           retval = vector_set_coverage_and_assign_ulong( tgt, &vall, &valh, 0, (tgt->width - 1) );
04478         }
04479         break;
04480       case VDATA_R64 :
04481         {
04482           double result       = vector_to_real64( left ) * vector_to_real64( right );
04483           retval              = !DEQ( tgt->value.r64->val, result );
04484           tgt->value.r64->val = result;
04485         }
04486         break;
04487       case VDATA_R32 :
04488         {
04489           float result        = (float)(vector_to_real64( left ) * vector_to_real64( right ));
04490           retval              = !FEQ( tgt->value.r32->val, result );
04491           tgt->value.r32->val = result;
04492         }
04493         break;
04494       default :  assert( 0 );  break;
04495     }
04496 
04497   }
04498 
04499   PROFILE_END;
04500 
04501   return( retval );
04502 
04503 }

bool vector_op_ne vector tgt,
const vector left,
const vector right
 

Performs not-equal comparison of two vectors.

Returns:
Returns TRUE if the assigned value differs from the original value; otherwise, returns FALSE.
Performs a not-equal comparison of the left and right expressions.
Parameters:
tgt  Target vector for storage of results
left  Expression on left of greater-than-or-equal sign
right  Expression on right of greater-than-or-equal sign

03951   { PROFILE(VECTOR_OP_NE);
03952 
03953   bool retval;  /* Return value for this function */
03954 
03955   if( vector_is_unknown( left ) || vector_is_unknown( right ) ) {
03956 
03957     retval = vector_set_to_x( tgt );
03958 
03959   } else {
03960 
03961     switch( tgt->suppl.part.data_type ) {
03962       case VDATA_UL :
03963         {
03964           ulong scratchl;
03965           ulong scratchh = 0;
03966           if( (left->suppl.part.data_type == VDATA_UL) && (right->suppl.part.data_type == VDATA_UL) ) {
03967             unsigned int lsize       = UL_SIZE(left->width);
03968             unsigned int rsize       = UL_SIZE(right->width);
03969             int          i           = ((lsize < rsize) ? rsize : lsize);
03970             unsigned int lmsb        = (left->width - 1);
03971             unsigned int rmsb        = (right->width - 1);
03972             bool         lmsb_is_one = (((left->value.ul[UL_DIV(lmsb)][VTYPE_INDEX_VAL_VALL]  >> UL_MOD(lmsb)) & 1) == 1);
03973             bool         rmsb_is_one = (((right->value.ul[UL_DIV(rmsb)][VTYPE_INDEX_VAL_VALL] >> UL_MOD(rmsb)) & 1) == 1);
03974             ulong        lvall;
03975             ulong        lvalh;
03976             ulong        rvall;
03977             ulong        rvalh;
03978             do {
03979               i--;
03980               vector_copy_val_and_sign_extend_ulong( left,  i, lmsb_is_one, &lvall, &lvalh );
03981               vector_copy_val_and_sign_extend_ulong( right, i, rmsb_is_one, &rvall, &rvalh );
03982             } while( (i > 0) && (lvall == rvall) );
03983             scratchl = (lvall != rvall);
03984           } else {
03985             scratchl = !DEQ( vector_to_real64( left ), vector_to_real64( right ) ) ? 1 : 0;
03986           }
03987           retval = vector_set_coverage_and_assign_ulong( tgt, &scratchl, &scratchh, 0, 0 );
03988         }
03989         break;
03990       default :  assert( 0 );  break;
03991     }
03992 
03993   }
03994 
03995   PROFILE_END;
03996 
03997   return( retval );
03998 
03999 }

bool vector_op_negate vector tgt,
const vector src
 

Performs a twos complement of the src vector and stores the new vector in tgt.

Returns:
Returns TRUE if assigned value differs from original value; otherwise, returns FALSE.
Performs a twos complement of the src vector and stores the result in the tgt vector.
Parameters:
tgt  Pointer to vector that will be assigned the new value
src  Pointer to vector that will be negated

04305   { PROFILE(VECTOR_OP_NEGATE);
04306 
04307   bool retval;  /* Return value for this function */
04308 
04309   if( vector_is_unknown( src ) ) {
04310    
04311     retval = vector_set_to_x( tgt );
04312 
04313   } else {
04314 
04315     switch( tgt->suppl.part.data_type ) {
04316       case VDATA_UL :
04317         {
04318           if( src->width <= UL_BITS ) {
04319             ulong vall = ~src->value.ul[0][VTYPE_INDEX_EXP_VALL] + 1;
04320             ulong valh = 0;
04321 
04322             retval = vector_set_coverage_and_assign_ulong( tgt, &vall, &valh, 0, (tgt->width - 1) );
04323           } else {
04324             ulong        vall[UL_DIV(MAX_BIT_WIDTH)];
04325             ulong        valh[UL_DIV(MAX_BIT_WIDTH)];
04326             unsigned int i, j;
04327             unsigned int size  = UL_SIZE( src->width );
04328             ulong        carry = 1;
04329             ulong        val;
04330 
04331             for( i=0; i<(size - 1); i++ ) {
04332               val     = ~src->value.ul[i][VTYPE_INDEX_EXP_VALL];
04333               vall[i] = 0;
04334               valh[i] = 0;
04335               for( j=0; j<UL_BITS; j++ ) {
04336                 ulong bit = ((val >> j) & 0x1) + carry;
04337                 carry     = bit >> 1;
04338                 vall[i]  |= (bit & 0x1) << j;
04339               }
04340             }
04341             val     = ~src->value.ul[i][VTYPE_INDEX_EXP_VALL];
04342             vall[i] = 0;
04343             valh[i] = 0;
04344             for( j=0; j<(tgt->width - (i << UL_DIV_VAL)); j++ ) {
04345               ulong bit = ((val >> j) & 0x1) + carry;
04346               carry     = bit >> 1;
04347               vall[i]  |= (bit & 0x1) << j;
04348             }
04349 
04350             retval = vector_set_coverage_and_assign_ulong( tgt, vall, valh, 0, (tgt->width - 1) );
04351           }
04352         }
04353         break;
04354       case VDATA_R64 :
04355         {
04356           double result       = (0.0 - vector_to_real64( src ));
04357           retval              = !DEQ( tgt->value.r64->val, result );
04358           tgt->value.r64->val = result;
04359         }
04360         break;
04361       case VDATA_R32 :
04362         {
04363           float result        = (float)(0.0 - vector_to_real64( src ));
04364           retval              = !FEQ( tgt->value.r32->val, result );
04365           tgt->value.r32->val = result;
04366         }
04367         break;
04368       default :  assert( 0 );  break;
04369     }
04370 
04371   }
04372 
04373   PROFILE_END;
04374 
04375   return( retval );
04376 
04377 }

bool vector_op_rshift vector tgt,
const vector left,
const vector right
 

Performs right shift operation on left expression by right expression bits.

Returns:
Returns TRUE if assigned value differs from original value; otherwise, returns FALSE.
Converts right expression into an integer value and right shifts the left expression the specified number of bit locations, zero-filling the MSB.
Parameters:
tgt  Target vector for storage of results
left  Expression value being shifted left
right  Expression containing number of bit positions to shift

04147   { PROFILE(VECTOR_OP_RSHIFT);
04148 
04149   bool retval;  /* Return value for this function */
04150 
04151   if( vector_is_unknown( right ) ) {
04152 
04153     retval = vector_set_to_x( tgt );
04154 
04155   } else {
04156 
04157     int shift_val = vector_to_int( right );
04158 
04159     switch( tgt->suppl.part.data_type ) {
04160       case VDATA_UL :
04161         {
04162           ulong vall[UL_DIV(MAX_BIT_WIDTH)];
04163           ulong valh[UL_DIV(MAX_BIT_WIDTH)];
04164           vector_rshift_ulong( left, vall, valh, shift_val, (left->width - 1) );
04165           retval = vector_set_coverage_and_assign_ulong( tgt, vall, valh, 0, (tgt->width - 1) );
04166         }
04167         break;
04168       default :  assert( 0 );  break;
04169     }
04170 
04171   }
04172 
04173   PROFILE_END;
04174 
04175   return( retval );
04176 
04177 }

bool vector_op_subtract vector tgt,
const vector left,
const vector right
 

Performs subtraction operation on left and right expression values.

Returns:
Returns TRUE if assigned value differs from original value; otherwise, returns FALSE.
Performs 4-state bitwise subtraction by performing bitwise inversion of right expression value, adding one to the result and adding this result to the left expression value.
Parameters:
tgt  Target vector for storage of results
left  Expression value on left side of - sign
right  Expression value on right side of - sign

04390   { PROFILE(VECTOR_OP_SUBTRACT);
04391 
04392   bool retval;  /* Return value for this function */
04393 
04394   /* If either the left or right vector is unknown, set the entire value to X */
04395   if( vector_is_unknown( left ) || vector_is_unknown( right ) ) {
04396 
04397     retval = vector_set_to_x( tgt );
04398 
04399   /* Otherwise, perform the subtraction operation */
04400   } else {
04401 
04402     switch( tgt->suppl.part.data_type ) {
04403       case VDATA_UL :
04404         {
04405           ulong        vall[UL_DIV(MAX_BIT_WIDTH)];
04406           ulong        valh[UL_DIV(MAX_BIT_WIDTH)];
04407           ulong        carry = 1;
04408           bool         lmsb_is_one = (((left->value.ul[UL_DIV(left->width-1)][VTYPE_INDEX_VAL_VALL]   >> UL_MOD(left->width  - 1)) & 1) == 1);
04409           bool         rmsb_is_one = (((right->value.ul[UL_DIV(right->width-1)][VTYPE_INDEX_VAL_VALL] >> UL_MOD(right->width - 1)) & 1) == 1);
04410           ulong        lvall, lvalh;
04411           ulong        rvall, rvalh;
04412           unsigned int i;
04413           for( i=0; i<UL_SIZE( tgt->width ); i++ ) {
04414             vector_copy_val_and_sign_extend_ulong( left,  i, lmsb_is_one, &lvall, &lvalh );
04415             vector_copy_val_and_sign_extend_ulong( right, i, rmsb_is_one, &rvall, &rvalh ); 
04416             rvall   = ~rvall;
04417             vall[i] = lvall + rvall + carry;
04418             valh[i] = 0;
04419             carry   = ((lvall & rvall) | ((lvall | rvall) & ~vall[i])) >> (UL_BITS - 1);
04420           }
04421           retval = vector_set_coverage_and_assign_ulong( tgt, vall, valh, 0, (tgt->width - 1) );
04422         }
04423         break;
04424       case VDATA_R64 :
04425         {
04426           double result       = vector_to_real64( left ) - vector_to_real64( right );
04427           retval              = !DEQ( tgt->value.r64->val, result );
04428           tgt->value.r64->val = result;
04429         }
04430         break;
04431       case VDATA_R32 :
04432         {
04433           float result        = (float)(vector_to_real64( left ) - vector_to_real64( right ));
04434           retval              = !FEQ( tgt->value.r32->val, result );
04435           tgt->value.r32->val = result;
04436         }
04437         break;
04438       default :  assert( 0 );  break;
04439     }
04440 
04441   }
04442 
04443   PROFILE_END;
04444 
04445   return( retval );
04446 
04447 }

bool vector_part_select_pull vector tgt,
vector src,
int  lsb,
int  msb,
bool  set_mem_rd
 

Sets specified target vector to bit range of source vector.

Returns:
Returns TRUE if stored data differed from original data; otherwise, returns FALSE.
Used for single- and multi-bit part selection. Bits are pulled from the source vector via the LSB and MSB range
Parameters:
tgt  Pointer to vector that will store the result
src  Pointer to vector containing data to store
lsb  LSB offset
msb  MSB offset
set_mem_rd  If TRUE, set the memory read bit in the source

01912   { PROFILE(VECTOR_PART_SELECT_PULL);
01913 
01914   bool retval;  /* Return value for this function */
01915 
01916   switch( src->suppl.part.data_type ) {
01917     case VDATA_UL :
01918       {
01919         ulong valh[UL_DIV(MAX_BIT_WIDTH)];
01920         ulong vall[UL_DIV(MAX_BIT_WIDTH)];
01921 
01922         /* Perform shift operation */
01923         vector_rshift_ulong( src, vall, valh, lsb, msb );
01924 
01925         /* If the src vector is of type MEM, set the MEM_RD bits in the source's supplemental field */
01926         if( set_mem_rd && (src->suppl.part.type == VTYPE_MEM) ) {
01927           if( UL_DIV(msb) == UL_DIV(lsb) ) {
01928             src->value.ul[UL_DIV(lsb)][VTYPE_INDEX_MEM_RD] |= UL_HMASK(msb) & UL_LMASK(lsb);
01929           } else {
01930             int i;
01931             src->value.ul[UL_DIV(lsb)][VTYPE_INDEX_MEM_RD] |= UL_LMASK(lsb);
01932             for( i=(UL_DIV(lsb) + 1); i<UL_DIV(msb); i++ ) {
01933               src->value.ul[UL_DIV(msb)][VTYPE_INDEX_MEM_RD] = UL_SET;
01934             }
01935             src->value.ul[UL_DIV(msb)][VTYPE_INDEX_MEM_RD] |= UL_HMASK(msb);
01936           } 
01937         }
01938 
01939         /* Perform value assignment and calculate coverage */
01940         retval = vector_set_coverage_and_assign_ulong( tgt, vall, valh, 0, (tgt->width - 1) );
01941 
01942       }
01943       break;
01944     default :  assert( 0 );  break;
01945   }
01946 
01947   PROFILE_END;
01948 
01949   return( retval );
01950 
01951 }

bool vector_part_select_push vector tgt,
int  tgt_lsb,
int  tgt_msb,
const vector src,
int  src_lsb,
int  src_msb,
bool  sign_extend
 

Sets specified target vector to bit range of source vector.

Returns:
Returns TRUE if stored data differed from original data; otherwise, returns FALSE.
Used for single- and multi-bit part selection. Bits are pushed from the source vector via the LSB and MSB range.
Parameters:
tgt  Pointer to vector that will store the result
tgt_lsb  LSB offset of target vector
tgt_msb  MSB offset of target vector
src  Pointer to vector containing data to store
src_lsb  LSB offset of source vector
src_msb  MSB offset of source vector
sign_extend  Set to TRUE if sign extension is needed

01967   { PROFILE(VECTOR_PART_SELECT_PUSH);
01968 
01969   bool retval;  /* Return value for this function */
01970 
01971   switch( src->suppl.part.data_type ) {
01972     case VDATA_UL :
01973       {
01974         ulong        valh[UL_DIV(MAX_BIT_WIDTH)];
01975         ulong        vall[UL_DIV(MAX_BIT_WIDTH)];
01976         unsigned int diff;
01977         unsigned int i; 
01978         ulong        signl, signh;
01979 
01980         /* Get the sign extension vector */
01981         vector_get_sign_extend_vector_ulong( src, &signl, &signh );
01982 
01983         /* If the LSB to assign exceeds the size of the actual vector, just create a value based on the signedness */
01984         if( (src_lsb > 0) && ((unsigned int)src_lsb >= src->width) ) {
01985 
01986           if( sign_extend && ((signl != 0) || (signh != 0)) ) {
01987             vector_sign_extend_ulong( vall, valh, signl, signh, (tgt_lsb - 1), tgt->width );
01988           } else {
01989             for( i=UL_DIV(tgt_lsb); i<=UL_DIV(tgt_msb); i++ ) {
01990               vall[i] = valh[i] = 0;
01991             }
01992           }
01993 
01994         /* Otherwise, pull the value from source vector */
01995         } else {
01996 
01997           /* First, initialize the vall/h arrays to zero */
01998           for( i=UL_DIV(tgt_lsb); i<=UL_DIV(tgt_msb); i++ ) {
01999             vall[i] = valh[i] = 0;
02000           }
02001   
02002           /* Left-shift the source vector to match up with target LSB */
02003           if( src_lsb < tgt_lsb ) {
02004             diff = (tgt_lsb - src_lsb);
02005             vector_lshift_ulong( src, vall, valh, diff, ((src_msb - src_lsb) + diff) );
02006           /* Otherwise, right-shift the source vector to match up */
02007           } else {
02008             diff = (src_lsb - tgt_lsb);
02009             vector_rshift_ulong( src, vall, valh, diff, ((src_msb - src_lsb) + diff) );
02010           }
02011 
02012           /* Now apply the sign extension, if necessary */
02013           if( sign_extend && ((signl != 0) || (signh != 0)) ) {
02014             vector_sign_extend_ulong( vall, valh, signl, signh, (tgt_lsb + (src_msb - src_lsb)), (tgt_msb + 1) );
02015           }
02016 
02017         }
02018 
02019         /* Now assign the calculated value and set coverage information */
02020         retval = vector_set_coverage_and_assign_ulong( tgt, vall, valh, tgt_lsb, tgt_msb );
02021       }
02022       break;
02023     default :  assert( 0 );  break;
02024   }
02025 
02026   PROFILE_END;
02027 
02028   return( retval );
02029 
02030 }

void vector_set_and_comb_evals vector tgt,
vector left,
vector right
 

Sets eval_a/b/c bits according to AND combinational logic coverage.

Sets the eval_a/b/c supplemental bits as necessary. This function should be called by expression_op_func__* functions that are AND-type combinational operations only and own their own vectors.

Parameters:
tgt  Pointer to target vector to set eval_a/b/c supplemental bits
left  Pointer to target vector on the left
right  Pointer to target vector on the right

02073   { PROFILE(VECTOR_SET_AND_COMB_EVALS);
02074 
02075   switch( tgt->suppl.part.data_type ) {
02076     case VDATA_UL :
02077       {
02078         unsigned int i;
02079         unsigned int size  = UL_SIZE( tgt->width );
02080         unsigned int lsize = UL_SIZE( left->width );
02081         unsigned int rsize = UL_SIZE( right->width );
02082 
02083         for( i=0; i<size; i++ ) {
02084           ulong* val    = tgt->value.ul[i];
02085           ulong* lval   = (i < lsize) ? left->value.ul[i]  : 0;
02086           ulong* rval   = (i < rsize) ? right->value.ul[i] : 0;
02087           ulong  lvall  = (i < lsize) ?  lval[VTYPE_INDEX_EXP_VALL] : 0;
02088           ulong  nlvalh = (i < lsize) ? ~lval[VTYPE_INDEX_EXP_VALH] : UL_SET;
02089           ulong  rvall  = (i < rsize) ?  rval[VTYPE_INDEX_EXP_VALL] : 0;
02090           ulong  nrvalh = (i < rsize) ? ~rval[VTYPE_INDEX_EXP_VALH] : UL_SET;
02091           
02092           val[VTYPE_INDEX_EXP_EVAL_A] |= nlvalh & ~lvall;
02093           val[VTYPE_INDEX_EXP_EVAL_B] |= nrvalh & ~rvall;
02094           val[VTYPE_INDEX_EXP_EVAL_C] |= nlvalh & nrvalh & lvall & rvall;
02095         }
02096       }
02097       break;
02098     case VDATA_R64 :
02099     case VDATA_R32 :
02100       break;
02101     default :  assert( 0 );  break;
02102   }
02103 
02104   PROFILE_END;
02105  
02106 }

bool vector_set_assigned vector vec,
int  msb,
int  lsb
 

Sets all assigned bits in vector bit value array within specified range.

Returns:
Returns TRUE if assigned bit that is being set to 1 in this function was found to be previously set; otherwise, returns FALSE.
Sets the assigned supplemental bit for the given bit range in the given vector. Called by race condition checker code.
Parameters:
vec  Pointer to vector value to set
msb  Most-significant bit to set in vector value
lsb  Least-significant bit to set in vector value

01469   { PROFILE(VECTOR_SET_ASSIGNED);
01470 
01471   bool prev_assigned = FALSE;  /* Specifies if any set bit was previously set */
01472 
01473   assert( vec != NULL );
01474   assert( ((msb - lsb) < 0) || ((unsigned int)(msb - lsb) < vec->width) );
01475   assert( vec->suppl.part.type == VTYPE_SIG );
01476 
01477   switch( vec->suppl.part.data_type ) {
01478     case VDATA_UL :
01479       {
01480         ulong lmask     = UL_LMASK(lsb);
01481         ulong hmask     = UL_HMASK(msb);
01482         int   i         = UL_DIV(lsb);
01483         int   msb_index = UL_DIV(msb);
01484         if( i == msb_index ) {
01485           lmask &= hmask;
01486           prev_assigned = ((vec->value.ul[i][VTYPE_INDEX_SIG_MISC] & lmask) != 0);
01487           vec->value.ul[i][VTYPE_INDEX_SIG_MISC] |= lmask;
01488         } else {
01489           prev_assigned |= ((vec->value.ul[i][VTYPE_INDEX_SIG_MISC] & lmask) != 0);
01490           vec->value.ul[i][VTYPE_INDEX_SIG_MISC] |= lmask;
01491           for( i++; i<msb_index; i++ ) {
01492             prev_assigned = (vec->value.ul[i][VTYPE_INDEX_SIG_MISC] != 0);
01493             vec->value.ul[i][VTYPE_INDEX_SIG_MISC] |= UL_SET;
01494           }
01495           prev_assigned |= ((vec->value.ul[i][VTYPE_INDEX_SIG_MISC] & hmask) != 0);
01496           vec->value.ul[i][VTYPE_INDEX_SIG_MISC] |= hmask;
01497         }
01498       }
01499       break;
01500     case VDATA_R64 :
01501       break;
01502     default :  assert( 0 );  break;
01503   }
01504 
01505   PROFILE_END;
01506 
01507   return( prev_assigned );
01508 
01509 }

bool vector_set_coverage_and_assign_ulong vector vec,
const ulong scratchl,
const ulong scratchh,
int  lsb,
int  msb
 

Set coverage information for given vector and assigns values from scratch arrays to vector.

Returns:
Returns TRUE if the assigned value has changed; otherwise, returns FALSE.
This function is called after a value has been stored in the SCRATCH arrays. This function calculates the vector coverage information based on the vector type and performs the assignment from the SCRATCH array to the
Parameters:
vec  Pointer to vector to calculate coverage metrics for and perform scratch -> actual assignment
scratchl  Pointer to scratch array containing new lower data
scratchh  Pointer to scratch array containing new upper data
lsb  Least-significant bit to get coverage for
msb  Most-significant bit to get coverage for

01524   { PROFILE(VECTOR_SET_COVERAGE_AND_ASSIGN);
01525 
01526   bool         changed = FALSE;          /* Set to TRUE if the assigned value has changed */
01527   unsigned int lindex  = UL_DIV(lsb);    /* Index of lowest array entry */
01528   unsigned int hindex  = UL_DIV(msb);    /* Index of highest array entry */
01529   ulong        lmask   = UL_LMASK(lsb);  /* Mask to be used in lower element */
01530   ulong        hmask   = UL_HMASK(msb);  /* Mask to be used in upper element */
01531   unsigned int i;                        /* Loop iterator */
01532   uint8        prev_set;                 /* Specifies if this vector value has previously been set */
01533 
01534   /* If the lindex and hindex are the same, set lmask to the AND of the high and low masks */
01535   if( lindex == hindex ) {
01536     lmask &= hmask;
01537   }
01538 
01539   switch( vec->suppl.part.type ) {
01540     case VTYPE_VAL :
01541       for( i=lindex; i<=hindex; i++ ) {
01542         ulong* tvall = &(vec->value.ul[i][VTYPE_INDEX_SIG_VALL]);
01543         ulong* tvalh = &(vec->value.ul[i][VTYPE_INDEX_SIG_VALH]);
01544         ulong  mask  = (i==lindex) ? lmask : (i==hindex ? hmask : UL_SET);
01545         *tvall = (*tvall & ~mask) | (scratchl[i] & mask);
01546         *tvalh = (*tvalh & ~mask) | (scratchh[i] & mask);
01547       }
01548       changed = TRUE;
01549       break;
01550     case VTYPE_SIG :
01551       prev_set = vec->suppl.part.set;
01552       for( i=lindex; i<=hindex; i++ ) {
01553         ulong* entry = vec->value.ul[i];
01554         ulong  mask  = (i==lindex) ? lmask : (i==hindex ? hmask : UL_SET);
01555         ulong  fvall = scratchl[i] & mask;
01556         ulong  fvalh = scratchh[i] & mask;
01557         ulong  tvall = entry[VTYPE_INDEX_SIG_VALL];
01558         ulong  tvalh = entry[VTYPE_INDEX_SIG_VALH];
01559         if( (fvall != (tvall & mask)) || (fvalh != (tvalh & mask)) ) {
01560           ulong tvalx = tvalh & ~tvall & entry[VTYPE_INDEX_SIG_MISC];
01561           ulong xval  = entry[VTYPE_INDEX_SIG_XHOLD];
01562           if( prev_set == 1 ) {
01563             entry[VTYPE_INDEX_SIG_TOG01] |= ((~tvalh & ~tvall) | (tvalx & ~xval)) & (~fvalh &  fvall) & mask;
01564             entry[VTYPE_INDEX_SIG_TOG10] |= ((~tvalh &  tvall) | (tvalx &  xval)) & (~fvalh & ~fvall) & mask;
01565           }
01566           entry[VTYPE_INDEX_SIG_VALL]  = (tvall & ~mask) | fvall;
01567           entry[VTYPE_INDEX_SIG_VALH]  = (tvalh & ~mask) | fvalh;
01568           entry[VTYPE_INDEX_SIG_XHOLD] = (xval  & ~mask) | (tvall & mask);
01569           entry[VTYPE_INDEX_SIG_MISC] |= ~fvalh & mask;
01570           changed = TRUE;
01571         }
01572       }
01573       break;
01574     case VTYPE_MEM :
01575       for( i=lindex; i<=hindex; i++ ) {
01576         ulong* entry = vec->value.ul[i];
01577         ulong  mask  = (i==lindex) ? lmask : (i==hindex ? hmask : UL_SET);
01578         ulong  fvall = scratchl[i] & mask;
01579         ulong  fvalh = scratchh[i] & mask;
01580         ulong  tvall = entry[VTYPE_INDEX_MEM_VALL];
01581         ulong  tvalh = entry[VTYPE_INDEX_MEM_VALH];
01582         if( (fvall != (tvall & mask)) || (fvalh != (tvalh & mask)) ) {
01583           ulong tvalx = tvalh & ~tvall & entry[VTYPE_INDEX_MEM_MISC];
01584           ulong xval  = entry[VTYPE_INDEX_MEM_XHOLD];
01585           entry[VTYPE_INDEX_MEM_TOG01] |= ((~tvalh & ~tvall) | (tvalx & ~xval)) & (~fvalh &  fvall) & mask;
01586           entry[VTYPE_INDEX_MEM_TOG10] |= ((~tvalh &  tvall) | (tvalx &  xval)) & (~fvalh & ~fvall) & mask;
01587           entry[VTYPE_INDEX_MEM_WR]    |= mask;
01588           entry[VTYPE_INDEX_MEM_VALL]   = (tvall & ~mask) | fvall;
01589           entry[VTYPE_INDEX_MEM_VALH]   = (tvalh & ~mask) | fvalh;
01590           entry[VTYPE_INDEX_MEM_XHOLD]  = (xval  & ~mask) | (tvall & mask);
01591           entry[VTYPE_INDEX_MEM_MISC]  |= ~fvalh & mask;
01592           changed = TRUE;
01593         }
01594       }
01595       break;
01596     case VTYPE_EXP :
01597       for( i=lindex; i<=hindex; i++ ) {
01598         ulong* entry = vec->value.ul[i];
01599         ulong  mask  = (i==lindex) ? lmask : (i==hindex ? hmask : UL_SET);
01600         ulong  fvall = scratchl[i] & mask;
01601         ulong  fvalh = scratchh[i] & mask;
01602         ulong  tvall = entry[VTYPE_INDEX_EXP_VALL];
01603         ulong  tvalh = entry[VTYPE_INDEX_EXP_VALH];
01604         if( (fvall != (tvall & mask)) || (fvalh != (tvalh & mask)) ) {
01605           entry[VTYPE_INDEX_EXP_VALL] = (tvall & ~mask) | fvall;
01606           entry[VTYPE_INDEX_EXP_VALH] = (tvalh & ~mask) | fvalh;
01607           changed = TRUE;
01608         }
01609       }
01610       break;
01611     default :  assert( 0 );  break;
01612   }
01613 
01614   PROFILE_END;
01615 
01616   return( changed );
01617 
01618 }

void vector_set_or_comb_evals vector tgt,
vector left,
vector right
 

Sets eval_a/b/c bits according to OR combinational logic coverage.

Sets the eval_a/b/c supplemental bits as necessary. This function should be called by expression_op_func__* functions that are OR-type combinational operations only and own their own vectors.

Parameters:
tgt  Pointer to target vector to set eval_a/b/c supplemental bits
left  Pointer to vector on left of expression
right  Pointer to vector on right of expression

02117   { PROFILE(VECTOR_SET_OR_COMB_EVALS);
02118 
02119   switch( tgt->suppl.part.data_type ) {
02120     case VDATA_UL :
02121       {
02122         unsigned int i;
02123         unsigned int size  = UL_SIZE( tgt->width );
02124         unsigned int lsize = UL_SIZE( left->width );
02125         unsigned int rsize = UL_SIZE( right->width );
02126 
02127         for( i=0; i<size; i++ ) {
02128           ulong* val    = tgt->value.ul[i];
02129           ulong* lval   = (i < lsize) ? left->value.ul[i]  : 0;
02130           ulong* rval   = (i < rsize) ? right->value.ul[i] : 0;
02131           ulong  lvall  = (i < lsize) ?  lval[VTYPE_INDEX_EXP_VALL] : 0;
02132           ulong  nlvalh = (i < lsize) ? ~lval[VTYPE_INDEX_EXP_VALH] : UL_SET;
02133           ulong  rvall  = (i < rsize) ?  rval[VTYPE_INDEX_EXP_VALL] : 0;
02134           ulong  nrvalh = (i < rsize) ? ~rval[VTYPE_INDEX_EXP_VALH] : UL_SET;
02135 
02136           val[VTYPE_INDEX_EXP_EVAL_A] |= nlvalh & lvall;
02137           val[VTYPE_INDEX_EXP_EVAL_B] |= nrvalh & rvall;
02138           val[VTYPE_INDEX_EXP_EVAL_C] |= nlvalh & nrvalh & ~lvall & ~rvall;
02139         }
02140       }
02141       break;
02142     case VDATA_R64 :
02143     case VDATA_R32 :
02144       break;
02145     default :  assert( 0 );  break;
02146   }
02147 
02148   PROFILE_END;
02149 
02150 }

void vector_set_other_comb_evals vector tgt,
vector left,
vector right
 

Sets eval_a/b/c/d bits according to other combinational logic coverage.

Sets the eval_a/b/c/d supplemental bits as necessary. This function should be called by expression_op_func__* functions that are OTHER-type combinational operations only and own their own vectors.

Parameters:
tgt  Pointer to target vector to set eval_a/b/c/d supplemental bits
left  Pointer to vector on left of expression
right  Pointer to vector on right of expression

02161   { PROFILE(VECTOR_SET_OTHER_COMB_EVALS);
02162 
02163   switch( tgt->suppl.part.data_type ) {
02164     case VDATA_UL :
02165       {
02166         unsigned int i;
02167         unsigned int size  = UL_SIZE( tgt->width );
02168         unsigned int lsize = UL_SIZE( left->width );
02169         unsigned int rsize = UL_SIZE( right->width );
02170 
02171         for( i=0; i<size; i++ ) { 
02172           ulong* val    = tgt->value.ul[i];
02173           ulong* lval   = (i < lsize) ? left->value.ul[i]  : 0;
02174           ulong* rval   = (i < rsize) ? right->value.ul[i] : 0;
02175           ulong  lvall  = (i < lsize) ?  lval[VTYPE_INDEX_EXP_VALL] : 0;
02176           ulong  nlvalh = (i < lsize) ? ~lval[VTYPE_INDEX_EXP_VALH] : UL_SET;
02177           ulong  rvall  = (i < rsize) ?  rval[VTYPE_INDEX_EXP_VALL] : 0;
02178           ulong  nrvalh = (i < rsize) ? ~rval[VTYPE_INDEX_EXP_VALH] : UL_SET;
02179           ulong  nvalh  = nlvalh & nrvalh;
02180 
02181           val[VTYPE_INDEX_EXP_EVAL_A] |= nvalh & ~lvall & ~rvall;
02182           val[VTYPE_INDEX_EXP_EVAL_B] |= nvalh & ~lvall &  rvall;
02183           val[VTYPE_INDEX_EXP_EVAL_C] |= nvalh &  lvall & ~rvall;
02184           val[VTYPE_INDEX_EXP_EVAL_D] |= nvalh &  lvall &  rvall;
02185         }
02186       }
02187       break;
02188     case VDATA_R64 :
02189     case VDATA_R32 :
02190       break;
02191     default :  assert( 0 );  break;
02192   }
02193 
02194   PROFILE_END;
02195   
02196 } 

bool vector_set_to_x vector vec  ) 
 

Sets entire vector value to a value of X.

Returns:
Returns TRUE if the given vector changed value; otherwise, returns FALSE.
Sets the entire specified vector to a value of X.
Parameters:
vec  Pointer to vector to set to a value of X

02269   { PROFILE(VECTOR_SET_TO_X);
02270 
02271   bool retval;  /* Return value for this function */
02272 
02273   switch( vec->suppl.part.data_type ) {
02274     case VDATA_UL:
02275       {
02276         ulong        scratchl[UL_DIV(MAX_BIT_WIDTH)];
02277         ulong        scratchh[UL_DIV(MAX_BIT_WIDTH)];
02278         ulong        end_mask = UL_HMASK(vec->width - 1);
02279         unsigned int i;
02280         for( i=0; i<(UL_SIZE(vec->width) - 1); i++ ) {
02281           scratchl[i] = 0;
02282           scratchh[i] = UL_SET;
02283         }
02284         scratchl[i] = 0;
02285         scratchh[i] = end_mask;
02286         retval = vector_set_coverage_and_assign_ulong( vec, scratchl, scratchh, 0, (vec->width - 1) );
02287       }
02288       break;
02289     case VDATA_R32 :
02290     case VDATA_R64 :
02291       retval = FALSE;
02292       break;
02293     default :  assert( 0 );  break;
02294   }
02295 
02296   PROFILE_END;
02297 
02298   return( retval );
02299 
02300 }

void vector_set_unary_evals vector vec  ) 
 

Sets eval_a/b bits according to unary coverage.

Called by expression_op_func__* functions for operations that are unary in nature.

Parameters:
vec  Pointer to vector to set eval_a/b bits for unary operation

02038   { PROFILE(VECTOR_SET_UNARY_EVALS);
02039 
02040   switch( vec->suppl.part.data_type ) {
02041     case VDATA_UL :
02042       {
02043         unsigned int i;
02044         unsigned int size = UL_SIZE(vec->width);
02045         for( i=0; i<size; i++ ) {
02046           ulong* entry = vec->value.ul[i];
02047           ulong  lval  =  entry[VTYPE_INDEX_EXP_VALL];
02048           ulong  nhval = ~entry[VTYPE_INDEX_EXP_VALH];
02049           entry[VTYPE_INDEX_EXP_EVAL_A] |= nhval & ~lval;
02050           entry[VTYPE_INDEX_EXP_EVAL_B] |= nhval &  lval;
02051         }
02052       }
02053       break;
02054     case VDATA_R64 :
02055     case VDATA_R32 :
02056       break;
02057     default :  assert( 0 );  break;
02058   }
02059 
02060   PROFILE_END;
02061 
02062 }

bool vector_set_value_ulong vector vec,
ulong **  value,
unsigned int  width
 

Sets specified vector value to new value and maintains coverage history.

Returns:
Returns TRUE if assignment was performed; otherwise, returns FALSE.
Allows the calling function to set any bit vector within the vector range. If the vector value has never been set, sets the value to the new value and returns. If the vector value has previously been set, checks to see if new vector bits have toggled, sets appropriate toggle values, sets the new value to this value and returns.
Parameters:
vec  Pointer to vector to set value to
value  New value to set vector value to
width  Width of new value

01861   { PROFILE(VECTOR_SET_VALUE);
01862 
01863   bool  retval = FALSE;                   /* Return value for this function */
01864   int   i;                                /* Loop iterator */
01865   int   v2st;                             /* Value to AND with from value bit if the target is a 2-state value */
01866   ulong scratchl[UL_DIV(MAX_BIT_WIDTH)];  /* Lower scratch array */
01867   ulong scratchh[UL_DIV(MAX_BIT_WIDTH)];  /* Upper scratch array */
01868 
01869   assert( vec != NULL );
01870 
01871   /* Adjust the width if it exceeds our width */
01872   if( vec->width < width ) {
01873     width = vec->width;
01874   }
01875 
01876   /* Get some information from the vector */
01877   v2st = vec->suppl.part.is_2state << 1;
01878 
01879   /* Set upper bits to 0 */
01880   for( i=UL_DIV(vec->width - 1); (unsigned int)i>UL_DIV(width - 1); i-- ) {
01881     scratchl[i] = 0;
01882     scratchh[i] = 0;
01883   }
01884 
01885   /* Calculate the new values and place them in the scratch arrays */
01886   for( ; i>=0; i-- ) {
01887     scratchl[i] = v2st ? (~value[i][VTYPE_INDEX_VAL_VALH] & value[i][VTYPE_INDEX_VAL_VALL]) : value[i][VTYPE_INDEX_VAL_VALL];
01888     scratchh[i] = v2st ? 0 : value[i][VTYPE_INDEX_VAL_VALH];
01889   }
01890 
01891   /* Calculate the coverage and perform the actual assignment */
01892   retval = vector_set_coverage_and_assign_ulong( vec, scratchl, scratchh, 0, (vec->width - 1) );
01893 
01894   PROFILE_END;
01895 
01896   return( retval );
01897 
01898 }

bool vector_sign_extend vector vec,
int  last
 

Bit fills the given vector with the appropriate value starting at the last bit.

int vector_to_int const vector vec  ) 
 

Converts vector into integer value.

Returns:
Returns integer value of specified vector.
Converts a vector structure into an integer value. If the number of bits for the vector exceeds the number of bits in an integer, the upper bits of the vector are unused.
Parameters:
vec  Pointer to vector to convert into integer

02311   { PROFILE(VECTOR_TO_INT);
02312 
02313   int          retval;  /* Integer value returned to calling function */
02314   unsigned int width = (vec->width > (sizeof( int ) * 8)) ? (sizeof( int ) * 8) : vec->width;
02315 
02316   assert( width > 0 );
02317 
02318   switch( vec->suppl.part.data_type ) {
02319     case VDATA_UL  :  retval = vec->value.ul[0][VTYPE_INDEX_VAL_VALL];  break;
02320     case VDATA_R64 :  retval = (int)round( vec->value.r64->val );       break;
02321     case VDATA_R32 :  retval = (int)roundf( vec->value.r32->val );       break;
02322     default        :  assert( 0 );  break;
02323   }
02324 
02325   /* If the vector is signed, sign-extend the integer */
02326   if( (vec->suppl.part.is_signed == 1) && (width < (sizeof( int ) * 8)) ) {
02327     /*@-shiftimplementation@*/
02328     retval |= ((UL_SET * ((retval >> (width - 1)) & 0x1)) << width);
02329     /*@=shiftimplementation@*/
02330   }
02331 
02332   PROFILE_END;
02333 
02334   return( retval );
02335 
02336 }

real64 vector_to_real64 const vector vec  ) 
 

Converts vector into a 64-bit real value.

Returns:
Returns 64-bit real value version of the specified vector.
Converts the specified vector to a 64-bit real number. If the value exceeds what can be stored in a 64-bit value, the upper bits are dropped.
Parameters:
vec  Pointer to vector to convert into a 64-bit real value

02388   { PROFILE(VECTOR_TO_REAL64);
02389 
02390   real64 retval;  /* Return value for this function */
02391 
02392   switch( vec->suppl.part.data_type ) {
02393     case VDATA_UL  :  retval = (double)vector_to_uint64( vec );  break;
02394     case VDATA_R64 :  retval = vec->value.r64->val;              break;
02395     case VDATA_R32 :  retval = (double)vec->value.r32->val;      break;
02396     default        :  assert( 0 );                               break;
02397   }
02398 
02399   PROFILE_END;
02400 
02401   return( retval );
02402 
02403 }

void vector_to_sim_time const vector vec,
uint64  scale,
sim_time time
 

Converts vector into a sim_time structure.

Converts a vector structure into a sim_time structure. If the number of bits for the vector exceeds the number of bits in an 64-bit integer, the upper bits of the vector are unused.

Parameters:
vec  Pointer to vector to convert into integer
scale  Scaling factor
time  Pointer to sim_time structure to populate

02414   { PROFILE(VECTOR_TO_SIM_TIME);
02415 
02416   union {
02417     struct {
02418       uint32 lo;
02419       uint32 hi;
02420     } u32;
02421     uint64 full;
02422   } time_u = {0};
02423 
02424   /* Calculate the full (64-bit) time value */
02425   switch( vec->suppl.part.data_type ) {
02426     case VDATA_UL  :
02427       assert( vec->value.ul[0][VTYPE_INDEX_VAL_VALH] == 0 );
02428 #if SIZEOF_LONG == 4
02429       time_u.u32.lo = vec->value.ul[0][VTYPE_INDEX_VAL_VALL];
02430       if( UL_SIZE( vec->width ) > 1 ) {
02431         assert( vec->value.ul[1][VTYPE_INDEX_VAL_VALH] == 0 );
02432         time_u.u32.hi = vec->value.ul[1][VTYPE_INDEX_VAL_VALL];
02433       }
02434 #elif SIZEOF_LONG == 8
02435       time_u.full = vec->value.ul[0][VTYPE_INDEX_VAL_VALL];
02436 #else
02437 #error "Unsupported long size"
02438 #endif
02439       time_u.full *= scale;
02440       break;
02441     case VDATA_R64 :  time_u.full = (uint64)round( vec->value.r64->val * scale );  break;
02442     case VDATA_R32 :  time_u.full = (uint64)roundf( vec->value.r32->val * scale );  break;
02443     default        :  assert( 0 );  break;
02444   }
02445 
02446   time->lo   = time_u.u32.lo;
02447   time->hi   = time_u.u32.hi;
02448   time->full = time_u.full;
02449 
02450   PROFILE_END;
02451 
02452 }

char* vector_to_string vector vec,
int  base,
bool  show_all
 

Converts vector into a string value in specified format.

Returns:
Returns pointer to the allocated/coverted string.
Converts a vector value into a string, allocating the memory for the string in this function and returning a pointer to that string. The type specifies what type of value to change vector into.
Parameters:
vec  Pointer to vector to convert
base  Base type of vector value
show_all  Set to TRUE causes all bits in vector to be displayed (otherwise, only significant bits are displayed)

02713   { PROFILE(VECTOR_TO_STRING);
02714 
02715   char* str = NULL;  /* Pointer to allocated string */
02716 
02717   if( base == QSTRING ) {
02718 
02719     int i, j;
02720     int vec_size = ((vec->width - 1) >> 3) + 2;
02721     int pos      = 0;
02722 
02723     /* Allocate memory for string from the heap */
02724     str = (char*)malloc_safe( vec_size );
02725 
02726     switch( vec->suppl.part.data_type ) {
02727       case VDATA_UL :
02728         {
02729           int offset = (((vec->width >> 3) & (UL_MOD_VAL >> 3)) == 0) ? SIZEOF_LONG : ((vec->width >> 3) & (UL_MOD_VAL >> 3));
02730           for( i=UL_SIZE(vec->width); i--; ) {
02731             ulong val = vec->value.ul[i][VTYPE_INDEX_VAL_VALL]; 
02732             for( j=(offset - 1); j>=0; j-- ) {
02733               str[pos] = (val >> ((unsigned int)j * 8)) & 0xff;
02734               pos++;
02735             }
02736             offset = SIZEOF_LONG;
02737           }
02738         }
02739         break;
02740       case VDATA_R64 :
02741         assert( 0 );
02742         break;
02743       default :  assert( 0 );  break;
02744     }
02745 
02746     str[pos] = '\0';
02747 
02748   } else if( base == DECIMAL ) {
02749 
02750     char         width_str[20];
02751     unsigned int rv = snprintf( width_str, 20, "%d", vector_to_int( vec ) );
02752     assert( rv < 20 );
02753     str = strdup_safe( width_str );
02754 
02755   } else if( vec->suppl.part.data_type == VDATA_R64 ) {
02756 
02757     if( vec->value.r64->str != NULL ) {
02758       str = strdup_safe( vec->value.r64->str );
02759     } else {
02760       char         width_str[100];
02761       unsigned int rv = snprintf( width_str, 100, "%f", vec->value.r64->val );
02762       assert( rv < 100 );
02763       str = strdup_safe( width_str );
02764     }
02765 
02766   } else if( vec->suppl.part.data_type == VDATA_R32 ) {
02767 
02768     if( vec->value.r32->str != NULL ) {
02769       str = strdup_safe( vec->value.r32->str );
02770     } else {
02771       char         width_str[30];
02772       unsigned int rv = snprintf( width_str, 30, "%f", vec->value.r32->val );
02773       assert( rv < 30 );
02774       str = strdup_safe( width_str );
02775     }
02776  
02777   } else {
02778 
02779     unsigned int rv;
02780     char*        tmp;
02781     unsigned int str_size;
02782     unsigned int group     = 1;
02783     char         type_char = 'b';
02784     char         width_str[20];
02785     int          vec_size  = ((vec->width - 1) >> 3) + 2;
02786     int          pos       = 0;
02787 
02788     switch( base ) {
02789       case BINARY :  
02790         vec_size  = (vec->width + 1);
02791         group     = 1;
02792         type_char = 'b';
02793         break;
02794       case OCTAL :  
02795         vec_size  = ((vec->width % 3) == 0) ? ((vec->width / 3) + 1)
02796                                             : ((vec->width / 3) + 2);
02797         group     = 3;
02798         type_char = 'o';
02799         break;
02800       case HEXIDECIMAL :  
02801         vec_size  = ((vec->width % 4) == 0) ? ((vec->width / 4) + 1)
02802                                             : ((vec->width / 4) + 2);
02803         group     = 4;
02804         type_char = 'h';
02805         break;
02806       default          :  
02807         assert( (base == BINARY) || (base == OCTAL)  || (base == HEXIDECIMAL) );
02808         /*@-unreachable@*/
02809         break;
02810         /*@=unreachable@*/
02811     }
02812 
02813     tmp = (char*)malloc_safe( vec_size );
02814 
02815     switch( vec->suppl.part.data_type ) {
02816       case VDATA_UL :
02817         {
02818           ulong value = 0;
02819           int    i;
02820           for( i=(vec->width - 1); i>=0; i-- ) {
02821             ulong* entry = vec->value.ul[UL_DIV(i)];
02822             if( ((entry[VTYPE_INDEX_VAL_VALH] >> UL_MOD(i)) & 0x1) == 1 ) {
02823               value = ((entry[VTYPE_INDEX_VAL_VALL] >> UL_MOD(i)) & 0x1) + 16;
02824             } else if( ((entry[VTYPE_INDEX_VAL_VALL] >> UL_MOD(i)) & 0x1) == 1 ) {
02825               value = (value < 16) ? (((ulong)1 << (UL_MOD(i) % group)) | value) : value;
02826             }
02827             assert( pos < vec_size );
02828             if( (i % group) == 0 ) {
02829               switch( value ) {
02830                 case 0x0 :  if( (pos > 0) || (i == 0) || show_all ) { tmp[pos] = '0';  pos++; }  break;
02831                 case 0x1 :  tmp[pos] = '1';  pos++;  break;
02832                 case 0x2 :  tmp[pos] = '2';  pos++;  break;
02833                 case 0x3 :  tmp[pos] = '3';  pos++;  break;
02834                 case 0x4 :  tmp[pos] = '4';  pos++;  break;
02835                 case 0x5 :  tmp[pos] = '5';  pos++;  break;
02836                 case 0x6 :  tmp[pos] = '6';  pos++;  break;
02837                 case 0x7 :  tmp[pos] = '7';  pos++;  break;
02838                 case 0x8 :  tmp[pos] = '8';  pos++;  break;
02839                 case 0x9 :  tmp[pos] = '9';  pos++;  break;
02840                 case 0xa :  tmp[pos] = 'A';  pos++;  break;
02841                 case 0xb :  tmp[pos] = 'B';  pos++;  break;
02842                 case 0xc :  tmp[pos] = 'C';  pos++;  break;
02843                 case 0xd :  tmp[pos] = 'D';  pos++;  break;
02844                 case 0xe :  tmp[pos] = 'E';  pos++;  break;
02845                 case 0xf :  tmp[pos] = 'F';  pos++;  break;
02846                 case 16  :  tmp[pos] = 'X';  pos++;  break;
02847                 case 17  :  tmp[pos] = 'Z';  pos++;  break;
02848                 default  :  
02849                   /* Value in vector_to_string exceeds allowed limit */
02850                   assert( value <= 17 );
02851                   /*@-unreachable@*/
02852                   break;
02853                   /*@=unreachable@*/
02854               }
02855               value = 0;
02856             }
02857           }
02858         }
02859         break;
02860       default :  assert( 0 );  break;
02861     }
02862 
02863     tmp[pos] = '\0';
02864 
02865     rv = snprintf( width_str, 20, "%u", vec->width );
02866     assert( rv < 20 );
02867     str_size = strlen( width_str ) + 2 + strlen( tmp ) + 1 + vec->suppl.part.is_signed;
02868     str      = (char*)malloc_safe( str_size );
02869     if( vec->suppl.part.is_signed == 0 ) {
02870       rv = snprintf( str, str_size, "%u'%c%s", vec->width, type_char, tmp );
02871     } else {
02872       rv = snprintf( str, str_size, "%u's%c%s", vec->width, type_char, tmp );
02873     }
02874     assert( rv < str_size );
02875 
02876     free_safe( tmp, vec_size );
02877 
02878   }
02879 
02880   PROFILE_END;
02881 
02882   return( str );
02883 
02884 }

uint64 vector_to_uint64 const vector vec  ) 
 

Converts vector into a 64-bit unsigned integer value.

Returns:
Returns integer value of specified vector.
Converts a vector structure into an integer value. If the number of bits for the vector exceeds the number of bits in an integer, the upper bits of the vector are unused.
Parameters:
vec  Pointer to vector to convert into integer

02347   { PROFILE(VECTOR_TO_UINT64);
02348 
02349   uint64 retval = 0;   /* 64-bit integer value returned to calling function */
02350 
02351   switch( vec->suppl.part.data_type ) {
02352     case VDATA_UL :
02353       if( (vec->width > 32) && (sizeof( ulong ) == 4) ) {
02354         retval = ((uint64)vec->value.ul[1][VTYPE_INDEX_VAL_VALL] << 32) | (uint64)vec->value.ul[0][VTYPE_INDEX_VAL_VALL];
02355       } else {
02356         retval = (uint64)vec->value.ul[0][VTYPE_INDEX_VAL_VALL];
02357       }
02358       break;
02359     case VDATA_R64 :
02360       retval = (uint64)round( vec->value.r64->val );
02361       break;
02362     case VDATA_R32 :
02363       retval = (uint64)roundf( vec->value.r32->val );
02364       break;
02365     default :  assert( 0 );  break;
02366   }
02367 
02368   /* If the vector is signed, sign-extend the integer */
02369   if( vec->suppl.part.is_signed == 1 ) {
02370     unsigned int width = (vec->width > 64) ? 64 : vec->width;
02371     retval |= (UINT64(0xffffffffffffffff) * ((retval >> (width - 1)) & 0x1)) << width;
02372   }
02373 
02374   PROFILE_END;
02375 
02376   return( retval );
02377 
02378 }

void vector_toggle_count vector vec,
unsigned int *  tog01_cnt,
unsigned int *  tog10_cnt
 

Counts toggle01 and toggle10 information from specifed vector.

Walks through specified vector counting the number of toggle01 bits that are set and the number of toggle10 bits that are set. Adds these values to the contents of tog01_cnt and tog10_cnt.

Parameters:
vec  Pointer to vector to parse
tog01_cnt  Number of bits in vector that toggled from 0 to 1
tog10_cnt  Number of bits in vector that toggled from 1 to 0

01390   { PROFILE(VECTOR_TOGGLE_COUNT);
01391 
01392   if( (vec->suppl.part.type == VTYPE_SIG) || (vec->suppl.part.type == VTYPE_MEM) ) {
01393 
01394     unsigned int i, j;
01395 
01396     switch( vec->suppl.part.data_type ) {
01397       case VDATA_UL :
01398         for( i=0; i<UL_SIZE(vec->width); i++ ) {
01399           for( j=0; j<UL_BITS; j++ ) {
01400             *tog01_cnt += ((vec->value.ul[i][VTYPE_INDEX_SIG_TOG01] >> j) & 0x1);
01401             *tog10_cnt += ((vec->value.ul[i][VTYPE_INDEX_SIG_TOG10] >> j) & 0x1);
01402           }
01403         }
01404         break;
01405       case VDATA_R64 :
01406         break;
01407       default :  assert( 0 );  break;
01408     }
01409 
01410   }
01411 
01412   PROFILE_END;
01413 
01414 }

bool vector_unary_and vector tgt,
const vector src
 

Performs unary AND operation on specified vector value.

Returns:
Returns TRUE if assigned value differs from original; otherwise, returns FALSE.
Performs unary AND operation on specified vector value.
Parameters:
tgt  Target vector for operation result storage
src  Source vector to be operated on

04727   { PROFILE(VECTOR_UNARY_AND);
04728 
04729   bool retval;  /* Return value for this function */
04730 
04731   switch( tgt->suppl.part.data_type ) {
04732     case VDATA_UL :
04733       {
04734         unsigned int i;
04735         unsigned int ssize = UL_SIZE( src->width );
04736         ulong        valh  = 0;
04737         ulong        vall  = 1;
04738         ulong        lmask = UL_HMASK(src->width - 1);
04739         for( i=0; i<(ssize-1); i++ ) {
04740           valh |= (src->value.ul[i][VTYPE_INDEX_VAL_VALH] != 0) ? 1 : 0;
04741           vall &= ~valh & ((src->value.ul[i][VTYPE_INDEX_VAL_VALL] == UL_SET) ? 1 : 0);
04742         }
04743         valh |= (src->value.ul[i][VTYPE_INDEX_VAL_VALH] != 0) ? 1 : 0;
04744         vall &= ~valh & ((src->value.ul[i][VTYPE_INDEX_VAL_VALL] == lmask) ? 1 : 0);
04745         retval = vector_set_coverage_and_assign_ulong( tgt, &vall, &valh, 0, 0 );
04746       }
04747       break;
04748     default :  assert( 0 );  break;
04749   }
04750 
04751   PROFILE_END;
04752 
04753   return( retval );
04754 
04755 }

bool vector_unary_inv vector tgt,
const vector src
 

Performs unary bitwise inversion operation on specified vector value.

Returns:
Returns TRUE if assigned value differs from orignal; otherwise, returns FALSE.
Performs a bitwise inversion on the specified vector.
Parameters:
tgt  Target vector for operation results to be stored
src  Source vector to perform operation on

04684   { PROFILE(VECTOR_UNARY_INV);
04685 
04686   bool retval;  /* Return value for this function */
04687 
04688   switch( src->suppl.part.data_type ) {
04689     case VDATA_UL :
04690       {
04691         ulong        vall[UL_DIV(MAX_BIT_WIDTH)];
04692         ulong        valh[UL_DIV(MAX_BIT_WIDTH)];
04693         ulong        mask = UL_HMASK(src->width - 1);
04694         ulong        tvalh;
04695         unsigned int i;
04696         unsigned int size = UL_SIZE( src->width );
04697 
04698         for( i=0; i<(size-1); i++ ) {
04699           tvalh   = src->value.ul[i][VTYPE_INDEX_EXP_VALH];
04700           vall[i] = ~tvalh & ~src->value.ul[i][VTYPE_INDEX_EXP_VALL];
04701           valh[i] = tvalh;
04702         }
04703         tvalh   = src->value.ul[i][VTYPE_INDEX_EXP_VALH];
04704         vall[i] = ~tvalh & ~src->value.ul[i][VTYPE_INDEX_EXP_VALL] & mask;
04705         valh[i] = tvalh & mask;
04706 
04707         retval = vector_set_coverage_and_assign_ulong( tgt, vall, valh, 0, (tgt->width - 1) );
04708       }
04709       break;
04710     default :  assert( 0 );  break;
04711   }
04712 
04713   PROFILE_END;
04714 
04715   return( retval );
04716 
04717 }

bool vector_unary_nand vector tgt,
const vector src
 

Performs unary NAND operation on specified vector value.

Returns:
Returns TRUE if assigned value differs from original; otherwise, returns FALSE.
Performs unary NAND operation on specified vector value.
Parameters:
tgt  Target vector for operation result storage
src  Source vector to be operated on

04765   { PROFILE(VECTOR_UNARY_NAND);
04766 
04767   bool retval;  /* Return value for this function */
04768 
04769   switch( tgt->suppl.part.data_type ) {
04770     case VDATA_UL :
04771       {
04772         unsigned int i;
04773         unsigned int ssize = UL_SIZE( src->width );
04774         ulong        valh  = 0;
04775         ulong        vall  = 0;
04776         ulong        lmask = UL_HMASK(src->width - 1);
04777         for( i=0; i<(ssize-1); i++ ) {
04778           valh |= (src->value.ul[i][VTYPE_INDEX_VAL_VALH] != 0) ? 1 : 0;
04779           vall |= ~valh & ((src->value.ul[i][VTYPE_INDEX_VAL_VALL] == UL_SET) ? 0 : 1);
04780         }
04781         valh |= (src->value.ul[i][VTYPE_INDEX_VAL_VALH] != 0) ? 1 : 0;
04782         vall |= ~valh & ((src->value.ul[i][VTYPE_INDEX_VAL_VALL] == lmask) ? 0 : 1);
04783         retval = vector_set_coverage_and_assign_ulong( tgt, &vall, &valh, 0, 0 );
04784       }
04785       break;
04786     default :  assert( 0 );  break;
04787   } 
04788 
04789   PROFILE_END;
04790 
04791   return( retval );
04792 
04793 }

bool vector_unary_nor vector tgt,
const vector src
 

Performs unary NOR operation on specified vector value.

Returns:
Returns TRUE if assigned value differs from original; otherwise, returns FALSE.
Performs unary NOR operation on specified vector value.
Parameters:
tgt  Target vector for operation result storage
src  Source vector to be operated on

04846   { PROFILE(VECTOR_UNARY_NOR);
04847 
04848   bool retval;  /* Return value for this function */
04849 
04850   switch( src->suppl.part.data_type ) {
04851     case VDATA_UL :
04852       {
04853         ulong        vall;
04854         ulong        valh;
04855         unsigned int i    = 0;
04856         unsigned int size = UL_SIZE( src->width );
04857         ulong        x    = 0;
04858         while( (i < size) && ((~src->value.ul[i][VTYPE_INDEX_VAL_VALH] & src->value.ul[i][VTYPE_INDEX_VAL_VALL]) == 0) ) {
04859           x |= src->value.ul[i][VTYPE_INDEX_VAL_VALH];
04860           i++;
04861         }
04862         if( i < size ) {
04863           vall = 0;
04864           valh = 0;
04865         } else {
04866           vall = (x == 0);
04867           valh = (x != 0);
04868         }
04869         retval = vector_set_coverage_and_assign_ulong( tgt, &vall, &valh, 0, 0 );
04870       }
04871       break;
04872     default :  assert( 0 );  break;
04873   }
04874 
04875   PROFILE_END;
04876 
04877   return( retval );
04878 
04879 }

bool vector_unary_not vector tgt,
const vector src
 

Performs unary logical NOT operation on specified vector value.

Returns:
Returns TRUE if assigned value differs from original; otherwise, returns FALSE.
Performs unary logical NOT operation on specified vector value.
Parameters:
tgt  Target vector for operation result storage
src  Source vector to be operated on

04979   { PROFILE(VECTOR_UNARY_NOT);
04980 
04981   bool retval;  /* Return value of this function */
04982 
04983   switch( src->suppl.part.data_type ) {
04984     case VDATA_UL :
04985       {
04986         ulong        vall;
04987         ulong        valh;
04988         unsigned int size = UL_SIZE( src->width );
04989         unsigned int i    = 0;
04990         while( (i < size) && (src->value.ul[i][VTYPE_INDEX_VAL_VALH] == 0) && (src->value.ul[i][VTYPE_INDEX_VAL_VALL] == 0) ) i++;
04991         if( i < size ) {
04992           vall = 0;
04993           valh = (src->value.ul[i][VTYPE_INDEX_VAL_VALH] != 0);
04994         } else {
04995           vall = 1;
04996           valh = 0;
04997         }
04998         retval = vector_set_coverage_and_assign_ulong( tgt, &vall, &valh, 0, 0 );
04999       }
05000       break;
05001     default :  assert( 0 );  break;
05002   }
05003 
05004   PROFILE_END;
05005 
05006   return( retval );
05007 
05008 }

bool vector_unary_nxor vector tgt,
const vector src
 

Performs unary NXOR operation on specified vector value.

Returns:
Returns TRUE if assigned value differs from original; otherwise, returns FALSE.
Performs unary NXOR operation on specified vector value.
Parameters:
tgt  Target vector for operation result storage
src  Source vector to be operated on

04934   { PROFILE(VECTOR_UNARY_NXOR);
04935 
04936   bool retval;  /* Return value for this function */
04937 
04938   switch( src->suppl.part.data_type ) {
04939     case VDATA_UL :
04940       {
04941         ulong        vall = 1;
04942         ulong        valh = 0;
04943         unsigned int i    = 0;
04944         unsigned int size = UL_SIZE( src->width );
04945         do {
04946           if( src->value.ul[i][VTYPE_INDEX_VAL_VALH] != 0 ) {
04947             vall = 0;
04948             valh = 1;
04949           } else {
04950             unsigned int j;
04951             ulong        tval = src->value.ul[i][VTYPE_INDEX_VAL_VALL];
04952             for( j=1; j<UL_BITS; j<<=1 ) {
04953               tval = tval ^ (tval >> j);
04954             }
04955             vall = (vall ^ tval) & 0x1;
04956           }
04957           i++;
04958         } while( (i < size) && (valh == 0) );
04959         retval = vector_set_coverage_and_assign_ulong( tgt, &vall, &valh, 0, 0 );
04960       }
04961       break;
04962     default :  assert( 0 );  break;
04963   }
04964 
04965   PROFILE_END;
04966 
04967   return( retval );
04968 
04969 }

bool vector_unary_or vector tgt,
const vector src
 

Performs unary OR operation on specified vector value.

Returns:
Returns TRUE if assigned value differs from original; otherwise, returns FALSE.
Performs unary OR operation on specified vector value.
Parameters:
tgt  Target vector for operation result storage
src  Source vector to be operated on

04803   { PROFILE(VECTOR_UNARY_OR);
04804 
04805   bool retval;  /* Return value for this function */
04806 
04807   switch( src->suppl.part.data_type ) {
04808     case VDATA_UL :
04809       {
04810         ulong        vall;
04811         ulong        valh;
04812         unsigned int i    = 0;
04813         unsigned int size = UL_SIZE( src->width );
04814         ulong        x    = 0;
04815         while( (i < size) && ((~src->value.ul[i][VTYPE_INDEX_VAL_VALH] & src->value.ul[i][VTYPE_INDEX_VAL_VALL]) == 0) ) {
04816           x |= src->value.ul[i][VTYPE_INDEX_VAL_VALH];
04817           i++;
04818         }
04819         if( i < size ) {
04820           vall = 1;
04821           valh = 0;
04822         } else {
04823           vall = 0;
04824           valh = (x != 0);
04825         }
04826         retval = vector_set_coverage_and_assign_ulong( tgt, &vall, &valh, 0, 0 );
04827       }
04828       break;
04829     default :  assert( 0 );  break;
04830   }
04831 
04832   PROFILE_END;
04833 
04834   return( retval );
04835 
04836 }

bool vector_unary_xor vector tgt,
const vector src
 

Performs unary XOR operation on specified vector value.

Returns:
Returns TRUE if assigned value differs from original; otherwise, returns FALSE.
Performs unary XOR operation on specified vector value.
Parameters:
tgt  Target vector for operation result storage
src  Source vector to be operated on

04889   { PROFILE(VECTOR_UNARY_XOR);
04890 
04891   bool retval;  /* Return value for this function */
04892 
04893   switch( src->suppl.part.data_type ) {
04894     case VDATA_UL :
04895       {
04896         ulong        vall = 0;
04897         ulong        valh = 0;
04898         unsigned int i    = 0;
04899         unsigned int size = UL_SIZE( src->width );
04900         do {
04901           if( src->value.ul[i][VTYPE_INDEX_VAL_VALH] != 0 ) {
04902             vall = 0;
04903             valh = 1;
04904           } else {
04905             unsigned int j;
04906             ulong        tval = src->value.ul[i][VTYPE_INDEX_VAL_VALL];
04907             for( j=1; j<UL_BITS; j<<=1 ) {
04908               tval = tval ^ (tval >> j);
04909             }
04910             vall = (vall ^ tval) & 0x1;
04911           }
04912           i++;
04913         } while( (i < size) && (valh == 0) );
04914         retval = vector_set_coverage_and_assign_ulong( tgt, &vall, &valh, 0, 0 );
04915       }
04916       break;
04917     default :  assert( 0 );  break;
04918   }
04919 
04920   PROFILE_END;
04921 
04922   return( retval );
04923 
04924 }

bool vector_vcd_assign vector vec,
const char *  value,
int  msb,
int  lsb
 

Assigns specified VCD value to specified vector.

Returns:
Returns TRUE if assigned value differs from the original value; otherwise, returns FALSE.
Exceptions:
anonymous Throw
Iterates through specified value string, setting the specified vector value to this value. Performs a VCD-specific bit-fill if the value size is not the size of the vector. The specified value string is assumed to be in binary format.
Parameters:
vec  Pointer to vector to set value to
value  String version of VCD value
msb  Most significant bit to assign to
lsb  Least significant bit to assign to

03075   { PROFILE(VECTOR_VCD_ASSIGN);
03076 
03077   bool        retval = FALSE;  /* Return value for this function */
03078   const char* ptr;             /* Pointer to current character under evaluation */
03079   int         i      = lsb;    /* Loop iterator */
03080 
03081   /* Make adjustment to MSB if necessary */
03082   msb = (msb > 0) ? msb : -msb;
03083 
03084   assert( vec != NULL );
03085   assert( value != NULL );
03086   assert( msb <= vec->width );
03087 
03088   /* Set pointer to LSB */
03089   ptr = (value + strlen( value )) - 1;
03090 
03091   switch( vec->suppl.part.data_type ) {
03092     case VDATA_UL :
03093       {
03094         ulong scratchl[UL_DIV(MAX_BIT_WIDTH)];
03095         ulong scratchh[UL_DIV(MAX_BIT_WIDTH)];
03096         scratchl[UL_DIV(i)] = 0;
03097         scratchh[UL_DIV(i)] = 0;
03098         while( ptr >= value ) {
03099           unsigned int index  = UL_DIV(i);
03100           unsigned int offset = UL_MOD(i);
03101           ulong        bit    = ((ulong)1 << offset);
03102           if( offset == 0 ) {
03103             scratchl[index] = 0;
03104             scratchh[index] = 0;
03105           }
03106           scratchl[index] |= ((*ptr == '1') || (*ptr == 'z')) ? bit : 0;
03107           scratchh[index] |= ((*ptr == 'x') || (*ptr == 'z')) ? bit : 0;
03108           ptr--;
03109           i++;
03110         }
03111         ptr++;
03112         /* Bit-fill */
03113         for( ; i<=msb; i++ ) {
03114           unsigned int index  = UL_DIV(i);
03115           unsigned int offset = UL_MOD(i);
03116           ulong        bit    = ((ulong)1 << offset);
03117           if( offset == 0 ) {
03118             scratchl[index] = 0;
03119             scratchh[index] = 0;
03120           }
03121           scratchl[index] |= (*ptr == 'z') ? bit : 0;
03122           scratchh[index] |= ((*ptr == 'x') || (*ptr == 'z')) ? bit : 0;
03123         }
03124         retval = vector_set_coverage_and_assign_ulong( vec, scratchl, scratchh, lsb, msb );
03125       }
03126       break;
03127     case VDATA_R64 :
03128       {
03129         double real;
03130         if( sscanf( value, "%lf", &real ) == 1 ) {
03131           retval = !DEQ( vec->value.r64->val, real );
03132           vec->value.r64->val = real;
03133         } else {
03134           assert( 0 );
03135         }
03136       }
03137       break;
03138     case VDATA_R32 :
03139       {
03140         float real;
03141         if( sscanf( value, "%f", &real ) != 1 ) {
03142           retval = !FEQ( vec->value.r32->val, real );
03143           vec->value.r32->val = real;
03144         } else {
03145           assert( 0 );
03146         }
03147       }
03148       break;
03149     default :  assert( 0 );  break;
03150   }
03151 
03152   /* Set the set bit to indicate that this vector has been evaluated */
03153   vec->suppl.part.set = 1;
03154 
03155   PROFILE_END;
03156 
03157   return( retval );
03158 
03159 }


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