vector.c File Reference

#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <math.h>
#include <float.h>
#include "defines.h"
#include "vector.h"
#include "util.h"

Defines

#define _ISOC99_SOURCE   1
#define UL_SIZE(width)   (UL_DIV((width) - 1) + 1)
#define UL_LMASK(lsb)   (UL_SET << UL_MOD(lsb))
#define UL_HMASK(msb)   (UL_SET >> ((UL_BITS - 1) - UL_MOD(msb)))

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.
static void vector_display_value_ulongs (ulong *vall, ulong *valh, int width)
void vector_display_ulong (ulong **value, unsigned int width, unsigned int type)
 Outputs ulong vector to standard output.
void vector_display_r64 (rv64 *value)
void vector_display_r32 (rv32 *value)
void vector_display (const vector *vec)
 Outputs vector contents to standard output.
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.
static void vector_get_sign_extend_vector_ulong (const vector *vec, ulong *signl, ulong *signh)
static void vector_sign_extend_ulong (ulong *vall, ulong *valh, ulong signl, ulong signh, int last, int width)
static void vector_lshift_ulong (const vector *vec, ulong *vall, ulong *valh, int lsb, int msb, bool xfill)
static void vector_rshift_ulong (const vector *vec, ulong *vall, ulong *valh, int lsb, int msb, bool xfill)
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_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.
static void vector_set_static (vector *vec, char *str, unsigned int bits_per_char)
char * vector_to_string (vector *vec, int base, bool show_all, unsigned int width)
 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.
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.
static bool vector_reverse_for_cmp_ulong (const vector *left, const vector *right)
static void vector_copy_val_and_sign_extend_ulong (const vector *vec, unsigned int index, bool msb_is_one, ulong *vall, ulong *valh)
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.
bool vector_op_clog2 (vector *tgt, const vector *src)
 Performs clog2 operation.
void vector_dealloc_value (vector *vec)
void vector_dealloc (vector *vec)
 Deallocates all memory allocated for vector.

Variables

static const unsigned int vector_type_sizes [4] = {VTYPE_INDEX_VAL_NUM, VTYPE_INDEX_SIG_NUM, VTYPE_INDEX_EXP_NUM, VTYPE_INDEX_MEM_NUM}
char user_msg [USER_MSG_LENGTH]
isuppl info_suppl

Detailed Description

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

Define Documentation

#define _ISOC99_SOURCE   1
#define UL_HMASK ( msb   )     (UL_SET >> ((UL_BITS - 1) - UL_MOD(msb)))
#define UL_LMASK ( lsb   )     (UL_SET << UL_MOD(lsb))
#define UL_SIZE ( width   )     (UL_DIV((width) - 1) + 1)

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

References vsuppl_u::data_type, MAX_BIT_WIDTH, vsuppl_u::part, PROFILE, PROFILE_END, vector_s::suppl, vector_s::ul, UL_DIV, UL_SIZE, vector_s::value, VDATA_UL, vector_set_coverage_and_assign_ulong(), VTYPE_INDEX_VAL_VALH, VTYPE_INDEX_VAL_VALL, and vector_s::width.

Referenced by expression_op_func__and(), and expression_op_func__and_a().

03278   { PROFILE(VECTOR_BITWISE_AND_OP);
03279   
03280   bool retval;  /* Return value for this function */
03281 
03282   switch( tgt->suppl.part.data_type ) {
03283     case VDATA_UL :
03284       { 
03285         ulong        scratchl[UL_DIV(MAX_BIT_WIDTH)];
03286         ulong        scratchh[UL_DIV(MAX_BIT_WIDTH)];
03287         unsigned int src1_size = UL_SIZE(src1->width);
03288         unsigned int src2_size = UL_SIZE(src2->width);
03289         unsigned int i;
03290         for( i=0; i<UL_SIZE(tgt->width); i++ ) {
03291           ulong* entry1 = src1->value.ul[i];
03292           ulong* entry2 = src2->value.ul[i];
03293           ulong  val1_l = (i<src1_size) ? entry1[VTYPE_INDEX_VAL_VALL] : 0;
03294           ulong  val1_h = (i<src1_size) ? entry1[VTYPE_INDEX_VAL_VALH] : 0;
03295           ulong  val2_l = (i<src2_size) ? entry2[VTYPE_INDEX_VAL_VALL] : 0;
03296           ulong  val2_h = (i<src2_size) ? entry2[VTYPE_INDEX_VAL_VALH] : 0;
03297           scratchl[i]   = ~(val1_h | val2_h) & (val1_l & val2_l);
03298           scratchh[i]   = (val1_h & val2_h) | (val1_h & val2_l) | (val2_h & val1_l);
03299         }
03300         retval = vector_set_coverage_and_assign_ulong( tgt, scratchl, scratchh, 0, (tgt->width - 1) );
03301       }
03302       break;
03303     default :  assert( 0 );  break;
03304   }
03305 
03306   PROFILE_END;
03307 
03308   return( retval );
03309  
03310 }

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

References vsuppl_u::data_type, MAX_BIT_WIDTH, vsuppl_u::part, PROFILE, PROFILE_END, vector_s::suppl, vector_s::ul, UL_DIV, UL_SIZE, vector_s::value, VDATA_UL, vector_set_coverage_and_assign_ulong(), VTYPE_INDEX_VAL_VALH, VTYPE_INDEX_VAL_VALL, and vector_s::width.

Referenced by expression_op_func__nand().

03323   { PROFILE(VECTOR_BITWISE_NAND_OP);   
03324                                       
03325   bool retval;  /* Return value for this function */
03326                                       
03327   switch( tgt->suppl.part.data_type ) {
03328     case VDATA_UL :                  
03329       {
03330         static ulong scratchl[UL_DIV(MAX_BIT_WIDTH)];
03331         static ulong scratchh[UL_DIV(MAX_BIT_WIDTH)];
03332         unsigned int src1_size = UL_SIZE(src1->width);
03333         unsigned int src2_size = UL_SIZE(src2->width);
03334         unsigned int i;
03335         for( i=0; i<UL_SIZE(tgt->width); i++ ) {
03336           ulong* entry1 = src1->value.ul[i];
03337           ulong* entry2 = src2->value.ul[i];
03338           ulong  val1_l = (i<src1_size) ? entry1[VTYPE_INDEX_VAL_VALL] : 0;
03339           ulong  val1_h = (i<src1_size) ? entry1[VTYPE_INDEX_VAL_VALH] : 0;
03340           ulong  val2_l = (i<src2_size) ? entry2[VTYPE_INDEX_VAL_VALL] : 0;
03341           ulong  val2_h = (i<src2_size) ? entry2[VTYPE_INDEX_VAL_VALH] : 0;
03342           scratchl[i] = ~(val1_h | val2_h) & ~(val1_l & val2_l);
03343           scratchh[i] = (val1_h & val2_h) | (val1_h & ~val2_l) | (val2_h & ~val1_l);
03344         }
03345         retval = vector_set_coverage_and_assign_ulong( tgt, scratchl, scratchh, 0, (tgt->width - 1) );
03346       }
03347       break;
03348     default :  assert( 0 );  break; 
03349   }
03350 
03351   PROFILE_END;
03352 
03353   return( retval );
03354  
03355 }

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

References vsuppl_u::data_type, MAX_BIT_WIDTH, vsuppl_u::part, PROFILE, PROFILE_END, vector_s::suppl, vector_s::ul, UL_DIV, UL_SIZE, vector_s::value, VDATA_UL, vector_set_coverage_and_assign_ulong(), VTYPE_INDEX_VAL_VALH, VTYPE_INDEX_VAL_VALL, and vector_s::width.

Referenced by expression_op_func__nor().

03413   { PROFILE(VECTOR_BITWISE_NOR_OP);
03414 
03415   bool retval;  /* Return value for this function */
03416 
03417   switch( tgt->suppl.part.data_type ) {
03418     case VDATA_UL :
03419       {
03420         static ulong scratchl[UL_DIV(MAX_BIT_WIDTH)];
03421         static ulong scratchh[UL_DIV(MAX_BIT_WIDTH)];
03422         unsigned int src1_size = UL_SIZE(src1->width);
03423         unsigned int src2_size = UL_SIZE(src2->width);
03424         unsigned int i;
03425         for( i=0; i<UL_SIZE(tgt->width); i++ ) {
03426           ulong* entry1 = src1->value.ul[i];
03427           ulong* entry2 = src2->value.ul[i];
03428           ulong  val1_l = (i<src1_size) ? entry1[VTYPE_INDEX_VAL_VALL] : 0;
03429           ulong  val1_h = (i<src1_size) ? entry1[VTYPE_INDEX_VAL_VALH] : 0;
03430           ulong  val2_l = (i<src2_size) ? entry2[VTYPE_INDEX_VAL_VALL] : 0;
03431           ulong  val2_h = (i<src2_size) ? entry2[VTYPE_INDEX_VAL_VALH] : 0;
03432           scratchl[i] = ~(val1_h | val2_h) & ~(val1_l | val2_l);
03433           scratchh[i] =  (val1_h & val2_h) |  (val1_h & val2_l) | (val2_h & val1_l);
03434         }
03435         retval = vector_set_coverage_and_assign_ulong( tgt, scratchl, scratchh, 0, (tgt->width - 1) );
03436       }
03437       break;
03438     default :  assert( 0 );  break;
03439   }
03440 
03441   PROFILE_END;
03442 
03443   return( retval );
03444 
03445 }

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

References vsuppl_u::data_type, MAX_BIT_WIDTH, vsuppl_u::part, PROFILE, PROFILE_END, vector_s::suppl, vector_s::ul, UL_DIV, UL_SIZE, vector_s::value, VDATA_UL, vector_set_coverage_and_assign_ulong(), VTYPE_INDEX_VAL_VALH, VTYPE_INDEX_VAL_VALL, and vector_s::width.

Referenced by expression_op_func__nxor().

03503   { PROFILE(VECTOR_BITWISE_NXOR_OP);
03504   
03505   bool retval;  /* Return value for this function */
03506 
03507   switch( tgt->suppl.part.data_type ) {
03508     case VDATA_UL :
03509       { 
03510         static ulong scratchl[UL_DIV(MAX_BIT_WIDTH)];
03511         static ulong scratchh[UL_DIV(MAX_BIT_WIDTH)];
03512         unsigned int src1_size = UL_SIZE(src1->width);
03513         unsigned int src2_size = UL_SIZE(src2->width);
03514         unsigned int i;
03515         for( i=0; i<UL_SIZE(tgt->width); i++ ) {
03516           ulong* entry1 = src1->value.ul[i];
03517           ulong* entry2 = src2->value.ul[i];
03518           ulong  val1_l = (i<src1_size) ? entry1[VTYPE_INDEX_VAL_VALL] : 0;
03519           ulong  val1_h = (i<src1_size) ? entry1[VTYPE_INDEX_VAL_VALH] : 0;
03520           ulong  val2_l = (i<src2_size) ? entry2[VTYPE_INDEX_VAL_VALL] : 0;
03521           ulong  val2_h = (i<src2_size) ? entry2[VTYPE_INDEX_VAL_VALH] : 0;
03522           scratchl[i] = ~(val1_l ^ val2_l) & ~(val1_h | val2_h);
03523           scratchh[i] =  (val1_h | val2_h);
03524         }
03525         retval = vector_set_coverage_and_assign_ulong( tgt, scratchl, scratchh, 0, (tgt->width - 1) );
03526       }
03527       break;
03528     default :  assert( 0 );  break;
03529   }
03530 
03531   PROFILE_END;
03532 
03533   return( retval );
03534  
03535 }

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

References vsuppl_u::data_type, MAX_BIT_WIDTH, vsuppl_u::part, PROFILE, PROFILE_END, vector_s::suppl, vector_s::ul, UL_DIV, UL_SIZE, vector_s::value, VDATA_UL, vector_set_coverage_and_assign_ulong(), VTYPE_INDEX_VAL_VALH, VTYPE_INDEX_VAL_VALL, and vector_s::width.

Referenced by expression_op_func__or(), and expression_op_func__or_a().

03368   { PROFILE(VECTOR_BITWISE_OR_OP);
03369 
03370   bool retval;  /* Return value for this function */
03371 
03372   switch( tgt->suppl.part.data_type ) {
03373     case VDATA_UL :
03374       {
03375         static ulong scratchl[UL_DIV(MAX_BIT_WIDTH)];
03376         static ulong scratchh[UL_DIV(MAX_BIT_WIDTH)];
03377         unsigned int src1_size = UL_SIZE(src1->width);
03378         unsigned int src2_size = UL_SIZE(src2->width);
03379         unsigned int i;
03380         for( i=0; i<UL_SIZE(tgt->width); i++ ) {
03381           ulong* entry1 = src1->value.ul[i];
03382           ulong* entry2 = src2->value.ul[i];
03383           ulong  val1_l = (i<src1_size) ? entry1[VTYPE_INDEX_VAL_VALL] : 0;
03384           ulong  val1_h = (i<src1_size) ? entry1[VTYPE_INDEX_VAL_VALH] : 0;
03385           ulong  val2_l = (i<src2_size) ? entry2[VTYPE_INDEX_VAL_VALL] : 0;
03386           ulong  val2_h = (i<src2_size) ? entry2[VTYPE_INDEX_VAL_VALH] : 0;
03387           scratchl[i] = (val1_l & ~val1_h) | (val2_l & ~val2_h);
03388           scratchh[i] = ~scratchl[i] & (val1_h | val2_h);
03389         }
03390         retval = vector_set_coverage_and_assign_ulong( tgt, scratchl, scratchh, 0, (tgt->width - 1) );
03391       }
03392       break;
03393     default :  assert( 0 );  break;
03394   }
03395 
03396   PROFILE_END;
03397 
03398   return( retval );
03399 
03400 }

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

References vsuppl_u::data_type, MAX_BIT_WIDTH, vsuppl_u::part, PROFILE, PROFILE_END, vector_s::suppl, vector_s::ul, UL_DIV, UL_SIZE, vector_s::value, VDATA_UL, vector_set_coverage_and_assign_ulong(), VTYPE_INDEX_VAL_VALH, VTYPE_INDEX_VAL_VALL, and vector_s::width.

Referenced by expression_op_func__xor(), and expression_op_func__xor_a().

03458   { PROFILE(VECTOR_BITWISE_XOR_OP);
03459 
03460   bool retval;  /* Return value for this function */
03461 
03462   switch( tgt->suppl.part.data_type ) {
03463     case VDATA_UL :
03464       {
03465         static ulong scratchl[UL_DIV(MAX_BIT_WIDTH)];
03466         static ulong scratchh[UL_DIV(MAX_BIT_WIDTH)];
03467         unsigned int src1_size = UL_SIZE(src1->width);
03468         unsigned int src2_size = UL_SIZE(src2->width);
03469         unsigned int i;
03470         for( i=0; i<UL_SIZE(tgt->width); i++ ) {
03471           ulong* entry1 = src1->value.ul[i];
03472           ulong* entry2 = src2->value.ul[i];
03473           ulong  val1_l = (i<src1_size) ? entry1[VTYPE_INDEX_VAL_VALL] : 0;
03474           ulong  val1_h = (i<src1_size) ? entry1[VTYPE_INDEX_VAL_VALH] : 0;
03475           ulong  val2_l = (i<src2_size) ? entry2[VTYPE_INDEX_VAL_VALL] : 0;
03476           ulong  val2_h = (i<src2_size) ? entry2[VTYPE_INDEX_VAL_VALH] : 0;
03477           scratchl[i] = (val1_l ^ val2_l) & ~(val1_h | val2_h);
03478           scratchh[i] = (val1_h | val2_h);
03479         }
03480         retval = vector_set_coverage_and_assign_ulong( tgt, scratchl, scratchh, 0, (tgt->width - 1) );
03481       }
03482       break;
03483     default :  assert( 0 );  break;
03484   }
03485 
03486   PROFILE_END;
03487 
03488   return( retval );
03489 
03490 }

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

References PROFILE, PROFILE_END, vector_s::ul, UL_DIV, UL_MOD, UL_SIZE, vector_s::value, vector_copy_val_and_sign_extend_ulong(), VTYPE_INDEX_VAL_VALL, and vector_s::width.

Referenced by arc_find_from_state(), arc_find_to_state(), expression_op_func__aedge(), vector_op_ceq(), and vector_op_cne().

03889   { PROFILE(VECTOR_CEQ_ULONG);
03890 
03891   unsigned int lsize       = UL_SIZE(left->width);
03892   unsigned int rsize       = UL_SIZE(right->width);
03893   int          i           = ((lsize < rsize) ? rsize : lsize);
03894   unsigned int lmsb        = (left->width - 1);
03895   unsigned int rmsb        = (right->width - 1);
03896   bool         lmsb_is_one = (((left->value.ul[UL_DIV(lmsb)][VTYPE_INDEX_VAL_VALL]  >> UL_MOD(lmsb)) & 1) == 1);
03897   bool         rmsb_is_one = (((right->value.ul[UL_DIV(rmsb)][VTYPE_INDEX_VAL_VALL] >> UL_MOD(rmsb)) & 1) == 1);
03898   ulong        lvall;
03899   ulong        lvalh;
03900   ulong        rvall;
03901   ulong        rvalh;
03902 
03903   do {
03904     i--;
03905     vector_copy_val_and_sign_extend_ulong( left,  i, lmsb_is_one, &lvall, &lvalh );
03906     vector_copy_val_and_sign_extend_ulong( right, i, rmsb_is_one, &rvall, &rvalh );
03907   } while( (i > 0) && (lvall == rvall) && (lvalh == rvalh) );
03908 
03909   PROFILE_END;
03910 
03911   return( (lvall == rvall) && (lvalh == rvalh) );
03912 
03913 }

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

References vsuppl_u::data_type, vsuppl_u::part, PROFILE, PROFILE_END, vector_s::suppl, TRUE, vsuppl_u::type, vector_copy(), vector_create(), and vector_s::width.

Referenced by vsignal_duplicate().

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

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

References vsuppl_u::data_type, vsuppl_u::part, PROFILE, PROFILE_END, vector_s::r32, vector_s::r64, rv32_s::str, rv64_s::str, strdup_safe, vector_s::suppl, vsuppl_u::type, vector_s::ul, UL_SIZE, rv32_s::val, rv64_s::val, vector_s::value, VDATA_R32, VDATA_R64, VDATA_UL, vector_type_sizes, and vector_s::width.

Referenced by arc_add(), expression_op_func__add_a(), expression_op_func__aedge(), expression_op_func__and_a(), expression_op_func__arshift_a(), expression_op_func__divide_a(), expression_op_func__lshift_a(), expression_op_func__mod_a(), expression_op_func__multiply_a(), expression_op_func__or_a(), expression_op_func__rshift_a(), expression_op_func__signed(), expression_op_func__sub_a(), expression_op_func__unsigned(), expression_op_func__xor_a(), fsm_table_set(), vector_clone(), vector_op_dec(), and vector_op_inc().

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

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

References vsuppl_u::data_type, vsuppl_u::part, PROFILE, PROFILE_END, vector_s::suppl, vsuppl_u::type, vector_s::ul, UL_DIV, UL_MOD, vector_s::value, VDATA_R32, VDATA_R64, VDATA_UL, vector_type_sizes, and vector_s::width.

Referenced by memory_display_memory(), and memory_get_mem_coverage().

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

static void vector_copy_val_and_sign_extend_ulong ( const vector vec,
unsigned int  index,
bool  msb_is_one,
ulong vall,
ulong valh 
) [inline, static]

Copies the specified indexed ulong from the given vector and sign extends the value as necessary.

Parameters:
vec Pointer to vector to copy and sign extend
index Current ulong index to copy and sign extend
msb_is_one Set to TRUE if MSB is a value of one
vall Pointer to the low ulong to copy and sign extend to
valh Pointer to the high ulong to copy and sign extend to

References vsuppl_u::is_signed, vsuppl_u::part, vector_s::suppl, vector_s::ul, UL_DIV, UL_LMASK, vector_s::value, VTYPE_INDEX_VAL_VALH, VTYPE_INDEX_VAL_VALL, and vector_s::width.

Referenced by vector_ceq_ulong(), vector_op_add(), vector_op_cxeq(), vector_op_czeq(), vector_op_eq(), vector_op_ge(), vector_op_gt(), vector_op_le(), vector_op_lt(), vector_op_ne(), and vector_op_subtract().

03560   {
03561 
03562   unsigned int last_index = UL_DIV(vec->width - 1);
03563 
03564   /* If we are at or exceeding the size of the current vector, it is a signed vector and the MSB is one, sign extend */
03565   if( (index >= last_index) && (vec->suppl.part.is_signed == 1) && msb_is_one ) {
03566     if( index == last_index ) {
03567       *vall = vec->value.ul[index][VTYPE_INDEX_VAL_VALL] | UL_LMASK(vec->width);
03568       *valh = vec->value.ul[index][VTYPE_INDEX_VAL_VALH];
03569     } else {
03570       *vall = UL_SET;
03571       *valh = 0;
03572     }
03573 
03574   /* Otherwise, if we are exceeding the index, set the vall and valh to 0 */
03575   } else if( index > last_index ) {
03576     *vall = 0;
03577     *valh = 0;
03578 
03579   /* Otherwise, just copy the value */
03580   } else {
03581     *vall = vec->value.ul[index][VTYPE_INDEX_VAL_VALL];
03582     *valh = vec->value.ul[index][VTYPE_INDEX_VAL_VALH];
03583   }
03584   
03585 }

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

References malloc_safe, PROFILE, PROFILE_END, TRUE, UL_SIZE, VDATA_R32, VDATA_R64, VDATA_UL, vector_init_r32(), vector_init_r64(), vector_init_ulong(), and vector_type_sizes.

Referenced by arc_add(), bind_perform(), db_create_expr_from_static(), expression_create_tmp_vecs(), expression_create_value(), fsm_arg_parse_state(), fsm_arg_parse_value(), memory_display_memory(), memory_get_mem_coverage(), static_expr_gen(), static_expr_gen_unary(), vector_clone(), vector_db_read(), vector_from_string(), vsignal_create(), and vsignal_create_vec().

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

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

References vsuppl_u::all, vsuppl_u::data_type, FATAL, vsuppl_u::owns_data, isuppl_u::part, vsuppl_u::part, print_output(), PROFILE, PROFILE_END, vector_s::suppl, Throw, vsuppl_u::type, vector_s::ul, vector_s::value, VDATA_R32, VDATA_R64, VDATA_UL, isuppl_u::vec_ul_size, vector_type_sizes, and vector_s::width.

Referenced by expression_db_merge(), and vsignal_db_merge().

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

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

References vsuppl_u::all, Catch_anonymous, vsuppl_u::data_type, FATAL, free_safe, vsuppl_u::owns_data, isuppl_u::part, vsuppl_u::part, print_output(), PROFILE, PROFILE_END, remove_underscores(), strdup_safe, Throw, TRUE, Try, vsuppl_u::type, VDATA_R32, VDATA_R64, VDATA_UL, isuppl_u::vec_ul_size, vector_create(), vector_dealloc(), vector_dealloc_value(), and vector_type_sizes.

Referenced by arc_db_read(), expression_db_read(), and vsignal_db_read().

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

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

References vsuppl_u::all, vsuppl_u::data_type, vsuppl_u::is_2state, vsuppl_u::owns_data, vsuppl_u::part, PROFILE, PROFILE_END, vector_s::r32, vector_s::r64, rv32_s::str, rv64_s::str, vector_s::suppl, vsuppl_u::type, vector_s::ul, UL_HMASK, UL_SIZE, rv32_s::val, rv64_s::val, vector_s::value, VDATA_R32, VDATA_R64, VDATA_UL, vector_type_sizes, VSUPPL_MASK, VTYPE_EXP, VTYPE_INDEX_VAL_VALH, VTYPE_INDEX_VAL_VALL, VTYPE_MEM, VTYPE_SIG, VTYPE_VAL, and vector_s::width.

Referenced by arc_db_write(), expression_db_write(), and vsignal_db_write().

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

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

References free_safe, vsuppl_u::owns_data, vsuppl_u::part, PROFILE, PROFILE_END, vector_s::suppl, vector_s::ul, vector_s::value, and vector_dealloc_value().

Referenced by arc_dealloc(), bind_signal(), db_create_expression(), defparam_add(), exclude_is_fsm_excluded(), exclude_set_fsm_exclude(), expression_db_read(), expression_dealloc(), fsm_arg_parse_state(), fsm_arg_parse_value(), fsm_db_read(), memory_display_memory(), memory_get_mem_coverage(), static_expr_gen(), static_expr_gen_unary(), vector_db_read(), vsignal_db_read(), and vsignal_dealloc().

05329   { PROFILE(VECTOR_DEALLOC);
05330 
05331   if( vec != NULL ) {
05332 
05333     /* Deallocate all vector values */
05334     if( (vec->value.ul != NULL) && (vec->suppl.part.owns_data == 1) ) {
05335       vector_dealloc_value( vec );
05336     }
05337 
05338     /* Deallocate vector itself */
05339     free_safe( vec, sizeof( vector ) );
05340 
05341   }
05342 
05343   PROFILE_END;
05344 
05345 }

void vector_dealloc_value ( vector vec  ) 

Deallocates the value structure for the given vector.

Parameters:
vec Pointer to vector to deallocate value for

References vsuppl_u::data_type, free_safe, vsuppl_u::part, PROFILE, PROFILE_END, vector_s::r32, vector_s::r64, rv32_s::str, rv64_s::str, vector_s::suppl, vsuppl_u::type, vector_s::ul, UL_SIZE, vector_s::value, VDATA_R32, VDATA_R64, VDATA_UL, vector_type_sizes, and vector_s::width.

Referenced by expression_dealloc(), expression_set_value(), vector_db_read(), vector_dealloc(), vsignal_create_vec(), and vsignal_from_string().

05293   { PROFILE(VECTOR_DEALLOC_VALUE);
05294 
05295   switch( vec->suppl.part.data_type ) {
05296     case VDATA_UL :
05297       if( vec->width > 0 ) {
05298         unsigned int i;
05299         unsigned int size = UL_SIZE( vec->width );
05300 
05301         for( i=0; i<size; i++ ) {
05302           free_safe( vec->value.ul[i], (sizeof( ulong ) * vector_type_sizes[vec->suppl.part.type]) );
05303         }
05304         free_safe( vec->value.ul, (sizeof( ulong* ) * size) );
05305         vec->value.ul = NULL;
05306       }
05307       break;
05308     case VDATA_R64 :
05309       free_safe( vec->value.r64->str, (strlen( vec->value.r64->str ) + 1) );
05310       free_safe( vec->value.r64, sizeof( rv64 ) );
05311       break;
05312     case VDATA_R32 :
05313       free_safe( vec->value.r32->str, (strlen( vec->value.r32->str ) + 1) );
05314       free_safe( vec->value.r32, sizeof( rv32 ) );
05315       break;
05316     default :  assert( 0 );  break;
05317   }
05318 
05319   PROFILE_END;
05320 
05321 }

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

References vsuppl_u::all, vsuppl_u::data_type, vsuppl_u::part, vector_s::r32, vector_s::r64, vector_s::suppl, vsuppl_u::type, vector_s::ul, vector_s::value, VDATA_R32, VDATA_R64, VDATA_UL, vector_display_r32(), vector_display_r64(), vector_display_ulong(), and vector_s::width.

01387   {
01388 
01389   assert( vec != NULL );
01390 
01391   /*@-formatcode@*/
01392   printf( "Vector (%p) => width: %u, suppl: %hhx\n", vec, vec->width, vec->suppl.all );
01393   /*@=formatcode@*/
01394 
01395   if( (vec->width > 0) && (vec->value.ul != NULL) ) {
01396     switch( vec->suppl.part.data_type ) {
01397       case VDATA_UL  :  vector_display_ulong( vec->value.ul, vec->width, vec->suppl.part.type );  break;
01398       case VDATA_R64 :  vector_display_r64( vec->value.r64 );  break;
01399       case VDATA_R32 :  vector_display_r32( vec->value.r32 );  break;
01400       default        :  assert( 0 );  break;
01401     }
01402   } else {
01403     printf( "NO DATA" );
01404   }
01405 
01406   printf( "\n" );
01407 
01408 }

void vector_display_r32 ( rv32 value  ) 

Outputs the contents of a 32-bit real vector value.

Parameters:
value Pointer to real32 structure from vector

References rv32_s::str, and rv32_s::val.

Referenced by vector_display().

01376   {
01377 
01378   printf( "read value: %s, stored value: %.16f", value->str, value->val );
01379 
01380 }

void vector_display_r64 ( rv64 value  ) 

Outputs the contents of a 64-bit real vector value.

Parameters:
value Pointer to real64 structure from vector

References rv64_s::str, and rv64_s::val.

Referenced by vector_display().

01365   {
01366 
01367   printf( "read value: %s, stored value: %.16lf", value->str, value->val );
01368 
01369 }

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

References PROFILE, PROFILE_END, UL_MOD, UL_SIZE, and VTYPE_INDEX_SIG_TOG01.

Referenced by memory_display_memory(), toggle_display_verbose(), and vector_display_ulong().

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

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

References PROFILE, PROFILE_END, UL_MOD, UL_SIZE, and VTYPE_INDEX_SIG_TOG10.

Referenced by memory_display_memory(), toggle_display_verbose(), and vector_display_ulong().

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

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

References UL_SIZE, vector_display_toggle01_ulong(), vector_display_toggle10_ulong(), vector_display_value_ulong(), vector_type_sizes, VTYPE_EXP, VTYPE_INDEX_EXP_EVAL_A, VTYPE_INDEX_EXP_EVAL_B, VTYPE_INDEX_EXP_EVAL_C, VTYPE_INDEX_EXP_EVAL_D, VTYPE_INDEX_MEM_RD, VTYPE_INDEX_MEM_WR, VTYPE_MEM, and VTYPE_SIG.

Referenced by vector_display().

01234   {
01235 
01236   unsigned int i, j;  /* Loop iterator */
01237 
01238   for( i=0; i<vector_type_sizes[type]; i++ ) {
01239     for( j=UL_SIZE(width); j--; ) {
01240       /*@-formatcode@*/
01241       printf( " %lx", value[j][i] );
01242       /*@=formatcode@*/
01243     }
01244   }
01245 
01246   /* Display value */
01247   printf( ", " );
01248   vector_display_value_ulong( value, width );
01249 
01250   switch( type ) {
01251 
01252     case VTYPE_SIG :
01253 
01254       /* Display toggle01 history */
01255       printf( ", 0->1: " );
01256       vector_display_toggle01_ulong( value, width, stdout );
01257 
01258       /* Display toggle10 history */
01259       printf( ", 1->0: " );
01260       vector_display_toggle10_ulong( value, width, stdout );
01261 
01262       break;
01263 
01264     case VTYPE_EXP :
01265 
01266       /* Display eval_a information */
01267       printf( ", a: %u'h", width );
01268       for( i=UL_SIZE(width); i--; ) {
01269         /*@-formatcode@*/
01270 #if SIZEOF_LONG == 4
01271         printf( "%08lx", value[i][VTYPE_INDEX_EXP_EVAL_A] );
01272 #elif SIZEOF_LONG == 8
01273         printf( "%016lx", value[i][VTYPE_INDEX_EXP_EVAL_A] );
01274 #else
01275 #error "Unsupported long size"
01276 #endif
01277         /*@=formatcode@*/
01278       }
01279 
01280       /* Display eval_b information */
01281       printf( ", b: %u'h", width );
01282       for( i=UL_SIZE(width); i--; ) {
01283         /*@-formatcode@*/
01284 #if SIZEOF_LONG == 4
01285         printf( "%08lx", value[i][VTYPE_INDEX_EXP_EVAL_B] );
01286 #elif SIZEOF_LONG == 8
01287         printf( "%016lx", value[i][VTYPE_INDEX_EXP_EVAL_B] );
01288 #endif
01289         /*@=formatcode@*/
01290       }
01291 
01292       /* Display eval_c information */
01293       printf( ", c: %u'h", width );
01294       for( i=UL_SIZE(width); i--; ) {
01295         /*@-formatcode@*/
01296 #if SIZEOF_LONG == 4
01297         printf( "%08lx", value[i][VTYPE_INDEX_EXP_EVAL_C] );
01298 #elif SIZEOF_LONG == 8
01299         printf( "%016lx", value[i][VTYPE_INDEX_EXP_EVAL_C] );
01300 #endif
01301         /*@=formatcode@*/
01302       }
01303 
01304       /* Display eval_d information */
01305       printf( ", d: %u'h", width );
01306       for( i=UL_SIZE(width); i--; ) {
01307         /*@-formatcode@*/
01308 #if SIZEOF_LONG == 4
01309         printf( "%08lx", value[i][VTYPE_INDEX_EXP_EVAL_D] );
01310 #elif SIZEOF_LONG == 8
01311         printf( "%016lx", value[i][VTYPE_INDEX_EXP_EVAL_D] );
01312 #endif
01313         /*@=formatcode@*/
01314       }
01315 
01316       break;
01317 
01318     case VTYPE_MEM :
01319   
01320       /* Display toggle01 history */
01321       printf( ", 0->1: " );
01322       vector_display_toggle01_ulong( value, width, stdout );
01323 
01324       /* Display toggle10 history */
01325       printf( ", 1->0: " );
01326       vector_display_toggle10_ulong( value, width, stdout );
01327 
01328       /* Write history */
01329       printf( ", wr: %u'h", width );
01330       for( i=UL_SIZE(width); i--; ) {
01331         /*@-formatcode@*/
01332 #if SIZEOF_LONG == 4
01333         printf( "%08lx", value[i][VTYPE_INDEX_MEM_WR] );
01334 #elif SIZEOF_LONG == 8
01335         printf( "%016lx", value[i][VTYPE_INDEX_MEM_WR] );
01336 #endif
01337         /*@=formatcode@*/
01338       }
01339 
01340       /* Read history */
01341       printf( ", rd: %u'h", width );
01342       for( i=UL_SIZE(width); i--; ) {
01343         /*@-formatcode@*/
01344 #if SIZEOF_LONG == 4
01345         printf( "%08lx", value[i][VTYPE_INDEX_MEM_RD] );
01346 #elif SIZEOF_LONG == 8
01347         printf( "%016lx", value[i][VTYPE_INDEX_MEM_RD] );
01348 #endif
01349         /*@=formatcode@*/
01350       }
01351 
01352       break;
01353 
01354     default : break;
01355 
01356   }
01357 
01358 }

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

References UL_MOD, UL_SIZE, VTYPE_INDEX_VAL_VALH, and VTYPE_INDEX_VAL_VALL.

Referenced by expression_display(), vector_display_ulong(), and vsignal_display().

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

static void vector_display_value_ulongs ( ulong vall,
ulong valh,
int  width 
) [static]

Displays the binary value of the specified ulong values to standard output.

Parameters:
vall Array of lower values
valh Array of upper values
width Number of bits to display

References UL_MOD, and UL_SIZE.

01202   {
01203 
01204   int i, j;  /* Loop iterator */
01205   int bits_left = UL_MOD(width - 1);
01206 
01207   printf( "value: %d'b", width );
01208   
01209   for( i=UL_SIZE(width); i--; ) {
01210     for( j=bits_left; j>=0; j-- ) {
01211       if( ((valh[i] >> (unsigned int)j) & 0x1) == 0 ) {
01212         printf( "%lu", ((vall[i] >> (unsigned int)j) & 0x1) );
01213       } else {
01214         if( ((vall[i] >> (unsigned int)j) & 0x1) == 0 ) {
01215           printf( "x" );
01216         } else {
01217           printf( "z" );
01218         }
01219       }
01220     }
01221     bits_left = (UL_BITS - 1);
01222   }
01223   
01224 }

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

References vsuppl_u::data_type, DEQ, FEQ, vsuppl_u::is_signed, MAX_BIT_WIDTH, vsuppl_u::part, PROFILE, PROFILE_END, vector_s::r32, vector_s::r64, vector_s::suppl, TRUE, UL_DIV, UL_SIZE, rv32_s::val, rv64_s::val, vector_s::value, VDATA_R32, VDATA_R64, VDATA_UL, vector_set_coverage_and_assign_ulong(), vector_sign_extend_ulong(), and vector_s::width.

Referenced by db_create_expr_from_static(), enumerate_resolve(), expression_op_func__random(), expression_op_func__repeat(), expression_op_func__rtoi(), expression_op_func__urandom(), fsm_arg_parse_state(), fsm_arg_parse_value(), static_expr_gen(), and static_expr_gen_unary().

02566   { PROFILE(VECTOR_FROM_INT);
02567 
02568   bool retval = TRUE;  /* Return value for this function */
02569 
02570   switch( vec->suppl.part.data_type ) {
02571     case VDATA_UL :
02572       {
02573         ulong        scratchl[UL_DIV(MAX_BIT_WIDTH)];
02574         ulong        scratchh[UL_DIV(MAX_BIT_WIDTH)];
02575         unsigned int i;
02576         unsigned int size        = (vec->width < (sizeof( int ) << 3)) ? UL_SIZE( vec->width ) : UL_SIZE( sizeof( int ) << 3 );
02577         bool         sign_extend = (value < 0) && (vec->width > (sizeof( int ) << 3));
02578         unsigned int shift       = (UL_BITS <= (sizeof( int ) << 3)) ? UL_BITS : (sizeof( int ) << 3);
02579         for( i=0; i<size; i++ ) {
02580           scratchl[i] = (ulong)value & UL_SET;
02581           scratchh[i] = 0;
02582           /*@-shiftimplementation@*/
02583           value >>= shift;
02584           /*@=shiftimplementation@*/
02585         }
02586         if( sign_extend ) {
02587           vector_sign_extend_ulong( scratchl, scratchh, UL_SET, UL_SET, (vec->width - 1), vec->width );
02588         } else {
02589           size = UL_SIZE( vec->width );
02590           for( ; i<size; i++ ) {
02591             scratchl[i] = scratchh[i] = 0;
02592           }
02593         }
02594         retval = vector_set_coverage_and_assign_ulong( vec, scratchl, scratchh, 0, (vec->width - 1) );
02595       }
02596       break;
02597     case VDATA_R64 :
02598       retval              = !DEQ( vec->value.r64->val, (double)value );
02599       vec->value.r64->val = (double)value;
02600       break;
02601     case VDATA_R32 :
02602       retval              = !FEQ( vec->value.r32->val, (float)value );
02603       vec->value.r32->val = (float)value;
02604       break;
02605     default :  assert( 0 );  break;
02606   }
02607 
02608   /* Because this value came from an integer, specify that the vector is signed */
02609   vec->suppl.part.is_signed = 1;
02610 
02611   PROFILE_END;
02612 
02613   return( retval );
02614 
02615 }

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

References vsuppl_u::data_type, DEQ, FEQ, vsuppl_u::part, PROFILE, PROFILE_END, vector_s::r32, vector_s::r64, vector_s::suppl, TRUE, rv32_s::val, rv64_s::val, vector_s::value, VDATA_R32, VDATA_R64, VDATA_UL, and vector_from_uint64().

Referenced by expression_op_func__add_a(), expression_op_func__assign(), expression_op_func__bitstoreal(), expression_op_func__bitstoshortreal(), expression_op_func__divide_a(), expression_op_func__func_call(), expression_op_func__itor(), expression_op_func__multiply_a(), expression_op_func__realtime(), expression_op_func__sub_a(), expression_op_func__value_plusargs(), inst_parm_add(), and sys_task_value_plusargs().

02676   { PROFILE(VECTOR_FROM_REAL64);
02677 
02678   bool retval = TRUE;  /* Return value for this function */
02679 
02680   switch( vec->suppl.part.data_type ) {
02681     case VDATA_UL :
02682       retval = vector_from_uint64( vec, (uint64)round( value ) );
02683       break;
02684     case VDATA_R64 :
02685       retval              = !DEQ( vec->value.r64->val, value );
02686       vec->value.r64->val = value;
02687       break;
02688     case VDATA_R32 :
02689       retval              = !FEQ( vec->value.r32->val, (float)value);
02690       vec->value.r32->val = (float)value;
02691       break;
02692     default :  assert( 0 );  break;
02693   }
02694 
02695   PROFILE_END;
02696 
02697   return( retval );
02698 
02699 }

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

References BINARY, DECIMAL, free_safe, HEXIDECIMAL, MAX_BIT_WIDTH, OCTAL, PROFILE, PROFILE_END, QSTRING, remove_underscores(), strdup_safe, TRUE, VDATA_R64, VDATA_UL, vector_create(), vector_from_uint64(), vector_set_static(), VTYPE_INDEX_VAL_VALL, and VTYPE_VAL.

Referenced by exclude_is_fsm_excluded(), exclude_set_fsm_exclude(), fsm_arg_parse_value(), and score_parse_args().

03025   { PROFILE(VECTOR_FROM_STRING);
03026 
03027   int    bits_per_char;         /* Number of bits represented by a single character in the value string str */
03028   int    size;                  /* Specifies bit width of vector to create */
03029   char   value[MAX_BIT_WIDTH];  /* String to store string value in */
03030   char   stype[3];              /* Temporary holder for type of string being parsed */
03031   int    chars_read;            /* Number of characters read by a sscanf() function call */
03032   double real;                  /* Container for real number */
03033 
03034   if( quoted ) {
03035 
03036     size = strlen( *str ) * 8;
03037 
03038     /* If this is the empty (null) string, allocate 8-bits */
03039     if( size == 0 ) {
03040       size = 8;
03041     }
03042 
03043     /* If we have exceeded the maximum number of bits, return a value of NULL */
03044     if( size > MAX_BIT_WIDTH ) {
03045 
03046       *vec  = NULL;
03047       *base = 0;
03048 
03049     } else {
03050 
03051       unsigned int pos = 0;
03052       int          i;
03053 
03054       /* Create vector */
03055       *vec  = vector_create( size, VTYPE_VAL, VDATA_UL, TRUE );
03056       *base = QSTRING;
03057 
03058       for( i=(strlen( *str ) - 1); i>=0; i-- ) {
03059         (*vec)->value.ul[pos>>(UL_DIV_VAL-3)][VTYPE_INDEX_VAL_VALL] |= (ulong)((*str)[i]) << ((pos & (UL_MOD_VAL >> 3)) << 3);
03060         pos++;
03061       }
03062 
03063     }
03064 
03065   } else {
03066 
03067     unsigned int slen = strlen( *str );
03068     char*        stmp = strdup_safe( *str );
03069 
03070     if( ((sscanf( *str, "%[0-9_]%[.]%[0-9_]", value, value, value ) == 3) ||
03071          (sscanf( *str, "-%[0-9_]%[.]%[0-9_]", value, value, value ) == 3)) &&
03072         (sscanf( remove_underscores( stmp ), "%lf%n", &real, &chars_read ) == 1) ) {
03073 
03074       *vec                         = vector_create( 64, VTYPE_VAL, VDATA_R64, TRUE );
03075       (*vec)->value.r64->val       = real;
03076       (*vec)->value.r64->str       = strdup_safe( *str );
03077       (*vec)->suppl.part.is_signed = 1;
03078       *str                         = *str + chars_read;
03079 
03080     } else {
03081 
03082       if( sscanf( *str, "%d'%[sSdD]%[0-9]%n", &size, stype, value, &chars_read ) == 3 ) {
03083         bits_per_char = 10;
03084         *base         = DECIMAL;
03085         *str          = *str + chars_read;
03086       } else if( sscanf( *str, "%d'%[sSbB]%[01xXzZ_\?]%n", &size, stype, value, &chars_read ) == 3 ) {
03087         bits_per_char = 1;
03088         *base         = BINARY;
03089         *str          = *str + chars_read;
03090       } else if( sscanf( *str, "%d'%[sSoO]%[0-7xXzZ_\?]%n", &size, stype, value, &chars_read ) == 3 ) {
03091         bits_per_char = 3;
03092         *base         = OCTAL;
03093         *str          = *str + chars_read;
03094       } else if( sscanf( *str, "%d'%[sShH]%[0-9a-fA-FxXzZ_\?]%n", &size, stype, value, &chars_read ) == 3 ) {
03095         bits_per_char = 4;
03096         *base         = HEXIDECIMAL;
03097         *str          = *str + chars_read;
03098       } else if( sscanf( *str, "'%[sSdD]%[0-9]%n", stype, value, &chars_read ) == 2 ) {
03099         bits_per_char = 10;
03100         *base         = DECIMAL;
03101         size          = 32;
03102         *str          = *str + chars_read;
03103       } else if( sscanf( *str, "'%[sSbB]%[01xXzZ_\?]%n", stype, value, &chars_read ) == 2 ) {
03104         bits_per_char = 1;
03105         *base         = BINARY;
03106         size          = 32;
03107         *str          = *str + chars_read;
03108       } else if( sscanf( *str, "'%[sSoO]%[0-7xXzZ_\?]%n", stype, value, &chars_read ) == 2 ) {
03109         bits_per_char = 3;
03110         *base         = OCTAL;
03111         size          = 32;
03112         *str          = *str + chars_read;
03113       } else if( sscanf( *str, "'%[sShH]%[0-9a-fA-FxXzZ_\?]%n", stype, value, &chars_read ) == 2 ) {
03114         bits_per_char = 4;
03115         *base         = HEXIDECIMAL;
03116         size          = 32;
03117         *str          = *str + chars_read;
03118       } else if( sscanf( *str, "%[0-9_]%n", value, &chars_read ) == 1 ) {
03119         bits_per_char = 10;
03120         *base         = DECIMAL;
03121         stype[0]      = 's';       
03122         stype[1]      = '\0';
03123         size          = 32;
03124         *str          = *str + chars_read;
03125       } else {
03126         /* If the specified string is none of the above, return NULL */
03127         bits_per_char = 0;
03128       }
03129 
03130       /* If we have exceeded the maximum number of bits, return a value of NULL */
03131       if( (size > MAX_BIT_WIDTH) || (bits_per_char == 0) ) {
03132 
03133         *vec  = NULL;
03134         *base = 0;
03135 
03136       } else {
03137 
03138         /* Create vector */
03139         *vec = vector_create( size, VTYPE_VAL, VDATA_UL, TRUE );
03140         if( *base == DECIMAL ) {
03141           (void)vector_from_uint64( *vec, ato64( value ) );
03142         } else {
03143           vector_set_static( *vec, value, bits_per_char ); 
03144         }
03145 
03146         /* Set the signed bit to the appropriate value based on the signed indicator in the vector string */
03147         if( (stype[0] == 's') || (stype [0] == 'S') ) {
03148           (*vec)->suppl.part.is_signed = 1;
03149         } else {
03150           (*vec)->suppl.part.is_signed = 0;
03151         }
03152 
03153       }
03154 
03155     }
03156 
03157     /* Deallocate memory */
03158     free_safe( stmp, (slen + 1) );
03159 
03160   }
03161 
03162   PROFILE_END;
03163 
03164 }

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

References PROFILE, PROFILE_END, vector_s::ul, vector_s::value, VTYPE_INDEX_VAL_VALL, and vector_s::width.

Referenced by sys_task_value_plusargs().

02999   { PROFILE(VECTOR_FROM_STRING_FIXED);
03000 
03001   unsigned int width = ((vec->width >> 3) < strlen( str )) ? (vec->width >> 3) : strlen( str );
03002   unsigned int pos = 0;
03003   int          i;
03004 
03005   /* TBD - Not sure if I need to support both endianness values here */
03006   for( i=(width-1); i>=0; i-- ) {
03007     vec->value.ul[pos>>(UL_DIV_VAL-3)][VTYPE_INDEX_VAL_VALL] |= (ulong)(str[i]) << ((pos & (UL_MOD_VAL >> 3)) << 3);
03008     pos++;
03009   }
03010 
03011   PROFILE_END;
03012 
03013 }

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

References vsuppl_u::data_type, DEQ, FEQ, vsuppl_u::is_signed, MAX_BIT_WIDTH, vsuppl_u::part, PROFILE, PROFILE_END, vector_s::r32, vector_s::r64, vector_s::suppl, TRUE, UL_DIV, UL_SIZE, rv32_s::val, rv64_s::val, vector_s::value, VDATA_R32, VDATA_R64, VDATA_UL, vector_set_coverage_and_assign_ulong(), and vector_s::width.

Referenced by expression_op_func__realtobits(), expression_op_func__shortrealtobits(), expression_op_func__time(), expression_op_func__urandom(), expression_op_func__urandom_range(), sys_task_value_plusargs(), vector_from_real64(), and vector_from_string().

02628   { PROFILE(VECTOR_FROM_UINT64);
02629 
02630   bool retval = TRUE;  /* Return value for this function */
02631 
02632   switch( vec->suppl.part.data_type ) {
02633     case VDATA_UL :
02634       {
02635         ulong        scratchl[UL_DIV(MAX_BIT_WIDTH)];
02636         ulong        scratchh[UL_DIV(MAX_BIT_WIDTH)];
02637         unsigned int i;
02638         unsigned int size  = (vec->width < (sizeof( uint64 ) << 3)) ? UL_SIZE( vec->width ) : UL_SIZE( sizeof( uint64 ) << 3 );
02639         unsigned int shift = (UL_BITS <= (sizeof( uint64 ) << 3)) ? UL_BITS : (sizeof( uint64 ) << 3); 
02640         for( i=0; i<size; i++ ) {
02641           scratchl[i] = (ulong)value & UL_SET;
02642           scratchh[i] = 0;
02643           value >>= shift;
02644         }
02645         retval = vector_set_coverage_and_assign_ulong( vec, scratchl, scratchh, 0, (vec->width - 1) );
02646       }
02647       break;
02648     case VDATA_R64 :
02649       retval              = !DEQ( vec->value.r64->val, (double)value );
02650       vec->value.r64->val = (double)value;
02651       break;
02652     case VDATA_R32 :
02653       retval              = !FEQ( vec->value.r32->val, (float)value );
02654       vec->value.r32->val = (float)value;
02655       break;
02656     default :  assert( 0 );  break;
02657   }
02658 
02659   /* Because this value came from an unsigned integer, specify that the vector is unsigned */
02660   vec->suppl.part.is_signed = 0;
02661 
02662   PROFILE_END;
02663 
02664   return( retval );
02665 
02666 }

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

References vsuppl_u::data_type, vsuppl_u::part, PROFILE, PROFILE_END, vector_s::suppl, vsuppl_u::type, vector_s::ul, UL_DIV, UL_MOD, vector_s::value, VDATA_R64, VDATA_UL, VTYPE_EXP, and VTYPE_INDEX_EXP_EVAL_A.

Referenced by combination_two_vars(), and combination_unary().

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

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

References vsuppl_u::data_type, vsuppl_u::part, PROFILE, PROFILE_END, vector_s::suppl, vector_s::ul, UL_SIZE, vector_s::value, VDATA_R64, VDATA_UL, VTYPE_INDEX_EXP_EVAL_A, VTYPE_INDEX_EXP_EVAL_B, and vector_s::width.

Referenced by combination_get_tree_stats(), and combination_unary().

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

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

References vsuppl_u::data_type, vsuppl_u::part, PROFILE, PROFILE_END, vector_s::suppl, vector_s::ul, UL_SIZE, vector_s::value, VDATA_R64, VDATA_UL, VTYPE_INDEX_EXP_EVAL_A, VTYPE_INDEX_EXP_EVAL_B, VTYPE_INDEX_EXP_EVAL_C, and vector_s::width.

Referenced by combination_get_tree_stats(), and combination_two_vars().

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

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

References vsuppl_u::data_type, vsuppl_u::part, PROFILE, PROFILE_END, vector_s::suppl, vector_s::ul, UL_SIZE, vector_s::value, VDATA_R64, VDATA_UL, VTYPE_INDEX_EXP_EVAL_A, VTYPE_INDEX_EXP_EVAL_B, VTYPE_INDEX_EXP_EVAL_C, VTYPE_INDEX_EXP_EVAL_D, and vector_s::width.

Referenced by combination_get_tree_stats(), and combination_two_vars().

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

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

References vsuppl_u::data_type, vsuppl_u::part, PROFILE, PROFILE_END, vector_s::suppl, vsuppl_u::type, vector_s::ul, UL_DIV, UL_MOD, vector_s::value, VDATA_R64, VDATA_UL, VTYPE_EXP, and VTYPE_INDEX_EXP_EVAL_B.

Referenced by combination_two_vars(), and combination_unary().

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

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

References vsuppl_u::data_type, vsuppl_u::part, PROFILE, PROFILE_END, vector_s::suppl, vsuppl_u::type, vector_s::ul, UL_DIV, UL_MOD, vector_s::value, VDATA_R64, VDATA_UL, VTYPE_EXP, and VTYPE_INDEX_EXP_EVAL_C.

Referenced by combination_two_vars().

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

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

References vsuppl_u::data_type, vsuppl_u::part, PROFILE, PROFILE_END, vector_s::suppl, vsuppl_u::type, vector_s::ul, UL_DIV, UL_MOD, vector_s::value, VDATA_R64, VDATA_UL, VTYPE_EXP, and VTYPE_INDEX_EXP_EVAL_D.

Referenced by combination_two_vars().

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

static void vector_get_sign_extend_vector_ulong ( const vector vec,
ulong signl,
ulong signh 
) [inline, static]

Calculates the lower and upper sign extension values for the given vector.

Parameters:
vec Pointer to vector to get MSB value from
signl Pointer to value that will contain the lower value vector
signh Pointer to value that will contain the upper value vector

References PROFILE, PROFILE_END, vector_s::ul, UL_DIV, UL_MOD, vector_s::value, VTYPE_INDEX_VAL_VALH, VTYPE_INDEX_VAL_VALL, and vector_s::width.

Referenced by vector_op_arshift(), and vector_part_select_push().

01658   { PROFILE(VECTOR_GET_SIGN_EXTEND_VECTOR_ULONG);
01659 
01660   ulong* entry     = vec->value.ul[UL_DIV(vec->width - 1)];
01661   ulong  last_mask = (ulong)1 << UL_MOD(vec->width - 1);
01662 
01663   *signl = ((entry[VTYPE_INDEX_VAL_VALL] & last_mask) != 0) ? UL_SET : 0;
01664   *signh = ((entry[VTYPE_INDEX_VAL_VALH] & last_mask) != 0) ? UL_SET : 0;
01665 
01666   PROFILE_END;
01667 
01668 }

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

References malloc_safe, PROFILE, PROFILE_END, UL_DIV, UL_MOD, and VTYPE_INDEX_SIG_TOG01.

Referenced by memory_get_mem_coverage(), and toggle_get_coverage().

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

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

References malloc_safe, PROFILE, PROFILE_END, UL_DIV, UL_MOD, and VTYPE_INDEX_SIG_TOG10.

Referenced by memory_get_mem_coverage(), and toggle_get_coverage().

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

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

References vsuppl_u::all, vsuppl_u::data_type, vsuppl_u::owns_data, vsuppl_u::part, PROFILE, PROFILE_END, vector_s::r32, rv32_s::str, strdup_safe, vector_s::suppl, vsuppl_u::type, rv32_s::val, vector_s::value, VDATA_R32, and vector_s::width.

Referenced by expression_create_tmp_vecs(), expression_create_value(), and vector_create().

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

References vsuppl_u::all, vsuppl_u::data_type, vsuppl_u::owns_data, vsuppl_u::part, PROFILE, PROFILE_END, vector_s::r64, rv64_s::str, strdup_safe, vector_s::suppl, vsuppl_u::type, rv64_s::val, vector_s::value, VDATA_R64, and vector_s::width.

Referenced by expression_create_tmp_vecs(), expression_create_value(), and vector_create().

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

References vsuppl_u::all, vsuppl_u::data_type, vsuppl_u::owns_data, vsuppl_u::part, PROFILE, PROFILE_END, vector_s::suppl, vsuppl_u::type, vector_s::ul, UL_HMASK, UL_SIZE, vector_s::value, VDATA_UL, vector_type_sizes, VTYPE_INDEX_VAL_VALH, VTYPE_INDEX_VAL_VALL, and vector_s::width.

Referenced by expression_create_tmp_vecs(), expression_create_value(), and vector_create().

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 & (width != 0);
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

References vsuppl_u::data_type, DEQ, FEQ, vsuppl_u::part, PROFILE, PROFILE_END, vector_s::r32, vector_s::r64, vector_s::suppl, vector_s::ul, UL_SIZE, rv32_s::val, rv64_s::val, vector_s::value, VDATA_R32, VDATA_R64, VDATA_UL, VTYPE_INDEX_VAL_VALL, and vector_s::width.

Referenced by expression_is_static_only_helper(), expression_op_func__cond_sel(), expression_op_func__wait(), expression_set_tf(), expression_set_tf_preclear(), vector_op_land(), and vector_op_lor().

02334   { PROFILE(VECTOR_IS_NOT_ZERO);
02335 
02336   unsigned int i = 0;  /* Loop iterator */
02337   unsigned int size;   /* Size of data array */
02338 
02339   assert( vec != NULL );
02340   assert( vec->value.ul != NULL );
02341 
02342   switch( vec->suppl.part.data_type ) {
02343     case VDATA_UL :
02344       size = UL_SIZE( vec->width );
02345       while( (i < size) && (vec->value.ul[i][VTYPE_INDEX_VAL_VALL] == 0) ) i++;
02346       break;
02347     case VDATA_R64 :
02348       size = DEQ( vec->value.r64->val, 0.0 ) ? 1 : 0;
02349       break;
02350     case VDATA_R32 :
02351       size = FEQ( vec->value.r32->val, 0.0) ? 1 : 0;
02352       break;
02353     default :  assert( 0 );  break;
02354   }
02355 
02356   PROFILE_END;
02357 
02358   return( i < size );
02359 
02360 }

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

References vsuppl_u::data_type, vsuppl_u::part, PROFILE, PROFILE_END, vector_s::suppl, vector_s::ul, UL_SIZE, vector_s::value, VDATA_R32, VDATA_R64, VDATA_UL, VTYPE_INDEX_VAL_VALH, and vector_s::width.

Referenced by arc_add(), enumerate_resolve(), expression_assign(), expression_create(), expression_op_func__cond_sel(), expression_op_func__exponent(), expression_resize(), expression_set_tf(), expression_set_tf_preclear(), vector_op_add(), vector_op_arshift(), vector_op_clog2(), vector_op_divide(), vector_op_eq(), vector_op_ge(), vector_op_gt(), vector_op_land(), vector_op_le(), vector_op_lor(), vector_op_lshift(), vector_op_lt(), vector_op_modulus(), vector_op_multiply(), vector_op_ne(), vector_op_negate(), vector_op_rshift(), and vector_op_subtract().

02303   { PROFILE(VECTOR_IS_UKNOWN);
02304 
02305   unsigned int i = 0;  /* Loop iterator */
02306   unsigned int size;   /* Size of data array */
02307 
02308   assert( vec != NULL );
02309   assert( vec->value.ul != NULL );
02310 
02311   switch( vec->suppl.part.data_type ) {
02312     case VDATA_UL :
02313       size = UL_SIZE( vec->width );
02314       while( (i < size) && (vec->value.ul[i][VTYPE_INDEX_VAL_VALH] == 0) ) i++;
02315       break;
02316     case VDATA_R64 :
02317     case VDATA_R32 :
02318       size = 0;
02319       break;
02320     default :  assert( 0 );  break;
02321   }
02322 
02323   PROFILE_END;
02324 
02325   return( i < size );
02326 
02327 }

static void vector_lshift_ulong ( const vector vec,
ulong vall,
ulong valh,
int  lsb,
int  msb,
bool  xfill 
) [static]

Performs a fast left-shift of 0-bit-aligned data in vector and stores the result in the vall/h value arrays.

Parameters:
vec Pointer to vector containing value that we want to left-shift
vall Pointer to intermediate value array containing lower bits of shifted value
valh Pointer to intermediate value array containing upper bits of shifted value
lsb LSB offset
msb MSB offset
xfill If set to TRUE, causes lower bits to be X filled

References PROFILE, PROFILE_END, vector_s::ul, UL_DIV, UL_HMASK, UL_LMASK, UL_MOD, vector_s::value, VTYPE_INDEX_VAL_VALH, VTYPE_INDEX_VAL_VALL, and vector_s::width.

Referenced by vector_op_lshift(), vector_part_select_push(), and vector_rshift_ulong().

01715   { PROFILE(VECTOR_LSHIFT_ULONG);
01716 
01717   int          from_msb = (msb - lsb);
01718   unsigned int diff     = UL_DIV(msb) - UL_DIV(from_msb);
01719 
01720   if( UL_DIV(lsb) == UL_DIV(msb) ) {
01721 
01722     int   i;
01723     ulong uset = xfill ? ~UL_LMASK(lsb) : 0;
01724     
01725     vall[diff] = (vec->value.ul[0][VTYPE_INDEX_VAL_VALL] << (unsigned int)lsb);
01726     valh[diff] = (vec->value.ul[0][VTYPE_INDEX_VAL_VALH] << (unsigned int)lsb) | uset;
01727 
01728     for( i=(diff-1); i>=0; i-- ) {
01729       vall[i] = 0;
01730       valh[i] = xfill ? UL_SET : 0;
01731     }
01732 
01733   } else {
01734   
01735     int  i;
01736     bool use_vec = msb > (vec->width - 1);
01737     int  hindex  = use_vec ? UL_DIV(vec->width - 1) : UL_DIV(msb);
01738     
01739     /* Transfer the vector value to the val array */
01740     for( i=0; i<=hindex; i++ ) {
01741       vall[i] = vec->value.ul[i][VTYPE_INDEX_VAL_VALL];
01742       valh[i] = vec->value.ul[i][VTYPE_INDEX_VAL_VALH];
01743     }
01744     
01745     if( use_vec ) {
01746 
01747       ulong uset1 = xfill ? ~UL_HMASK(vec->width - 1) : 0;
01748       ulong uset2 = xfill ? UL_SET : 0;
01749             
01750       valh[i-1] = valh[i-1] | uset1;
01751 
01752       for( ; i<=UL_DIV(msb); i++ ) {
01753         vall[i] = 0;
01754         valh[i] = uset2;
01755       }
01756 
01757     }
01758 
01759     if( UL_MOD(lsb) == 0 ) {
01760 
01761       int i;
01762     
01763       for( i=UL_DIV(from_msb); i>=0; i-- ) {
01764         vall[i+diff] = vall[i];
01765         valh[i+diff] = valh[i];
01766       }
01767 
01768       for( i=(diff-1); i>=0; i-- ) {
01769         vall[i] = 0;
01770         valh[i] = xfill ? UL_SET : 0;
01771       }
01772 
01773     } else if( UL_MOD(msb) > UL_MOD(from_msb) ) {
01774 
01775       unsigned int mask_bits1  = UL_MOD(from_msb + 1);
01776       unsigned int shift_bits1 = UL_MOD(msb) - UL_MOD(from_msb);
01777       ulong        mask1       = UL_SET >> (UL_BITS - mask_bits1);
01778       ulong        mask2       = UL_SET << (UL_BITS - shift_bits1);
01779       ulong        mask3       = ~mask2;
01780       ulong        uset        = xfill ? ~UL_LMASK(lsb) : 0;
01781       int          i;
01782       
01783       vall[UL_DIV(msb)] = (vall[UL_DIV(from_msb)] & mask1) << shift_bits1;
01784       valh[UL_DIV(msb)] = (valh[UL_DIV(from_msb)] & mask1) << shift_bits1;
01785 
01786       for( i=(UL_DIV(from_msb) - 1); i>=0; i-- ) {
01787         vall[i+diff+1] |= ((vall[i] & mask2) >> (UL_BITS - shift_bits1));
01788         valh[i+diff+1] |= ((valh[i] & mask2) >> (UL_BITS - shift_bits1));
01789         vall[i+diff]    = ((vall[i] & mask3) << shift_bits1);
01790         valh[i+diff]    = ((valh[i] & mask3) << shift_bits1);
01791       }
01792 
01793       valh[diff] |= uset;
01794 
01795       for( i=(diff - 1); i>=0; i-- ) {
01796         vall[i] = 0;
01797         valh[i] = xfill ? UL_SET : 0;
01798       }
01799 
01800     } else {
01801 
01802       unsigned int mask_bits1  = UL_MOD(from_msb);
01803       unsigned int shift_bits1 = mask_bits1 - UL_MOD(msb);
01804       ulong        mask2       = UL_SET >> (UL_BITS - shift_bits1);
01805       ulong        mask3       = ~mask2;
01806       ulong        uset        = xfill ? ~UL_LMASK(lsb) : 0;
01807       int          i;
01808             
01809       vall[UL_DIV(msb)] = (vall[UL_DIV(from_msb)] & mask3) >> shift_bits1;
01810       valh[UL_DIV(msb)] = (valh[UL_DIV(from_msb)] & mask3) >> shift_bits1;
01811 
01812       for( i=UL_DIV(from_msb); i>=0; i-- ) {
01813         vall[(i+diff)-1] = ((vall[i] & mask2) << (UL_BITS - shift_bits1));
01814         valh[(i+diff)-1] = ((valh[i] & mask2) << (UL_BITS - shift_bits1));
01815         if( i > 0 ) {
01816           vall[(i+diff)-1] |= ((vall[i-1] & mask3) >> shift_bits1);
01817           valh[(i+diff)-1] |= ((valh[i-1] & mask3) >> shift_bits1);
01818         }
01819       }
01820 
01821       valh[diff-1] |= uset;
01822 
01823       for( i=(diff - 2); i>=0; i-- ) {
01824         vall[i] = 0;
01825         valh[i] = xfill ? UL_SET : 0;
01826       }
01827       
01828     }
01829 
01830   }
01831 
01832   PROFILE_END;
01833 
01834 }

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

References vsuppl_u::data_type, vsuppl_u::part, PROFILE, PROFILE_END, vector_s::suppl, vector_s::ul, UL_DIV, UL_HMASK, UL_LMASK, vector_s::value, VDATA_R64, VDATA_UL, VTYPE_INDEX_MEM_RD, and VTYPE_INDEX_MEM_WR.

Referenced by memory_display_memory(), memory_get_mem_coverage(), memory_get_stat(), and rank_gather_signal_cov().

01455   { PROFILE(VECTOR_MEM_RW_COUNT);
01456 
01457   unsigned int i, j;  /* Loop iterator */
01458 
01459   switch( vec->suppl.part.data_type ) {
01460     case VDATA_UL :
01461       { 
01462         ulong lmask = UL_LMASK(lsb);
01463         ulong hmask = UL_HMASK(msb);
01464         if( UL_DIV(lsb) == UL_DIV(msb) ) {
01465           lmask &= hmask;
01466         }
01467         for( i=UL_DIV(lsb); i<=UL_DIV(msb); i++ ) {
01468           ulong mask = (i == UL_DIV(lsb)) ? lmask : ((i == UL_DIV(msb)) ? hmask : UL_SET);
01469           ulong wr   = vec->value.ul[i][VTYPE_INDEX_MEM_WR] & mask;
01470           ulong rd   = vec->value.ul[i][VTYPE_INDEX_MEM_RD] & mask;
01471           for( j=0; j<UL_BITS; j++ ) {
01472             *wr_cnt += (wr >> j) & 0x1;
01473             *rd_cnt += (rd >> j) & 0x1;
01474           }
01475         }
01476       }
01477       break;
01478     case VDATA_R64 :
01479       break;
01480     default :  assert( 0 );  break;
01481   }
01482 
01483   PROFILE_END;
01484 
01485 }

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

References vsuppl_u::data_type, vsuppl_u::owns_data, vsuppl_u::part, PROFILE, PROFILE_END, vector_s::suppl, vsuppl_u::type, vector_s::ul, UL_SIZE, vector_s::value, VDATA_R32, VDATA_R64, VDATA_UL, vector_type_sizes, and vector_s::width.

Referenced by expression_merge(), and vsignal_merge().

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

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

References vsuppl_u::data_type, DEQ, FEQ, MAX_BIT_WIDTH, vsuppl_u::part, PROFILE, PROFILE_END, vector_s::r32, vector_s::r64, vector_s::suppl, vector_s::ul, UL_DIV, UL_MOD, UL_SIZE, rv32_s::val, rv64_s::val, vector_s::value, VDATA_R32, VDATA_R64, VDATA_UL, vector_copy_val_and_sign_extend_ulong(), vector_is_unknown(), vector_set_coverage_and_assign_ulong(), vector_set_to_x(), vector_to_real64(), VTYPE_INDEX_VAL_VALL, and vector_s::width.

Referenced by expression_op_func__add(), expression_op_func__add_a(), and vector_op_inc().

04341   { PROFILE(VECTOR_OP_ADD);
04342 
04343   bool retval;  /* Return value for this function */
04344 
04345   /* If either the left or right vector is unknown, set the entire value to X */
04346   if( vector_is_unknown( left ) || vector_is_unknown( right ) ) {
04347 
04348     retval = vector_set_to_x( tgt );
04349 
04350   /* Otherwise, perform the addition operation */
04351   } else {
04352 
04353     switch( tgt->suppl.part.data_type ) {
04354       case VDATA_UL :
04355         {
04356           ulong        vall[UL_DIV(MAX_BIT_WIDTH)];
04357           ulong        valh[UL_DIV(MAX_BIT_WIDTH)];
04358           ulong        carry = 0;
04359           bool         lmsb_is_one = (((left->value.ul[UL_DIV(left->width-1)][VTYPE_INDEX_VAL_VALL]   >> UL_MOD(left->width  - 1)) & 1) == 1);
04360           bool         rmsb_is_one = (((right->value.ul[UL_DIV(right->width-1)][VTYPE_INDEX_VAL_VALL] >> UL_MOD(right->width - 1)) & 1) == 1);
04361           ulong        lvall, lvalh;
04362           ulong        rvall, rvalh;
04363           unsigned int i;
04364           for( i=0; i<UL_SIZE( tgt->width ); i++ ) {
04365             vector_copy_val_and_sign_extend_ulong( left,  i, lmsb_is_one, &lvall, &lvalh ); 
04366             vector_copy_val_and_sign_extend_ulong( right, i, rmsb_is_one, &rvall, &rvalh ); 
04367             vall[i] = lvall + rvall + carry;
04368             valh[i] = 0;
04369             carry   = ((lvall & rvall) | ((lvall | rvall) & ~vall[i])) >> (UL_BITS - 1);
04370           }
04371           retval = vector_set_coverage_and_assign_ulong( tgt, vall, valh, 0, (tgt->width - 1) );
04372         }
04373         break;
04374       case VDATA_R64 :
04375         {
04376           double result       = vector_to_real64( left ) + vector_to_real64( right );
04377           retval              = !DEQ( tgt->value.r64->val, result );
04378           tgt->value.r64->val = result;
04379         }
04380         break;
04381       case VDATA_R32 :
04382         {
04383           float result        = (float)(vector_to_real64( left ) + vector_to_real64( right ));
04384           retval              = !FEQ( tgt->value.r32->val, result );
04385           tgt->value.r32->val = result;
04386         }
04387         break;
04388       default :  assert( 0 );  break;
04389     }
04390 
04391   }
04392 
04393   PROFILE_END;
04394 
04395   return( retval );
04396 
04397 }    

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

References vsuppl_u::data_type, FALSE, vsuppl_u::is_signed, MAX_BIT_WIDTH, vsuppl_u::part, PROFILE, PROFILE_END, vector_s::suppl, UL_DIV, VDATA_UL, vector_get_sign_extend_vector_ulong(), vector_is_unknown(), vector_rshift_ulong(), vector_set_coverage_and_assign_ulong(), vector_set_to_x(), vector_sign_extend_ulong(), vector_to_int(), and vector_s::width.

Referenced by expression_op_func__arshift(), and expression_op_func__arshift_a().

04291   { PROFILE(VECTOR_OP_ARSHIFT);
04292 
04293   bool retval;  /* Return value for this function */
04294 
04295   if( vector_is_unknown( right ) ) {
04296   
04297     retval = vector_set_to_x( tgt );
04298     
04299   } else {
04300   
04301     int shift_val = vector_to_int( right );
04302     
04303     switch( tgt->suppl.part.data_type ) {
04304       case VDATA_UL :
04305         {
04306           ulong        vall[UL_DIV(MAX_BIT_WIDTH)];
04307           ulong        valh[UL_DIV(MAX_BIT_WIDTH)];
04308           ulong        signl, signh;
04309           unsigned int msb = left->width - 1;
04310 
04311           vector_rshift_ulong( left, vall, valh, shift_val, msb, FALSE );
04312           if( left->suppl.part.is_signed ) {
04313             vector_get_sign_extend_vector_ulong( left, &signl, &signh );
04314             vector_sign_extend_ulong( vall, valh, signl, signh, (msb - shift_val), tgt->width );
04315           }
04316         
04317           retval = vector_set_coverage_and_assign_ulong( tgt, vall, valh, 0, (tgt->width - 1) );
04318         }
04319         break;
04320       default :  assert( 0 );  break;
04321     }
04322 
04323   }
04324 
04325   PROFILE_END;
04326 
04327   return( retval );
04328 
04329 }

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

References vsuppl_u::data_type, vsuppl_u::part, PROFILE, PROFILE_END, vector_s::suppl, VDATA_UL, vector_ceq_ulong(), and vector_set_coverage_and_assign_ulong().

Referenced by expression_op_func__case(), and expression_op_func__ceq().

03924   { PROFILE(VECTOR_OP_CEQ);
03925 
03926   bool retval;  /* Return value for this function */
03927 
03928   switch( tgt->suppl.part.data_type ) {
03929     case VDATA_UL :
03930       {
03931         ulong scratchl = vector_ceq_ulong( left, right );
03932         ulong scratchh = 0;
03933         retval = vector_set_coverage_and_assign_ulong( tgt, &scratchl, &scratchh, 0, 0 );
03934       }
03935       break;
03936     default :  assert( 0 );  break;
03937   }
03938 
03939   PROFILE_END;
03940 
03941   return( retval );
03942 
03943 }

bool vector_op_clog2 ( vector tgt,
const vector src 
)

Performs clog2 operation.

Returns:
Returns TRUE if the new value differs from the old value; otherwise, returns FALSE.

Performs clog2 operation.

Parameters:
tgt Pointer to vector to store results in
src Pointer to value to perform operation on

References vsuppl_u::data_type, vsuppl_u::part, PROFILE, PROFILE_END, vector_s::suppl, vector_s::ul, UL_SIZE, vector_s::value, VDATA_R32, VDATA_R64, VDATA_UL, vector_is_unknown(), vector_set_coverage_and_assign_ulong(), vector_set_to_x(), vector_to_uint64(), VTYPE_INDEX_VAL_VALL, and vector_s::width.

Referenced by expression_op_func__clog2().

05223   { PROFILE(VECTOR_OP_CLOG2);
05224 
05225   bool  retval;
05226   ulong vall = 0;
05227   ulong valh = 0;
05228 
05229   if( vector_is_unknown( src ) ) {
05230 
05231     retval = vector_set_to_x( tgt );
05232 
05233   } else {
05234 
05235     switch( src->suppl.part.data_type ) {
05236       case VDATA_UL :
05237         {
05238           unsigned int size     = UL_SIZE(src->width);
05239           unsigned int num_ones = 0;
05240           while( size > 0 ) {
05241             ulong i = src->value.ul[--size][VTYPE_INDEX_VAL_VALL];
05242             while( i != 0 ) {
05243               vall++;
05244               num_ones += (i & 0x1);
05245               i >>= 1;
05246             }
05247             if( vall != 0 ) {
05248               vall += (size * UL_BITS);
05249               if( num_ones == 1 ) {
05250                 while( (size > 0) && (src->value.ul[--size][VTYPE_INDEX_VAL_VALL] == 0) );
05251                 if( size == 0 ) {
05252                   vall--;
05253                 }
05254               }
05255               break;
05256             }
05257           }
05258         }
05259         break;
05260       case VDATA_R64 :
05261       case VDATA_R32 :
05262         {
05263           uint64       i        = vector_to_uint64( src ) - 1;
05264           unsigned int num_ones = 0;
05265           while( i != 0 ) {
05266             vall++;
05267             num_ones += (i & 0x1);
05268             i >>= 1;
05269           }
05270           if( num_ones == 1 ) {
05271             vall--;
05272           }
05273         }
05274         break;
05275       default :  assert( 0 );  break;
05276     } 
05277 
05278     retval = vector_set_coverage_and_assign_ulong( tgt, &vall, &valh, 0, (tgt->width - 1) );
05279 
05280   }
05281 
05282   PROFILE_END;
05283 
05284   return( retval );
05285 
05286 }

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

References vsuppl_u::data_type, vsuppl_u::part, PROFILE, PROFILE_END, vector_s::suppl, VDATA_UL, vector_ceq_ulong(), and vector_set_coverage_and_assign_ulong().

Referenced by expression_op_func__cne().

04112   { PROFILE(VECTOR_OP_CNE);
04113 
04114   bool retval;  /* Return value for this function */
04115   
04116   switch( tgt->suppl.part.data_type ) {
04117     case VDATA_UL :
04118       {
04119         ulong scratchl = !vector_ceq_ulong( left, right );
04120         ulong scratchh = 0;
04121         retval = vector_set_coverage_and_assign_ulong( tgt, &scratchl, &scratchh, 0, 0 );
04122       }
04123       break;
04124     default :  assert( 0 );  break;
04125   }
04126 
04127   PROFILE_END;
04128 
04129   return( retval );
04130 
04131 }

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

References vsuppl_u::data_type, vsuppl_u::part, PROFILE, PROFILE_END, vector_s::suppl, vector_s::ul, UL_DIV, UL_HMASK, UL_MOD, UL_SIZE, vector_s::value, VDATA_UL, vector_copy_val_and_sign_extend_ulong(), vector_set_coverage_and_assign_ulong(), VTYPE_INDEX_VAL_VALL, and vector_s::width.

Referenced by expression_op_func__casex().

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

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

References vsuppl_u::data_type, vsuppl_u::part, PROFILE, PROFILE_END, vector_s::suppl, vector_s::ul, UL_DIV, UL_HMASK, UL_MOD, UL_SIZE, vector_s::value, VDATA_UL, vector_copy_val_and_sign_extend_ulong(), vector_set_coverage_and_assign_ulong(), VTYPE_INDEX_VAL_VALL, and vector_s::width.

Referenced by expression_op_func__casez().

04002   { PROFILE(VECTOR_OP_CZEQ);
04003 
04004   bool retval;  /* Return value for this function */
04005 
04006   switch( tgt->suppl.part.data_type ) {
04007     case VDATA_UL :
04008       {
04009         ulong        scratchl    = 0;
04010         ulong        scratchh    = 0;
04011         unsigned int lsize       = UL_SIZE(left->width);
04012         unsigned int rsize       = UL_SIZE(right->width);
04013         int          i           = ((lsize < rsize) ? rsize : lsize) - 1;
04014         unsigned int lmsb        = (left->width - 1);
04015         unsigned int rmsb        = (right->width - 1);
04016         bool         lmsb_is_one = (((left->value.ul[UL_DIV(lmsb)][VTYPE_INDEX_VAL_VALL]  >> UL_MOD(lmsb)) & 1) == 1);
04017         bool         rmsb_is_one = (((right->value.ul[UL_DIV(rmsb)][VTYPE_INDEX_VAL_VALL] >> UL_MOD(rmsb)) & 1) == 1);
04018         ulong        mask        = (left->width < right->width) ? UL_HMASK(left->width - 1) : UL_HMASK(right->width - 1);
04019         ulong        lvall;
04020         ulong        lvalh;
04021         ulong        rvall;
04022         ulong        rvalh;
04023         vector_copy_val_and_sign_extend_ulong( left,  i, lmsb_is_one, &lvall, &lvalh );
04024         vector_copy_val_and_sign_extend_ulong( right, i, rmsb_is_one, &rvall, &rvalh );
04025         while( (i > 0) && ((((~(lvall ^ rvall) & ~(lvalh ^ rvalh)) | (lvalh & lvall) | (rvalh & rvall)) & mask) == mask) ) {
04026           mask  = UL_SET;
04027           i--;
04028           vector_copy_val_and_sign_extend_ulong( left,  i, lmsb_is_one, &lvall, &lvalh );
04029           vector_copy_val_and_sign_extend_ulong( right, i, rmsb_is_one, &rvall, &rvalh );
04030         }
04031         scratchl = ((((~(lvall ^ rvall) & ~(lvalh ^ rvalh)) | (lvalh & lvall) | (rvalh & rvall)) & mask) == mask);
04032         retval   = vector_set_coverage_and_assign_ulong( tgt, &scratchl, &scratchh, 0, 0 );
04033       }
04034       break;
04035     default :  assert( 0 );  break;
04036   }
04037 
04038   PROFILE_END;
04039 
04040   return( retval );
04041 
04042 }

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

References vsuppl_u::data_type, vecblk_s::index, vsuppl_u::part, PROFILE, PROFILE_END, vector_s::r32, vector_s::r64, vector_s::suppl, TRUE, vector_s::ul, rv32_s::val, rv64_s::val, vector_s::value, VDATA_R32, VDATA_R64, VDATA_UL, vecblk_s::vec, vector_copy(), vector_op_subtract(), and VTYPE_INDEX_VAL_VALL.

Referenced by expression_op_func__idec(), and expression_op_func__pdec().

04752   { PROFILE(VECTOR_OP_DEC);
04753 
04754   switch( tgt->suppl.part.data_type ) {
04755     case VDATA_UL :
04756       {
04757         vector* tmp1 = &(tvb->vec[tvb->index++]);
04758         vector* tmp2 = &(tvb->vec[tvb->index++]);
04759         vector_copy( tgt, tmp1 );
04760         tmp2->value.ul[0][VTYPE_INDEX_VAL_VALL] = 1;
04761         (void)vector_op_subtract( tgt, tmp1, tmp2 );
04762       }
04763     case VDATA_R64 :
04764       tgt->value.r64->val -= 1.0;
04765       break;
04766     case VDATA_R32 :
04767       tgt->value.r32->val -= 1.0;
04768       break;
04769     default :  assert( 0 );  break;
04770   }
04771 
04772   PROFILE_END;
04773 
04774   return( TRUE );
04775 
04776 }

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

References vsuppl_u::data_type, DEQ, FEQ, vsuppl_u::part, PROFILE, PROFILE_END, vector_s::r32, vector_s::r64, vector_s::suppl, vector_s::ul, rv32_s::val, rv64_s::val, vector_s::value, VDATA_R32, VDATA_R64, VDATA_UL, vector_is_unknown(), vector_set_coverage_and_assign_ulong(), vector_set_to_x(), vector_to_real64(), and VTYPE_INDEX_EXP_VALL.

Referenced by expression_op_func__divide(), and expression_op_func__divide_a().

04616   { PROFILE(VECTOR_OP_DIVIDE);
04617 
04618   bool retval;  /* Return value for this function */
04619 
04620   if( vector_is_unknown( left ) || vector_is_unknown( right ) ) {
04621 
04622     retval = vector_set_to_x( tgt );
04623 
04624   } else {
04625 
04626     switch( tgt->suppl.part.data_type ) {
04627       case VDATA_UL :
04628         {
04629           ulong vall;
04630           ulong valh = 0;
04631           ulong rval = right->value.ul[0][VTYPE_INDEX_EXP_VALL];
04632           if( rval == 0 ) {
04633             retval = vector_set_to_x( tgt );
04634           } else {
04635             vall = left->value.ul[0][VTYPE_INDEX_EXP_VALL] / rval;
04636             retval = vector_set_coverage_and_assign_ulong( tgt, &vall, &valh, 0, (UL_BITS - 1) );
04637           }
04638         }
04639         break;
04640       case VDATA_R64 :
04641         {
04642           double result       = vector_to_real64( left ) / vector_to_real64( right );
04643           retval              = !DEQ( tgt->value.r64->val, result);
04644           tgt->value.r64->val = result;
04645         }
04646         break;
04647       case VDATA_R32 :
04648         {
04649           float result        = (float)(vector_to_real64( left ) / vector_to_real64( right ));
04650           retval              = !FEQ( tgt->value.r32->val, result );
04651           tgt->value.r32->val = result;
04652         }
04653         break;
04654       default :  assert( 0 );  break;
04655     }
04656 
04657   }
04658 
04659   PROFILE_END;
04660 
04661   return( retval );
04662 
04663 }

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

References vsuppl_u::data_type, DEQ, vsuppl_u::part, PROFILE, PROFILE_END, vector_s::suppl, vector_s::ul, UL_DIV, UL_MOD, UL_SIZE, vector_s::value, VDATA_UL, vector_copy_val_and_sign_extend_ulong(), vector_is_unknown(), vector_set_coverage_and_assign_ulong(), vector_set_to_x(), vector_to_real64(), VTYPE_INDEX_VAL_VALL, and vector_s::width.

Referenced by expression_op_func__eq().

03832   { PROFILE(VECTOR_OP_EQ);
03833 
03834   bool retval;  /* Return value for this function */
03835 
03836   if( vector_is_unknown( left ) || vector_is_unknown( right ) ) {
03837 
03838     retval = vector_set_to_x( tgt );
03839 
03840   } else {
03841 
03842     switch( tgt->suppl.part.data_type ) {
03843       case VDATA_UL :
03844         {
03845           ulong scratchl;
03846           ulong scratchh = 0;
03847           if( (left->suppl.part.data_type == VDATA_UL) && (right->suppl.part.data_type == VDATA_UL) ) {
03848             unsigned int lsize       = UL_SIZE(left->width);
03849             unsigned int rsize       = UL_SIZE(right->width);
03850             int          i           = ((lsize < rsize) ? rsize : lsize);
03851             unsigned int lmsb        = (left->width - 1);
03852             unsigned int rmsb        = (right->width - 1);
03853             bool         lmsb_is_one = (((left->value.ul[UL_DIV(lmsb)][VTYPE_INDEX_VAL_VALL]  >> UL_MOD(lmsb)) & 1) == 1);
03854             bool         rmsb_is_one = (((right->value.ul[UL_DIV(rmsb)][VTYPE_INDEX_VAL_VALL] >> UL_MOD(rmsb)) & 1) == 1);
03855             ulong        lvall;
03856             ulong        lvalh;
03857             ulong        rvall;
03858             ulong        rvalh;
03859             do {
03860               i--;
03861               vector_copy_val_and_sign_extend_ulong( left,  i, lmsb_is_one, &lvall, &lvalh );
03862               vector_copy_val_and_sign_extend_ulong( right, i, rmsb_is_one, &rvall, &rvalh );
03863             } while( (i > 0) && (lvall == rvall) );
03864             scratchl = (lvall == rvall);
03865           } else {
03866             scratchl = DEQ( vector_to_real64( left ), vector_to_real64( right )) ? 1 : 0;
03867           }
03868           retval = vector_set_coverage_and_assign_ulong( tgt, &scratchl, &scratchh, 0, 0 );
03869         }
03870         break;
03871       default :  assert( 0 );  break;
03872     }
03873 
03874   }
03875 
03876   PROFILE_END;
03877 
03878   return( retval );
03879 
03880 }

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

References vsuppl_u::data_type, MAX_BIT_WIDTH, vsuppl_u::part, PROFILE, PROFILE_END, vector_s::suppl, vector_s::ul, UL_DIV, UL_MOD, vector_s::value, VDATA_UL, vector_set_coverage_and_assign_ulong(), vector_to_int(), VTYPE_INDEX_VAL_VALH, VTYPE_INDEX_VAL_VALL, and vector_s::width.

Referenced by expression_op_func__expand().

05121   { PROFILE(VECTOR_OP_EXPAND);
05122 
05123   bool retval;  /* Return value for this function */
05124 
05125   switch( tgt->suppl.part.data_type ) {
05126     case VDATA_UL :
05127       {
05128         ulong        vall[UL_DIV(MAX_BIT_WIDTH)];
05129         ulong        valh[UL_DIV(MAX_BIT_WIDTH)];
05130         unsigned int i, j;
05131         unsigned int rwidth     = right->width;
05132         unsigned int multiplier = vector_to_int( left );
05133         unsigned int pos        = 0;
05134         for( i=0; i<multiplier; i++ ) {
05135           for( j=0; j<rwidth; j++ ) {
05136             ulong*       rval     = right->value.ul[UL_DIV(j)];
05137             unsigned int my_index = UL_DIV(pos);
05138             unsigned int offset   = UL_MOD(pos);
05139             if( offset == 0 ) {
05140               vall[my_index] = 0;
05141               valh[my_index] = 0;
05142             }
05143             vall[my_index] |= ((rval[VTYPE_INDEX_VAL_VALL] >> UL_MOD(j)) & 0x1) << offset;
05144             valh[my_index] |= ((rval[VTYPE_INDEX_VAL_VALH] >> UL_MOD(j)) & 0x1) << offset;
05145             pos++;
05146           }
05147         }
05148         retval = vector_set_coverage_and_assign_ulong( tgt, vall, valh, 0, (tgt->width - 1) );
05149       }
05150       break;
05151     default :  assert( 0 );  break;
05152   }
05153 
05154   PROFILE_END;
05155 
05156   return( retval );
05157 
05158 }

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

References vsuppl_u::data_type, vsuppl_u::part, PROFILE, PROFILE_END, vector_s::suppl, vector_s::ul, UL_DIV, UL_MOD, UL_SIZE, vector_s::value, VDATA_UL, vector_copy_val_and_sign_extend_ulong(), vector_is_unknown(), vector_reverse_for_cmp_ulong(), vector_set_coverage_and_assign_ulong(), vector_set_to_x(), vector_to_real64(), VTYPE_INDEX_VAL_VALL, and vector_s::width.

Referenced by expression_op_func__ge().

03773   { PROFILE(VECTOR_OP_GE);
03774 
03775   bool retval;  /* Return value for this function */
03776 
03777   if( vector_is_unknown( left ) || vector_is_unknown( right ) ) {
03778 
03779     retval = vector_set_to_x( tgt );
03780 
03781   } else {
03782 
03783     switch( tgt->suppl.part.data_type ) {
03784       case VDATA_UL :
03785         {
03786           ulong scratchl;
03787           ulong scratchh = 0;
03788           if( (left->suppl.part.data_type == VDATA_UL) && (right->suppl.part.data_type == VDATA_UL) ) {
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             do {
03801               i--;
03802               vector_copy_val_and_sign_extend_ulong( left,  i, lmsb_is_one, &lvall, &lvalh );
03803               vector_copy_val_and_sign_extend_ulong( right, i, rmsb_is_one, &rvall, &rvalh );
03804             } while( (i > 0) && (lvall == rvall) );
03805             scratchl = vector_reverse_for_cmp_ulong( left, right ) ? (rvall >= lvall) : (lvall >= rvall);
03806           } else {
03807             scratchl = (vector_to_real64( left ) >= vector_to_real64( right )) ? 1 : 0;
03808           }
03809           retval = vector_set_coverage_and_assign_ulong( tgt, &scratchl, &scratchh, 0, 0 );
03810         }
03811         break;
03812       default :  assert( 0 );  break;
03813     }
03814 
03815   }
03816 
03817   PROFILE_END;
03818 
03819   return( retval );
03820 
03821 }

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

References vsuppl_u::data_type, vsuppl_u::part, PROFILE, PROFILE_END, vector_s::suppl, vector_s::ul, UL_DIV, UL_MOD, UL_SIZE, vector_s::value, VDATA_UL, vector_copy_val_and_sign_extend_ulong(), vector_is_unknown(), vector_reverse_for_cmp_ulong(), vector_set_coverage_and_assign_ulong(), vector_set_to_x(), vector_to_real64(), VTYPE_INDEX_VAL_VALL, and vector_s::width.

Referenced by expression_op_func__gt().

03714   { PROFILE(VECTOR_OP_GT);
03715 
03716   bool retval;  /* Return value for this function */
03717 
03718   if( vector_is_unknown( left ) || vector_is_unknown( right ) ) {
03719  
03720     retval = vector_set_to_x( tgt );
03721 
03722   } else {
03723 
03724     switch( tgt->suppl.part.data_type ) {
03725       case VDATA_UL :
03726         {
03727           ulong scratchl;
03728           ulong scratchh = 0;
03729           if( (left->suppl.part.data_type == VDATA_UL) && (right->suppl.part.data_type == VDATA_UL) ) {
03730             unsigned int lsize       = UL_SIZE(left->width);
03731             unsigned int rsize       = UL_SIZE(right->width);
03732             int          i           = ((lsize < rsize) ? rsize : lsize);
03733             unsigned int lmsb        = (left->width - 1);
03734             unsigned int rmsb        = (right->width - 1);
03735             bool         lmsb_is_one = (((left->value.ul[UL_DIV(lmsb)][VTYPE_INDEX_VAL_VALL]  >> UL_MOD(lmsb)) & 1) == 1);
03736             bool         rmsb_is_one = (((right->value.ul[UL_DIV(rmsb)][VTYPE_INDEX_VAL_VALL] >> UL_MOD(rmsb)) & 1) == 1);
03737             ulong        lvall;
03738             ulong        lvalh;
03739             ulong        rvall;
03740             ulong        rvalh;
03741             do {
03742               i--;
03743               vector_copy_val_and_sign_extend_ulong( left,  i, lmsb_is_one, &lvall, &lvalh );
03744               vector_copy_val_and_sign_extend_ulong( right, i, rmsb_is_one, &rvall, &rvalh );
03745             } while( (i > 0) && (lvall == rvall) );
03746             scratchl = vector_reverse_for_cmp_ulong( left, right ) ? (rvall > lvall) : (lvall > rvall);
03747           } else {
03748             scratchl = (vector_to_real64( left ) > vector_to_real64( right )) ? 1 : 0;
03749           }
03750           retval = vector_set_coverage_and_assign_ulong( tgt, &scratchl, &scratchh, 0, 0 );
03751         }
03752         break;
03753       default :  assert( 0 );  break;
03754     }
03755 
03756   }
03757 
03758   PROFILE_END;
03759 
03760   return( retval );
03761 
03762 }

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

References vsuppl_u::data_type, vecblk_s::index, vsuppl_u::part, PROFILE, PROFILE_END, vector_s::r32, vector_s::r64, vector_s::suppl, TRUE, vector_s::ul, rv32_s::val, rv64_s::val, vector_s::value, VDATA_R32, VDATA_R64, VDATA_UL, vecblk_s::vec, vector_copy(), vector_op_add(), and VTYPE_INDEX_VAL_VALL.

Referenced by expression_op_func__iinc(), and expression_op_func__pinc().

04717   { PROFILE(VECTOR_OP_INC);
04718 
04719   switch( tgt->suppl.part.data_type ) {
04720     case VDATA_UL :
04721       {
04722         vector* tmp1 = &(tvb->vec[tvb->index++]);
04723         vector* tmp2 = &(tvb->vec[tvb->index++]);
04724         vector_copy( tgt, tmp1 );
04725         tmp2->value.ul[0][VTYPE_INDEX_VAL_VALL] = 1;
04726         (void)vector_op_add( tgt, tmp1, tmp2 );
04727       }
04728       break;
04729     case VDATA_R64 :
04730       tgt->value.r64->val += 1.0;
04731       break;
04732     case VDATA_R32 :
04733       tgt->value.r32->val += 1.0;
04734       break;
04735     default :  assert( 0 );  break;
04736   }
04737 
04738   PROFILE_END;
04739 
04740   return( TRUE );
04741 
04742 }

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

References vsuppl_u::data_type, vsuppl_u::part, PROFILE, PROFILE_END, vector_s::suppl, VDATA_UL, vector_is_not_zero(), vector_is_unknown(), and vector_set_coverage_and_assign_ulong().

Referenced by expression_op_func__land().

04174   { PROFILE(VECTOR_OP_LAND);
04175 
04176   bool retval;                                 /* Return value for this function */
04177   bool lunknown = vector_is_unknown( left );   /* Check for left value being unknown */
04178   bool runknown = vector_is_unknown( right );  /* Check for right value being unknown */
04179 
04180   switch( tgt->suppl.part.data_type ) {
04181     case VDATA_UL :
04182       {
04183         ulong valh = (lunknown && runknown) ? 1 : 0;
04184         ulong vall = ((!lunknown && vector_is_not_zero( left )) && (!runknown && vector_is_not_zero( right ))) ? 1 : 0;
04185         retval     = vector_set_coverage_and_assign_ulong( tgt, &vall, &valh, 0, 0 );
04186       }
04187       break;
04188     default :  assert( 0 );  break;
04189   }
04190 
04191   PROFILE_END;
04192 
04193   return( retval );
04194 
04195 }

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

References vsuppl_u::data_type, vsuppl_u::part, PROFILE, PROFILE_END, vector_s::suppl, vector_s::ul, UL_DIV, UL_MOD, UL_SIZE, vector_s::value, VDATA_UL, vector_copy_val_and_sign_extend_ulong(), vector_is_unknown(), vector_reverse_for_cmp_ulong(), vector_set_coverage_and_assign_ulong(), vector_set_to_x(), vector_to_real64(), VTYPE_INDEX_VAL_VALL, and vector_s::width.

Referenced by expression_op_func__le().

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

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

References vsuppl_u::data_type, MAX_BIT_WIDTH, vsuppl_u::part, PROFILE, PROFILE_END, vector_s::suppl, vector_s::ul, UL_DIV, UL_MOD, UL_SIZE, vector_s::value, VDATA_UL, vector_set_coverage_and_assign_ulong(), VTYPE_INDEX_EXP_VALH, VTYPE_INDEX_EXP_VALL, VTYPE_INDEX_VAL_VALH, VTYPE_INDEX_VAL_VALL, and vector_s::width.

Referenced by expression_op_func__list().

05169   { PROFILE(VECTOR_OP_LIST);
05170         
05171   bool retval;  /* Return value for this function */
05172           
05173   switch( tgt->suppl.part.data_type ) {
05174     case VDATA_UL :
05175       {       
05176         ulong        vall[UL_DIV(MAX_BIT_WIDTH)];
05177         ulong        valh[UL_DIV(MAX_BIT_WIDTH)];
05178         unsigned int i;
05179         unsigned int pos    = right->width;
05180         unsigned int lwidth = left->width;
05181         unsigned int rsize  = (pos == 0) ? 0 : UL_SIZE( pos );
05182 
05183         /* Load right vector directly */
05184         for( i=0; i<rsize; i++ ) {
05185           ulong* rval = right->value.ul[i];
05186           vall[i] = rval[VTYPE_INDEX_VAL_VALL];
05187           valh[i] = rval[VTYPE_INDEX_VAL_VALH];
05188         }
05189 
05190         /* Load left vector a bit at at time */
05191         for( i=0; i<lwidth; i++ ) {
05192           ulong*       lval     = left->value.ul[UL_DIV(i)];
05193           unsigned int my_index = UL_DIV(pos);
05194           unsigned int offset   = UL_MOD(pos);
05195           if( offset == 0 ) {
05196             vall[my_index] = 0;
05197             valh[my_index] = 0;
05198           }
05199           vall[my_index] |= ((lval[VTYPE_INDEX_EXP_VALL] >> UL_MOD(i)) & 0x1) << offset;
05200           valh[my_index] |= ((lval[VTYPE_INDEX_EXP_VALH] >> UL_MOD(i)) & 0x1) << offset;
05201           pos++;
05202         }
05203         retval = vector_set_coverage_and_assign_ulong( tgt, vall, valh, 0, ((lwidth + right->width) - 1) );
05204       }
05205       break;
05206     default :  assert( 0 );  break;
05207   }
05208 
05209   PROFILE_END;
05210 
05211   return( retval );
05212   
05213 }

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

References vsuppl_u::data_type, vsuppl_u::part, PROFILE, PROFILE_END, vector_s::suppl, VDATA_UL, vector_is_not_zero(), vector_is_unknown(), and vector_set_coverage_and_assign_ulong().

Referenced by expression_op_func__lor().

04142   { PROFILE(VECTOR_OP_LOR);
04143 
04144   bool retval;                                 /* Return value for this function */
04145   bool lunknown = vector_is_unknown( left );   /* Check for left value being unknown */
04146   bool runknown = vector_is_unknown( right );  /* Check for right value being unknown */
04147 
04148   switch( tgt->suppl.part.data_type ) {
04149     case VDATA_UL :
04150       {
04151         ulong valh = (lunknown && runknown) ? 1 : 0;
04152         ulong vall = ((!lunknown && vector_is_not_zero( left )) || (!runknown && vector_is_not_zero( right ))) ? 1 : 0;
04153         retval     = vector_set_coverage_and_assign_ulong( tgt, &vall, &valh, 0, 0 );
04154       }
04155       break;
04156     default :  assert( 0 );  break;
04157   }
04158 
04159   PROFILE_END;
04160 
04161   return( retval );
04162 
04163 }

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

References vsuppl_u::data_type, FALSE, MAX_BIT_WIDTH, vsuppl_u::part, PROFILE, PROFILE_END, vector_s::suppl, UL_DIV, VDATA_UL, vector_is_unknown(), vector_lshift_ulong(), vector_set_coverage_and_assign_ulong(), vector_set_to_x(), vector_to_int(), and vector_s::width.

Referenced by expression_op_func__lshift(), and expression_op_func__lshift_a().

04207   { PROFILE(VECTOR_OP_LSHIFT);
04208 
04209   bool retval;  /* Return value for this function */
04210 
04211   if( vector_is_unknown( right ) ) {
04212 
04213     retval = vector_set_to_x( tgt );
04214 
04215   } else { 
04216 
04217     int shift_val = vector_to_int( right );
04218 
04219     switch( tgt->suppl.part.data_type ) {
04220       case VDATA_UL :
04221         {
04222           ulong vall[UL_DIV(MAX_BIT_WIDTH)];
04223           ulong valh[UL_DIV(MAX_BIT_WIDTH)];
04224           vector_lshift_ulong( left, vall, valh, shift_val, ((left->width + shift_val) - 1), FALSE );
04225           retval = vector_set_coverage_and_assign_ulong( tgt, vall, valh, 0, (tgt->width - 1) );
04226         }
04227         break;
04228       default :  assert( 0 );  break;
04229     }
04230 
04231   }
04232 
04233   PROFILE_END;
04234 
04235   return( retval );
04236     
04237 }

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

References vsuppl_u::data_type, vsuppl_u::part, PROFILE, PROFILE_END, vector_s::suppl, vector_s::ul, UL_DIV, UL_MOD, UL_SIZE, vector_s::value, VDATA_UL, vector_copy_val_and_sign_extend_ulong(), vector_is_unknown(), vector_reverse_for_cmp_ulong(), vector_set_coverage_and_assign_ulong(), vector_set_to_x(), vector_to_real64(), VTYPE_INDEX_VAL_VALL, and vector_s::width.

Referenced by expression_op_func__lt(), and expression_op_func__repeat().

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

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

References vsuppl_u::data_type, vsuppl_u::part, PROFILE, PROFILE_END, vector_s::suppl, vector_s::ul, vector_s::value, VDATA_UL, vector_is_unknown(), vector_set_coverage_and_assign_ulong(), vector_set_to_x(), and VTYPE_INDEX_EXP_VALL.

Referenced by expression_op_func__mod(), and expression_op_func__mod_a().

04674   { PROFILE(VECTOR_OP_MODULUS);
04675 
04676   bool retval;  /* Return value for this function */
04677 
04678   if( vector_is_unknown( left ) || vector_is_unknown( right ) ) {
04679 
04680     retval = vector_set_to_x( tgt );
04681 
04682   } else {
04683 
04684     switch( tgt->suppl.part.data_type ) {
04685       case VDATA_UL :
04686         {
04687           ulong vall;
04688           ulong valh = 0;
04689           ulong rval = right->value.ul[0][VTYPE_INDEX_EXP_VALL];
04690           if( rval == 0 ) {
04691             retval = vector_set_to_x( tgt );
04692           } else {
04693             vall = left->value.ul[0][VTYPE_INDEX_EXP_VALL] % rval;
04694             retval = vector_set_coverage_and_assign_ulong( tgt, &vall, &valh, 0, (UL_BITS - 1) );
04695           }
04696         }
04697         break;
04698       default :  assert( 0 );  break;
04699     }
04700 
04701   }
04702 
04703   PROFILE_END;
04704 
04705   return( retval );
04706 
04707 }

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

References vsuppl_u::data_type, DEQ, FEQ, vsuppl_u::part, PROFILE, PROFILE_END, vector_s::r32, vector_s::r64, vector_s::suppl, vector_s::ul, rv32_s::val, rv64_s::val, vector_s::value, VDATA_R32, VDATA_R64, VDATA_UL, vector_is_unknown(), vector_set_coverage_and_assign_ulong(), vector_set_to_x(), vector_to_real64(), VTYPE_INDEX_VAL_VALL, and vector_s::width.

Referenced by expression_op_func__multiply(), and expression_op_func__multiply_a().

04564   { PROFILE(VECTOR_OP_MULTIPLY);
04565 
04566   bool retval;  /* Return value for this function */
04567 
04568   if( vector_is_unknown( left ) || vector_is_unknown( right ) ) {
04569 
04570     retval = vector_set_to_x( tgt );
04571 
04572   } else {
04573 
04574     switch( tgt->suppl.part.data_type ) {
04575       case VDATA_UL :
04576         {
04577           ulong vall = left->value.ul[0][VTYPE_INDEX_VAL_VALL] * right->value.ul[0][VTYPE_INDEX_VAL_VALL];
04578           ulong valh = 0;
04579           retval = vector_set_coverage_and_assign_ulong( tgt, &vall, &valh, 0, (tgt->width - 1) );
04580         }
04581         break;
04582       case VDATA_R64 :
04583         {
04584           double result       = vector_to_real64( left ) * vector_to_real64( right );
04585           retval              = !DEQ( tgt->value.r64->val, result );
04586           tgt->value.r64->val = result;
04587         }
04588         break;
04589       case VDATA_R32 :
04590         {
04591           float result        = (float)(vector_to_real64( left ) * vector_to_real64( right ));
04592           retval              = !FEQ( tgt->value.r32->val, result );
04593           tgt->value.r32->val = result;
04594         }
04595         break;
04596       default :  assert( 0 );  break;
04597     }
04598 
04599   }
04600 
04601   PROFILE_END;
04602 
04603   return( retval );
04604 
04605 }

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

References vsuppl_u::data_type, DEQ, vsuppl_u::part, PROFILE, PROFILE_END, vector_s::suppl, vector_s::ul, UL_DIV, UL_MOD, UL_SIZE, vector_s::value, VDATA_UL, vector_copy_val_and_sign_extend_ulong(), vector_is_unknown(), vector_set_coverage_and_assign_ulong(), vector_set_to_x(), vector_to_real64(), VTYPE_INDEX_VAL_VALL, and vector_s::width.

Referenced by expression_op_func__ne().

04053   { PROFILE(VECTOR_OP_NE);
04054 
04055   bool retval;  /* Return value for this function */
04056 
04057   if( vector_is_unknown( left ) || vector_is_unknown( right ) ) {
04058 
04059     retval = vector_set_to_x( tgt );
04060 
04061   } else {
04062 
04063     switch( tgt->suppl.part.data_type ) {
04064       case VDATA_UL :
04065         {
04066           ulong scratchl;
04067           ulong scratchh = 0;
04068           if( (left->suppl.part.data_type == VDATA_UL) && (right->suppl.part.data_type == VDATA_UL) ) {
04069             unsigned int lsize       = UL_SIZE(left->width);
04070             unsigned int rsize       = UL_SIZE(right->width);
04071             int          i           = ((lsize < rsize) ? rsize : lsize);
04072             unsigned int lmsb        = (left->width - 1);
04073             unsigned int rmsb        = (right->width - 1);
04074             bool         lmsb_is_one = (((left->value.ul[UL_DIV(lmsb)][VTYPE_INDEX_VAL_VALL]  >> UL_MOD(lmsb)) & 1) == 1);
04075             bool         rmsb_is_one = (((right->value.ul[UL_DIV(rmsb)][VTYPE_INDEX_VAL_VALL] >> UL_MOD(rmsb)) & 1) == 1);
04076             ulong        lvall;
04077             ulong        lvalh;
04078             ulong        rvall;
04079             ulong        rvalh;
04080             do {
04081               i--;
04082               vector_copy_val_and_sign_extend_ulong( left,  i, lmsb_is_one, &lvall, &lvalh );
04083               vector_copy_val_and_sign_extend_ulong( right, i, rmsb_is_one, &rvall, &rvalh );
04084             } while( (i > 0) && (lvall == rvall) );
04085             scratchl = (lvall != rvall);
04086           } else {
04087             scratchl = !DEQ( vector_to_real64( left ), vector_to_real64( right ) ) ? 1 : 0;
04088           }
04089           retval = vector_set_coverage_and_assign_ulong( tgt, &scratchl, &scratchh, 0, 0 );
04090         }
04091         break;
04092       default :  assert( 0 );  break;
04093     }
04094 
04095   }
04096 
04097   PROFILE_END;
04098 
04099   return( retval );
04100 
04101 }

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

References vsuppl_u::data_type, DEQ, FEQ, MAX_BIT_WIDTH, vsuppl_u::part, PROFILE, PROFILE_END, vector_s::r32, vector_s::r64, vector_s::suppl, vector_s::ul, UL_DIV, UL_SIZE, rv32_s::val, rv64_s::val, vector_s::value, VDATA_R32, VDATA_R64, VDATA_UL, vector_is_unknown(), vector_set_coverage_and_assign_ulong(), vector_set_to_x(), vector_to_real64(), VTYPE_INDEX_EXP_VALL, and vector_s::width.

Referenced by expression_op_func__negate().

04407   { PROFILE(VECTOR_OP_NEGATE);
04408 
04409   bool retval;  /* Return value for this function */
04410 
04411   if( vector_is_unknown( src ) ) {
04412    
04413     retval = vector_set_to_x( tgt );
04414 
04415   } else {
04416 
04417     switch( tgt->suppl.part.data_type ) {
04418       case VDATA_UL :
04419         {
04420           if( src->width <= UL_BITS ) {
04421             ulong vall = ~src->value.ul[0][VTYPE_INDEX_EXP_VALL] + 1;
04422             ulong valh = 0;
04423 
04424             retval = vector_set_coverage_and_assign_ulong( tgt, &vall, &valh, 0, (tgt->width - 1) );
04425           } else {
04426             ulong        vall[UL_DIV(MAX_BIT_WIDTH)];
04427             ulong        valh[UL_DIV(MAX_BIT_WIDTH)];
04428             unsigned int i, j;
04429             unsigned int size  = UL_SIZE( src->width );
04430             ulong        carry = 1;
04431             ulong        val;
04432 
04433             for( i=0; i<(size - 1); i++ ) {
04434               val     = ~src->value.ul[i][VTYPE_INDEX_EXP_VALL];
04435               vall[i] = 0;
04436               valh[i] = 0;
04437               for( j=0; j<UL_BITS; j++ ) {
04438                 ulong bit = ((val >> j) & 0x1) + carry;
04439                 carry     = bit >> 1;
04440                 vall[i]  |= (bit & 0x1) << j;
04441               }
04442             }
04443             val     = ~src->value.ul[i][VTYPE_INDEX_EXP_VALL];
04444             vall[i] = 0;
04445             valh[i] = 0;
04446             for( j=0; j<(tgt->width - (i << UL_DIV_VAL)); j++ ) {
04447               ulong bit = ((val >> j) & 0x1) + carry;
04448               carry     = bit >> 1;
04449               vall[i]  |= (bit & 0x1) << j;
04450             }
04451 
04452             retval = vector_set_coverage_and_assign_ulong( tgt, vall, valh, 0, (tgt->width - 1) );
04453           }
04454         }
04455         break;
04456       case VDATA_R64 :
04457         {
04458           double result       = (0.0 - vector_to_real64( src ));
04459           retval              = !DEQ( tgt->value.r64->val, result );
04460           tgt->value.r64->val = result;
04461         }
04462         break;
04463       case VDATA_R32 :
04464         {
04465           float result        = (float)(0.0 - vector_to_real64( src ));
04466           retval              = !FEQ( tgt->value.r32->val, result );
04467           tgt->value.r32->val = result;
04468         }
04469         break;
04470       default :  assert( 0 );  break;
04471     }
04472 
04473   }
04474 
04475   PROFILE_END;
04476 
04477   return( retval );
04478 
04479 }

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

References vsuppl_u::data_type, FALSE, MAX_BIT_WIDTH, vsuppl_u::part, PROFILE, PROFILE_END, vector_s::suppl, UL_DIV, VDATA_UL, vector_is_unknown(), vector_rshift_ulong(), vector_set_coverage_and_assign_ulong(), vector_set_to_x(), vector_to_int(), and vector_s::width.

Referenced by expression_op_func__rshift(), and expression_op_func__rshift_a().

04249   { PROFILE(VECTOR_OP_RSHIFT);
04250 
04251   bool retval;  /* Return value for this function */
04252 
04253   if( vector_is_unknown( right ) ) {
04254 
04255     retval = vector_set_to_x( tgt );
04256 
04257   } else {
04258 
04259     int shift_val = vector_to_int( right );
04260 
04261     switch( tgt->suppl.part.data_type ) {
04262       case VDATA_UL :
04263         {
04264           ulong vall[UL_DIV(MAX_BIT_WIDTH)];
04265           ulong valh[UL_DIV(MAX_BIT_WIDTH)];
04266           vector_rshift_ulong( left, vall, valh, shift_val, (left->width - 1), FALSE );
04267           retval = vector_set_coverage_and_assign_ulong( tgt, vall, valh, 0, (tgt->width - 1) );
04268         }
04269         break;
04270       default :  assert( 0 );  break;
04271     }
04272 
04273   }
04274 
04275   PROFILE_END;
04276 
04277   return( retval );
04278 
04279 }

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

References vsuppl_u::data_type, DEQ, FEQ, MAX_BIT_WIDTH, vsuppl_u::part, PROFILE, PROFILE_END, vector_s::r32, vector_s::r64, vector_s::suppl, vector_s::ul, UL_DIV, UL_MOD, UL_SIZE, rv32_s::val, rv64_s::val, vector_s::value, VDATA_R32, VDATA_R64, VDATA_UL, vector_copy_val_and_sign_extend_ulong(), vector_is_unknown(), vector_set_coverage_and_assign_ulong(), vector_set_to_x(), vector_to_real64(), VTYPE_INDEX_VAL_VALL, and vector_s::width.

Referenced by expression_op_func__sub_a(), expression_op_func__subtract(), and vector_op_dec().

04492   { PROFILE(VECTOR_OP_SUBTRACT);
04493 
04494   bool retval;  /* Return value for this function */
04495 
04496   /* If either the left or right vector is unknown, set the entire value to X */
04497   if( vector_is_unknown( left ) || vector_is_unknown( right ) ) {
04498 
04499     retval = vector_set_to_x( tgt );
04500 
04501   /* Otherwise, perform the subtraction operation */
04502   } else {
04503 
04504     switch( tgt->suppl.part.data_type ) {
04505       case VDATA_UL :
04506         {
04507           ulong        vall[UL_DIV(MAX_BIT_WIDTH)];
04508           ulong        valh[UL_DIV(MAX_BIT_WIDTH)];
04509           ulong        carry = 1;
04510           bool         lmsb_is_one = (((left->value.ul[UL_DIV(left->width-1)][VTYPE_INDEX_VAL_VALL]   >> UL_MOD(left->width  - 1)) & 1) == 1);
04511           bool         rmsb_is_one = (((right->value.ul[UL_DIV(right->width-1)][VTYPE_INDEX_VAL_VALL] >> UL_MOD(right->width - 1)) & 1) == 1);
04512           ulong        lvall, lvalh;
04513           ulong        rvall, rvalh;
04514           unsigned int i;
04515           for( i=0; i<UL_SIZE( tgt->width ); i++ ) {
04516             vector_copy_val_and_sign_extend_ulong( left,  i, lmsb_is_one, &lvall, &lvalh );
04517             vector_copy_val_and_sign_extend_ulong( right, i, rmsb_is_one, &rvall, &rvalh ); 
04518             rvall   = ~rvall;
04519             vall[i] = lvall + rvall + carry;
04520             valh[i] = 0;
04521             carry   = ((lvall & rvall) | ((lvall | rvall) & ~vall[i])) >> (UL_BITS - 1);
04522           }
04523           retval = vector_set_coverage_and_assign_ulong( tgt, vall, valh, 0, (tgt->width - 1) );
04524         }
04525         break;
04526       case VDATA_R64 :
04527         {
04528           double result       = vector_to_real64( left ) - vector_to_real64( right );
04529           retval              = !DEQ( tgt->value.r64->val, result );
04530           tgt->value.r64->val = result;
04531         }
04532         break;
04533       case VDATA_R32 :
04534         {
04535           float result        = (float)(vector_to_real64( left ) - vector_to_real64( right ));
04536           retval              = !FEQ( tgt->value.r32->val, result );
04537           tgt->value.r32->val = result;
04538         }
04539         break;
04540       default :  assert( 0 );  break;
04541     }
04542 
04543   }
04544 
04545   PROFILE_END;
04546 
04547   return( retval );
04548 
04549 }

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

References vsuppl_u::data_type, MAX_BIT_WIDTH, vsuppl_u::part, PROFILE, PROFILE_END, vector_s::suppl, TRUE, vsuppl_u::type, vector_s::ul, UL_DIV, UL_HMASK, UL_LMASK, vector_s::value, VDATA_UL, vector_rshift_ulong(), vector_set_coverage_and_assign_ulong(), VTYPE_INDEX_MEM_RD, VTYPE_MEM, and vector_s::width.

Referenced by expression_op_func__mbit(), expression_op_func__mbit_neg(), expression_op_func__mbit_pos(), and expression_op_func__sbit().

02013   { PROFILE(VECTOR_PART_SELECT_PULL);
02014 
02015   bool retval;  /* Return value for this function */
02016 
02017   switch( src->suppl.part.data_type ) {
02018     case VDATA_UL :
02019       {
02020         ulong valh[UL_DIV(MAX_BIT_WIDTH)];
02021         ulong vall[UL_DIV(MAX_BIT_WIDTH)];
02022 
02023         /* Perform shift operation */
02024         vector_rshift_ulong( src, vall, valh, lsb, msb, TRUE );
02025 
02026         /* If the src vector is of type MEM, set the MEM_RD bits in the source's supplemental field */
02027         if( set_mem_rd && (src->suppl.part.type == VTYPE_MEM) ) {
02028           if( UL_DIV(msb) == UL_DIV(lsb) ) {
02029             src->value.ul[UL_DIV(lsb)][VTYPE_INDEX_MEM_RD] |= UL_HMASK(msb) & UL_LMASK(lsb);
02030           } else {
02031             int i;
02032             src->value.ul[UL_DIV(lsb)][VTYPE_INDEX_MEM_RD] |= UL_LMASK(lsb);
02033             for( i=(UL_DIV(lsb) + 1); i<=UL_DIV(msb); i++ ) {
02034               src->value.ul[UL_DIV(msb)][VTYPE_INDEX_MEM_RD] = UL_SET;
02035             }
02036             src->value.ul[UL_DIV(msb)][VTYPE_INDEX_MEM_RD] |= UL_HMASK(msb);
02037           } 
02038         }
02039 
02040         /* Perform value assignment and calculate coverage */
02041         retval = vector_set_coverage_and_assign_ulong( tgt, vall, valh, 0, (tgt->width - 1) );
02042       }
02043       break;
02044     default :  assert( 0 );  break;
02045   }
02046 
02047   PROFILE_END;
02048 
02049   return( retval );
02050 
02051 }

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

References vsuppl_u::data_type, FALSE, MAX_BIT_WIDTH, vsuppl_u::part, PROFILE, PROFILE_END, vector_s::suppl, UL_DIV, VDATA_UL, vector_get_sign_extend_vector_ulong(), vector_lshift_ulong(), vector_rshift_ulong(), vector_set_coverage_and_assign_ulong(), vector_sign_extend_ulong(), and vector_s::width.

Referenced by expression_assign(), and sim_perform_nba().

02067   { PROFILE(VECTOR_PART_SELECT_PUSH);
02068 
02069   bool retval;  /* Return value for this function */
02070 
02071   switch( src->suppl.part.data_type ) {
02072     case VDATA_UL :
02073       {
02074         ulong        valh[UL_DIV(MAX_BIT_WIDTH)];
02075         ulong        vall[UL_DIV(MAX_BIT_WIDTH)];
02076         unsigned int diff;
02077         unsigned int i; 
02078         ulong        signl, signh;
02079 
02080         /* Get the sign extension vector */
02081         vector_get_sign_extend_vector_ulong( src, &signl, &signh );
02082 
02083         /* If the LSB to assign exceeds the size of the actual vector, just create a value based on the signedness */
02084         if( (src_lsb > 0) && ((unsigned int)src_lsb >= src->width) ) {
02085 
02086           if( sign_extend && ((signl != 0) || (signh != 0)) ) {
02087             vector_sign_extend_ulong( vall, valh, signl, signh, (tgt_lsb - 1), tgt->width );
02088           } else {
02089             for( i=UL_DIV(tgt_lsb); i<=UL_DIV(tgt_msb); i++ ) {
02090               vall[i] = valh[i] = 0;
02091             }
02092           }
02093 
02094         /* Otherwise, pull the value from source vector */
02095         } else {
02096 
02097           /* First, initialize the vall/h arrays to zero */
02098           for( i=UL_DIV(tgt_lsb); i<=UL_DIV(tgt_msb); i++ ) {
02099             vall[i] = valh[i] = 0;
02100           }
02101   
02102           /* Left-shift the source vector to match up with target LSB */
02103           if( src_lsb < tgt_lsb ) {
02104             diff = (tgt_lsb - src_lsb);
02105             vector_lshift_ulong( src, vall, valh, diff, ((src_msb - src_lsb) + diff), FALSE );
02106           /* Otherwise, right-shift the source vector to match up */
02107           } else {
02108             diff = (src_lsb - tgt_lsb);
02109             vector_rshift_ulong( src, vall, valh, diff, ((src_msb - src_lsb) + diff), FALSE );
02110           }
02111 
02112           /* Now apply the sign extension, if necessary */
02113           if( sign_extend && ((signl != 0) || (signh != 0)) ) {
02114             vector_sign_extend_ulong( vall, valh, signl, signh, (tgt_lsb + (src_msb - src_lsb)), (tgt_msb + 1) );
02115           }
02116 
02117         }
02118 
02119         /* Now assign the calculated value and set coverage information */
02120         retval = vector_set_coverage_and_assign_ulong( tgt, vall, valh, tgt_lsb, tgt_msb );
02121       }
02122       break;
02123     default :  assert( 0 );  break;
02124   }
02125 
02126   PROFILE_END;
02127 
02128   return( retval );
02129 
02130 }

static bool vector_reverse_for_cmp_ulong ( const vector left,
const vector right 
) [inline, static]
Returns:
Returns TRUE if vectors need to be reversed for comparison purposes; otherwise, returns FALSE.
Parameters:
left Pointer to left vector that is being compared
right Pointer to right vector that is being compared

References vsuppl_u::is_signed, vsuppl_u::part, vector_s::suppl, vector_s::ul, UL_DIV, UL_MOD, vector_s::value, VTYPE_INDEX_VAL_VALL, and vector_s::width.

Referenced by vector_op_ge(), vector_op_gt(), vector_op_le(), and vector_op_lt().

03543   {
03544 
03545   return( left->suppl.part.is_signed && right->suppl.part.is_signed &&
03546           (((left->value.ul[UL_DIV(left->width-1)][VTYPE_INDEX_VAL_VALL]   >> UL_MOD(left->width  - 1)) & 0x1) !=
03547            ((right->value.ul[UL_DIV(right->width-1)][VTYPE_INDEX_VAL_VALL] >> UL_MOD(right->width - 1)) & 0x1)) );
03548 
03549 }

static void vector_rshift_ulong ( const vector vec,
ulong vall,
ulong valh,
int  lsb,
int  msb,
bool  xfill 
) [static]

Performs a fast right-shift to zero-align data in vector and stores the result in the vall/h value arrays.

Parameters:
vec Pointer to vector containing value that we want to right-shift
vall Pointer to intermediate value array containing lower bits of shifted value
valh Pointer to intermediate value array containing upper bits of shifted value
lsb LSB of vec range to shift
msb MSB of vec range to shift
xfill Set to TRUE if the upper bits should be X filled or not

References PROFILE, PROFILE_END, vector_s::ul, UL_DIV, UL_HMASK, UL_MOD, UL_SIZE, vector_s::value, vector_lshift_ulong(), VTYPE_INDEX_VAL_VALH, VTYPE_INDEX_VAL_VALL, and vector_s::width.

Referenced by vector_op_arshift(), vector_op_rshift(), vector_part_select_pull(), and vector_part_select_push().

01847   { PROFILE(VECTOR_RSHIFT_ULONG);
01848 
01849   int          adj_lsb = (lsb < 0) ? 0 : lsb;
01850   int          diff    = UL_DIV(adj_lsb);
01851   unsigned int rwidth  = (msb - adj_lsb) + 1;
01852   
01853   if( adj_lsb > msb ) {
01854 
01855     unsigned int i;
01856 
01857     for( i=0; i<UL_SIZE( vec->width ); i++ ) {
01858       vall[i] = 0;
01859       valh[i] = xfill ? UL_SET : 0;
01860     }
01861 
01862   } else if( lsb < 0 ) {
01863 
01864     /* First, left shift the data */
01865     vector_lshift_ulong( vec, vall, valh, (0 - lsb), (msb + (0 - lsb)), xfill ); 
01866 
01867   } else {
01868 
01869     bool use_vec = msb > (vec->width - 1);
01870     int  hindex  = use_vec ? UL_DIV(vec->width - 1) : UL_DIV(msb);
01871     int  i;
01872     int  start_i;
01873     
01874     /* Transfer the vector value to the val array */
01875     for( i=0; i<=hindex; i++ ) {
01876       vall[i] = vec->value.ul[i][VTYPE_INDEX_VAL_VALL];
01877       valh[i] = vec->value.ul[i][VTYPE_INDEX_VAL_VALH];
01878     }
01879     
01880     if( use_vec ) {
01881 
01882       ulong uset1 = xfill ? ~UL_HMASK(vec->width - 1) : 0;
01883       ulong uset2 = xfill ? UL_SET : 0;
01884             
01885       valh[i-1] = valh[i-1] | uset1;
01886       
01887       for( ; i<=UL_DIV(msb); i++ ) {
01888         vall[i] = 0;
01889         valh[i] = uset2;
01890       }
01891 
01892     }
01893     
01894     if( UL_DIV(adj_lsb) == UL_DIV(msb) ) {
01895 
01896       vall[0] = (vall[diff] >> UL_MOD(adj_lsb));
01897       valh[0] = (valh[diff] >> UL_MOD(adj_lsb));
01898       start_i = 1;
01899 
01900     } else if( UL_MOD(adj_lsb) == 0 ) {
01901 
01902       unsigned int i;
01903       ulong        lmask = UL_HMASK(msb);
01904 
01905       for( i=diff; i<UL_DIV(msb); i++ ) {
01906         vall[i-diff] = vall[i];
01907         valh[i-diff] = valh[i];
01908       }
01909       vall[i-diff] = vall[i] & lmask;
01910       valh[i-diff] = valh[i] & lmask;
01911       start_i      = (i - diff) + 1;
01912 
01913     } else {
01914 
01915       unsigned int shift_bits = UL_MOD(adj_lsb);
01916       ulong        mask1      = UL_SET << shift_bits;
01917       ulong        mask2      = ~mask1;
01918       ulong        mask3      = UL_SET >> ((UL_BITS - 1) - UL_MOD(msb - adj_lsb));
01919       unsigned int hindex     = UL_DIV(msb);
01920       unsigned int i;
01921 
01922       for( i=0; i<=UL_DIV(rwidth - 1); i++ ) {
01923         vall[i]  = (vall[i+diff] & mask1) >> shift_bits;
01924         valh[i]  = (valh[i+diff] & mask1) >> shift_bits;
01925         if( (i+diff+1) <= hindex ) {
01926           vall[i] |= (vall[i+diff+1] & mask2) << (UL_BITS - shift_bits);
01927           valh[i] |= (valh[i+diff+1] & mask2) << (UL_BITS - shift_bits);
01928         }
01929       }
01930 
01931       vall[i-1] &= mask3;
01932       valh[i-1] &= mask3;
01933       start_i    = i;
01934 
01935     }
01936         
01937     /* Bit-fill with zeroes or X */
01938     for( ; start_i<=UL_SIZE( vec->width ); start_i++ ) {
01939       vall[start_i] = 0;
01940       valh[start_i] = xfill ? UL_SET : 0;
01941     }
01942 
01943   }
01944 
01945   PROFILE_END;
01946 
01947 }

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

References vsuppl_u::data_type, vsuppl_u::part, PROFILE, PROFILE_END, vector_s::suppl, vector_s::ul, UL_SIZE, vector_s::value, VDATA_R32, VDATA_R64, VDATA_UL, VTYPE_INDEX_EXP_EVAL_A, VTYPE_INDEX_EXP_EVAL_B, VTYPE_INDEX_EXP_EVAL_C, VTYPE_INDEX_EXP_VALH, VTYPE_INDEX_EXP_VALL, and vector_s::width.

Referenced by expression_op_func__and(), expression_op_func__and_a(), expression_op_func__land(), and expression_op_func__nand().

02173   { PROFILE(VECTOR_SET_AND_COMB_EVALS);
02174 
02175   switch( tgt->suppl.part.data_type ) {
02176     case VDATA_UL :
02177       {
02178         unsigned int i;
02179         unsigned int size  = UL_SIZE( tgt->width );
02180         unsigned int lsize = UL_SIZE( left->width );
02181         unsigned int rsize = UL_SIZE( right->width );
02182 
02183         for( i=0; i<size; i++ ) {
02184           ulong* val    = tgt->value.ul[i];
02185           ulong* lval   = (i < lsize) ? left->value.ul[i]  : 0;
02186           ulong* rval   = (i < rsize) ? right->value.ul[i] : 0;
02187           ulong  lvall  = (i < lsize) ?  lval[VTYPE_INDEX_EXP_VALL] : 0;
02188           ulong  nlvalh = (i < lsize) ? ~lval[VTYPE_INDEX_EXP_VALH] : UL_SET;
02189           ulong  rvall  = (i < rsize) ?  rval[VTYPE_INDEX_EXP_VALL] : 0;
02190           ulong  nrvalh = (i < rsize) ? ~rval[VTYPE_INDEX_EXP_VALH] : UL_SET;
02191           
02192           val[VTYPE_INDEX_EXP_EVAL_A] |= nlvalh & ~lvall;
02193           val[VTYPE_INDEX_EXP_EVAL_B] |= nrvalh & ~rvall;
02194           val[VTYPE_INDEX_EXP_EVAL_C] |= nlvalh & nrvalh & lvall & rvall;
02195         }
02196       }
02197       break;
02198     case VDATA_R64 :
02199     case VDATA_R32 :
02200       break;
02201     default :  assert( 0 );  break;
02202   }
02203 
02204   PROFILE_END;
02205  
02206 }

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

References vsuppl_u::data_type, FALSE, vsuppl_u::part, PROFILE, PROFILE_END, vector_s::suppl, vsuppl_u::type, vector_s::ul, UL_DIV, UL_HMASK, UL_LMASK, vector_s::value, VDATA_R64, VDATA_UL, VTYPE_INDEX_SIG_MISC, VTYPE_SIG, and vector_s::width.

Referenced by race_check_one_block_assignment().

01498   { PROFILE(VECTOR_SET_ASSIGNED);
01499 
01500   bool prev_assigned = FALSE;  /* Specifies if any set bit was previously set */
01501 
01502   assert( vec != NULL );
01503   assert( ((msb - lsb) < 0) || ((unsigned int)(msb - lsb) < vec->width) );
01504   assert( vec->suppl.part.type == VTYPE_SIG );
01505 
01506   switch( vec->suppl.part.data_type ) {
01507     case VDATA_UL :
01508       {
01509         ulong lmask     = UL_LMASK(lsb);
01510         ulong hmask     = UL_HMASK(msb);
01511         int   i         = UL_DIV(lsb);
01512         int   msb_index = UL_DIV(msb);
01513         if( i == msb_index ) {
01514           lmask &= hmask;
01515           prev_assigned = ((vec->value.ul[i][VTYPE_INDEX_SIG_MISC] & lmask) != 0);
01516           vec->value.ul[i][VTYPE_INDEX_SIG_MISC] |= lmask;
01517         } else {
01518           prev_assigned |= ((vec->value.ul[i][VTYPE_INDEX_SIG_MISC] & lmask) != 0);
01519           vec->value.ul[i][VTYPE_INDEX_SIG_MISC] |= lmask;
01520           for( i++; i<msb_index; i++ ) {
01521             prev_assigned = (vec->value.ul[i][VTYPE_INDEX_SIG_MISC] != 0);
01522             vec->value.ul[i][VTYPE_INDEX_SIG_MISC] |= UL_SET;
01523           }
01524           prev_assigned |= ((vec->value.ul[i][VTYPE_INDEX_SIG_MISC] & hmask) != 0);
01525           vec->value.ul[i][VTYPE_INDEX_SIG_MISC] |= hmask;
01526         }
01527       }
01528       break;
01529     case VDATA_R64 :
01530       break;
01531     default :  assert( 0 );  break;
01532   }
01533 
01534   PROFILE_END;
01535 
01536   return( prev_assigned );
01537 
01538 }

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

References FALSE, vsuppl_u::part, PROFILE, PROFILE_END, vsuppl_u::set, vector_s::suppl, TRUE, vsuppl_u::type, vector_s::ul, UL_DIV, UL_HMASK, UL_LMASK, vector_s::value, VTYPE_EXP, VTYPE_INDEX_EXP_VALH, VTYPE_INDEX_EXP_VALL, VTYPE_INDEX_MEM_MISC, VTYPE_INDEX_MEM_TOG01, VTYPE_INDEX_MEM_TOG10, VTYPE_INDEX_MEM_VALH, VTYPE_INDEX_MEM_VALL, VTYPE_INDEX_MEM_WR, VTYPE_INDEX_MEM_XHOLD, VTYPE_INDEX_SIG_MISC, VTYPE_INDEX_SIG_TOG01, VTYPE_INDEX_SIG_TOG10, VTYPE_INDEX_SIG_VALH, VTYPE_INDEX_SIG_VALL, VTYPE_INDEX_SIG_XHOLD, VTYPE_MEM, VTYPE_SIG, and VTYPE_VAL.

Referenced by expression_op_func__default(), expression_op_func__exponent(), expression_op_func__test_plusargs(), expression_op_func__value_plusargs(), vector_bitwise_and_op(), vector_bitwise_nand_op(), vector_bitwise_nor_op(), vector_bitwise_nxor_op(), vector_bitwise_or_op(), vector_bitwise_xor_op(), vector_from_int(), vector_from_uint64(), vector_op_add(), vector_op_arshift(), vector_op_ceq(), vector_op_clog2(), vector_op_cne(), vector_op_cxeq(), vector_op_czeq(), vector_op_divide(), vector_op_eq(), vector_op_expand(), vector_op_ge(), vector_op_gt(), vector_op_land(), vector_op_le(), vector_op_list(), vector_op_lor(), vector_op_lshift(), vector_op_lt(), vector_op_modulus(), vector_op_multiply(), vector_op_ne(), vector_op_negate(), vector_op_rshift(), vector_op_subtract(), vector_part_select_pull(), vector_part_select_push(), vector_set_to_x(), vector_set_value_ulong(), vector_unary_and(), vector_unary_inv(), vector_unary_nand(), vector_unary_nor(), vector_unary_not(), vector_unary_nxor(), vector_unary_or(), vector_unary_xor(), and vector_vcd_assign().

01553   { PROFILE(VECTOR_SET_COVERAGE_AND_ASSIGN);
01554 
01555   bool         changed = FALSE;          /* Set to TRUE if the assigned value has changed */
01556   unsigned int lindex  = UL_DIV(lsb);    /* Index of lowest array entry */
01557   unsigned int hindex  = UL_DIV(msb);    /* Index of highest array entry */
01558   ulong        lmask   = UL_LMASK(lsb);  /* Mask to be used in lower element */
01559   ulong        hmask   = UL_HMASK(msb);  /* Mask to be used in upper element */
01560   unsigned int i;                        /* Loop iterator */
01561   uint8        prev_set;                 /* Specifies if this vector value has previously been set */
01562 
01563   /* If the lindex and hindex are the same, set lmask to the AND of the high and low masks */
01564   if( lindex == hindex ) {
01565     lmask &= hmask;
01566   }
01567 
01568   switch( vec->suppl.part.type ) {
01569     case VTYPE_VAL :
01570       for( i=lindex; i<=hindex; i++ ) {
01571         ulong* tvall = &(vec->value.ul[i][VTYPE_INDEX_SIG_VALL]);
01572         ulong* tvalh = &(vec->value.ul[i][VTYPE_INDEX_SIG_VALH]);
01573         ulong  mask  = (i==lindex) ? lmask : (i==hindex ? hmask : UL_SET);
01574         *tvall = (*tvall & ~mask) | (scratchl[i] & mask);
01575         *tvalh = (*tvalh & ~mask) | (scratchh[i] & mask);
01576       }
01577       changed = TRUE;
01578       break;
01579     case VTYPE_SIG :
01580       prev_set = vec->suppl.part.set;
01581       for( i=lindex; i<=hindex; i++ ) {
01582         ulong* entry = vec->value.ul[i];
01583         ulong  mask  = (i==lindex) ? lmask : (i==hindex ? hmask : UL_SET);
01584         ulong  fvall = scratchl[i] & mask;
01585         ulong  fvalh = scratchh[i] & mask;
01586         ulong  tvall = entry[VTYPE_INDEX_SIG_VALL];
01587         ulong  tvalh = entry[VTYPE_INDEX_SIG_VALH];
01588         if( (fvall != (tvall & mask)) || (fvalh != (tvalh & mask)) ) {
01589           ulong tvalx = tvalh & ~tvall & entry[VTYPE_INDEX_SIG_MISC];
01590           ulong xval  = entry[VTYPE_INDEX_SIG_XHOLD];
01591           ulong xmask = mask & ~tvalh;
01592           if( prev_set == 1 ) {
01593             entry[VTYPE_INDEX_SIG_TOG01] |= ((~tvalh & ~tvall) | (tvalx & ~xval)) & (~fvalh &  fvall) & mask;
01594             entry[VTYPE_INDEX_SIG_TOG10] |= ((~tvalh &  tvall) | (tvalx &  xval)) & (~fvalh & ~fvall) & mask;
01595           }
01596           entry[VTYPE_INDEX_SIG_VALL]  = (tvall & ~mask)  | fvall;
01597           entry[VTYPE_INDEX_SIG_VALH]  = (tvalh & ~mask)  | fvalh;
01598           entry[VTYPE_INDEX_SIG_XHOLD] = (xval  & ~xmask) | (tvall & xmask);
01599           entry[VTYPE_INDEX_SIG_MISC] |= ~fvalh & mask;
01600           changed = TRUE;
01601         }
01602       }
01603       break;
01604     case VTYPE_MEM :
01605       for( i=lindex; i<=hindex; i++ ) {
01606         ulong* entry = vec->value.ul[i];
01607         ulong  mask  = (i==lindex) ? lmask : (i==hindex ? hmask : UL_SET);
01608         ulong  fvall = scratchl[i] & mask;
01609         ulong  fvalh = scratchh[i] & mask;
01610         ulong  tvall = entry[VTYPE_INDEX_MEM_VALL];
01611         ulong  tvalh = entry[VTYPE_INDEX_MEM_VALH];
01612         if( (fvall != (tvall & mask)) || (fvalh != (tvalh & mask)) ) {
01613           ulong tvalx = tvalh & ~tvall & entry[VTYPE_INDEX_MEM_MISC];
01614           ulong xval  = entry[VTYPE_INDEX_MEM_XHOLD];
01615           ulong xmask = mask & ~tvalh;
01616           entry[VTYPE_INDEX_MEM_TOG01] |= ((~tvalh & ~tvall) | (tvalx & ~xval)) & (~fvalh &  fvall) & mask;
01617           entry[VTYPE_INDEX_MEM_TOG10] |= ((~tvalh &  tvall) | (tvalx &  xval)) & (~fvalh & ~fvall) & mask;
01618           entry[VTYPE_INDEX_MEM_WR]    |= mask;
01619           entry[VTYPE_INDEX_MEM_VALL]   = (tvall & ~mask)  | fvall;
01620           entry[VTYPE_INDEX_MEM_VALH]   = (tvalh & ~mask)  | fvalh;
01621           entry[VTYPE_INDEX_MEM_XHOLD]  = (xval  & ~xmask) | (tvall & xmask);
01622           entry[VTYPE_INDEX_MEM_MISC]  |= ~fvalh & mask;
01623           changed = TRUE;
01624         }
01625       }
01626       break;
01627     case VTYPE_EXP :
01628       for( i=lindex; i<=hindex; i++ ) {
01629         ulong* entry = vec->value.ul[i];
01630         ulong  mask  = (i==lindex) ? lmask : (i==hindex ? hmask : UL_SET);
01631         ulong  fvall = scratchl[i] & mask;
01632         ulong  fvalh = scratchh[i] & mask;
01633         ulong  tvall = entry[VTYPE_INDEX_EXP_VALL];
01634         ulong  tvalh = entry[VTYPE_INDEX_EXP_VALH];
01635         if( (fvall != (tvall & mask)) || (fvalh != (tvalh & mask)) ) {
01636           entry[VTYPE_INDEX_EXP_VALL] = (tvall & ~mask) | fvall;
01637           entry[VTYPE_INDEX_EXP_VALH] = (tvalh & ~mask) | fvalh;
01638           changed = TRUE;
01639         }
01640       }
01641       break;
01642     default :  assert( 0 );  break;
01643   }
01644 
01645   PROFILE_END;
01646 
01647   return( changed );
01648 
01649 }

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

References vsuppl_u::data_type, vsuppl_u::part, PROFILE, PROFILE_END, vector_s::suppl, vector_s::ul, UL_SIZE, vector_s::value, VDATA_R32, VDATA_R64, VDATA_UL, VTYPE_INDEX_EXP_EVAL_A, VTYPE_INDEX_EXP_EVAL_B, VTYPE_INDEX_EXP_EVAL_C, VTYPE_INDEX_EXP_VALH, VTYPE_INDEX_EXP_VALL, and vector_s::width.

Referenced by expression_op_func__lor(), expression_op_func__nor(), expression_op_func__or(), and expression_op_func__or_a().

02217   { PROFILE(VECTOR_SET_OR_COMB_EVALS);
02218 
02219   switch( tgt->suppl.part.data_type ) {
02220     case VDATA_UL :
02221       {
02222         unsigned int i;
02223         unsigned int size  = UL_SIZE( tgt->width );
02224         unsigned int lsize = UL_SIZE( left->width );
02225         unsigned int rsize = UL_SIZE( right->width );
02226 
02227         for( i=0; i<size; i++ ) {
02228           ulong* val    = tgt->value.ul[i];
02229           ulong* lval   = (i < lsize) ? left->value.ul[i]  : 0;
02230           ulong* rval   = (i < rsize) ? right->value.ul[i] : 0;
02231           ulong  lvall  = (i < lsize) ?  lval[VTYPE_INDEX_EXP_VALL] : 0;
02232           ulong  nlvalh = (i < lsize) ? ~lval[VTYPE_INDEX_EXP_VALH] : UL_SET;
02233           ulong  rvall  = (i < rsize) ?  rval[VTYPE_INDEX_EXP_VALL] : 0;
02234           ulong  nrvalh = (i < rsize) ? ~rval[VTYPE_INDEX_EXP_VALH] : UL_SET;
02235 
02236           val[VTYPE_INDEX_EXP_EVAL_A] |= nlvalh & lvall;
02237           val[VTYPE_INDEX_EXP_EVAL_B] |= nrvalh & rvall;
02238           val[VTYPE_INDEX_EXP_EVAL_C] |= nlvalh & nrvalh & ~lvall & ~rvall;
02239         }
02240       }
02241       break;
02242     case VDATA_R64 :
02243     case VDATA_R32 :
02244       break;
02245     default :  assert( 0 );  break;
02246   }
02247 
02248   PROFILE_END;
02249 
02250 }

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

References vsuppl_u::data_type, vsuppl_u::part, PROFILE, PROFILE_END, vector_s::suppl, vector_s::ul, UL_SIZE, vector_s::value, VDATA_R32, VDATA_R64, VDATA_UL, VTYPE_INDEX_EXP_EVAL_A, VTYPE_INDEX_EXP_EVAL_B, VTYPE_INDEX_EXP_EVAL_C, VTYPE_INDEX_EXP_EVAL_D, VTYPE_INDEX_EXP_VALH, VTYPE_INDEX_EXP_VALL, and vector_s::width.

Referenced by expression_op_func__add(), expression_op_func__add_a(), expression_op_func__nxor(), expression_op_func__sub_a(), expression_op_func__subtract(), expression_op_func__xor(), and expression_op_func__xor_a().

02261   { PROFILE(VECTOR_SET_OTHER_COMB_EVALS);
02262 
02263   switch( tgt->suppl.part.data_type ) {
02264     case VDATA_UL :
02265       {
02266         unsigned int i;
02267         unsigned int size  = UL_SIZE( tgt->width );
02268         unsigned int lsize = UL_SIZE( left->width );
02269         unsigned int rsize = UL_SIZE( right->width );
02270 
02271         for( i=0; i<size; i++ ) { 
02272           ulong* val    = tgt->value.ul[i];
02273           ulong* lval   = (i < lsize) ? left->value.ul[i]  : 0;
02274           ulong* rval   = (i < rsize) ? right->value.ul[i] : 0;
02275           ulong  lvall  = (i < lsize) ?  lval[VTYPE_INDEX_EXP_VALL] : 0;
02276           ulong  nlvalh = (i < lsize) ? ~lval[VTYPE_INDEX_EXP_VALH] : UL_SET;
02277           ulong  rvall  = (i < rsize) ?  rval[VTYPE_INDEX_EXP_VALL] : 0;
02278           ulong  nrvalh = (i < rsize) ? ~rval[VTYPE_INDEX_EXP_VALH] : UL_SET;
02279           ulong  nvalh  = nlvalh & nrvalh;
02280 
02281           val[VTYPE_INDEX_EXP_EVAL_A] |= nvalh & ~lvall & ~rvall;
02282           val[VTYPE_INDEX_EXP_EVAL_B] |= nvalh & ~lvall &  rvall;
02283           val[VTYPE_INDEX_EXP_EVAL_C] |= nvalh &  lvall & ~rvall;
02284           val[VTYPE_INDEX_EXP_EVAL_D] |= nvalh &  lvall &  rvall;
02285         }
02286       }
02287       break;
02288     case VDATA_R64 :
02289     case VDATA_R32 :
02290       break;
02291     default :  assert( 0 );  break;
02292   }
02293 
02294   PROFILE_END;
02295   
02296 } 

static void vector_set_static ( vector vec,
char *  str,
unsigned int  bits_per_char 
) [static]

Iterates through string str starting at the left-most character, calculates the int value of the character and sets the appropriate number of bits in the specified vector locations.

Parameters:
vec Pointer to vector to add static value to
str Value string to add
bits_per_char Number of bits necessary to store a value character (1, 3, or 4)

References vsuppl_u::data_type, vsuppl_u::part, PROFILE, PROFILE_END, vector_s::suppl, vector_s::ul, UL_DIV, UL_HMASK, UL_LMASK, UL_MOD, UL_SIZE, vector_s::value, VDATA_UL, VTYPE_INDEX_VAL_VALH, VTYPE_INDEX_VAL_VALL, and vector_s::width.

Referenced by vector_from_string().

02709   { PROFILE(VECTOR_SET_STATIC);
02710 
02711   char*        ptr       = str + (strlen( str ) - 1);  /* Pointer to current character evaluating */
02712   unsigned int pos       = 0;                          /* Current bit position in vector */
02713   unsigned int i;                                      /* Loop iterator */
02714   int          data_type = vec->suppl.part.data_type;  /* Copy of data type for performance reasons */
02715 
02716   while( ptr >= str ) {
02717     if( *ptr != '_' ) {
02718       if( (*ptr == 'x') || (*ptr == 'X') ) {
02719         switch( data_type ) {
02720           case VDATA_UL :
02721             for( i=0; i<bits_per_char; i++ ) {
02722               if( (i + pos) < vec->width ) {
02723                 vec->value.ul[UL_DIV(i+pos)][VTYPE_INDEX_VAL_VALH] |= ((ulong)1 << UL_MOD(i+pos));
02724               }
02725             }
02726             break;
02727           default :  assert( 0 );  break;
02728         }
02729       } else if( (*ptr == 'z') || (*ptr == 'Z') || (*ptr == '?') ) {
02730         switch( data_type ) {
02731           case VDATA_UL :
02732             for( i=0; i<bits_per_char; i++ ) {
02733               if( (i + pos) < vec->width ) {
02734                 unsigned int index = UL_DIV(i + pos);
02735                 ulong        value = ((ulong)1 << UL_MOD(i + pos));
02736                 vec->value.ul[index][VTYPE_INDEX_VAL_VALL] |= value;
02737                 vec->value.ul[index][VTYPE_INDEX_VAL_VALH] |= value;
02738               }
02739             }
02740             break;
02741           default :  assert( 0 );  break;
02742         }
02743       } else {
02744         ulong val;
02745         if( (*ptr >= 'a') && (*ptr <= 'f') ) {
02746           val = (*ptr - 'a') + 10;
02747         } else if( (*ptr >= 'A') && (*ptr <= 'F') ) {
02748           val = (*ptr - 'A') + 10;
02749         } else {
02750           assert( (*ptr >= '0') && (*ptr <= '9') );
02751           val = *ptr - '0';
02752         }
02753         switch( data_type ) {
02754           case VDATA_UL :
02755             for( i=0; i<bits_per_char; i++ ) {
02756               if( (i + pos) < vec->width ) {
02757                 vec->value.ul[UL_DIV(i+pos)][VTYPE_INDEX_VAL_VALL] |= ((val >> i) & 0x1) << UL_MOD(i + pos);
02758               }
02759             }
02760             break;
02761           default :  assert( 0 );  break;
02762         }
02763       }
02764       pos = pos + bits_per_char;
02765     }
02766     ptr--;
02767   }
02768 
02769   /* Bit-fill, if necessary */
02770   if( pos < vec->width ) {
02771     switch( data_type ) {
02772       case VDATA_UL :
02773         {
02774           ulong hfill = (vec->value.ul[UL_DIV(pos)][VTYPE_INDEX_VAL_VALH] & ((ulong)1 << UL_MOD(pos - 1))) ? UL_SET : 0x0;
02775           ulong lfill = (vec->value.ul[UL_DIV(pos)][VTYPE_INDEX_VAL_VALL] & ((ulong)1 << UL_MOD(pos - 1))) ? hfill  : 0x0;
02776           ulong lmask = UL_LMASK(pos);
02777           ulong hmask = UL_HMASK(vec->width - 1);
02778           if( UL_DIV(pos) == UL_DIV(vec->width - 1) ) {
02779             ulong mask = lmask & hmask;
02780             vec->value.ul[UL_DIV(pos)][VTYPE_INDEX_VAL_VALL] |= lfill & mask;
02781             vec->value.ul[UL_DIV(pos)][VTYPE_INDEX_VAL_VALH] |= hfill & mask;
02782           } else {
02783             vec->value.ul[UL_DIV(pos)][VTYPE_INDEX_VAL_VALL] |= lfill & lmask;
02784             vec->value.ul[UL_DIV(pos)][VTYPE_INDEX_VAL_VALH] |= hfill & lmask;
02785             for( i=(UL_DIV(pos) + 1); i<(UL_SIZE( vec->width ) - 1); i++ ) {
02786               vec->value.ul[i][VTYPE_INDEX_VAL_VALL] = lfill;
02787               vec->value.ul[i][VTYPE_INDEX_VAL_VALH] = hfill;
02788             }
02789             vec->value.ul[i][VTYPE_INDEX_VAL_VALL] = lfill & hmask;
02790             vec->value.ul[i][VTYPE_INDEX_VAL_VALH] = hfill & hmask;
02791           }
02792         }
02793         break;
02794       default :  assert( 0 );
02795     }
02796   }
02797 
02798   PROFILE_END;
02799 
02800 }

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

References vsuppl_u::data_type, FALSE, MAX_BIT_WIDTH, vsuppl_u::part, PROFILE, PROFILE_END, vector_s::suppl, UL_DIV, UL_HMASK, UL_SIZE, VDATA_R32, VDATA_R64, VDATA_UL, vector_set_coverage_and_assign_ulong(), and vector_s::width.

Referenced by expression_op_func__cond_sel(), expression_op_func__exponent(), vector_op_add(), vector_op_arshift(), vector_op_clog2(), vector_op_divide(), vector_op_eq(), vector_op_ge(), vector_op_gt(), vector_op_le(), vector_op_lshift(), vector_op_lt(), vector_op_modulus(), vector_op_multiply(), vector_op_ne(), vector_op_negate(), vector_op_rshift(), and vector_op_subtract().

02369   { PROFILE(VECTOR_SET_TO_X);
02370 
02371   bool retval;  /* Return value for this function */
02372 
02373   switch( vec->suppl.part.data_type ) {
02374     case VDATA_UL:
02375       {
02376         ulong        scratchl[UL_DIV(MAX_BIT_WIDTH)];
02377         ulong        scratchh[UL_DIV(MAX_BIT_WIDTH)];
02378         ulong        end_mask = UL_HMASK(vec->width - 1);
02379         unsigned int i;
02380         for( i=0; i<(UL_SIZE(vec->width) - 1); i++ ) {
02381           scratchl[i] = 0;
02382           scratchh[i] = UL_SET;
02383         }
02384         scratchl[i] = 0;
02385         scratchh[i] = end_mask;
02386         retval = vector_set_coverage_and_assign_ulong( vec, scratchl, scratchh, 0, (vec->width - 1) );
02387       }
02388       break;
02389     case VDATA_R32 :
02390     case VDATA_R64 :
02391       retval = FALSE;
02392       break;
02393     default :  assert( 0 );  break;
02394   }
02395 
02396   PROFILE_END;
02397 
02398   return( retval );
02399 
02400 }

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

References vsuppl_u::data_type, vsuppl_u::part, PROFILE, PROFILE_END, vector_s::suppl, vector_s::ul, UL_SIZE, vector_s::value, VDATA_R32, VDATA_R64, VDATA_UL, VTYPE_INDEX_EXP_EVAL_A, VTYPE_INDEX_EXP_EVAL_B, VTYPE_INDEX_EXP_VALH, VTYPE_INDEX_EXP_VALL, and vector_s::width.

Referenced by expression_op_func__arshift(), expression_op_func__arshift_a(), expression_op_func__case(), expression_op_func__casex(), expression_op_func__casez(), expression_op_func__ceq(), expression_op_func__cne(), expression_op_func__concat(), expression_op_func__cond(), expression_op_func__cond_sel(), expression_op_func__default(), expression_op_func__divide(), expression_op_func__divide_a(), expression_op_func__eq(), expression_op_func__expand(), expression_op_func__exponent(), expression_op_func__func_call(), expression_op_func__ge(), expression_op_func__gt(), expression_op_func__le(), expression_op_func__list(), expression_op_func__lshift(), expression_op_func__lshift_a(), expression_op_func__lt(), expression_op_func__mod(), expression_op_func__mod_a(), expression_op_func__multiply(), expression_op_func__multiply_a(), expression_op_func__ne(), expression_op_func__negate(), expression_op_func__repeat(), expression_op_func__rshift(), expression_op_func__rshift_a(), expression_op_func__task_call(), expression_op_func__test_plusargs(), expression_op_func__uand(), expression_op_func__uinv(), expression_op_func__unand(), expression_op_func__unor(), expression_op_func__unot(), expression_op_func__unxor(), expression_op_func__uor(), expression_op_func__uxor(), and expression_op_func__value_plusargs().

02138   { PROFILE(VECTOR_SET_UNARY_EVALS);
02139 
02140   switch( vec->suppl.part.data_type ) {
02141     case VDATA_UL :
02142       {
02143         unsigned int i;
02144         unsigned int size = UL_SIZE(vec->width);
02145         for( i=0; i<size; i++ ) {
02146           ulong* entry = vec->value.ul[i];
02147           ulong  lval  =  entry[VTYPE_INDEX_EXP_VALL];
02148           ulong  nhval = ~entry[VTYPE_INDEX_EXP_VALH];
02149           entry[VTYPE_INDEX_EXP_EVAL_A] |= nhval & ~lval;
02150           entry[VTYPE_INDEX_EXP_EVAL_B] |= nhval &  lval;
02151         }
02152       }
02153       break;
02154     case VDATA_R64 :
02155     case VDATA_R32 :
02156       break;
02157     default :  assert( 0 );  break;
02158   }
02159 
02160   PROFILE_END;
02161 
02162 }

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

References FALSE, vsuppl_u::is_2state, MAX_BIT_WIDTH, vsuppl_u::part, PROFILE, PROFILE_END, vector_s::suppl, UL_DIV, vector_set_coverage_and_assign_ulong(), VTYPE_INDEX_VAL_VALH, VTYPE_INDEX_VAL_VALL, and vector_s::width.

Referenced by enumerate_resolve(), expression_op_func__concat(), expression_op_func__cond(), expression_op_func__cond_sel(), expression_op_func__dly_op(), expression_op_func__func_call(), expression_op_func__idec(), expression_op_func__iinc(), expression_op_func__passign(), expression_op_func__pdec(), expression_op_func__pinc(), expression_op_func__sassign(), and inst_parm_add().

01962   { PROFILE(VECTOR_SET_VALUE);
01963 
01964   bool  retval = FALSE;                   /* Return value for this function */
01965   int   i;                                /* Loop iterator */
01966   int   v2st;                             /* Value to AND with from value bit if the target is a 2-state value */
01967   ulong scratchl[UL_DIV(MAX_BIT_WIDTH)];  /* Lower scratch array */
01968   ulong scratchh[UL_DIV(MAX_BIT_WIDTH)];  /* Upper scratch array */
01969 
01970   assert( vec != NULL );
01971 
01972   /* Adjust the width if it exceeds our width */
01973   if( vec->width < width ) {
01974     width = vec->width;
01975   }
01976 
01977   /* Get some information from the vector */
01978   v2st = vec->suppl.part.is_2state << 1;
01979 
01980   /* Set upper bits to 0 */
01981   for( i=UL_DIV(vec->width - 1); (unsigned int)i>UL_DIV(width - 1); i-- ) {
01982     scratchl[i] = 0;
01983     scratchh[i] = 0;
01984   }
01985 
01986   /* Calculate the new values and place them in the scratch arrays */
01987   for( ; i>=0; i-- ) {
01988     scratchl[i] = v2st ? (~value[i][VTYPE_INDEX_VAL_VALH] & value[i][VTYPE_INDEX_VAL_VALL]) : value[i][VTYPE_INDEX_VAL_VALL];
01989     scratchh[i] = v2st ? 0 : value[i][VTYPE_INDEX_VAL_VALH];
01990   }
01991 
01992   /* Calculate the coverage and perform the actual assignment */
01993   retval = vector_set_coverage_and_assign_ulong( vec, scratchl, scratchh, 0, (vec->width - 1) );
01994 
01995   PROFILE_END;
01996 
01997   return( retval );
01998 
01999 }

static void vector_sign_extend_ulong ( ulong vall,
ulong valh,
ulong  signl,
ulong  signh,
int  last,
int  width 
) [static]

Performs signedness bit fill for the given value arrays.

Parameters:
vall Pointer to lower value array to bit fill
valh Pointer to upper value array to bit fill
signl Sign-extension value for the lower value (call vector_get_sign_extend_vector_ulong)
signh Sign-extension value for the upper value (call vector_get_sign_extend_vector_ulong)
last Index of last bit in vall/h to evalulate for bit fill
width Width of vall/h to fill

References PROFILE, PROFILE_END, UL_DIV, UL_LMASK, UL_MOD, and UL_SIZE.

Referenced by vector_from_int(), vector_op_arshift(), and vector_part_select_push().

01680   { PROFILE(VECTOR_SIGN_EXTEND_ULONG);
01681 
01682   /* If any special sign-extension is necessary, handle it now */
01683   if( (signl != 0) || (signh != 0) ) {
01684     unsigned int i    = UL_DIV(last + 1);
01685     unsigned int size = UL_SIZE( width );
01686     if( UL_MOD(last + 1) == 0 ) {
01687       vall[i] = signl;
01688       valh[i] = signh;
01689     } else {
01690       ulong fmask = UL_LMASK(last + 1);
01691       vall[i] |= signl & fmask;
01692       valh[i] |= signh & fmask;
01693     }
01694     for( i++; i<size; i++ ) {
01695       vall[i] = signl;
01696       valh[i] = signh;
01697     }
01698   }
01699 
01700   PROFILE_END;
01701 
01702 }

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

References vsuppl_u::data_type, vsuppl_u::is_signed, vsuppl_u::part, PROFILE, PROFILE_END, vector_s::r32, vector_s::r64, vector_s::suppl, vector_s::ul, rv32_s::val, rv64_s::val, vector_s::value, VDATA_R32, VDATA_R64, VDATA_UL, VTYPE_INDEX_VAL_VALL, and vector_s::width.

Referenced by codegen_gen_expr(), combination_underline_tree(), enumerate_resolve(), expression_assign(), expression_create(), expression_op_func__exponent(), expression_op_func__itor(), expression_op_func__mbit(), expression_op_func__mbit_neg(), expression_op_func__mbit_pos(), expression_op_func__random(), expression_op_func__repeat(), expression_op_func__sbit(), expression_op_func__srandom(), expression_op_func__urandom(), expression_resize(), expression_set_value(), gen_item_resolve(), inst_parm_add(), param_set_sig_size(), race_check_one_block_assignment(), static_expr_calc_lsb_and_width_post(), vector_op_arshift(), vector_op_expand(), vector_op_lshift(), vector_op_rshift(), and vector_to_string().

02411   { PROFILE(VECTOR_TO_INT);
02412 
02413   int          retval;  /* Integer value returned to calling function */
02414   unsigned int width = (vec->width > (sizeof( int ) * 8)) ? (sizeof( int ) * 8) : vec->width;
02415 
02416   assert( width > 0 );
02417 
02418   switch( vec->suppl.part.data_type ) {
02419     case VDATA_UL  :  retval = vec->value.ul[0][VTYPE_INDEX_VAL_VALL];  break;
02420     case VDATA_R64 :  retval = (int)round( vec->value.r64->val );       break;
02421     case VDATA_R32 :  retval = (int)roundf( vec->value.r32->val );       break;
02422     default        :  assert( 0 );  break;
02423   }
02424 
02425   /* If the vector is signed, sign-extend the integer */
02426   if( (vec->suppl.part.is_signed == 1) && (width < (sizeof( int ) * 8)) ) {
02427     /*@-shiftimplementation@*/
02428     retval |= ((UL_SET * ((retval >> (width - 1)) & 0x1)) << width);
02429     /*@=shiftimplementation@*/
02430   }
02431 
02432   PROFILE_END;
02433 
02434   return( retval );
02435 
02436 }

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

References vsuppl_u::data_type, vsuppl_u::part, PROFILE, PROFILE_END, vector_s::r32, vector_s::r64, vector_s::suppl, rv32_s::val, rv64_s::val, vector_s::value, VDATA_R32, VDATA_R64, VDATA_UL, and vector_to_uint64().

Referenced by expression_op_func__assign(), vector_op_add(), vector_op_divide(), vector_op_eq(), vector_op_ge(), vector_op_gt(), vector_op_le(), vector_op_lt(), vector_op_multiply(), vector_op_ne(), vector_op_negate(), and vector_op_subtract().

02488   { PROFILE(VECTOR_TO_REAL64);
02489 
02490   real64 retval;  /* Return value for this function */
02491 
02492   switch( vec->suppl.part.data_type ) {
02493     case VDATA_UL  :  retval = (double)vector_to_uint64( vec );  break;
02494     case VDATA_R64 :  retval = vec->value.r64->val;              break;
02495     case VDATA_R32 :  retval = (double)vec->value.r32->val;      break;
02496     default        :  assert( 0 );                               break;
02497   }
02498 
02499   PROFILE_END;
02500 
02501   return( retval );
02502 
02503 }

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

References vsuppl_u::data_type, sim_time_s::full, sim_time_s::hi, sim_time_s::lo, vsuppl_u::part, PROFILE, PROFILE_END, vector_s::r32, vector_s::r64, vector_s::suppl, vector_s::ul, UL_SIZE, rv32_s::val, rv64_s::val, vector_s::value, VDATA_R32, VDATA_R64, VDATA_UL, VTYPE_INDEX_VAL_VALH, VTYPE_INDEX_VAL_VALL, and vector_s::width.

Referenced by expression_op_func__delay().

02514   { PROFILE(VECTOR_TO_SIM_TIME);
02515 
02516   union {
02517     struct {
02518       uint32 lo;
02519       uint32 hi;
02520     } u32;
02521     uint64 full;
02522   } time_u = {0};
02523 
02524   /* Calculate the full (64-bit) time value */
02525   switch( vec->suppl.part.data_type ) {
02526     case VDATA_UL  :
02527       assert( vec->value.ul[0][VTYPE_INDEX_VAL_VALH] == 0 );
02528 #if SIZEOF_LONG == 4
02529       time_u.u32.lo = vec->value.ul[0][VTYPE_INDEX_VAL_VALL];
02530       if( UL_SIZE( vec->width ) > 1 ) {
02531         assert( vec->value.ul[1][VTYPE_INDEX_VAL_VALH] == 0 );
02532         time_u.u32.hi = vec->value.ul[1][VTYPE_INDEX_VAL_VALL];
02533       }
02534 #elif SIZEOF_LONG == 8
02535       time_u.full = vec->value.ul[0][VTYPE_INDEX_VAL_VALL];
02536 #else
02537 #error "Unsupported long size"
02538 #endif
02539       time_u.full *= scale;
02540       break;
02541     case VDATA_R64 :  time_u.full = (uint64)round( vec->value.r64->val * scale );  break;
02542     case VDATA_R32 :  time_u.full = (uint64)roundf( vec->value.r32->val * scale );  break;
02543     default        :  assert( 0 );  break;
02544   }
02545 
02546   time->lo   = time_u.u32.lo;
02547   time->hi   = time_u.u32.hi;
02548   time->full = time_u.full;
02549 
02550   PROFILE_END;
02551 
02552 }

char* vector_to_string ( vector vec,
int  base,
bool  show_all,
unsigned int  width 
)

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)
width If set to a value greater than 0, uses this width to output instead of the supplied vector

References BINARY, vsuppl_u::data_type, DECIMAL, free_safe, HEXIDECIMAL, vsuppl_u::is_signed, malloc_safe, OCTAL, vsuppl_u::part, PROFILE, PROFILE_END, QSTRING, vector_s::r32, vector_s::r64, rv32_s::str, rv64_s::str, strdup_safe, vector_s::suppl, vector_s::ul, UL_DIV, UL_MOD, UL_SIZE, rv32_s::val, rv64_s::val, vector_s::value, VDATA_R32, VDATA_R64, VDATA_UL, vector_to_int(), VTYPE_INDEX_VAL_VALH, VTYPE_INDEX_VAL_VALL, and vector_s::width.

Referenced by arc_display(), arc_get_states(), arc_get_transitions(), codegen_gen_expr(), combination_underline_tree(), expression_op_func__test_plusargs(), expression_op_func__value_plusargs(), fsm_arg_parse_attr(), fsm_arg_parse_trans(), and ovl_get_coverage_point().

02814   { PROFILE(VECTOR_TO_STRING);
02815 
02816   char* str = NULL;  /* Pointer to allocated string */
02817 
02818   /* Calculate the width to output */
02819   if( (width == 0) || (vec->width < width) ) {
02820     width = vec->width;
02821   }
02822 
02823   if( base == QSTRING ) {
02824 
02825     int i, j;
02826     int vec_size = ((width - 1) >> 3) + 2;
02827     int pos      = 0;
02828 
02829     /* Allocate memory for string from the heap */
02830     str = (char*)malloc_safe( vec_size );
02831 
02832     switch( vec->suppl.part.data_type ) {
02833       case VDATA_UL :
02834         {
02835           int offset = (((width >> 3) & (UL_MOD_VAL >> 3)) == 0) ? SIZEOF_LONG : ((width >> 3) & (UL_MOD_VAL >> 3));
02836           for( i=UL_SIZE(width); i--; ) {
02837             ulong val = vec->value.ul[i][VTYPE_INDEX_VAL_VALL]; 
02838             for( j=(offset - 1); j>=0; j-- ) {
02839               str[pos] = (val >> ((unsigned int)j * 8)) & 0xff;
02840               pos++;
02841             }
02842             offset = SIZEOF_LONG;
02843           }
02844         }
02845         break;
02846       case VDATA_R64 :
02847         assert( 0 );
02848         break;
02849       default :  assert( 0 );  break;
02850     }
02851 
02852     str[pos] = '\0';
02853 
02854   } else if( base == DECIMAL ) {
02855 
02856     char         width_str[20];
02857     unsigned int rv = snprintf( width_str, 20, "%d", vector_to_int( vec ) );
02858     assert( rv < 20 );
02859     str = strdup_safe( width_str );
02860 
02861   } else if( vec->suppl.part.data_type == VDATA_R64 ) {
02862 
02863     if( vec->value.r64->str != NULL ) {
02864       str = strdup_safe( vec->value.r64->str );
02865     } else {
02866       char         width_str[100];
02867       unsigned int rv = snprintf( width_str, 100, "%f", vec->value.r64->val );
02868       assert( rv < 100 );
02869       str = strdup_safe( width_str );
02870     }
02871 
02872   } else if( vec->suppl.part.data_type == VDATA_R32 ) {
02873 
02874     if( vec->value.r32->str != NULL ) {
02875       str = strdup_safe( vec->value.r32->str );
02876     } else {
02877       char         width_str[30];
02878       unsigned int rv = snprintf( width_str, 30, "%f", vec->value.r32->val );
02879       assert( rv < 30 );
02880       str = strdup_safe( width_str );
02881     }
02882  
02883   } else {
02884 
02885     unsigned int rv;
02886     char*        tmp;
02887     unsigned int str_size;
02888     unsigned int group     = 1;
02889     char         type_char = 'b';
02890     char         width_str[20];
02891     int          vec_size  = ((width - 1) >> 3) + 2;
02892     int          pos       = 0;
02893 
02894     switch( base ) {
02895       case BINARY :  
02896         vec_size  = (width + 1);
02897         group     = 1;
02898         type_char = 'b';
02899         break;
02900       case OCTAL :  
02901         vec_size  = ((width % 3) == 0) ? ((width / 3) + 1)
02902                                        : ((width / 3) + 2);
02903         group     = 3;
02904         type_char = 'o';
02905         break;
02906       case HEXIDECIMAL :  
02907         vec_size  = ((width % 4) == 0) ? ((width / 4) + 1)
02908                                        : ((width / 4) + 2);
02909         group     = 4;
02910         type_char = 'h';
02911         break;
02912       default          :  
02913         assert( (base == BINARY) || (base == OCTAL)  || (base == HEXIDECIMAL) );
02914         /*@-unreachable@*/
02915         break;
02916         /*@=unreachable@*/
02917     }
02918 
02919     tmp = (char*)malloc_safe( vec_size );
02920 
02921     switch( vec->suppl.part.data_type ) {
02922       case VDATA_UL :
02923         {
02924           ulong value = 0;
02925           int    i;
02926           for( i=(width - 1); i>=0; i-- ) {
02927             ulong* entry = vec->value.ul[UL_DIV(i)];
02928             if( ((entry[VTYPE_INDEX_VAL_VALH] >> UL_MOD(i)) & 0x1) == 1 ) {
02929               value = ((entry[VTYPE_INDEX_VAL_VALL] >> UL_MOD(i)) & 0x1) + 16;
02930             } else if( ((entry[VTYPE_INDEX_VAL_VALL] >> UL_MOD(i)) & 0x1) == 1 ) {
02931               value = (value < 16) ? (((ulong)1 << (UL_MOD(i) % group)) | value) : value;
02932             }
02933             assert( pos < vec_size );
02934             if( (i % group) == 0 ) {
02935               switch( value ) {
02936                 case 0x0 :  if( (pos > 0) || (i == 0) || show_all ) { tmp[pos] = '0';  pos++; }  break;
02937                 case 0x1 :  tmp[pos] = '1';  pos++;  break;
02938                 case 0x2 :  tmp[pos] = '2';  pos++;  break;
02939                 case 0x3 :  tmp[pos] = '3';  pos++;  break;
02940                 case 0x4 :  tmp[pos] = '4';  pos++;  break;
02941                 case 0x5 :  tmp[pos] = '5';  pos++;  break;
02942                 case 0x6 :  tmp[pos] = '6';  pos++;  break;
02943                 case 0x7 :  tmp[pos] = '7';  pos++;  break;
02944                 case 0x8 :  tmp[pos] = '8';  pos++;  break;
02945                 case 0x9 :  tmp[pos] = '9';  pos++;  break;
02946                 case 0xa :  tmp[pos] = 'A';  pos++;  break;
02947                 case 0xb :  tmp[pos] = 'B';  pos++;  break;
02948                 case 0xc :  tmp[pos] = 'C';  pos++;  break;
02949                 case 0xd :  tmp[pos] = 'D';  pos++;  break;
02950                 case 0xe :  tmp[pos] = 'E';  pos++;  break;
02951                 case 0xf :  tmp[pos] = 'F';  pos++;  break;
02952                 case 16  :  tmp[pos] = 'X';  pos++;  break;
02953                 case 17  :  tmp[pos] = 'Z';  pos++;  break;
02954                 default  :  
02955                   /* Value in vector_to_string exceeds allowed limit */
02956                   assert( value <= 17 );
02957                   /*@-unreachable@*/
02958                   break;
02959                   /*@=unreachable@*/
02960               }
02961               value = 0;
02962             }
02963           }
02964         }
02965         break;
02966       default :  assert( 0 );  break;
02967     }
02968 
02969     tmp[pos] = '\0';
02970 
02971     rv = snprintf( width_str, 20, "%u", width );
02972     assert( rv < 20 );
02973     str_size = strlen( width_str ) + 2 + strlen( tmp ) + 1 + vec->suppl.part.is_signed;
02974     str      = (char*)malloc_safe( str_size );
02975     if( vec->suppl.part.is_signed == 0 ) {
02976       rv = snprintf( str, str_size, "%u'%c%s", width, type_char, tmp );
02977     } else {
02978       rv = snprintf( str, str_size, "%u's%c%s", width, type_char, tmp );
02979     }
02980     assert( rv < str_size );
02981 
02982     free_safe( tmp, vec_size );
02983 
02984   }
02985 
02986   PROFILE_END;
02987 
02988   return( str );
02989 
02990 }

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

References vsuppl_u::data_type, vsuppl_u::is_signed, vsuppl_u::part, PROFILE, PROFILE_END, vector_s::r32, vector_s::r64, vector_s::suppl, vector_s::ul, rv32_s::val, rv64_s::val, vector_s::value, VDATA_R32, VDATA_R64, VDATA_UL, VTYPE_INDEX_VAL_VALL, and vector_s::width.

Referenced by expression_op_func__bitstoreal(), expression_op_func__bitstoshortreal(), expression_op_func__cond_sel(), expression_op_func__urandom_range(), vector_op_clog2(), and vector_to_real64().

02447   { PROFILE(VECTOR_TO_UINT64);
02448 
02449   uint64 retval = 0;   /* 64-bit integer value returned to calling function */
02450 
02451   switch( vec->suppl.part.data_type ) {
02452     case VDATA_UL :
02453       if( (vec->width > 32) && (sizeof( ulong ) == 4) ) {
02454         retval = ((uint64)vec->value.ul[1][VTYPE_INDEX_VAL_VALL] << 32) | (uint64)vec->value.ul[0][VTYPE_INDEX_VAL_VALL];
02455       } else {
02456         retval = (uint64)vec->value.ul[0][VTYPE_INDEX_VAL_VALL];
02457       }
02458       break;
02459     case VDATA_R64 :
02460       retval = (uint64)round( vec->value.r64->val );
02461       break;
02462     case VDATA_R32 :
02463       retval = (uint64)roundf( vec->value.r32->val );
02464       break;
02465     default :  assert( 0 );  break;
02466   }
02467 
02468   /* If the vector is signed, sign-extend the integer */
02469   if( vec->suppl.part.is_signed == 1 ) {
02470     unsigned int width = (vec->width > 64) ? 64 : vec->width;
02471     retval |= (UINT64(0xffffffffffffffff) * ((retval >> (width - 1)) & 0x1)) << width;
02472   }
02473 
02474   PROFILE_END;
02475 
02476   return( retval );
02477 
02478 }

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

References vsuppl_u::data_type, vsuppl_u::part, PROFILE, PROFILE_END, vector_s::suppl, vsuppl_u::type, vector_s::ul, UL_SIZE, vector_s::value, VDATA_R64, VDATA_UL, VTYPE_INDEX_SIG_TOG01, VTYPE_INDEX_SIG_TOG10, VTYPE_MEM, VTYPE_SIG, and vector_s::width.

Referenced by exclude_sig_assign_and_recalc(), memory_display_memory(), memory_display_verbose(), memory_get_mem_coverage(), memory_get_stat(), toggle_collect(), toggle_display_verbose(), and toggle_get_stats().

01419   { PROFILE(VECTOR_TOGGLE_COUNT);
01420 
01421   if( (vec->suppl.part.type == VTYPE_SIG) || (vec->suppl.part.type == VTYPE_MEM) ) {
01422 
01423     unsigned int i, j;
01424 
01425     switch( vec->suppl.part.data_type ) {
01426       case VDATA_UL :
01427         for( i=0; i<UL_SIZE(vec->width); i++ ) {
01428           for( j=0; j<UL_BITS; j++ ) {
01429             *tog01_cnt += ((vec->value.ul[i][VTYPE_INDEX_SIG_TOG01] >> j) & 0x1);
01430             *tog10_cnt += ((vec->value.ul[i][VTYPE_INDEX_SIG_TOG10] >> j) & 0x1);
01431           }
01432         }
01433         break;
01434       case VDATA_R64 :
01435         break;
01436       default :  assert( 0 );  break;
01437     }
01438 
01439   }
01440 
01441   PROFILE_END;
01442 
01443 }

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

References vsuppl_u::data_type, vsuppl_u::part, PROFILE, PROFILE_END, vector_s::suppl, vector_s::ul, UL_HMASK, UL_SIZE, vector_s::value, VDATA_UL, vector_set_coverage_and_assign_ulong(), VTYPE_INDEX_VAL_VALH, VTYPE_INDEX_VAL_VALL, and vector_s::width.

Referenced by expression_op_func__uand().

04829   { PROFILE(VECTOR_UNARY_AND);
04830 
04831   bool retval;  /* Return value for this function */
04832 
04833   switch( tgt->suppl.part.data_type ) {
04834     case VDATA_UL :
04835       {
04836         unsigned int i;
04837         unsigned int ssize = UL_SIZE( src->width );
04838         ulong        valh  = 0;
04839         ulong        vall  = 1;
04840         ulong        lmask = UL_HMASK(src->width - 1);
04841         for( i=0; i<(ssize-1); i++ ) {
04842           valh |= (src->value.ul[i][VTYPE_INDEX_VAL_VALH] != 0) ? 1 : 0;
04843           vall &= ~valh & ((src->value.ul[i][VTYPE_INDEX_VAL_VALL] == UL_SET) ? 1 : 0);
04844         }
04845         valh |= (src->value.ul[i][VTYPE_INDEX_VAL_VALH] != 0) ? 1 : 0;
04846         vall &= ~valh & ((src->value.ul[i][VTYPE_INDEX_VAL_VALL] == lmask) ? 1 : 0);
04847         retval = vector_set_coverage_and_assign_ulong( tgt, &vall, &valh, 0, 0 );
04848       }
04849       break;
04850     default :  assert( 0 );  break;
04851   }
04852 
04853   PROFILE_END;
04854 
04855   return( retval );
04856 
04857 }

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

References vsuppl_u::data_type, MAX_BIT_WIDTH, vsuppl_u::part, PROFILE, PROFILE_END, vector_s::suppl, vector_s::ul, UL_DIV, UL_HMASK, UL_SIZE, vector_s::value, VDATA_UL, vector_set_coverage_and_assign_ulong(), VTYPE_INDEX_EXP_VALH, VTYPE_INDEX_EXP_VALL, and vector_s::width.

Referenced by expression_op_func__uinv().

04786   { PROFILE(VECTOR_UNARY_INV);
04787 
04788   bool retval;  /* Return value for this function */
04789 
04790   switch( src->suppl.part.data_type ) {
04791     case VDATA_UL :
04792       {
04793         ulong        vall[UL_DIV(MAX_BIT_WIDTH)];
04794         ulong        valh[UL_DIV(MAX_BIT_WIDTH)];
04795         ulong        mask = UL_HMASK(src->width - 1);
04796         ulong        tvalh;
04797         unsigned int i;
04798         unsigned int size = UL_SIZE( src->width );
04799 
04800         for( i=0; i<(size-1); i++ ) {
04801           tvalh   = src->value.ul[i][VTYPE_INDEX_EXP_VALH];
04802           vall[i] = ~tvalh & ~src->value.ul[i][VTYPE_INDEX_EXP_VALL];
04803           valh[i] = tvalh;
04804         }
04805         tvalh   = src->value.ul[i][VTYPE_INDEX_EXP_VALH];
04806         vall[i] = ~tvalh & ~src->value.ul[i][VTYPE_INDEX_EXP_VALL] & mask;
04807         valh[i] = tvalh & mask;
04808 
04809         retval = vector_set_coverage_and_assign_ulong( tgt, vall, valh, 0, (tgt->width - 1) );
04810       }
04811       break;
04812     default :  assert( 0 );  break;
04813   }
04814 
04815   PROFILE_END;
04816 
04817   return( retval );
04818 
04819 }

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

References vsuppl_u::data_type, vsuppl_u::part, PROFILE, PROFILE_END, vector_s::suppl, vector_s::ul, UL_HMASK, UL_SIZE, vector_s::value, VDATA_UL, vector_set_coverage_and_assign_ulong(), VTYPE_INDEX_VAL_VALH, VTYPE_INDEX_VAL_VALL, and vector_s::width.

Referenced by expression_op_func__unand().

04867   { PROFILE(VECTOR_UNARY_NAND);
04868 
04869   bool retval;  /* Return value for this function */
04870 
04871   switch( tgt->suppl.part.data_type ) {
04872     case VDATA_UL :
04873       {
04874         unsigned int i;
04875         unsigned int ssize = UL_SIZE( src->width );
04876         ulong        valh  = 0;
04877         ulong        vall  = 0;
04878         ulong        lmask = UL_HMASK(src->width - 1);
04879         for( i=0; i<(ssize-1); i++ ) {
04880           valh |= (src->value.ul[i][VTYPE_INDEX_VAL_VALH] != 0) ? 1 : 0;
04881           vall |= ~valh & ((src->value.ul[i][VTYPE_INDEX_VAL_VALL] == UL_SET) ? 0 : 1);
04882         }
04883         valh |= (src->value.ul[i][VTYPE_INDEX_VAL_VALH] != 0) ? 1 : 0;
04884         vall |= ~valh & ((src->value.ul[i][VTYPE_INDEX_VAL_VALL] == lmask) ? 0 : 1);
04885         retval = vector_set_coverage_and_assign_ulong( tgt, &vall, &valh, 0, 0 );
04886       }
04887       break;
04888     default :  assert( 0 );  break;
04889   } 
04890 
04891   PROFILE_END;
04892 
04893   return( retval );
04894 
04895 }

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

References vsuppl_u::data_type, vsuppl_u::part, PROFILE, PROFILE_END, vector_s::suppl, vector_s::ul, UL_SIZE, vector_s::value, VDATA_UL, vector_set_coverage_and_assign_ulong(), VTYPE_INDEX_VAL_VALH, VTYPE_INDEX_VAL_VALL, and vector_s::width.

Referenced by expression_op_func__unor().

04948   { PROFILE(VECTOR_UNARY_NOR);
04949 
04950   bool retval;  /* Return value for this function */
04951 
04952   switch( src->suppl.part.data_type ) {
04953     case VDATA_UL :
04954       {
04955         ulong        vall;
04956         ulong        valh;
04957         unsigned int i    = 0;
04958         unsigned int size = UL_SIZE( src->width );
04959         ulong        x    = 0;
04960         while( (i < size) && ((~src->value.ul[i][VTYPE_INDEX_VAL_VALH] & src->value.ul[i][VTYPE_INDEX_VAL_VALL]) == 0) ) {
04961           x |= src->value.ul[i][VTYPE_INDEX_VAL_VALH];
04962           i++;
04963         }
04964         if( i < size ) {
04965           vall = 0;
04966           valh = 0;
04967         } else {
04968           vall = (x == 0);
04969           valh = (x != 0);
04970         }
04971         retval = vector_set_coverage_and_assign_ulong( tgt, &vall, &valh, 0, 0 );
04972       }
04973       break;
04974     default :  assert( 0 );  break;
04975   }
04976 
04977   PROFILE_END;
04978 
04979   return( retval );
04980 
04981 }

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

References vsuppl_u::data_type, vsuppl_u::part, PROFILE, PROFILE_END, vector_s::suppl, vector_s::ul, UL_SIZE, vector_s::value, VDATA_UL, vector_set_coverage_and_assign_ulong(), VTYPE_INDEX_VAL_VALH, VTYPE_INDEX_VAL_VALL, and vector_s::width.

Referenced by expression_op_func__unot().

05081   { PROFILE(VECTOR_UNARY_NOT);
05082 
05083   bool retval;  /* Return value of this function */
05084 
05085   switch( src->suppl.part.data_type ) {
05086     case VDATA_UL :
05087       {
05088         ulong        vall;
05089         ulong        valh;
05090         unsigned int size = UL_SIZE( src->width );
05091         unsigned int i    = 0;
05092         while( (i < size) && (src->value.ul[i][VTYPE_INDEX_VAL_VALH] == 0) && (src->value.ul[i][VTYPE_INDEX_VAL_VALL] == 0) ) i++;
05093         if( i < size ) {
05094           vall = 0;
05095           valh = (src->value.ul[i][VTYPE_INDEX_VAL_VALH] != 0);
05096         } else {
05097           vall = 1;
05098           valh = 0;
05099         }
05100         retval = vector_set_coverage_and_assign_ulong( tgt, &vall, &valh, 0, 0 );
05101       }
05102       break;
05103     default :  assert( 0 );  break;
05104   }
05105 
05106   PROFILE_END;
05107 
05108   return( retval );
05109 
05110 }

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

References vsuppl_u::data_type, vsuppl_u::part, PROFILE, PROFILE_END, vector_s::suppl, vector_s::ul, UL_SIZE, vector_s::value, VDATA_UL, vector_set_coverage_and_assign_ulong(), VTYPE_INDEX_VAL_VALH, VTYPE_INDEX_VAL_VALL, and vector_s::width.

Referenced by expression_op_func__unxor().

05036   { PROFILE(VECTOR_UNARY_NXOR);
05037 
05038   bool retval;  /* Return value for this function */
05039 
05040   switch( src->suppl.part.data_type ) {
05041     case VDATA_UL :
05042       {
05043         ulong        vall = 1;
05044         ulong        valh = 0;
05045         unsigned int i    = 0;
05046         unsigned int size = UL_SIZE( src->width );
05047         do {
05048           if( src->value.ul[i][VTYPE_INDEX_VAL_VALH] != 0 ) {
05049             vall = 0;
05050             valh = 1;
05051           } else {
05052             unsigned int j;
05053             ulong        tval = src->value.ul[i][VTYPE_INDEX_VAL_VALL];
05054             for( j=1; j<UL_BITS; j<<=1 ) {
05055               tval = tval ^ (tval >> j);
05056             }
05057             vall = (vall ^ tval) & 0x1;
05058           }
05059           i++;
05060         } while( (i < size) && (valh == 0) );
05061         retval = vector_set_coverage_and_assign_ulong( tgt, &vall, &valh, 0, 0 );
05062       }
05063       break;
05064     default :  assert( 0 );  break;
05065   }
05066 
05067   PROFILE_END;
05068 
05069   return( retval );
05070 
05071 }

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

References vsuppl_u::data_type, vsuppl_u::part, PROFILE, PROFILE_END, vector_s::suppl, vector_s::ul, UL_SIZE, vector_s::value, VDATA_UL, vector_set_coverage_and_assign_ulong(), VTYPE_INDEX_VAL_VALH, VTYPE_INDEX_VAL_VALL, and vector_s::width.

Referenced by expression_op_func__uor().

04905   { PROFILE(VECTOR_UNARY_OR);
04906 
04907   bool retval;  /* Return value for this function */
04908 
04909   switch( src->suppl.part.data_type ) {
04910     case VDATA_UL :
04911       {
04912         ulong        vall;
04913         ulong        valh;
04914         unsigned int i    = 0;
04915         unsigned int size = UL_SIZE( src->width );
04916         ulong        x    = 0;
04917         while( (i < size) && ((~src->value.ul[i][VTYPE_INDEX_VAL_VALH] & src->value.ul[i][VTYPE_INDEX_VAL_VALL]) == 0) ) {
04918           x |= src->value.ul[i][VTYPE_INDEX_VAL_VALH];
04919           i++;
04920         }
04921         if( i < size ) {
04922           vall = 1;
04923           valh = 0;
04924         } else {
04925           vall = 0;
04926           valh = (x != 0);
04927         }
04928         retval = vector_set_coverage_and_assign_ulong( tgt, &vall, &valh, 0, 0 );
04929       }
04930       break;
04931     default :  assert( 0 );  break;
04932   }
04933 
04934   PROFILE_END;
04935 
04936   return( retval );
04937 
04938 }

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

References vsuppl_u::data_type, vsuppl_u::part, PROFILE, PROFILE_END, vector_s::suppl, vector_s::ul, UL_SIZE, vector_s::value, VDATA_UL, vector_set_coverage_and_assign_ulong(), VTYPE_INDEX_VAL_VALH, VTYPE_INDEX_VAL_VALL, and vector_s::width.

Referenced by expression_op_func__uxor().

04991   { PROFILE(VECTOR_UNARY_XOR);
04992 
04993   bool retval;  /* Return value for this function */
04994 
04995   switch( src->suppl.part.data_type ) {
04996     case VDATA_UL :
04997       {
04998         ulong        vall = 0;
04999         ulong        valh = 0;
05000         unsigned int i    = 0;
05001         unsigned int size = UL_SIZE( src->width );
05002         do {
05003           if( src->value.ul[i][VTYPE_INDEX_VAL_VALH] != 0 ) {
05004             vall = 0;
05005             valh = 1;
05006           } else {
05007             unsigned int j;
05008             ulong        tval = src->value.ul[i][VTYPE_INDEX_VAL_VALL];
05009             for( j=1; j<UL_BITS; j<<=1 ) {
05010               tval = tval ^ (tval >> j);
05011             }
05012             vall = (vall ^ tval) & 0x1;
05013           }
05014           i++;
05015         } while( (i < size) && (valh == 0) );
05016         retval = vector_set_coverage_and_assign_ulong( tgt, &vall, &valh, 0, 0 );
05017       }
05018       break;
05019     default :  assert( 0 );  break;
05020   }
05021 
05022   PROFILE_END;
05023 
05024   return( retval );
05025 
05026 }

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

References vsuppl_u::data_type, DEQ, FALSE, FEQ, MAX_BIT_WIDTH, vsuppl_u::part, PROFILE, PROFILE_END, vector_s::r32, vector_s::r64, vsuppl_u::set, vector_s::suppl, UL_DIV, UL_MOD, rv32_s::val, rv64_s::val, vector_s::value, VDATA_R32, VDATA_R64, VDATA_UL, and vector_set_coverage_and_assign_ulong().

Referenced by vsignal_vcd_assign().

03181   { PROFILE(VECTOR_VCD_ASSIGN);
03182 
03183   bool        retval = FALSE;  /* Return value for this function */
03184   const char* ptr;             /* Pointer to current character under evaluation */
03185   int         i      = lsb;    /* Loop iterator */
03186 
03187   /* Make adjustment to MSB if necessary */
03188   msb = (msb > 0) ? msb : -msb;
03189 
03190   assert( vec != NULL );
03191   assert( value != NULL );
03192   assert( msb <= vec->width );
03193 
03194   /* Set pointer to LSB */
03195   ptr = (value + strlen( value )) - 1;
03196 
03197   switch( vec->suppl.part.data_type ) {
03198     case VDATA_UL :
03199       {
03200         ulong scratchl[UL_DIV(MAX_BIT_WIDTH)];
03201         ulong scratchh[UL_DIV(MAX_BIT_WIDTH)];
03202         scratchl[UL_DIV(i)] = 0;
03203         scratchh[UL_DIV(i)] = 0;
03204         while( ptr >= value ) {
03205           unsigned int index  = UL_DIV(i);
03206           unsigned int offset = UL_MOD(i);
03207           ulong        bit    = ((ulong)1 << offset);
03208           if( offset == 0 ) {
03209             scratchl[index] = 0;
03210             scratchh[index] = 0;
03211           }
03212           scratchl[index] |= ((*ptr == '1') || (*ptr == 'z')) ? bit : 0;
03213           scratchh[index] |= ((*ptr == 'x') || (*ptr == 'z')) ? bit : 0;
03214           ptr--;
03215           i++;
03216         }
03217         ptr++;
03218         /* Bit-fill */
03219         for( ; i<=msb; i++ ) {
03220           unsigned int index  = UL_DIV(i);
03221           unsigned int offset = UL_MOD(i);
03222           ulong        bit    = ((ulong)1 << offset);
03223           if( offset == 0 ) {
03224             scratchl[index] = 0;
03225             scratchh[index] = 0;
03226           }
03227           scratchl[index] |= (*ptr == 'z') ? bit : 0;
03228           scratchh[index] |= ((*ptr == 'x') || (*ptr == 'z')) ? bit : 0;
03229         }
03230         retval = vector_set_coverage_and_assign_ulong( vec, scratchl, scratchh, lsb, msb );
03231       }
03232       break;
03233     case VDATA_R64 :
03234       {
03235         double real;
03236         if( sscanf( value, "%lf", &real ) == 1 ) {
03237           retval = !DEQ( vec->value.r64->val, real );
03238           vec->value.r64->val = real;
03239         } else {
03240           assert( 0 );
03241         }
03242       }
03243       break;
03244     case VDATA_R32 :
03245       {
03246         float real;
03247         if( sscanf( value, "%f", &real ) != 1 ) {
03248           retval = !FEQ( vec->value.r32->val, real );
03249           vec->value.r32->val = real;
03250         } else {
03251           assert( 0 );
03252         }
03253       }
03254       break;
03255     default :  assert( 0 );  break;
03256   }
03257 
03258   /* Set the set bit to indicate that this vector has been evaluated */
03259   vec->suppl.part.set = 1;
03260 
03261   PROFILE_END;
03262 
03263   return( retval );
03264 
03265 }


Variable Documentation

Informational line for the CDD file.

char user_msg[USER_MSG_LENGTH]

Holds some output that will be displayed via the print_output command. This is created globally so that memory does not need to be reallocated for each function that wishes to use it.

const unsigned int vector_type_sizes[4] = {VTYPE_INDEX_VAL_NUM, VTYPE_INDEX_SIG_NUM, VTYPE_INDEX_EXP_NUM, VTYPE_INDEX_MEM_NUM} [static]

Contains the structure sizes for the various vector types (vector "type" supplemental field is the index to this array

Referenced by vector_copy(), vector_copy_range(), vector_create(), vector_db_merge(), vector_db_read(), vector_db_write(), vector_dealloc_value(), vector_display_ulong(), vector_init_ulong(), and vector_merge().

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