Merge branch 'master' into x-sizer5

This commit is contained in:
Stephen Williams 2014-06-14 19:13:42 -07:00
commit ccce9d9271
32 changed files with 4085 additions and 4077 deletions

View File

@ -71,7 +71,7 @@ const char HELP[] =
#endif #endif
#include <fcntl.h> #include <fcntl.h>
#if HAVE_GETOPT_H #ifdef HAVE_GETOPT_H
#include <getopt.h> #include <getopt.h>
#endif #endif

View File

@ -2832,9 +2832,11 @@ unsigned PEIdent::test_width(Design*des, NetScope*scope, width_mode_t&mode)
const index_component_t&index_tail = name_tail.index.back(); const index_component_t&index_tail = name_tail.index.back();
ivl_assert(*this, index_tail.msb); ivl_assert(*this, index_tail.msb);
} }
// If we have a net in hand, then we can predict what // If we have a net in hand, then we can predict what the
// the slice width will be. If not, then just guess. // slice width will be. If not, then assume it will be a
if (net == 0) // simple bit select. If the net only has a single dimension
// then this is still a simple bit select.
if ((net == 0) || (net->packed_dimensions() <= 1))
use_width = 1; use_width = 1;
break; break;
default: default:

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2002-2012 Stephen Williams (steve@icarus.com) * Copyright (c) 2002-2014 Stephen Williams (steve@icarus.com)
* *
* This source code is free software; you can redistribute it * This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU * and/or modify it in source code form under the terms of the GNU
@ -843,7 +843,7 @@ bool NetCondit::synth_async(Design*des, NetScope*scope,
if (mux_width < mux_lwidth && if_ && else_) { if (mux_width < mux_lwidth && if_ && else_) {
if (debug_synth2) { if (debug_synth2) {
cerr << get_fileline() << ": NetCondit::synth_async: " cerr << get_fileline() << ": NetCondit::synth_async: "
<< "This MetMux only impacts a few bits of output," << "This MetMux only impacts a few bits of output,"
<< " so combine nex_out with statement input." << " so combine nex_out with statement input."
<< endl; << endl;
cerr << get_fileline() << ": NetCondit::synth_async: " cerr << get_fileline() << ": NetCondit::synth_async: "

View File

@ -1656,7 +1656,7 @@ extern "C" const char* ivl_nexus_name(ivl_nexus_t net)
assert(net); assert(net);
if (net->name_ == 0) { if (net->name_ == 0) {
char tmp[2 * sizeof(net) + 5]; char tmp[2 * sizeof(net) + 5];
snprintf(tmp, sizeof tmp, "n%p", net); snprintf(tmp, sizeof tmp, "n%p", (void *)net);
net->name_ = api_strings.add(tmp); net->name_ = api_strings.add(tmp);
} }
return net->name_; return net->name_;

View File

@ -625,7 +625,7 @@ struct ivl_parameter_s {
*/ */
struct ivl_process_s { struct ivl_process_s {
ivl_process_type_t type_ : 2; ivl_process_type_t type_ : 2;
int analog_flag : 1; unsigned int analog_flag : 1;
ivl_scope_t scope_; ivl_scope_t scope_;
ivl_statement_t stmt_; ivl_statement_t stmt_;
perm_string file; perm_string file;

View File

@ -231,7 +231,7 @@ static void show_property_expression(ivl_expr_t net, unsigned ind)
{ {
ivl_signal_t sig = ivl_expr_signal(net); ivl_signal_t sig = ivl_expr_signal(net);
const char* pnam = ivl_expr_name(net); const char* pnam = ivl_expr_name(net);
char*signed_flag = ivl_expr_signed(net)? "signed" : "unsigned"; const char*signed_flag = ivl_expr_signed(net)? "signed" : "unsigned";
if (ivl_expr_value(net) == IVL_VT_REAL) { if (ivl_expr_value(net) == IVL_VT_REAL) {
fprintf(out, "%*s<property base=%s, prop=%s, real>\n", ind, "", fprintf(out, "%*s<property base=%s, prop=%s, real>\n", ind, "",

View File

@ -401,7 +401,7 @@ static unsigned calc_can_skip_unsigned(ivl_expr_t oper1, ivl_expr_t oper2)
static void emit_expr_binary(ivl_scope_t scope, ivl_expr_t expr, unsigned wid, static void emit_expr_binary(ivl_scope_t scope, ivl_expr_t expr, unsigned wid,
unsigned is_full_prec) unsigned is_full_prec)
{ {
char *oper = "<invalid>"; const char *oper = "<invalid>";
ivl_expr_t oper1 = ivl_expr_oper1(expr); ivl_expr_t oper1 = ivl_expr_oper1(expr);
ivl_expr_t oper2 = ivl_expr_oper2(expr); ivl_expr_t oper2 = ivl_expr_oper2(expr);
unsigned can_skip_unsigned = calc_can_skip_unsigned(oper1, oper2); unsigned can_skip_unsigned = calc_can_skip_unsigned(oper1, oper2);
@ -976,7 +976,7 @@ static void emit_expr_ternary(ivl_scope_t scope, ivl_expr_t expr, unsigned wid,
static void emit_expr_unary(ivl_scope_t scope, ivl_expr_t expr, unsigned wid, static void emit_expr_unary(ivl_scope_t scope, ivl_expr_t expr, unsigned wid,
unsigned is_full_prec) unsigned is_full_prec)
{ {
char *oper = "invalid"; const char *oper = "invalid";
ivl_expr_t oper1 = ivl_expr_oper1(expr); ivl_expr_t oper1 = ivl_expr_oper1(expr);
switch (ivl_expr_opcode(expr)) { switch (ivl_expr_opcode(expr)) {
case '-': oper = "-"; break; case '-': oper = "-"; break;

View File

@ -24,7 +24,7 @@
const char *func_rtn_name = 0; const char *func_rtn_name = 0;
static char*get_time_const(int time_value) static const char*get_time_const(int time_value)
{ {
switch (time_value) { switch (time_value) {
case 2: return "100s"; case 2: return "100s";

View File

@ -408,7 +408,8 @@ static void emit_assign_and_opt_opcode(ivl_scope_t scope, ivl_statement_t stmt,
unsigned allow_opcode) unsigned allow_opcode)
{ {
unsigned wid; unsigned wid;
char opcode, *opcode_str; char opcode;
const char *opcode_str;
assert (ivl_statement_type(stmt) == IVL_ST_ASSIGN); assert (ivl_statement_type(stmt) == IVL_ST_ASSIGN);
// HERE: Do we need to calculate the width? The compiler should have already // HERE: Do we need to calculate the width? The compiler should have already
@ -941,7 +942,7 @@ static void emit_stmt_block_named(ivl_scope_t scope, ivl_statement_t stmt)
static void emit_stmt_case(ivl_scope_t scope, ivl_statement_t stmt) static void emit_stmt_case(ivl_scope_t scope, ivl_statement_t stmt)
{ {
char *case_type; const char *case_type;
unsigned idx, default_case, count = ivl_stmt_case_count(stmt); unsigned idx, default_case, count = ivl_stmt_case_count(stmt);
switch (ivl_statement_type(stmt)) { switch (ivl_statement_type(stmt)) {
case IVL_ST_CASE: case IVL_ST_CASE:

View File

@ -30,7 +30,7 @@ static void show_prop_type_vector(ivl_type_t ptype)
unsigned packed_dimensions = ivl_type_packed_dimensions(ptype); unsigned packed_dimensions = ivl_type_packed_dimensions(ptype);
assert(packed_dimensions < 2); assert(packed_dimensions < 2);
char*signed_flag = ivl_type_signed(ptype)? "s" : ""; const char*signed_flag = ivl_type_signed(ptype)? "s" : "";
char code = data_type==IVL_VT_BOOL? 'b' : 'L'; char code = data_type==IVL_VT_BOOL? 'b' : 'L';
if (packed_dimensions == 0) { if (packed_dimensions == 0) {

View File

@ -230,7 +230,7 @@ static void str_repeat(char*buf, const char*str, unsigned rpt)
* If the drive strength is strong we can draw a C4<> constant as the * If the drive strength is strong we can draw a C4<> constant as the
* pull value, otherwise we need to draw a C8<> constant. * pull value, otherwise we need to draw a C8<> constant.
*/ */
static char* draw_net_pull(ivl_net_logic_t lptr, ivl_drive_t drive, char*level) static char* draw_net_pull(ivl_net_logic_t lptr, ivl_drive_t drive, const char*level)
{ {
char*result; char*result;
char tmp[32]; char tmp[32];

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2001-2012 Stephen Williams (steve@icarus.com) * Copyright (c) 2001-2014 Stephen Williams (steve@icarus.com)
* *
* This source code is free software; you can redistribute it * This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU * and/or modify it in source code form under the terms of the GNU
@ -1816,7 +1816,7 @@ static int sfunc_has_modpath_output(ivl_lpm_t lptr)
static void draw_sfunc_output_def(ivl_lpm_t net, char type) static void draw_sfunc_output_def(ivl_lpm_t net, char type)
{ {
ivl_nexus_t nex = ivl_lpm_q(net); ivl_nexus_t nex = ivl_lpm_q(net);
char *suf = (type == 'd') ? "/d" : ""; const char *suf = (type == 'd') ? "/d" : "";
switch (data_type_of_nexus(nex)) { switch (data_type_of_nexus(nex)) {
case IVL_VT_REAL: case IVL_VT_REAL:
@ -2165,8 +2165,10 @@ int draw_scope(ivl_scope_t net, ivl_scope_t parent)
} }
fprintf(vvp_out, "S_%p .scope %s%s, \"%s\" \"%s\" %d %d", fprintf(vvp_out, "S_%p .scope %s%s, \"%s\" \"%s\" %d %d",
net, prefix, type, vvp_mangle_name(ivl_scope_basename(net)), net, prefix, type,
ivl_scope_tname(net), ivl_file_table_index(ivl_scope_file(net)), vvp_mangle_name(ivl_scope_basename(net)),
vvp_mangle_name(ivl_scope_tname(net)),
ivl_file_table_index(ivl_scope_file(net)),
ivl_scope_lineno(net)); ivl_scope_lineno(net));
if (parent) { if (parent) {
@ -2191,7 +2193,8 @@ int draw_scope(ivl_scope_t net, ivl_scope_t parent)
if( name == 0 ) if( name == 0 )
name = ""; name = "";
fprintf( vvp_out, " .port_info %u %s %u \"%s\"\n", fprintf( vvp_out, " .port_info %u %s %u \"%s\"\n",
idx, vvp_port_info_type_str(ptype), width, name ); idx, vvp_port_info_type_str(ptype), width,
vvp_mangle_name(name) );
} }
} }
@ -2201,7 +2204,7 @@ int draw_scope(ivl_scope_t net, ivl_scope_t parent)
switch (ivl_expr_type(pex)) { switch (ivl_expr_type(pex)) {
case IVL_EX_STRING: case IVL_EX_STRING:
fprintf(vvp_out, "P_%p .param/str \"%s\" %d %d %d, \"%s\";\n", fprintf(vvp_out, "P_%p .param/str \"%s\" %d %d %d, \"%s\";\n",
par, ivl_parameter_basename(par), par, vvp_mangle_name(ivl_parameter_basename(par)),
ivl_parameter_local(par), ivl_parameter_local(par),
ivl_file_table_index(ivl_parameter_file(par)), ivl_file_table_index(ivl_parameter_file(par)),
ivl_parameter_lineno(par), ivl_parameter_lineno(par),
@ -2209,7 +2212,7 @@ int draw_scope(ivl_scope_t net, ivl_scope_t parent)
break; break;
case IVL_EX_NUMBER: case IVL_EX_NUMBER:
fprintf(vvp_out, "P_%p .param/l \"%s\" %d %d %d, %sC4<", fprintf(vvp_out, "P_%p .param/l \"%s\" %d %d %d, %sC4<",
par, ivl_parameter_basename(par), par, vvp_mangle_name(ivl_parameter_basename(par)),
ivl_parameter_local(par), ivl_parameter_local(par),
ivl_file_table_index(ivl_parameter_file(par)), ivl_file_table_index(ivl_parameter_file(par)),
ivl_parameter_lineno(par), ivl_parameter_lineno(par),
@ -2225,8 +2228,9 @@ int draw_scope(ivl_scope_t net, ivl_scope_t parent)
case IVL_EX_REALNUM: case IVL_EX_REALNUM:
{ char *res = draw_Cr_to_string(ivl_expr_dvalue(pex)); { char *res = draw_Cr_to_string(ivl_expr_dvalue(pex));
fprintf(vvp_out, "P_%p .param/real \"%s\" %d %d %d, %s; " fprintf(vvp_out, "P_%p .param/real \"%s\" %d %d %d, %s; "
"value=%#g\n", par, ivl_parameter_basename(par), "value=%#g\n", par,
ivl_parameter_local(par), vvp_mangle_name(ivl_parameter_basename(par)),
ivl_parameter_local(par),
ivl_file_table_index(ivl_parameter_file(par)), ivl_file_table_index(ivl_parameter_file(par)),
ivl_parameter_lineno(par), res, ivl_parameter_lineno(par), res,
ivl_expr_dvalue(pex)); ivl_expr_dvalue(pex));

View File

@ -1,4 +1,4 @@
/* /*
FastLZ - lightning-fast lossless compression library FastLZ - lightning-fast lossless compression library
Copyright (C) 2007 Ariya Hidayat (ariya@kde.org) Copyright (C) 2007 Ariya Hidayat (ariya@kde.org)
@ -53,7 +53,7 @@
#define FASTLZ_INLINE inline #define FASTLZ_INLINE inline
#elif defined(__BORLANDC__) || defined(_MSC_VER) || defined(__LCC__) #elif defined(__BORLANDC__) || defined(_MSC_VER) || defined(__LCC__)
#define FASTLZ_INLINE __inline #define FASTLZ_INLINE __inline
#else #else
#define FASTLZ_INLINE #define FASTLZ_INLINE
#endif #endif
@ -87,7 +87,7 @@ int fastlz_decompress(const void* input, int length, void* output, int maxout);
#define MAX_DISTANCE 8192 #define MAX_DISTANCE 8192
#if !defined(FASTLZ_STRICT_ALIGN) #if !defined(FASTLZ_STRICT_ALIGN)
#define FASTLZ_READU16(p) *((const flzuint16*)(p)) #define FASTLZ_READU16(p) *((const flzuint16*)(p))
#else #else
#define FASTLZ_READU16(p) ((p)[0] | (p)[1]<<8) #define FASTLZ_READU16(p) ((p)[0] | (p)[1]<<8)
#endif #endif
@ -233,7 +233,7 @@ static FASTLZ_INLINE int FASTLZ_COMPRESSOR(const void* input, int length, void*
*hslot = anchor; *hslot = anchor;
/* is this a match? check the first 3 bytes */ /* is this a match? check the first 3 bytes */
if(distance==0 || if(distance==0 ||
#if FASTLZ_LEVEL==1 #if FASTLZ_LEVEL==1
(distance >= MAX_DISTANCE) || (distance >= MAX_DISTANCE) ||
#else #else
@ -246,11 +246,11 @@ static FASTLZ_INLINE int FASTLZ_COMPRESSOR(const void* input, int length, void*
/* far, needs at least 5-byte match */ /* far, needs at least 5-byte match */
if(distance >= MAX_DISTANCE) if(distance >= MAX_DISTANCE)
{ {
if(*ip++ != *ref++ || *ip++!= *ref++) if(*ip++ != *ref++ || *ip++!= *ref++)
goto literal; goto literal;
len += 2; len += 2;
} }
match: match:
#endif #endif
@ -346,7 +346,7 @@ static FASTLZ_INLINE int FASTLZ_COMPRESSOR(const void* input, int length, void*
while(len > MAX_LEN-2) while(len > MAX_LEN-2)
{ {
*op++ = (7 << 5) + (distance >> 8); *op++ = (7 << 5) + (distance >> 8);
*op++ = MAX_LEN - 2 - 7 -2; *op++ = MAX_LEN - 2 - 7 -2;
*op++ = (distance & 255); *op++ = (distance & 255);
len -= MAX_LEN-2; len -= MAX_LEN-2;
} }
@ -457,7 +457,7 @@ static FASTLZ_INLINE int FASTLZ_DECOMPRESSOR(const void* input, int length, void
ref = op - ofs - MAX_DISTANCE; ref = op - ofs - MAX_DISTANCE;
} }
#endif #endif
#ifdef FASTLZ_SAFE #ifdef FASTLZ_SAFE
if (FASTLZ_UNEXPECT_CONDITIONAL(op + len + 3 > op_limit)) if (FASTLZ_UNEXPECT_CONDITIONAL(op + len + 3 > op_limit))
return 0; return 0;
@ -530,7 +530,7 @@ static FASTLZ_INLINE int FASTLZ_DECOMPRESSOR(const void* input, int length, void
return 0; return 0;
#endif #endif
*op++ = *ip++; *op++ = *ip++;
for(--ctrl; ctrl; ctrl--) for(--ctrl; ctrl; ctrl--)
*op++ = *ip++; *op++ = *ip++;

View File

@ -1,4 +1,4 @@
/* /*
FastLZ - lightning-fast lossless compression library FastLZ - lightning-fast lossless compression library
Copyright (C) 2007 Ariya Hidayat (ariya@kde.org) Copyright (C) 2007 Ariya Hidayat (ariya@kde.org)
@ -47,11 +47,11 @@ extern "C" {
#endif #endif
/** /**
Compress a block of data in the input buffer and returns the size of Compress a block of data in the input buffer and returns the size of
compressed block. The size of input buffer is specified by length. The compressed block. The size of input buffer is specified by length. The
minimum input buffer size is 16. minimum input buffer size is 16.
The output buffer must be at least 5% larger than the input buffer The output buffer must be at least 5% larger than the input buffer
and can not be smaller than 66 bytes. and can not be smaller than 66 bytes.
If the input is not compressible, the return value might be larger than If the input is not compressible, the return value might be larger than
@ -63,9 +63,9 @@ extern "C" {
int fastlz_compress(const void* input, int length, void* output); int fastlz_compress(const void* input, int length, void* output);
/** /**
Decompress a block of compressed data and returns the size of the Decompress a block of compressed data and returns the size of the
decompressed block. If error occurs, e.g. the compressed data is decompressed block. If error occurs, e.g. the compressed data is
corrupted or the output buffer is not large enough, then 0 (zero) corrupted or the output buffer is not large enough, then 0 (zero)
will be returned instead. will be returned instead.
The input buffer and the output buffer can not overlap. The input buffer and the output buffer can not overlap.
@ -74,14 +74,14 @@ int fastlz_compress(const void* input, int length, void* output);
more than what is specified in maxout. more than what is specified in maxout.
*/ */
int fastlz_decompress(const void* input, int length, void* output, int maxout); int fastlz_decompress(const void* input, int length, void* output, int maxout);
/** /**
Compress a block of data in the input buffer and returns the size of Compress a block of data in the input buffer and returns the size of
compressed block. The size of input buffer is specified by length. The compressed block. The size of input buffer is specified by length. The
minimum input buffer size is 16. minimum input buffer size is 16.
The output buffer must be at least 5% larger than the input buffer The output buffer must be at least 5% larger than the input buffer
and can not be smaller than 66 bytes. and can not be smaller than 66 bytes.
If the input is not compressible, the return value might be larger than If the input is not compressible, the return value might be larger than
@ -89,14 +89,14 @@ int fastlz_decompress(const void* input, int length, void* output, int maxout);
The input buffer and the output buffer can not overlap. The input buffer and the output buffer can not overlap.
Compression level can be specified in parameter level. At the moment, Compression level can be specified in parameter level. At the moment,
only level 1 and level 2 are supported. only level 1 and level 2 are supported.
Level 1 is the fastest compression and generally useful for short data. Level 1 is the fastest compression and generally useful for short data.
Level 2 is slightly slower but it gives better compression ratio. Level 2 is slightly slower but it gives better compression ratio.
Note that the compressed data, regardless of the level, can always be Note that the compressed data, regardless of the level, can always be
decompressed using the function fastlz_decompress above. decompressed using the function fastlz_decompress above.
*/ */
int fastlz_compress_level(int level, const void* input, int length, void* output); int fastlz_compress_level(int level, const void* input, int length, void* output);

File diff suppressed because it is too large Load Diff

View File

@ -51,15 +51,15 @@ enum fstFileType {
FST_FT_VERILOG = 0, FST_FT_VERILOG = 0,
FST_FT_VHDL = 1, FST_FT_VHDL = 1,
FST_FT_VERILOG_VHDL = 2, FST_FT_VERILOG_VHDL = 2,
FST_FT_MAX = 2 FST_FT_MAX = 2
}; };
enum fstBlockType { enum fstBlockType {
FST_BL_HDR = 0, FST_BL_HDR = 0,
FST_BL_VCDATA = 1, FST_BL_VCDATA = 1,
FST_BL_BLACKOUT = 2, FST_BL_BLACKOUT = 2,
FST_BL_GEOM = 3, FST_BL_GEOM = 3,
FST_BL_HIER = 4, FST_BL_HIER = 4,
FST_BL_VCDATA_DYN_ALIAS = 5, FST_BL_VCDATA_DYN_ALIAS = 5,
@ -67,8 +67,8 @@ enum fstBlockType {
FST_BL_HIER_LZ4DUO = 7, FST_BL_HIER_LZ4DUO = 7,
FST_BL_VCDATA_DYN_ALIAS2 = 8, FST_BL_VCDATA_DYN_ALIAS2 = 8,
FST_BL_ZWRAPPER = 254, /* indicates that whole trace is gz wrapped */ FST_BL_ZWRAPPER = 254, /* indicates that whole trace is gz wrapped */
FST_BL_SKIP = 255 /* used while block is being written */ FST_BL_SKIP = 255 /* used while block is being written */
}; };
enum fstScopeType { enum fstScopeType {
@ -108,7 +108,7 @@ enum fstScopeType {
}; };
enum fstVarType { enum fstVarType {
FST_VT_MIN = 0, /* start of vartypes */ FST_VT_MIN = 0, /* start of vartypes */
FST_VT_VCD_EVENT = 0, FST_VT_VCD_EVENT = 0,
FST_VT_VCD_INTEGER = 1, FST_VT_VCD_INTEGER = 1,
@ -118,7 +118,7 @@ enum fstVarType {
FST_VT_VCD_REG = 5, FST_VT_VCD_REG = 5,
FST_VT_VCD_SUPPLY0 = 6, FST_VT_VCD_SUPPLY0 = 6,
FST_VT_VCD_SUPPLY1 = 7, FST_VT_VCD_SUPPLY1 = 7,
FST_VT_VCD_TIME = 8, FST_VT_VCD_TIME = 8,
FST_VT_VCD_TRI = 9, FST_VT_VCD_TRI = 9,
FST_VT_VCD_TRIAND = 10, FST_VT_VCD_TRIAND = 10,
FST_VT_VCD_TRIOR = 11, FST_VT_VCD_TRIOR = 11,
@ -129,21 +129,21 @@ enum fstVarType {
FST_VT_VCD_WIRE = 16, FST_VT_VCD_WIRE = 16,
FST_VT_VCD_WOR = 17, FST_VT_VCD_WOR = 17,
FST_VT_VCD_PORT = 18, FST_VT_VCD_PORT = 18,
FST_VT_VCD_SPARRAY = 19, /* used to define the rownum (index) port for a sparse array */ FST_VT_VCD_SPARRAY = 19, /* used to define the rownum (index) port for a sparse array */
FST_VT_VCD_REALTIME = 20, FST_VT_VCD_REALTIME = 20,
FST_VT_GEN_STRING = 21, /* generic string type (max len is defined dynamically via fstWriterEmitVariableLengthValueChange) */ FST_VT_GEN_STRING = 21, /* generic string type (max len is defined dynamically via fstWriterEmitVariableLengthValueChange) */
FST_VT_SV_BIT = 22, FST_VT_SV_BIT = 22,
FST_VT_SV_LOGIC = 23, FST_VT_SV_LOGIC = 23,
FST_VT_SV_INT = 24, /* declare as size = 32 */ FST_VT_SV_INT = 24, /* declare as size = 32 */
FST_VT_SV_SHORTINT = 25, /* declare as size = 16 */ FST_VT_SV_SHORTINT = 25, /* declare as size = 16 */
FST_VT_SV_LONGINT = 26, /* declare as size = 64 */ FST_VT_SV_LONGINT = 26, /* declare as size = 64 */
FST_VT_SV_BYTE = 27, /* declare as size = 8 */ FST_VT_SV_BYTE = 27, /* declare as size = 8 */
FST_VT_SV_ENUM = 28, /* declare as appropriate type range */ FST_VT_SV_ENUM = 28, /* declare as appropriate type range */
FST_VT_SV_SHORTREAL = 29, /* declare and emit same as FST_VT_VCD_REAL (needs to be emitted as double, not a float) */ FST_VT_SV_SHORTREAL = 29, /* declare and emit same as FST_VT_VCD_REAL (needs to be emitted as double, not a float) */
FST_VT_MAX = 29 /* end of vartypes */ FST_VT_MAX = 29 /* end of vartypes */
}; };
enum fstVarDir { enum fstVarDir {
@ -174,7 +174,7 @@ enum fstHierType {
enum fstAttrType { enum fstAttrType {
FST_AT_MIN = 0, FST_AT_MIN = 0,
FST_AT_MISC = 0, /* self-contained: does not need matching FST_HT_ATTREND */ FST_AT_MISC = 0, /* self-contained: does not need matching FST_HT_ATTREND */
FST_AT_ARRAY = 1, FST_AT_ARRAY = 1,
FST_AT_ENUM = 2, FST_AT_ENUM = 2,
FST_AT_PACK = 3, FST_AT_PACK = 3,
@ -185,9 +185,9 @@ enum fstAttrType {
enum fstMiscType { enum fstMiscType {
FST_MT_MIN = 0, FST_MT_MIN = 0,
FST_MT_COMMENT = 0, /* use fstWriterSetComment() to emit */ FST_MT_COMMENT = 0, /* use fstWriterSetComment() to emit */
FST_MT_ENVVAR = 1, /* use fstWriterSetEnvVar() to emit */ FST_MT_ENVVAR = 1, /* use fstWriterSetEnvVar() to emit */
FST_MT_SUPVAR = 2, /* use fstWriterCreateVar2() to emit */ FST_MT_SUPVAR = 2, /* use fstWriterCreateVar2() to emit */
FST_MT_PATHNAME = 3, /* reserved for fstWriterSetSourceStem() string -> number management */ FST_MT_PATHNAME = 3, /* reserved for fstWriterSetSourceStem() string -> number management */
FST_MT_SOURCESTEM = 4, /* use fstWriterSetSourceStem() to emit */ FST_MT_SOURCESTEM = 4, /* use fstWriterSetSourceStem() to emit */
FST_MT_SOURCEISTEM = 5, /* use fstWriterSetSourceInstantiationStem() to emit */ FST_MT_SOURCEISTEM = 5, /* use fstWriterSetSourceInstantiationStem() to emit */
@ -274,7 +274,7 @@ enum fstSupplementalDataType {
FST_SDT_MAX = 16, FST_SDT_MAX = 16,
FST_SDT_SVT_SHIFT_COUNT = 10, /* FST_SVT_* is ORed in by fstWriterCreateVar2() to the left after shifting FST_SDT_SVT_SHIFT_COUNT */ FST_SDT_SVT_SHIFT_COUNT = 10, /* FST_SVT_* is ORed in by fstWriterCreateVar2() to the left after shifting FST_SDT_SVT_SHIFT_COUNT */
FST_SDT_ABS_MAX = ((1<<(FST_SDT_SVT_SHIFT_COUNT))-1) FST_SDT_ABS_MAX = ((1<<(FST_SDT_SVT_SHIFT_COUNT))-1)
}; };
@ -283,141 +283,141 @@ struct fstHier
unsigned char htyp; unsigned char htyp;
union { union {
/* if htyp == FST_HT_SCOPE */ /* if htyp == FST_HT_SCOPE */
struct fstHierScope { struct fstHierScope {
unsigned char typ; /* FST_ST_MIN ... FST_ST_MAX */ unsigned char typ; /* FST_ST_MIN ... FST_ST_MAX */
const char *name; const char *name;
const char *component; const char *component;
uint32_t name_length; /* strlen(u.scope.name) */ uint32_t name_length; /* strlen(u.scope.name) */
uint32_t component_length; /* strlen(u.scope.component) */ uint32_t component_length; /* strlen(u.scope.component) */
} scope; } scope;
/* if htyp == FST_HT_VAR */ /* if htyp == FST_HT_VAR */
struct fstHierVar { struct fstHierVar {
unsigned char typ; /* FST_VT_MIN ... FST_VT_MAX */ unsigned char typ; /* FST_VT_MIN ... FST_VT_MAX */
unsigned char direction; /* FST_VD_MIN ... FST_VD_MAX */ unsigned char direction; /* FST_VD_MIN ... FST_VD_MAX */
unsigned char svt_workspace; /* zeroed out by FST reader, for client code use */ unsigned char svt_workspace; /* zeroed out by FST reader, for client code use */
unsigned char sdt_workspace; /* zeroed out by FST reader, for client code use */ unsigned char sdt_workspace; /* zeroed out by FST reader, for client code use */
unsigned int sxt_workspace; /* zeroed out by FST reader, for client code use */ unsigned int sxt_workspace; /* zeroed out by FST reader, for client code use */
const char *name; const char *name;
uint32_t length; uint32_t length;
fstHandle handle; fstHandle handle;
uint32_t name_length; /* strlen(u.var.name) */ uint32_t name_length; /* strlen(u.var.name) */
unsigned is_alias : 1; unsigned is_alias : 1;
} var; } var;
/* if htyp == FST_HT_ATTRBEGIN */ /* if htyp == FST_HT_ATTRBEGIN */
struct fstHierAttr { struct fstHierAttr {
unsigned char typ; /* FST_AT_MIN ... FST_AT_MAX */ unsigned char typ; /* FST_AT_MIN ... FST_AT_MAX */
unsigned char subtype; /* from fstMiscType, fstArrayType, fstEnumValueType, fstPackType */ unsigned char subtype; /* from fstMiscType, fstArrayType, fstEnumValueType, fstPackType */
const char *name; const char *name;
uint64_t arg; /* number of array elements, struct members, or some other payload (possibly ignored) */ uint64_t arg; /* number of array elements, struct members, or some other payload (possibly ignored) */
uint64_t arg_from_name; /* for when name is overloaded as a variable-length integer (FST_AT_MISC + FST_MT_SOURCESTEM) */ uint64_t arg_from_name; /* for when name is overloaded as a variable-length integer (FST_AT_MISC + FST_MT_SOURCESTEM) */
uint32_t name_length; /* strlen(u.attr.name) */ uint32_t name_length; /* strlen(u.attr.name) */
} attr; } attr;
} u; } u;
}; };
/* /*
* writer functions * writer functions
*/ */
void fstWriterClose(void *ctx); void fstWriterClose(void *ctx);
void * fstWriterCreate(const char *nam, int use_compressed_hier); void * fstWriterCreate(const char *nam, int use_compressed_hier);
/* used for Verilog/SV */ /* used for Verilog/SV */
fstHandle fstWriterCreateVar(void *ctx, enum fstVarType vt, enum fstVarDir vd, fstHandle fstWriterCreateVar(void *ctx, enum fstVarType vt, enum fstVarDir vd,
uint32_t len, const char *nam, fstHandle aliasHandle); uint32_t len, const char *nam, fstHandle aliasHandle);
/* future expansion for VHDL and other languages. The variable type, data type, etc map onto /* future expansion for VHDL and other languages. The variable type, data type, etc map onto
the current Verilog/SV one. The "type" string is optional for a more verbose or custom description */ the current Verilog/SV one. The "type" string is optional for a more verbose or custom description */
fstHandle fstWriterCreateVar2(void *ctx, enum fstVarType vt, enum fstVarDir vd, fstHandle fstWriterCreateVar2(void *ctx, enum fstVarType vt, enum fstVarDir vd,
uint32_t len, const char *nam, fstHandle aliasHandle, uint32_t len, const char *nam, fstHandle aliasHandle,
const char *type, enum fstSupplementalVarType svt, enum fstSupplementalDataType sdt); const char *type, enum fstSupplementalVarType svt, enum fstSupplementalDataType sdt);
void fstWriterEmitValueChange(void *ctx, fstHandle handle, const void *val); void fstWriterEmitValueChange(void *ctx, fstHandle handle, const void *val);
void fstWriterEmitVariableLengthValueChange(void *ctx, fstHandle handle, const void *val, uint32_t len); void fstWriterEmitVariableLengthValueChange(void *ctx, fstHandle handle, const void *val, uint32_t len);
void fstWriterEmitDumpActive(void *ctx, int enable); void fstWriterEmitDumpActive(void *ctx, int enable);
void fstWriterEmitTimeChange(void *ctx, uint64_t tim); void fstWriterEmitTimeChange(void *ctx, uint64_t tim);
void fstWriterFlushContext(void *ctx); void fstWriterFlushContext(void *ctx);
int fstWriterGetDumpSizeLimitReached(void *ctx); int fstWriterGetDumpSizeLimitReached(void *ctx);
int fstWriterGetFseekFailed(void *ctx); int fstWriterGetFseekFailed(void *ctx);
void fstWriterSetAttrBegin(void *ctx, enum fstAttrType attrtype, int subtype, void fstWriterSetAttrBegin(void *ctx, enum fstAttrType attrtype, int subtype,
const char *attrname, uint64_t arg); const char *attrname, uint64_t arg);
void fstWriterSetAttrEnd(void *ctx); void fstWriterSetAttrEnd(void *ctx);
void fstWriterSetComment(void *ctx, const char *comm); void fstWriterSetComment(void *ctx, const char *comm);
void fstWriterSetDate(void *ctx, const char *dat); void fstWriterSetDate(void *ctx, const char *dat);
void fstWriterSetDumpSizeLimit(void *ctx, uint64_t numbytes); void fstWriterSetDumpSizeLimit(void *ctx, uint64_t numbytes);
void fstWriterSetEnvVar(void *ctx, const char *envvar); void fstWriterSetEnvVar(void *ctx, const char *envvar);
void fstWriterSetFileType(void *ctx, enum fstFileType filetype); void fstWriterSetFileType(void *ctx, enum fstFileType filetype);
void fstWriterSetPackType(void *ctx, enum fstWriterPackType typ); void fstWriterSetPackType(void *ctx, enum fstWriterPackType typ);
void fstWriterSetParallelMode(void *ctx, int enable); void fstWriterSetParallelMode(void *ctx, int enable);
void fstWriterSetRepackOnClose(void *ctx, int enable); /* type = 0 (none), 1 (libz) */ void fstWriterSetRepackOnClose(void *ctx, int enable); /* type = 0 (none), 1 (libz) */
void fstWriterSetScope(void *ctx, enum fstScopeType scopetype, void fstWriterSetScope(void *ctx, enum fstScopeType scopetype,
const char *scopename, const char *scopecomp); const char *scopename, const char *scopecomp);
void fstWriterSetSourceInstantiationStem(void *ctx, const char *path, unsigned int line, unsigned int use_realpath); void fstWriterSetSourceInstantiationStem(void *ctx, const char *path, unsigned int line, unsigned int use_realpath);
void fstWriterSetSourceStem(void *ctx, const char *path, unsigned int line, unsigned int use_realpath); void fstWriterSetSourceStem(void *ctx, const char *path, unsigned int line, unsigned int use_realpath);
void fstWriterSetTimescale(void *ctx, int ts); void fstWriterSetTimescale(void *ctx, int ts);
void fstWriterSetTimescaleFromString(void *ctx, const char *s); void fstWriterSetTimescaleFromString(void *ctx, const char *s);
void fstWriterSetTimezero(void *ctx, int64_t tim); void fstWriterSetTimezero(void *ctx, int64_t tim);
void fstWriterSetUpscope(void *ctx); void fstWriterSetUpscope(void *ctx);
void fstWriterSetVersion(void *ctx, const char *vers); void fstWriterSetVersion(void *ctx, const char *vers);
/* /*
* reader functions * reader functions
*/ */
void fstReaderClose(void *ctx); void fstReaderClose(void *ctx);
void fstReaderClrFacProcessMask(void *ctx, fstHandle facidx); void fstReaderClrFacProcessMask(void *ctx, fstHandle facidx);
void fstReaderClrFacProcessMaskAll(void *ctx); void fstReaderClrFacProcessMaskAll(void *ctx);
uint64_t fstReaderGetAliasCount(void *ctx); uint64_t fstReaderGetAliasCount(void *ctx);
const char * fstReaderGetCurrentFlatScope(void *ctx); const char * fstReaderGetCurrentFlatScope(void *ctx);
void * fstReaderGetCurrentScopeUserInfo(void *ctx); void * fstReaderGetCurrentScopeUserInfo(void *ctx);
int fstReaderGetCurrentScopeLen(void *ctx); int fstReaderGetCurrentScopeLen(void *ctx);
const char * fstReaderGetDateString(void *ctx); const char * fstReaderGetDateString(void *ctx);
int fstReaderGetDoubleEndianMatchState(void *ctx); int fstReaderGetDoubleEndianMatchState(void *ctx);
uint64_t fstReaderGetDumpActivityChangeTime(void *ctx, uint32_t idx); uint64_t fstReaderGetDumpActivityChangeTime(void *ctx, uint32_t idx);
unsigned char fstReaderGetDumpActivityChangeValue(void *ctx, uint32_t idx); unsigned char fstReaderGetDumpActivityChangeValue(void *ctx, uint32_t idx);
uint64_t fstReaderGetEndTime(void *ctx); uint64_t fstReaderGetEndTime(void *ctx);
int fstReaderGetFacProcessMask(void *ctx, fstHandle facidx); int fstReaderGetFacProcessMask(void *ctx, fstHandle facidx);
int fstReaderGetFileType(void *ctx); int fstReaderGetFileType(void *ctx);
int fstReaderGetFseekFailed(void *ctx); int fstReaderGetFseekFailed(void *ctx);
fstHandle fstReaderGetMaxHandle(void *ctx); fstHandle fstReaderGetMaxHandle(void *ctx);
uint64_t fstReaderGetMemoryUsedByWriter(void *ctx); uint64_t fstReaderGetMemoryUsedByWriter(void *ctx);
uint32_t fstReaderGetNumberDumpActivityChanges(void *ctx); uint32_t fstReaderGetNumberDumpActivityChanges(void *ctx);
uint64_t fstReaderGetScopeCount(void *ctx); uint64_t fstReaderGetScopeCount(void *ctx);
uint64_t fstReaderGetStartTime(void *ctx); uint64_t fstReaderGetStartTime(void *ctx);
signed char fstReaderGetTimescale(void *ctx); signed char fstReaderGetTimescale(void *ctx);
int64_t fstReaderGetTimezero(void *ctx); int64_t fstReaderGetTimezero(void *ctx);
uint64_t fstReaderGetValueChangeSectionCount(void *ctx); uint64_t fstReaderGetValueChangeSectionCount(void *ctx);
char * fstReaderGetValueFromHandleAtTime(void *ctx, uint64_t tim, fstHandle facidx, char *buf); char * fstReaderGetValueFromHandleAtTime(void *ctx, uint64_t tim, fstHandle facidx, char *buf);
uint64_t fstReaderGetVarCount(void *ctx); uint64_t fstReaderGetVarCount(void *ctx);
const char * fstReaderGetVersionString(void *ctx); const char * fstReaderGetVersionString(void *ctx);
struct fstHier *fstReaderIterateHier(void *ctx); struct fstHier *fstReaderIterateHier(void *ctx);
int fstReaderIterateHierRewind(void *ctx); int fstReaderIterateHierRewind(void *ctx);
int fstReaderIterBlocks(void *ctx, int fstReaderIterBlocks(void *ctx,
void (*value_change_callback)(void *user_callback_data_pointer, uint64_t time, fstHandle facidx, const unsigned char *value), void (*value_change_callback)(void *user_callback_data_pointer, uint64_t time, fstHandle facidx, const unsigned char *value),
void *user_callback_data_pointer, FILE *vcdhandle); void *user_callback_data_pointer, FILE *vcdhandle);
int fstReaderIterBlocks2(void *ctx, int fstReaderIterBlocks2(void *ctx,
void (*value_change_callback)(void *user_callback_data_pointer, uint64_t time, fstHandle facidx, const unsigned char *value), void (*value_change_callback)(void *user_callback_data_pointer, uint64_t time, fstHandle facidx, const unsigned char *value),
void (*value_change_callback_varlen)(void *user_callback_data_pointer, uint64_t time, fstHandle facidx, const unsigned char *value, uint32_t len), void (*value_change_callback_varlen)(void *user_callback_data_pointer, uint64_t time, fstHandle facidx, const unsigned char *value, uint32_t len),
void *user_callback_data_pointer, FILE *vcdhandle); void *user_callback_data_pointer, FILE *vcdhandle);
void fstReaderIterBlocksSetNativeDoublesOnCallback(void *ctx, int enable); void fstReaderIterBlocksSetNativeDoublesOnCallback(void *ctx, int enable);
void * fstReaderOpen(const char *nam); void * fstReaderOpen(const char *nam);
void * fstReaderOpenForUtilitiesOnly(void); void * fstReaderOpenForUtilitiesOnly(void);
const char * fstReaderPopScope(void *ctx); const char * fstReaderPopScope(void *ctx);
int fstReaderProcessHier(void *ctx, FILE *vcdhandle); int fstReaderProcessHier(void *ctx, FILE *vcdhandle);
const char * fstReaderPushScope(void *ctx, const char *nam, void *user_info); const char * fstReaderPushScope(void *ctx, const char *nam, void *user_info);
void fstReaderResetScope(void *ctx); void fstReaderResetScope(void *ctx);
void fstReaderSetFacProcessMask(void *ctx, fstHandle facidx); void fstReaderSetFacProcessMask(void *ctx, fstHandle facidx);
void fstReaderSetFacProcessMaskAll(void *ctx); void fstReaderSetFacProcessMaskAll(void *ctx);
void fstReaderSetLimitTimeRange(void *ctx, uint64_t start_time, uint64_t end_time); void fstReaderSetLimitTimeRange(void *ctx, uint64_t start_time, uint64_t end_time);
void fstReaderSetUnlimitedTimeRange(void *ctx); void fstReaderSetUnlimitedTimeRange(void *ctx);
void fstReaderSetVcdExtensions(void *ctx, int enable); void fstReaderSetVcdExtensions(void *ctx, int enable);
/* /*
* utility functions * utility functions
*/ */
int fstUtilityBinToEsc(unsigned char *d, unsigned char *s, int len); int fstUtilityBinToEsc(unsigned char *d, unsigned char *s, int len);
int fstUtilityEscToBin(unsigned char *d, unsigned char *s, int len); int fstUtilityEscToBin(unsigned char *d, unsigned char *s, int len);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -30,18 +30,18 @@
static char *lxt2_wr_vcd_truncate_bitvec(char *s) static char *lxt2_wr_vcd_truncate_bitvec(char *s)
{ {
char l, r; char l, r;
r=*s; r=*s;
if(r=='1') if(r=='1')
{ {
return s; return s;
} }
else else
{ {
s++; s++;
} }
for(;;s++) for(;;s++)
{ {
l=r; r=*s; l=r; r=*s;
@ -50,7 +50,7 @@ for(;;s++)
if(l!=r) if(l!=r)
{ {
return(((l=='0')&&(r=='1'))?s:s-1); return(((l=='0')&&(r=='1'))?s:s-1);
} }
} }
} }
@ -155,7 +155,7 @@ static lxt2_wr_ds_Tree * lxt2_wr_ds_insert(granmsk_t i, lxt2_wr_ds_Tree * t, int
/* Insert i into the tree t, unless it's already there. */ /* Insert i into the tree t, unless it's already there. */
/* Return a pointer to the resulting tree. */ /* Return a pointer to the resulting tree. */
lxt2_wr_ds_Tree * n; lxt2_wr_ds_Tree * n;
n = (lxt2_wr_ds_Tree *) calloc (1, sizeof (lxt2_wr_ds_Tree)); n = (lxt2_wr_ds_Tree *) calloc (1, sizeof (lxt2_wr_ds_Tree));
if (n == NULL) { if (n == NULL) {
fprintf(stderr, "ds_insert: ran out of memory, exiting.\n"); fprintf(stderr, "ds_insert: ran out of memory, exiting.\n");
@ -245,7 +245,7 @@ static lxt2_wr_dslxt_Tree * lxt2_wr_dslxt_insert(char *i, lxt2_wr_dslxt_Tree * t
/* Return a pointer to the resulting tree. */ /* Return a pointer to the resulting tree. */
lxt2_wr_dslxt_Tree * n; lxt2_wr_dslxt_Tree * n;
int dir; int dir;
n = (lxt2_wr_dslxt_Tree *) calloc (1, sizeof (lxt2_wr_dslxt_Tree)); n = (lxt2_wr_dslxt_Tree *) calloc (1, sizeof (lxt2_wr_dslxt_Tree));
if (n == NULL) { if (n == NULL) {
fprintf(stderr, "dslxt_insert: ran out of memory, exiting.\n"); fprintf(stderr, "dslxt_insert: ran out of memory, exiting.\n");
@ -281,7 +281,7 @@ static lxt2_wr_dslxt_Tree * lxt2_wr_dslxt_insert(char *i, lxt2_wr_dslxt_Tree * t
/* /*
* functions which emit various big endian * functions which emit various big endian
* data to a file * data to a file
*/ */
static int lxt2_wr_emit_u8(struct lxt2_wr_trace *lt, int value) static int lxt2_wr_emit_u8(struct lxt2_wr_trace *lt, int value)
{ {
unsigned char buf[1]; unsigned char buf[1];
@ -340,7 +340,7 @@ return(rc);
* data to a file. (lt->position needs to be * data to a file. (lt->position needs to be
* fixed up on gzclose so the tables don't * fixed up on gzclose so the tables don't
* get out of sync!) * get out of sync!)
*/ */
static int gzwrite_buffered(struct lxt2_wr_trace *lt) static int gzwrite_buffered(struct lxt2_wr_trace *lt)
{ {
int rc = 1; int rc = 1;
@ -446,7 +446,7 @@ return(rc);
static int lxt2_wr_emit_stringz(struct lxt2_wr_trace *lt, char *value) static int lxt2_wr_emit_stringz(struct lxt2_wr_trace *lt, char *value)
{ {
int rc=1; int rc=1;
do do
{ {
rc&=lxt2_wr_emit_u8z(lt, *value); rc&=lxt2_wr_emit_u8z(lt, *value);
} while(*(value++)); } while(*(value++));
@ -473,7 +473,7 @@ for(p=s;*p;p++)
{ {
h=h^(g>>24); h=h^(g>>24);
h=h^g; h=h^g;
} }
} }
h^=h2; /* combine the two hashes */ h^=h2; /* combine the two hashes */
@ -500,17 +500,17 @@ struct lxt2_wr_symbol *temp;
hv=lxt2_wr_hash(s); hv=lxt2_wr_hash(s);
if(!(temp=lt->sym[hv])) return(NULL); /* no hash entry, add here wanted to add */ if(!(temp=lt->sym[hv])) return(NULL); /* no hash entry, add here wanted to add */
while(temp) while(temp)
{ {
if(!strcmp(temp->name,s)) if(!strcmp(temp->name,s))
{ {
return(temp); /* in table already */ return(temp); /* in table already */
} }
if(!temp->next) break; if(!temp->next) break;
temp=temp->next; temp=temp->next;
} }
return(NULL); /* not found, add here if you want to add*/ return(NULL); /* not found, add here if you want to add*/
} }
@ -535,13 +535,13 @@ if(lt->compress_fac_str)
lxt2_wr_emit_u16z(lt, i); lxt2_wr_emit_u16z(lt, i);
lxt2_wr_emit_stringz(lt, str+i); lxt2_wr_emit_stringz(lt, str+i);
free(lt->compress_fac_str); free(lt->compress_fac_str);
} }
else else
{ {
lxt2_wr_emit_u16z(lt, 0); lxt2_wr_emit_u16z(lt, 0);
lxt2_wr_emit_stringz(lt, str); lxt2_wr_emit_stringz(lt, str);
} }
lt->compress_fac_str = (char *) malloc((lt->compress_fac_len=len)+1); lt->compress_fac_str = (char *) malloc((lt->compress_fac_len=len)+1);
strcpy(lt->compress_fac_str, str); strcpy(lt->compress_fac_str, str);
} }
@ -567,10 +567,10 @@ while(lastch!=s->name)
if(*lastch=='[') if(*lastch=='[')
{ {
*lastch=0x00; *lastch=0x00;
return; return;
} }
lastch--; lastch--;
} }
return; return;
} }
@ -597,19 +597,19 @@ if((lt)&&(lt->numfacs))
strip_brack(s); strip_brack(s);
s=s->symchain; s=s->symchain;
} }
else else
for(i=0;i<lt->numfacs;i++) for(i=0;i<lt->numfacs;i++)
{ {
lt->sorted_facs[lt->numfacs - i - 1] = s; /* facs were chained backwards so reverse to restore bitslicing */ lt->sorted_facs[lt->numfacs - i - 1] = s; /* facs were chained backwards so reverse to restore bitslicing */
s=s->symchain; s=s->symchain;
} }
wave_msort(lt->sorted_facs, lt->numfacs); wave_msort(lt->sorted_facs, lt->numfacs);
if(lt->partial_preference) if(lt->partial_preference)
{ {
/* move preferenced facs up */ /* move preferenced facs up */
struct lxt2_wr_symbol **prefcache = aliascache; struct lxt2_wr_symbol **prefcache = aliascache;
int prefs_encountered = 0; int prefs_encountered = 0;
facs_encountered = 0; facs_encountered = 0;
for(i=0;i<lt->numfacs;i++) for(i=0;i<lt->numfacs;i++)
@ -700,7 +700,7 @@ if((lt)&&(lt->numfacs))
free(lt->compress_fac_str); lt->compress_fac_str=NULL; free(lt->compress_fac_str); lt->compress_fac_str=NULL;
lt->compress_fac_len=0; lt->compress_fac_len=0;
lt->zfacname_predec_size = lt->zpackcount; lt->zfacname_predec_size = lt->zpackcount;
gzflush_buffered(lt, 1); gzflush_buffered(lt, 1);
fseeko(lt->handle, 0L, SEEK_END); fseeko(lt->handle, 0L, SEEK_END);
lt->position=ftello(lt->handle); lt->position=ftello(lt->handle);
@ -746,7 +746,7 @@ if((lt)&&(lt->numfacs))
} }
/* /*
* initialize the trace and get back an lt context * initialize the trace and get back an lt context
*/ */
struct lxt2_wr_trace *lxt2_wr_init(const char *name) struct lxt2_wr_trace *lxt2_wr_init(const char *name)
@ -805,15 +805,15 @@ if(lt)
{ {
lt->partial = 1; lt->partial = 1;
lt->partial_zip = (zipmode != 0); lt->partial_zip = (zipmode != 0);
lt->partial_iter = LXT2_WR_PARTIAL_SIZE; lt->partial_iter = LXT2_WR_PARTIAL_SIZE;
} }
} }
void lxt2_wr_set_partial_preference(struct lxt2_wr_trace *lt, const char *name) void lxt2_wr_set_partial_preference(struct lxt2_wr_trace *lt, const char *name)
{ {
struct lxt2_wr_symbol *s; struct lxt2_wr_symbol *s;
if((lt)&&(name)&&(!lt->sorted_facs)) if((lt)&&(name)&&(!lt->sorted_facs))
{ {
s=lxt2_wr_symfind(lt, name); s=lxt2_wr_symfind(lt, name);
if(s) if(s)
@ -852,8 +852,8 @@ if(lt)
/* /*
* set initial value of trace (0, 1, x, z) only legal vals * set initial value of trace (0, 1, x, z) only legal vals
*/ */
void lxt2_wr_set_initial_value(struct lxt2_wr_trace *lt, char value) void lxt2_wr_set_initial_value(struct lxt2_wr_trace *lt, char value)
{ {
if(lt) if(lt)
{ {
switch(value) switch(value)
@ -991,7 +991,7 @@ return(sa);
} }
/* /*
* set current time/granule updating * set current time/granule updating
*/ */
int lxt2_wr_inc_time_by_delta(struct lxt2_wr_trace *lt, unsigned int timeval) int lxt2_wr_inc_time_by_delta(struct lxt2_wr_trace *lt, unsigned int timeval)
@ -1221,7 +1221,7 @@ if(using_partial)
lxt2_wr_emit_u32(lt, partial_length+9); /* size of this section (uncompressed) */ lxt2_wr_emit_u32(lt, partial_length+9); /* size of this section (uncompressed) */
lxt2_wr_emit_u32(lt, iter); /* begin iter of section */ lxt2_wr_emit_u32(lt, iter); /* begin iter of section */
fflush(lt->handle); fflush(lt->handle);
lt->zhandle = gzdopen(dup(fileno(lt->handle)), lt->zmode); lt->zhandle = gzdopen(dup(fileno(lt->handle)), lt->zmode);
lt->zpackcount = 0; lt->zpackcount = 0;
} }
@ -1331,7 +1331,7 @@ if((lt->timegranule>=lt->maxgranule)||(do_finalize)||(early_flush))
lxt2_wr_emit_u32(lt, 0); /* size of this section (uncompressed) */ lxt2_wr_emit_u32(lt, 0); /* size of this section (uncompressed) */
lxt2_wr_emit_u32(lt, ~0); /* control section */ lxt2_wr_emit_u32(lt, ~0); /* control section */
fflush(lt->handle); fflush(lt->handle);
lt->zhandle = gzdopen(dup(fileno(lt->handle)), lt->zmode); lt->zhandle = gzdopen(dup(fileno(lt->handle)), lt->zmode);
lt->zpackcount = 0; lt->zpackcount = 0;
} }
@ -1354,9 +1354,9 @@ if((lt->timegranule>=lt->maxgranule)||(do_finalize)||(early_flush))
exit(255); exit(255);
} }
lxt2_wr_emit_stringz(lt, ds->item); lxt2_wr_emit_stringz(lt, ds->item);
ds2 = ds->next; ds2 = ds->next;
free(ds->item); free(ds->item);
free(ds); free(ds);
ds = ds2; ds = ds2;
} }
@ -1382,7 +1382,7 @@ if((lt->timegranule>=lt->maxgranule)||(do_finalize)||(early_flush))
#endif #endif
dt2 = dt->next; dt2 = dt->next;
free(dt); free(dt);
dt = dt2; dt = dt2;
} }
lt->mapdict_head = lt->mapdict_curr = lt->mapdict = NULL; lt->mapdict_head = lt->mapdict_curr = lt->mapdict = NULL;
@ -1399,11 +1399,11 @@ if((lt->timegranule>=lt->maxgranule)||(do_finalize)||(early_flush))
if(using_partial_zip) if(using_partial_zip)
{ {
off_t c_len; off_t c_len;
gzflush_buffered(lt, 1); gzflush_buffered(lt, 1);
fseeko(lt->handle, 0L, SEEK_END); fseeko(lt->handle, 0L, SEEK_END);
lt->position=ftello(lt->handle); lt->position=ftello(lt->handle);
c_len = lt->position - current_iter_pos - 12; c_len = lt->position - current_iter_pos - 12;
fseeko(lt->handle, current_iter_pos, SEEK_SET); fseeko(lt->handle, current_iter_pos, SEEK_SET);
@ -1467,7 +1467,7 @@ if(lt)
{ {
lt->bumptime = 0; lt->bumptime = 0;
if(!lt->flush_valid) if(!lt->flush_valid)
{ {
lt->timepos++; lt->timepos++;
} }
@ -1475,7 +1475,7 @@ if(lt)
{ {
lt->flush_valid = 0; lt->flush_valid = 0;
} }
if(lt->timepos == LXT2_WR_GRANULE_SIZE) if(lt->timepos == LXT2_WR_GRANULE_SIZE)
{ {
/* fprintf(stderr, "flushing granule to disk at time %d\n", (unsigned int)timeval); */ /* fprintf(stderr, "flushing granule to disk at time %d\n", (unsigned int)timeval); */
@ -1484,7 +1484,7 @@ if(lt)
} }
/* fprintf(stderr, "updating time to %d (%d dict entries/%d bytes)\n", (unsigned int)timeval, lt->num_dict_entries, lt->dict_string_mem_required); */ /* fprintf(stderr, "updating time to %d (%d dict entries/%d bytes)\n", (unsigned int)timeval, lt->num_dict_entries, lt->dict_string_mem_required); */
lt->timetable[lt->timepos] = timeval; lt->timetable[lt->timepos] = timeval;
lt->lasttime = timeval; lt->lasttime = timeval;
} }
} }
@ -1493,7 +1493,7 @@ if(lt)
lt->timeset = 1; lt->timeset = 1;
lt->mintime = lt->maxtime = timeval; lt->mintime = lt->maxtime = timeval;
lt->timetable[lt->timepos] = timeval; lt->timetable[lt->timepos] = timeval;
} }
if( (!lt->timepos) && (!lt->timegranule) ) if( (!lt->timepos) && (!lt->timegranule) )
@ -1524,7 +1524,7 @@ if(lt)
else if (s->flags&LXT2_WR_SYM_F_DOUBLE) else if (s->flags&LXT2_WR_SYM_F_DOUBLE)
{ {
double value = 0; double value = 0;
sscanf(s->value, "%lg", &value); sscanf(s->value, "%lg", &value);
errno = 0; errno = 0;
lxt2_wr_emit_value_double(lt, s, 0, value); lxt2_wr_emit_value_double(lt, s, 0, value);
@ -1625,7 +1625,7 @@ int rc=0;
if((!lt)||(lt->blackout)||(!s)||(row)) return(rc); if((!lt)||(lt->blackout)||(!s)||(row)) return(rc);
if(!lt->emitted) if(!lt->emitted)
{ {
lxt2_wr_emitfacs(lt); lxt2_wr_emitfacs(lt);
lt->emitted = 1; lt->emitted = 1;
@ -1666,7 +1666,7 @@ if(s->flags&LXT2_WR_SYM_F_DOUBLE)
if(lt->dict_curr) if(lt->dict_curr)
{ {
lt->dict_curr->next = lt->dict; lt->dict_curr->next = lt->dict;
lt->dict_curr = lt->dict; lt->dict_curr = lt->dict;
} }
else else
@ -1707,7 +1707,7 @@ int rc=0;
if((!lt)||(lt->blackout)||(!s)||(!value)||(row)) return(rc); if((!lt)||(lt->blackout)||(!s)||(!value)||(row)) return(rc);
if(!lt->emitted) if(!lt->emitted)
{ {
lxt2_wr_emitfacs(lt); lxt2_wr_emitfacs(lt);
lt->emitted = 1; lt->emitted = 1;
@ -1746,7 +1746,7 @@ if(s->flags&LXT2_WR_SYM_F_STRING)
if(lt->dict_curr) if(lt->dict_curr)
{ {
lt->dict_curr->next = lt->dict; lt->dict_curr->next = lt->dict;
lt->dict_curr = lt->dict; lt->dict_curr = lt->dict;
} }
else else
@ -1791,7 +1791,7 @@ int i;
if((!lt)||(lt->blackout)||(!s)||(!value)||(!*value)||(row)) return(rc); if((!lt)||(lt->blackout)||(!s)||(!value)||(!*value)||(row)) return(rc);
if(!lt->emitted) if(!lt->emitted)
{ {
lxt2_wr_emitfacs(lt); lxt2_wr_emitfacs(lt);
lt->emitted = 1; lt->emitted = 1;
@ -1856,12 +1856,12 @@ if(!(s->flags&(LXT2_WR_SYM_F_DOUBLE|LXT2_WR_SYM_F_STRING)))
prevch = *vpnt; prevch = *vpnt;
while(*vpnt) while(*vpnt)
{ {
if(prevch == *vpnt) if(prevch == *vpnt)
{ {
vpnt++; vpnt++;
} }
else else
{ {
prevch = 0; prevch = 0;
break; break;
} }
@ -1968,7 +1968,7 @@ idxchk: if(idx<0)
if(lt->dict_curr) if(lt->dict_curr)
{ {
lt->dict_curr->next = lt->dict; lt->dict_curr->next = lt->dict;
lt->dict_curr = lt->dict; lt->dict_curr = lt->dict;
} }
else else
@ -2016,15 +2016,15 @@ struct lxt2_wr_symbol *s;
if((lt)&&(!lt->blackout)) if((lt)&&(!lt->blackout))
{ {
if(!lt->emitted) if(!lt->emitted)
{ {
lxt2_wr_emitfacs(lt); lxt2_wr_emitfacs(lt);
lt->emitted = 1; lt->emitted = 1;
if(!lt->timeset) if(!lt->timeset)
{ {
lxt2_wr_set_time(lt, 0); lxt2_wr_set_time(lt, 0);
} }
} }
s = lt->symchain; s = lt->symchain;
@ -2036,7 +2036,7 @@ if((lt)&&(!lt->blackout))
{ {
s->msk |= (LXT2_WR_GRAN_1VAL<<lt->timepos); s->msk |= (LXT2_WR_GRAN_1VAL<<lt->timepos);
s->chg[s->chgpos] = LXT2_WR_ENC_BLACKOUT; s->chg[s->chgpos] = LXT2_WR_ENC_BLACKOUT;
s->chgpos++; s->chgpos++;
} }
else else
@ -2158,7 +2158,7 @@ if(lt)
{ {
struct lxt2_wr_symbol *s = lt->symchain; struct lxt2_wr_symbol *s = lt->symchain;
struct lxt2_wr_symbol *s2; struct lxt2_wr_symbol *s2;
while(s) while(s)
{ {
free(s->name); free(s->name);
@ -2170,7 +2170,7 @@ if(lt)
lt->symchain=NULL; lt->symchain=NULL;
} }
free(lt->lxtname); free(lt->lxtname);
free(lt->sorted_facs); free(lt->sorted_facs);
fclose(lt->handle); fclose(lt->handle);
@ -2193,13 +2193,13 @@ if(lt)
/* /*
* time zero offset * time zero offset
*/ */
void lxt2_wr_set_timezero(struct lxt2_wr_trace *lt, lxtstime_t timeval) void lxt2_wr_set_timezero(struct lxt2_wr_trace *lt, lxtstime_t timeval)
{ {
if(lt) if(lt)
{ {
lt->timezero = timeval; lt->timezero = timeval;
} }
} }

View File

@ -3,19 +3,19 @@
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation * to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense, * the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the * and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions: * Software is furnished to do so, subject to the following conditions:
* *
* The above copyright notice and this permission notice shall be included in * The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software. * all copies or substantial portions of the Software.
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE. * DEALINGS IN THE SOFTWARE.
*/ */
@ -83,12 +83,12 @@ typedef unsigned long long granmsk_t;
#define LXT2_WR_GRAN_1VAL (LXT2_WR_ULLDESC(1)) #define LXT2_WR_GRAN_1VAL (LXT2_WR_ULLDESC(1))
#else #else
typedef unsigned int granmsk_t; typedef unsigned int granmsk_t;
#define LXT2_WR_GRAN_0VAL (0) #define LXT2_WR_GRAN_0VAL (0)
#define LXT2_WR_GRAN_1VAL (1) #define LXT2_WR_GRAN_1VAL (1)
#endif #endif
enum LXT2_WR_Encodings { enum LXT2_WR_Encodings {
LXT2_WR_ENC_0, LXT2_WR_ENC_0,
LXT2_WR_ENC_1, LXT2_WR_ENC_1,
LXT2_WR_ENC_INV, LXT2_WR_ENC_INV,
@ -132,12 +132,12 @@ struct lxt2_wr_ds_tree_node {
*/ */
typedef struct lxt2_wr_dslxt_tree_node lxt2_wr_dslxt_Tree; typedef struct lxt2_wr_dslxt_tree_node lxt2_wr_dslxt_Tree;
struct lxt2_wr_dslxt_tree_node { struct lxt2_wr_dslxt_tree_node {
lxt2_wr_dslxt_Tree * left, * right; lxt2_wr_dslxt_Tree * left, * right;
char *item; char *item;
unsigned int val; unsigned int val;
lxt2_wr_dslxt_Tree * next; lxt2_wr_dslxt_Tree * next;
}; };
struct lxt2_wr_trace struct lxt2_wr_trace
{ {

View File

@ -132,7 +132,7 @@ static dslxt_Tree * dslxt_insert(char *i, dslxt_Tree * t, unsigned int val) {
/* Return a pointer to the resulting tree. */ /* Return a pointer to the resulting tree. */
dslxt_Tree * n; dslxt_Tree * n;
int dir; int dir;
n = (dslxt_Tree *) calloc (1, sizeof (dslxt_Tree)); n = (dslxt_Tree *) calloc (1, sizeof (dslxt_Tree));
if (n == NULL) { if (n == NULL) {
fprintf(stderr, "dslxt_insert: ran out of memory, exiting.\n"); fprintf(stderr, "dslxt_insert: ran out of memory, exiting.\n");
@ -190,7 +190,7 @@ static dslxt_Tree * dslxt_delete(char *i, dslxt_Tree * t) {
/* /*
* functions which emit various big endian * functions which emit various big endian
* data to a file * data to a file
*/ */
static int lt_emit_u8(struct lt_trace *lt, int value) static int lt_emit_u8(struct lt_trace *lt, int value)
{ {
unsigned char buf[1]; unsigned char buf[1];
@ -271,7 +271,7 @@ return(nmemb);
static int lt_emit_string(struct lt_trace *lt, char *value) static int lt_emit_string(struct lt_trace *lt, char *value)
{ {
int rc=1; int rc=1;
do do
{ {
rc&=lt_emit_u8(lt, *value); rc&=lt_emit_u8(lt, *value);
} while(*(value++)); } while(*(value++));
@ -284,7 +284,7 @@ return(rc);
* data to a file. (lt->position needs to be * data to a file. (lt->position needs to be
* fixed up on gzclose so the tables don't * fixed up on gzclose so the tables don't
* get out of sync!) * get out of sync!)
*/ */
static int lt_emit_u8z(struct lt_trace *lt, int value) static int lt_emit_u8z(struct lt_trace *lt, int value)
{ {
unsigned char buf[1]; unsigned char buf[1];
@ -371,7 +371,7 @@ return(nmemb);
static int lt_emit_stringz(struct lt_trace *lt, char *value) static int lt_emit_stringz(struct lt_trace *lt, char *value)
{ {
int rc=1; int rc=1;
do do
{ {
rc&=lt_emit_u8z(lt, *value); rc&=lt_emit_u8z(lt, *value);
} while(*(value++)); } while(*(value++));
@ -383,7 +383,7 @@ return(rc);
* data to a file. (lt->position needs to be * data to a file. (lt->position needs to be
* fixed up on BZ2_bzclose so the tables don't * fixed up on BZ2_bzclose so the tables don't
* get out of sync!) * get out of sync!)
*/ */
static int lt_emit_u8bz(struct lt_trace *lt, int value) static int lt_emit_u8bz(struct lt_trace *lt, int value)
{ {
unsigned char buf[1]; unsigned char buf[1];
@ -470,7 +470,7 @@ return(nmemb);
static int lt_emit_stringbz(struct lt_trace *lt, char *value) static int lt_emit_stringbz(struct lt_trace *lt, char *value)
{ {
int rc=1; int rc=1;
do do
{ {
rc&=lt_emit_u8bz(lt, *value); rc&=lt_emit_u8bz(lt, *value);
} while(*(value++)); } while(*(value++));
@ -537,7 +537,7 @@ for(p=s;*p;p++)
{ {
h=h^(g>>24); h=h^(g>>24);
h=h^g; h=h^g;
} }
} }
h^=h2; /* combine the two hashes */ h^=h2; /* combine the two hashes */
@ -564,17 +564,17 @@ struct lt_symbol *temp;
hv=lt_hash(s); hv=lt_hash(s);
if(!(temp=lt->sym[hv])) return(NULL); /* no hash entry, add here wanted to add */ if(!(temp=lt->sym[hv])) return(NULL); /* no hash entry, add here wanted to add */
while(temp) while(temp)
{ {
if(!strcmp(temp->name,s)) if(!strcmp(temp->name,s))
{ {
return(temp); /* in table already */ return(temp); /* in table already */
} }
if(!temp->next) break; if(!temp->next) break;
temp=temp->next; temp=temp->next;
} }
return(NULL); /* not found, add here if you want to add*/ return(NULL); /* not found, add here if you want to add*/
} }
@ -599,13 +599,13 @@ if(lt->compress_fac_str)
lt_emit_u16z(lt, i); lt_emit_u16z(lt, i);
lt_emit_stringz(lt, str+i); lt_emit_stringz(lt, str+i);
free(lt->compress_fac_str); free(lt->compress_fac_str);
} }
else else
{ {
lt_emit_u16z(lt, 0); lt_emit_u16z(lt, 0);
lt_emit_stringz(lt, str); lt_emit_stringz(lt, str);
} }
lt->compress_fac_str = (char *) malloc((lt->compress_fac_len=len)+1); lt->compress_fac_str = (char *) malloc((lt->compress_fac_len=len)+1);
strcpy(lt->compress_fac_str, str); strcpy(lt->compress_fac_str, str);
} }
@ -626,10 +626,10 @@ while(lastch!=s->name)
if(*lastch=='[') if(*lastch=='[')
{ {
*lastch=0x00; *lastch=0x00;
return; return;
} }
lastch--; lastch--;
} }
return; return;
} }
@ -655,12 +655,12 @@ if((lt)&&(lt->numfacs))
strip_brack(s); strip_brack(s);
s=s->symchain; s=s->symchain;
} }
else else
for(i=0;i<lt->numfacs;i++) for(i=0;i<lt->numfacs;i++)
{ {
lt->sorted_facs[lt->numfacs - i - 1] = s; /* facs were chained backwards so reverse to restore bitslicing*/ lt->sorted_facs[lt->numfacs - i - 1] = s; /* facs were chained backwards so reverse to restore bitslicing*/
s=s->symchain; s=s->symchain;
} }
wave_msort(lt->sorted_facs, lt->numfacs); wave_msort(lt->sorted_facs, lt->numfacs);
for(i=0;i<lt->numfacs;i++) for(i=0;i<lt->numfacs;i++)
@ -688,7 +688,7 @@ if((lt)&&(lt->numfacs))
free(lt->compress_fac_str); lt->compress_fac_str=NULL; free(lt->compress_fac_str); lt->compress_fac_str=NULL;
lt->compress_fac_len=0; lt->compress_fac_len=0;
lt->zfacname_predec_size = lt->zpackcount; lt->zfacname_predec_size = lt->zpackcount;
gzclose(lt->zhandle); gzclose(lt->zhandle);
fseeko(lt->handle, 0L, SEEK_END); fseeko(lt->handle, 0L, SEEK_END);
lt->position=ftello(lt->handle); lt->position=ftello(lt->handle);
@ -723,13 +723,13 @@ if((lt)&&(lt->numfacs))
if(is_interlaced_trace) if(is_interlaced_trace)
{ {
lt->zhandle = gzdopen(dup(fileno(lt->handle)), "wb9"); lt->zhandle = gzdopen(dup(fileno(lt->handle)), "wb9");
lt->sync_table_offset = lt->position; lt->sync_table_offset = lt->position;
for(i=0;i<lt->numfacs;i++) for(i=0;i<lt->numfacs;i++)
{ {
lt_emit_u32z(lt, lt->sorted_facs[i]->last_change); lt_emit_u32z(lt, lt->sorted_facs[i]->last_change);
} }
gzclose(lt->zhandle); lt->zhandle = NULL; gzclose(lt->zhandle); lt->zhandle = NULL;
fseeko(lt->handle, 0L, SEEK_END); fseeko(lt->handle, 0L, SEEK_END);
lt->position=ftello(lt->handle); lt->position=ftello(lt->handle);
@ -740,7 +740,7 @@ if((lt)&&(lt->numfacs))
} }
/* /*
* initialize the trace and get back an lt context * initialize the trace and get back an lt context
*/ */
struct lt_trace *lt_init(const char *name) struct lt_trace *lt_init(const char *name)
@ -866,7 +866,7 @@ switch(numbytes_trans&3)
case 3: lt->lt_emit_u32(lt, numtrans); break; case 3: lt->lt_emit_u32(lt, numtrans); break;
} }
/* printf("Clock finish for '%s' at %lld ending with '%c' for %d repeats over a switch delta of %d\n", /* printf("Clock finish for '%s' at %lld ending with '%c' for %d repeats over a switch delta of %d\n",
s->name, lt->timeval, s->clk_prevval, s->clk_numtrans - LT_CLKPACK, s->clk_delta); */ s->name, lt->timeval, s->clk_prevval, s->clk_numtrans - LT_CLKPACK, s->clk_delta); */
s->clk_prevtrans = ULLDescriptor(~0); s->clk_prevtrans = ULLDescriptor(~0);
s->clk_numtrans = 0; s->clk_numtrans = 0;
@ -967,7 +967,7 @@ switch(numbytes_trans&3)
case 3: lt->lt_emit_u32(lt, numtrans); break; case 3: lt->lt_emit_u32(lt, numtrans); break;
} }
/* printf("Clock finish for '%s' at %lld ending with '%08x' for %d repeats over a switch delta of %lld\n", /* printf("Clock finish for '%s' at %lld ending with '%08x' for %d repeats over a switch delta of %lld\n",
s->name, lt->timeval, s->clk_prevval, s->clk_numtrans - LT_CLKPACK_M, s->clk_delta); */ s->name, lt->timeval, s->clk_prevval, s->clk_numtrans - LT_CLKPACK_M, s->clk_delta); */
s->clk_prevtrans = ULLDescriptor(~0); s->clk_prevtrans = ULLDescriptor(~0);
s->clk_numtrans = 0; s->clk_numtrans = 0;
@ -1035,7 +1035,7 @@ for(i=0;i<lt->num_dict_entries;i++)
/* fprintf(stderr, "%8d) '%s'\n", ds->val, ds->item); */ /* fprintf(stderr, "%8d) '%s'\n", ds->val, ds->item); */
lt_emit_stringz(lt, ds->item+1); lt_emit_stringz(lt, ds->item+1);
} }
gzclose(lt->zhandle); gzclose(lt->zhandle);
fseeko(lt->handle, 0L, SEEK_END); fseeko(lt->handle, 0L, SEEK_END);
lt->position=ftello(lt->handle); lt->position=ftello(lt->handle);
@ -1072,13 +1072,13 @@ if(lt)
if(s->clk_numtrans > LT_CLKPACK_M) lt_flushclock_m(lt, s); if(s->clk_numtrans > LT_CLKPACK_M) lt_flushclock_m(lt, s);
} }
else else
{ {
if(s->clk_numtrans > LT_CLKPACK) lt_flushclock(lt, s); if(s->clk_numtrans > LT_CLKPACK) lt_flushclock(lt, s);
} }
} }
s=s->symchain; s=s->symchain;
} }
lt_set_dumpon(lt); /* in case it was turned off */ lt_set_dumpon(lt); /* in case it was turned off */
@ -1134,7 +1134,7 @@ if(lt)
while(t) while(t)
{ {
lt_emit_u32z(lt, t->position - lastposition); lastposition = t->position; lt_emit_u32z(lt, t->position - lastposition); lastposition = t->position;
t=t->next; t=t->next;
} }
t=lt->timehead; t=lt->timehead;
@ -1144,9 +1144,9 @@ if(lt)
{ {
lxttime_t delta = t->timeval - lasttime; lxttime_t delta = t->timeval - lasttime;
lt_emit_u64z(lt, (int)(delta>>32), (int)delta); lasttime = t->timeval; lt_emit_u64z(lt, (int)(delta>>32), (int)delta); lasttime = t->timeval;
t2=t->next; t2=t->next;
free(t); free(t);
t=t2; t=t2;
} }
} }
@ -1155,12 +1155,12 @@ if(lt)
while(t) while(t)
{ {
lt_emit_u32z(lt, (int)(t->timeval - lasttime)); lasttime = t->timeval; lt_emit_u32z(lt, (int)(t->timeval - lasttime)); lasttime = t->timeval;
t2=t->next; t2=t->next;
free(t); free(t);
t=t2; t=t2;
} }
lt->timehead = lt->timecurr = NULL; lt->timehead = lt->timecurr = NULL;
} }
@ -1170,7 +1170,7 @@ if(lt)
lt->ztime_table_size = lt->position - lt->ztime_table_size; lt->ztime_table_size = lt->position - lt->ztime_table_size;
} }
if(lt->initial_value>=0) if(lt->initial_value>=0)
{ {
lt->initial_value_offset = lt->position; lt->initial_value_offset = lt->position;
lt_emit_u8(lt, lt->initial_value); lt_emit_u8(lt, lt->initial_value);
@ -1185,7 +1185,7 @@ if(lt)
if(lt->double_used) if(lt->double_used)
{ {
lt->double_test_offset = lt->position; lt->double_test_offset = lt->position;
lt_emit_double(lt, 3.14159); lt_emit_double(lt, 3.14159);
} }
if(lt->dumpoffcount) if(lt->dumpoffcount)
@ -1201,7 +1201,7 @@ if(lt)
lt_emit_u64(lt, (int)((ltt->timeval)>>32), (int)ltt->timeval); lt_emit_u64(lt, (int)((ltt->timeval)>>32), (int)ltt->timeval);
ltt2 = ltt; ltt2 = ltt;
ltt=ltt->next; ltt=ltt->next;
free(ltt2); free(ltt2);
} }
lt->dumpoffhead = lt->dumpoffcurr = NULL; lt->dumpoffhead = lt->dumpoffcurr = NULL;
@ -1253,7 +1253,7 @@ if(lt)
{ {
struct lt_symbol *sc = lt->symchain; struct lt_symbol *sc = lt->symchain;
struct lt_symbol *s2; struct lt_symbol *s2;
while(sc) while(sc)
{ {
free(sc->name); free(sc->name);
@ -1262,7 +1262,7 @@ if(lt)
sc=s2; sc=s2;
} }
} }
free(lt->sorted_facs); free(lt->sorted_facs);
fclose(lt->handle); fclose(lt->handle);
free(lt); free(lt);
@ -1368,7 +1368,7 @@ return(sa);
} }
/* /*
* set current time * set current time
*/ */
int lt_inc_time_by_delta(struct lt_trace *lt, unsigned int timeval) int lt_inc_time_by_delta(struct lt_trace *lt, unsigned int timeval)
@ -1407,7 +1407,7 @@ if(lt)
else else
{ {
free(trl); free(trl);
goto bail; goto bail;
} }
} }
else else
@ -1485,7 +1485,7 @@ if((lt)&&(!lt->emitted))
} }
/* /*
* sets change interlace * sets change interlace
*/ */
void lt_set_no_interlace(struct lt_trace *lt) void lt_set_no_interlace(struct lt_trace *lt)
{ {
@ -1510,12 +1510,12 @@ if((lt)&&(!lt->emitted)&&(!lt->sorted_facs))
strip_brack(s); strip_brack(s);
s=s->symchain; s=s->symchain;
} }
else else
for(i=0;i<lt->numfacs;i++) for(i=0;i<lt->numfacs;i++)
{ {
lt->sorted_facs[lt->numfacs - i - 1] = s; /* facs were chained backwards so reverse to restore bitslicing */ lt->sorted_facs[lt->numfacs - i - 1] = s; /* facs were chained backwards so reverse to restore bitslicing */
s=s->symchain; s=s->symchain;
} }
wave_msort(lt->sorted_facs, lt->numfacs); wave_msort(lt->sorted_facs, lt->numfacs);
for(i=0;i<lt->numfacs;i++) for(i=0;i<lt->numfacs;i++)
@ -1555,12 +1555,12 @@ if(lt)
{ {
int tag; int tag;
switch(value) switch(value)
{ {
case '0': tag = 0; break; case '0': tag = 0; break;
case '1': tag = 1; break; case '1': tag = 1; break;
case 'Z': case 'Z':
case 'z': tag = 2; break; case 'z': tag = 2; break;
case 'X': case 'X':
case 'x': tag = 3; break; case 'x': tag = 3; break;
case 'H': case 'H':
case 'h': tag = 4; break; case 'h': tag = 4; break;
@ -1686,7 +1686,7 @@ if(!(s->flags&(LT_SYM_F_DOUBLE|LT_SYM_F_STRING)))
s->clk_mask <<= 1; s->clk_mask <<= 1;
s->clk_mask |= 1; s->clk_mask |= 1;
if( ((s->clk_mask&0x1f)==0x1f) && if( ((s->clk_mask&0x1f)==0x1f) &&
( (delta1=(ivalue - s->clk_prevval1) & lt_optimask[s->len]) == ((s->clk_prevval1 - s->clk_prevval3) & lt_optimask[s->len]) ) && ( (delta1=(ivalue - s->clk_prevval1) & lt_optimask[s->len]) == ((s->clk_prevval1 - s->clk_prevval3) & lt_optimask[s->len]) ) &&
( (delta2=(s->clk_prevval - s->clk_prevval2) & lt_optimask[s->len]) == ((s->clk_prevval2 - s->clk_prevval4) & lt_optimask[s->len]) ) && ( (delta2=(s->clk_prevval - s->clk_prevval2) & lt_optimask[s->len]) == ((s->clk_prevval2 - s->clk_prevval4) & lt_optimask[s->len]) ) &&
( (delta1==delta2) || ((!delta1)&&(!delta2)) ) ( (delta1==delta2) || ((!delta1)&&(!delta2)) )
@ -1862,7 +1862,7 @@ if(!(s->flags&(LT_SYM_F_DOUBLE|LT_SYM_F_STRING)))
{ {
tag = (numbytes<<4); tag = (numbytes<<4);
} }
lt->lt_emit_u8(lt, tag); lt->lt_emit_u8(lt, tag);
switch(numbytes&3) switch(numbytes&3)
{ {
@ -1883,7 +1883,7 @@ if(!(s->flags&(LT_SYM_F_DOUBLE|LT_SYM_F_STRING)))
} }
lt->lt_emit_u8(lt, optimized ? (3+optimized1) : 0); lt->lt_emit_u8(lt, optimized ? (3+optimized1) : 0);
} }
s->last_change = start_position; s->last_change = start_position;
if(s->rows>0) if(s->rows>0)
@ -1949,7 +1949,7 @@ if(!(s->flags&(LT_SYM_F_DOUBLE|LT_SYM_F_STRING)))
{ {
if(lt->num_dict_entries==(256*65536)) lt->dict32_offset = lt->position; if(lt->num_dict_entries==(256*65536)) lt->dict32_offset = lt->position;
} }
lt->num_dict_entries++; lt->num_dict_entries++;
} }
@ -1994,14 +1994,14 @@ if(!(s->flags&(LT_SYM_F_DOUBLE|LT_SYM_F_STRING)))
value <<= (24-len); value <<= (24-len);
rc=lt->lt_emit_u24(lt, value); rc=lt->lt_emit_u24(lt, value);
} }
else else
{ {
value <<= (32-len); value <<= (32-len);
rc=lt->lt_emit_u32(lt, value); rc=lt->lt_emit_u32(lt, value);
} }
} }
} }
if(lt->timebuff) if(lt->timebuff)
{ {
lt->timechangecount++; lt->timechangecount++;
@ -2063,7 +2063,7 @@ if((s->flags)&LT_SYM_F_DOUBLE)
{ {
numbytes = 0; numbytes = 0;
} }
start_position = lt->position; start_position = lt->position;
s->last_change = start_position; s->last_change = start_position;
@ -2119,7 +2119,7 @@ if((s->flags)&LT_SYM_F_DOUBLE)
} }
rc=lt->lt_emit_double(lt, value); rc=lt->lt_emit_double(lt, value);
if(lt->timebuff) if(lt->timebuff)
{ {
lt->timechangecount++; lt->timechangecount++;
@ -2181,7 +2181,7 @@ if((s->flags)&LT_SYM_F_STRING)
{ {
numbytes = 0; numbytes = 0;
} }
start_position = lt->position; start_position = lt->position;
s->last_change = start_position; s->last_change = start_position;
@ -2237,7 +2237,7 @@ if((s->flags)&LT_SYM_F_STRING)
} }
rc=lt->lt_emit_string(lt, value); rc=lt->lt_emit_string(lt, value);
if(lt->timebuff) if(lt->timebuff)
{ {
lt->timechangecount++; lt->timechangecount++;
@ -2318,7 +2318,7 @@ if(!(s->flags&(LT_SYM_F_DOUBLE|LT_SYM_F_STRING)))
s->clk_mask <<= 1; s->clk_mask <<= 1;
s->clk_mask |= legal; s->clk_mask |= legal;
if( ((s->clk_mask&0x1f)==0x1f) && if( ((s->clk_mask&0x1f)==0x1f) &&
( (delta1=(ivalue - s->clk_prevval1) & lt_optimask[s->len]) == ((s->clk_prevval1 - s->clk_prevval3) & lt_optimask[s->len]) ) && ( (delta1=(ivalue - s->clk_prevval1) & lt_optimask[s->len]) == ((s->clk_prevval1 - s->clk_prevval3) & lt_optimask[s->len]) ) &&
( (delta2=(s->clk_prevval - s->clk_prevval2) & lt_optimask[s->len]) == ((s->clk_prevval2 - s->clk_prevval4) & lt_optimask[s->len]) ) && ( (delta2=(s->clk_prevval - s->clk_prevval2) & lt_optimask[s->len]) == ((s->clk_prevval2 - s->clk_prevval4) & lt_optimask[s->len]) ) &&
( (delta1==delta2) || ((!delta1)&&(!delta2)) ) ( (delta1==delta2) || ((!delta1)&&(!delta2)) )
@ -2350,7 +2350,7 @@ if(!(s->flags&(LT_SYM_F_DOUBLE|LT_SYM_F_STRING)))
s->clk_prevval1 = s->clk_prevval; s->clk_prevval1 = s->clk_prevval;
s->clk_prevval = ivalue; s->clk_prevval = ivalue;
/* printf("Clock value '%08x' for '%s' [len=%d] at %lld (#%d)\n", /* printf("Clock value '%08x' for '%s' [len=%d] at %lld (#%d)\n",
ivalue, s->name, len, lt->timeval, s->clk_numtrans); */ ivalue, s->name, len, lt->timeval, s->clk_numtrans); */
return(1); return(1);
} }
@ -2480,12 +2480,12 @@ if(!(s->flags&(LT_SYM_F_DOUBLE|LT_SYM_F_STRING)))
while((ch=*(pnt++))) while((ch=*(pnt++)))
{ {
switch(ch) switch(ch)
{ {
case '0': case '0':
case '1': mvl|=LT_MVL_2; break; case '1': mvl|=LT_MVL_2; break;
case 'Z': case 'Z':
case 'z': case 'z':
case 'X': case 'X':
case 'x': mvl|=LT_MVL_4; break; case 'x': mvl|=LT_MVL_4; break;
default: mvl|=LT_MVL_9; break; default: mvl|=LT_MVL_9; break;
} }
@ -2494,13 +2494,13 @@ if(!(s->flags&(LT_SYM_F_DOUBLE|LT_SYM_F_STRING)))
} }
switch(prevch) switch(prevch)
{ {
case 0x00: tagadd = 0; break; case 0x00: tagadd = 0; break;
case '0': tagadd = 3; break; case '0': tagadd = 3; break;
case '1': tagadd = 4; break; case '1': tagadd = 4; break;
case 'Z': case 'Z':
case 'z': tagadd = 5; break; case 'z': tagadd = 5; break;
case 'X': case 'X':
case 'x': tagadd = 6; break; case 'x': tagadd = 6; break;
case 'H': case 'H':
case 'h': tagadd = 7; break; case 'h': tagadd = 7; break;
@ -2597,7 +2597,7 @@ if(!(s->flags&(LT_SYM_F_DOUBLE|LT_SYM_F_STRING)))
int outval = 0; int outval = 0;
int thisval= 0; int thisval= 0;
pnt = value; pnt = value;
if((lt->dictmode)&&(len2>lt->mindictwidth)) if((lt->dictmode)&&(len2>lt->mindictwidth))
{ {
@ -2628,7 +2628,7 @@ if(!(s->flags&(LT_SYM_F_DOUBLE|LT_SYM_F_STRING)))
{ {
if(lt->num_dict_entries==(256*65536)) lt->dict32_offset = lt->position; if(lt->num_dict_entries==(256*65536)) lt->dict32_offset = lt->position;
} }
lt->num_dict_entries++; lt->num_dict_entries++;
} }
@ -2666,8 +2666,8 @@ if(!(s->flags&(LT_SYM_F_DOUBLE|LT_SYM_F_STRING)))
outval |= (thisval<<bitpos); outval |= (thisval<<bitpos);
bitpos--; bitpos--;
if((bitpos==-1)||(i==len2-1)) if((bitpos==-1)||(i==len2-1))
{ {
lt->lt_emit_u8(lt, outval); lt->lt_emit_u8(lt, outval);
outval = 0; outval = 0;
bitpos = 7; bitpos = 7;
} }
@ -2681,7 +2681,7 @@ if(!(s->flags&(LT_SYM_F_DOUBLE|LT_SYM_F_STRING)))
int outval = 0; int outval = 0;
int thisval= 0; int thisval= 0;
pnt = value; pnt = value;
for(i=0;i<len2;i++) for(i=0;i<len2;i++)
{ {
@ -2700,8 +2700,8 @@ if(!(s->flags&(LT_SYM_F_DOUBLE|LT_SYM_F_STRING)))
outval |= (thisval<<bitpos); outval |= (thisval<<bitpos);
bitpos-=2; bitpos-=2;
if((bitpos==-2)||(i==len2-1)) if((bitpos==-2)||(i==len2-1))
{ {
lt->lt_emit_u8(lt, outval); lt->lt_emit_u8(lt, outval);
outval = 0; outval = 0;
bitpos = 6; bitpos = 6;
} }
@ -2715,7 +2715,7 @@ if(!(s->flags&(LT_SYM_F_DOUBLE|LT_SYM_F_STRING)))
int outval = 0; int outval = 0;
int thisval= 0; int thisval= 0;
pnt = value; pnt = value;
for(i=0;i<len2;i++) for(i=0;i<len2;i++)
{ {
@ -2744,8 +2744,8 @@ if(!(s->flags&(LT_SYM_F_DOUBLE|LT_SYM_F_STRING)))
outval |= (thisval<<bitpos); outval |= (thisval<<bitpos);
bitpos-=4; bitpos-=4;
if((bitpos==-4)||(i==len2-1)) if((bitpos==-4)||(i==len2-1))
{ {
lt->lt_emit_u8(lt, outval); lt->lt_emit_u8(lt, outval);
outval = 0; outval = 0;
bitpos = 4; bitpos = 4;
} }
@ -2755,7 +2755,7 @@ if(!(s->flags&(LT_SYM_F_DOUBLE|LT_SYM_F_STRING)))
rc=1; rc=1;
} }
if(lt->timebuff) if(lt->timebuff)
{ {
lt->timechangecount++; lt->timechangecount++;

View File

@ -3,19 +3,19 @@
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation * to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense, * the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the * and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions: * Software is furnished to do so, subject to the following conditions:
* *
* The above copyright notice and this permission notice shall be included in * The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software. * all copies or substantial portions of the Software.
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE. * DEALINGS IN THE SOFTWARE.
*/ */
@ -47,11 +47,11 @@ extern "C" {
typedef struct dslxt_tree_node dslxt_Tree; typedef struct dslxt_tree_node dslxt_Tree;
struct dslxt_tree_node { struct dslxt_tree_node {
dslxt_Tree * left, * right; dslxt_Tree * left, * right;
char *item; char *item;
unsigned int val; unsigned int val;
}; };
#define LT_HDRID (0x0138) #define LT_HDRID (0x0138)
#define LT_VERSION (0x0004) #define LT_VERSION (0x0004)
@ -180,7 +180,7 @@ unsigned double_used : 1;
unsigned do_strip_brackets : 1; unsigned do_strip_brackets : 1;
unsigned clock_compress : 1; unsigned clock_compress : 1;
unsigned dictmode : 1; /* dictionary compression enabled */ unsigned dictmode : 1; /* dictionary compression enabled */
unsigned zmode : 2; /* for value changes */ unsigned zmode : 2; /* for value changes */
unsigned emitted : 1; /* gate off change field zmode changes when set */ unsigned emitted : 1; /* gate off change field zmode changes when set */
}; };
@ -252,9 +252,9 @@ void lt_set_dumpoff(struct lt_trace *lt);
void lt_set_dumpon(struct lt_trace *lt); void lt_set_dumpon(struct lt_trace *lt);
/* /*
* value change functions..note that if the value string len for * value change functions..note that if the value string len for
* lt_emit_value_bit_string() is shorter than the symbol length * lt_emit_value_bit_string() is shorter than the symbol length
* it will be left justified with the rightmost character used as * it will be left justified with the rightmost character used as
* a repeat value that will be propagated to pad the value string out: * a repeat value that will be propagated to pad the value string out:
* *
* "10x" for 8 bits becomes "10xxxxxx" * "10x" for 8 bits becomes "10xxxxxx"

View File

@ -102,7 +102,7 @@ static PLI_INT32 sys_countdrivers_compiletf(ICARUS_VPI_CONST PLI_BYTE8 *name)
/* The optional arguments must be variables. */ /* The optional arguments must be variables. */
for (arg_num = 2; arg_num < 7; arg_num += 1) { for (arg_num = 2; arg_num < 7; arg_num += 1) {
char *arg_name = NULL; const char *arg_name = NULL;
switch (arg_num) { switch (arg_num) {
case 2: arg_name = "second"; break; case 2: arg_name = "second"; break;
case 3: arg_name = "third"; break; case 3: arg_name = "third"; break;

View File

@ -587,7 +587,7 @@ static unsigned check_numeric_args(vpiHandle argv, unsigned count,
/* Check that the first count arguments are numeric. Currently /* Check that the first count arguments are numeric. Currently
* only three are needed/supported. */ * only three are needed/supported. */
for (idx = 0; idx < count; idx += 1) { for (idx = 0; idx < count; idx += 1) {
char *loc = NULL; const char *loc = NULL;
vpiHandle arg = vpi_scan(argv); vpiHandle arg = vpi_scan(argv);
/* Get the name for this argument. */ /* Get the name for this argument. */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2000-2013 Stephen Williams (steve@icarus.com) * Copyright (c) 2000-2014 Stephen Williams (steve@icarus.com)
* *
* This source code is free software; you can redistribute it * This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU * and/or modify it in source code form under the terms of the GNU
@ -552,7 +552,7 @@ static PLI_INT32 sys_random_calltf(ICARUS_VPI_CONST PLI_BYTE8 *name)
return 0; return 0;
} }
/* From System Verilog 3.1a. */ /* From SystemVerilog. */
static PLI_INT32 sys_urandom_range_compiletf(ICARUS_VPI_CONST PLI_BYTE8 *name) static PLI_INT32 sys_urandom_range_compiletf(ICARUS_VPI_CONST PLI_BYTE8 *name)
{ {
vpiHandle callh = vpi_handle(vpiSysTfCall, 0); vpiHandle callh = vpi_handle(vpiSysTfCall, 0);
@ -561,20 +561,17 @@ static PLI_INT32 sys_urandom_range_compiletf(ICARUS_VPI_CONST PLI_BYTE8 *name)
/* Check that there are arguments. */ /* Check that there are arguments. */
if (argv == 0) { if (argv == 0) {
vpi_printf("ERROR: %s requires two arguments.\n", name); vpi_printf("ERROR: %s requires one or two arguments.\n", name);
vpi_control(vpiFinish, 1); vpi_control(vpiFinish, 1);
return 0; return 0;
} }
/* Check that there are at least two arguments. */ /* Check that there is at least one argument. */
arg = vpi_scan(argv); /* This should never be zero. */ arg = vpi_scan(argv); /* This should never be zero. */
assert(arg); assert(arg);
arg = vpi_scan(argv); arg = vpi_scan(argv);
if (arg == 0) { /* Is this a single argument function call? */
vpi_printf("ERROR: %s requires two arguments.\n", name); if (arg == 0) return 0;
vpi_control(vpiFinish, 1);
return 0;
}
/* These functions takes at most two argument. */ /* These functions takes at most two argument. */
arg = vpi_scan(argv); arg = vpi_scan(argv);
@ -588,7 +585,7 @@ static PLI_INT32 sys_urandom_range_compiletf(ICARUS_VPI_CONST PLI_BYTE8 *name)
return 0; return 0;
} }
/* From System Verilog 3.1a. */ /* From SystemVerilog. */
static unsigned long urandom(long *seed, unsigned long max, unsigned long min) static unsigned long urandom(long *seed, unsigned long max, unsigned long min)
{ {
static long i_seed = 0; static long i_seed = 0;
@ -603,7 +600,7 @@ static unsigned long urandom(long *seed, unsigned long max, unsigned long min)
return result; return result;
} }
/* From System Verilog 3.1a. */ /* From SystemVerilog. */
static PLI_INT32 sys_urandom_calltf(ICARUS_VPI_CONST PLI_BYTE8 *name) static PLI_INT32 sys_urandom_calltf(ICARUS_VPI_CONST PLI_BYTE8 *name)
{ {
vpiHandle callh, argv, seed = 0; vpiHandle callh, argv, seed = 0;
@ -639,7 +636,7 @@ static PLI_INT32 sys_urandom_calltf(ICARUS_VPI_CONST PLI_BYTE8 *name)
return 0; return 0;
} }
/* From System Verilog 3.1a. */ /* From SystemVerilog. */
static PLI_INT32 sys_urandom_range_calltf(ICARUS_VPI_CONST PLI_BYTE8 *name) static PLI_INT32 sys_urandom_range_calltf(ICARUS_VPI_CONST PLI_BYTE8 *name)
{ {
vpiHandle callh, argv, maxval, minval; vpiHandle callh, argv, maxval, minval;
@ -656,8 +653,14 @@ static PLI_INT32 sys_urandom_range_calltf(ICARUS_VPI_CONST PLI_BYTE8 *name)
vpi_get_value(maxval, &val); vpi_get_value(maxval, &val);
i_maxval = val.value.integer; i_maxval = val.value.integer;
vpi_get_value(minval, &val); /* Is this a two or one argument function call? */
i_minval = val.value.integer; if (minval) {
vpi_get_value(minval, &val);
i_minval = val.value.integer;
vpi_free_object(argv);
} else {
i_minval = 0;
}
/* Swap the two arguments if they are out of order. */ /* Swap the two arguments if they are out of order. */
if (i_minval > i_maxval) { if (i_minval > i_maxval) {
@ -669,7 +672,6 @@ static PLI_INT32 sys_urandom_range_calltf(ICARUS_VPI_CONST PLI_BYTE8 *name)
/* Calculate and return the result. */ /* Calculate and return the result. */
val.value.integer = urandom(0, i_maxval, i_minval); val.value.integer = urandom(0, i_maxval, i_minval);
vpi_put_value(callh, &val, 0, vpiNoDelay); vpi_put_value(callh, &val, 0, vpiNoDelay);
vpi_free_object(argv);
return 0; return 0;
} }
@ -922,7 +924,7 @@ void sys_random_register()
res = vpi_register_systf(&tf_data); res = vpi_register_systf(&tf_data);
vpip_make_systf_system_defined(res); vpip_make_systf_system_defined(res);
/* From System Verilog 3.1a. */ /* From SystemVerilog. */
tf_data.type = vpiSysFunc; tf_data.type = vpiSysFunc;
tf_data.sysfunctype = vpiSysFuncSized; tf_data.sysfunctype = vpiSysFuncSized;
tf_data.tfname = "$urandom"; tf_data.tfname = "$urandom";
@ -933,7 +935,7 @@ void sys_random_register()
res = vpi_register_systf(&tf_data); res = vpi_register_systf(&tf_data);
vpip_make_systf_system_defined(res); vpip_make_systf_system_defined(res);
/* From System Verilog 3.1a. */ /* From SystemVerilog. */
tf_data.type = vpiSysFunc; tf_data.type = vpiSysFunc;
tf_data.sysfunctype = vpiSysFuncSized; tf_data.sysfunctype = vpiSysFuncSized;
tf_data.tfname = "$urandom_range"; tf_data.tfname = "$urandom_range";

View File

@ -1,4 +1,4 @@
/* /*
* Copyright (c) Tony Bybell 1999. * Copyright (c) Tony Bybell 1999.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
@ -10,7 +10,7 @@
#ifndef WAVE_ALLOCA_H #ifndef WAVE_ALLOCA_H
#define WAVE_ALLOCA_H #define WAVE_ALLOCA_H
#include <stdlib.h> #include <stdlib.h>
#if HAVE_ALLOCA_H #ifdef HAVE_ALLOCA_H
#include <alloca.h> #include <alloca.h>
#elif defined(__GNUC__) #elif defined(__GNUC__)
#ifndef __MINGW32__ #ifndef __MINGW32__
@ -25,5 +25,5 @@
#define alloca _alloca #define alloca _alloca
#endif #endif
#define wave_alloca alloca #define wave_alloca alloca
#endif #endif

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2001-2013 Stephen Williams (steve@icarus.com) * Copyright (c) 2001-2014 Stephen Williams (steve@icarus.com)
* *
* This source code is free software; you can redistribute it * This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU * and/or modify it in source code form under the terms of the GNU
@ -760,7 +760,7 @@ void vvp_signal_value::get_signal_value(struct t_vpi_value*vp)
static void real_signal_value(struct t_vpi_value*vp, double rval) static void real_signal_value(struct t_vpi_value*vp, double rval)
{ {
char*rbuf = need_result_buf(64 + 1, RBUF_VAL); char*rbuf = (char *) need_result_buf(64 + 1, RBUF_VAL);
switch (vp->format) { switch (vp->format) {
case vpiObjTypeVal: case vpiObjTypeVal:

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2001-2012 Stephen Williams (steve@icarus.com) * Copyright (c) 2001-2014 Stephen Williams (steve@icarus.com)
* *
* This source code is free software; you can redistribute it * This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU * and/or modify it in source code form under the terms of the GNU
@ -131,7 +131,7 @@ void __vpiStringConst::vpi_get_value(p_vpi_value vp)
vp->format = vpiStringVal; vp->format = vpiStringVal;
case vpiStringVal: case vpiStringVal:
rbuf = need_result_buf(size + 1, RBUF_VAL); rbuf = (char *) need_result_buf(size + 1, RBUF_VAL);
strcpy(rbuf, value_); strcpy(rbuf, value_);
vp->value.str = rbuf; vp->value.str = rbuf;
break; break;
@ -143,7 +143,7 @@ void __vpiStringConst::vpi_get_value(p_vpi_value vp)
fprintf(stderr, "Warning (vpi_const.cc): %%d on constant strings only looks " fprintf(stderr, "Warning (vpi_const.cc): %%d on constant strings only looks "
"at first 4 bytes!\n"); "at first 4 bytes!\n");
} }
rbuf = need_result_buf(size + 1, RBUF_VAL); rbuf = (char *) need_result_buf(size + 1, RBUF_VAL);
uint_value = 0; uint_value = 0;
for(unsigned i=0; i<size; i += 1){ for(unsigned i=0; i<size; i += 1){
uint_value <<=8; uint_value <<=8;
@ -154,7 +154,7 @@ void __vpiStringConst::vpi_get_value(p_vpi_value vp)
break; break;
case vpiBinStrVal: case vpiBinStrVal:
rbuf = need_result_buf(8 * size + 1, RBUF_VAL); rbuf = (char *) need_result_buf(8 * size + 1, RBUF_VAL);
cp = rbuf; cp = rbuf;
for(unsigned i=0; i<size; i += 1){ for(unsigned i=0; i<size; i += 1){
for(int bit=7; bit>=0; bit -= 1){ for(int bit=7; bit>=0; bit -= 1){
@ -166,7 +166,7 @@ void __vpiStringConst::vpi_get_value(p_vpi_value vp)
break; break;
case vpiHexStrVal: case vpiHexStrVal:
rbuf = need_result_buf(2 * size + 1, RBUF_VAL); rbuf = (char *) need_result_buf(2 * size + 1, RBUF_VAL);
cp = rbuf; cp = rbuf;
for(unsigned i=0; i<size; i += 1){ for(unsigned i=0; i<size; i += 1){
for(int nibble=1; nibble>=0; nibble -= 1){ for(int nibble=1; nibble>=0; nibble -= 1){
@ -571,7 +571,7 @@ int __vpiDecConst::vpi_get(int code)
void __vpiDecConst::vpi_get_value(p_vpi_value vp) void __vpiDecConst::vpi_get_value(p_vpi_value vp)
{ {
char*rbuf = need_result_buf(64 + 1, RBUF_VAL); char*rbuf = (char *) need_result_buf(64 + 1, RBUF_VAL);
char*cp = rbuf; char*cp = rbuf;
switch (vp->format) { switch (vp->format) {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2008-2013 Stephen Williams (steve@icarus.com) * Copyright (c) 2008-2014 Stephen Williams (steve@icarus.com)
* *
* This source code is free software; you can redistribute it * This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU * and/or modify it in source code form under the terms of the GNU
@ -584,7 +584,7 @@ static void vec4_get_value_string(const vvp_vector4_t&word_val, unsigned width,
unsigned nchar = width / 8; unsigned nchar = width / 8;
unsigned tail = width % 8; unsigned tail = width % 8;
char*rbuf = need_result_buf(nchar + 1, RBUF_VAL); char*rbuf = (char *) need_result_buf(nchar + 1, RBUF_VAL);
char*cp = rbuf; char*cp = rbuf;
if (tail > 0) { if (tail > 0) {
@ -636,7 +636,7 @@ void vpip_vec4_get_value(const vvp_vector4_t&word_val, unsigned width,
break; break;
case vpiBinStrVal: case vpiBinStrVal:
rbuf = need_result_buf(width+1, RBUF_VAL); rbuf = (char *) need_result_buf(width+1, RBUF_VAL);
for (unsigned idx = 0 ; idx < width ; idx += 1) { for (unsigned idx = 0 ; idx < width ; idx += 1) {
vvp_bit4_t bit = word_val.value(idx); vvp_bit4_t bit = word_val.value(idx);
rbuf[width-idx-1] = vvp_bit4_to_ascii(bit); rbuf[width-idx-1] = vvp_bit4_to_ascii(bit);
@ -647,7 +647,7 @@ void vpip_vec4_get_value(const vvp_vector4_t&word_val, unsigned width,
case vpiOctStrVal: { case vpiOctStrVal: {
unsigned hwid = ((width+2) / 3) + 1; unsigned hwid = ((width+2) / 3) + 1;
rbuf = need_result_buf(hwid, RBUF_VAL); rbuf = (char *) need_result_buf(hwid, RBUF_VAL);
vpip_vec4_to_oct_str(word_val, rbuf, hwid); vpip_vec4_to_oct_str(word_val, rbuf, hwid);
vp->value.str = rbuf; vp->value.str = rbuf;
break; break;
@ -655,7 +655,7 @@ void vpip_vec4_get_value(const vvp_vector4_t&word_val, unsigned width,
case vpiDecStrVal: { case vpiDecStrVal: {
// HERE need a better estimate. // HERE need a better estimate.
rbuf = need_result_buf(width+1, RBUF_VAL); rbuf = (char *) need_result_buf(width+1, RBUF_VAL);
vpip_vec4_to_dec_str(word_val, rbuf, width+1, signed_flag); vpip_vec4_to_dec_str(word_val, rbuf, width+1, signed_flag);
vp->value.str = rbuf; vp->value.str = rbuf;
break; break;
@ -663,7 +663,7 @@ void vpip_vec4_get_value(const vvp_vector4_t&word_val, unsigned width,
case vpiHexStrVal: { case vpiHexStrVal: {
unsigned hwid = ((width + 3) / 4) + 1; unsigned hwid = ((width + 3) / 4) + 1;
rbuf = need_result_buf(hwid, RBUF_VAL); rbuf = (char *) need_result_buf(hwid, RBUF_VAL);
vpip_vec4_to_hex_str(word_val, rbuf, hwid); vpip_vec4_to_hex_str(word_val, rbuf, hwid);
vp->value.str = rbuf; vp->value.str = rbuf;
break; break;
@ -714,8 +714,8 @@ void vpip_vec4_get_value(const vvp_vector4_t&word_val, unsigned width,
case vpiVectorVal: { case vpiVectorVal: {
unsigned hwid = (width + 31)/32; unsigned hwid = (width + 31)/32;
rbuf = need_result_buf(hwid * sizeof(s_vpi_vecval), RBUF_VAL); s_vpi_vecval *op = (p_vpi_vecval)
s_vpi_vecval *op = (p_vpi_vecval)rbuf; need_result_buf(hwid * sizeof(s_vpi_vecval), RBUF_VAL);
vp->value.vector = op; vp->value.vector = op;
op->aval = op->bval = 0; op->aval = op->bval = 0;
@ -759,8 +759,6 @@ void vpip_vec4_get_value(const vvp_vector4_t&word_val, unsigned width,
void vpip_vec2_get_value(const vvp_vector2_t&word_val, unsigned width, void vpip_vec2_get_value(const vvp_vector2_t&word_val, unsigned width,
bool signed_flag, s_vpi_value*vp) bool signed_flag, s_vpi_value*vp)
{ {
char *rbuf = 0;
switch (vp->format) { switch (vp->format) {
default: default:
fprintf(stderr, "sorry: Format %d not implemented for " fprintf(stderr, "sorry: Format %d not implemented for "
@ -779,8 +777,8 @@ void vpip_vec2_get_value(const vvp_vector2_t&word_val, unsigned width,
case vpiVectorVal: { case vpiVectorVal: {
unsigned hwid = (width + 31)/32; unsigned hwid = (width + 31)/32;
rbuf = need_result_buf(hwid * sizeof(s_vpi_vecval), RBUF_VAL); s_vpi_vecval *op = (p_vpi_vecval)
s_vpi_vecval *op = (p_vpi_vecval)rbuf; need_result_buf(hwid * sizeof(s_vpi_vecval), RBUF_VAL);
vp->value.vector = op; vp->value.vector = op;
op->aval = op->bval = 0; op->aval = op->bval = 0;
@ -860,7 +858,7 @@ void vpip_real_get_value(double real, s_vpi_value*vp)
break; break;
case vpiDecStrVal: case vpiDecStrVal:
rbuf = need_result_buf(1025, RBUF_VAL); rbuf = (char *) need_result_buf(1025, RBUF_VAL);
vpip_vec4_to_dec_str(vvp_vector4_t(1024, real), rbuf, 1025, true); vpip_vec4_to_dec_str(vvp_vector4_t(1024, real), rbuf, 1025, true);
vp->value.str = rbuf; vp->value.str = rbuf;
break; break;
@ -934,7 +932,7 @@ void vpip_string_get_value(const string&val, s_vpi_value*vp)
vp->format = vpiStringVal; vp->format = vpiStringVal;
case vpiStringVal: case vpiStringVal:
rbuf = need_result_buf(val.size() + 1, RBUF_VAL); rbuf = (char *) need_result_buf(val.size() + 1, RBUF_VAL);
strcpy(rbuf, val.c_str()); strcpy(rbuf, val.c_str());
vp->value.str = rbuf; vp->value.str = rbuf;
break; break;

View File

@ -789,7 +789,7 @@ enum vpi_rbuf_t {
RBUF_DEL RBUF_DEL
/* Delete the storage for both buffers. */ /* Delete the storage for both buffers. */
}; };
extern char *need_result_buf(unsigned cnt, vpi_rbuf_t type); extern void *need_result_buf(unsigned cnt, vpi_rbuf_t type);
/* following two routines use need_result_buf(, RBUF_STR) */ /* following two routines use need_result_buf(, RBUF_STR) */
extern char *simple_set_rbuf_str(const char *s1); extern char *simple_set_rbuf_str(const char *s1);
extern char *generic_get_str(int code, vpiHandle ref, const char *name, const char *index); extern char *generic_get_str(int code, vpiHandle ref, const char *name, const char *index);

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2001-2013 Stephen Williams (steve@icarus.com) * Copyright (c) 2001-2014 Stephen Williams (steve@icarus.com)
* *
* This source code is free software; you can redistribute it * This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU * and/or modify it in source code form under the terms of the GNU
@ -62,9 +62,9 @@ extern const char oct_digits[64];
* buffer can be reused for that purpose. Whenever I have a need, the * buffer can be reused for that purpose. Whenever I have a need, the
* need_result_buf function makes sure that need can be met. * need_result_buf function makes sure that need can be met.
*/ */
char *need_result_buf(unsigned cnt, vpi_rbuf_t type) void *need_result_buf(unsigned cnt, vpi_rbuf_t type)
{ {
static char*result_buf[2] = {0, 0}; static void*result_buf[2] = {0, 0};
static size_t result_buf_size[2] = {0, 0}; static size_t result_buf_size[2] = {0, 0};
if (type == RBUF_DEL) { if (type == RBUF_DEL) {
@ -82,10 +82,10 @@ char *need_result_buf(unsigned cnt, vpi_rbuf_t type)
cnt = (cnt + 0x0fff) & ~0x0fff; cnt = (cnt + 0x0fff) & ~0x0fff;
if (result_buf_size[type] == 0) { if (result_buf_size[type] == 0) {
result_buf[type] = (char*)malloc(cnt); result_buf[type] = malloc(cnt);
result_buf_size[type] = cnt; result_buf_size[type] = cnt;
} else if (result_buf_size[type] < cnt) { } else if (result_buf_size[type] < cnt) {
result_buf[type] = (char*)realloc(result_buf[type], cnt); result_buf[type] = realloc(result_buf[type], cnt);
result_buf_size[type] = cnt; result_buf_size[type] = cnt;
} }
@ -94,7 +94,7 @@ char *need_result_buf(unsigned cnt, vpi_rbuf_t type)
char *simple_set_rbuf_str(const char *s1) char *simple_set_rbuf_str(const char *s1)
{ {
char *res = need_result_buf(strlen(s1)+1, RBUF_STR); char *res = (char *) need_result_buf(strlen(s1)+1, RBUF_STR);
if (res) strcpy(res,s1); if (res) strcpy(res,s1);
return res; return res;
} }
@ -109,7 +109,7 @@ char *generic_get_str(int code, vpiHandle ref, const char *name, const char *ind
} }
if (index != NULL) len += strlen(index) + 2; /* include space for brackets */ if (index != NULL) len += strlen(index) + 2; /* include space for brackets */
char *res = need_result_buf(len, RBUF_STR); char *res = (char *) need_result_buf(len, RBUF_STR);
if (!res) { if (!res) {
free(bn); free(bn);
return NULL; return NULL;
@ -143,7 +143,7 @@ static vpiHandle fill_in_net4(struct __vpiSignal*obj,
static void format_vpiBinStrVal(vvp_signal_value*sig, int base, unsigned wid, static void format_vpiBinStrVal(vvp_signal_value*sig, int base, unsigned wid,
s_vpi_value*vp) s_vpi_value*vp)
{ {
char *rbuf = need_result_buf(wid+1, RBUF_VAL); char *rbuf = (char *) need_result_buf(wid+1, RBUF_VAL);
long end = base + (signed)wid; long end = base + (signed)wid;
long offset = end - 1; long offset = end - 1;
long ssize = (signed)sig->value_size(); long ssize = (signed)sig->value_size();
@ -164,7 +164,7 @@ static void format_vpiOctStrVal(vvp_signal_value*sig, int base, unsigned wid,
s_vpi_value*vp) s_vpi_value*vp)
{ {
unsigned dwid = (wid + 2) / 3; unsigned dwid = (wid + 2) / 3;
char *rbuf = need_result_buf(dwid+1, RBUF_VAL); char *rbuf = (char *) need_result_buf(dwid+1, RBUF_VAL);
long end = base + (signed)wid; long end = base + (signed)wid;
long ssize = (signed)sig->value_size(); long ssize = (signed)sig->value_size();
unsigned val = 0; unsigned val = 0;
@ -220,7 +220,7 @@ static void format_vpiHexStrVal(vvp_signal_value*sig, int base, unsigned wid,
s_vpi_value*vp) s_vpi_value*vp)
{ {
unsigned dwid = (wid + 3) / 4; unsigned dwid = (wid + 3) / 4;
char *rbuf = need_result_buf(dwid+1, RBUF_VAL); char *rbuf = (char *) need_result_buf(dwid+1, RBUF_VAL);
long end = base + (signed)wid; long end = base + (signed)wid;
long ssize = (signed)sig->value_size(); long ssize = (signed)sig->value_size();
unsigned val = 0; unsigned val = 0;
@ -280,7 +280,7 @@ static void format_vpiDecStrVal(vvp_signal_value*sig, int base, unsigned wid,
int signed_flag, s_vpi_value*vp) int signed_flag, s_vpi_value*vp)
{ {
unsigned hwid = (sig->value_size()+2) / 3 + 1; unsigned hwid = (sig->value_size()+2) / 3 + 1;
char *rbuf = need_result_buf(hwid, RBUF_VAL); char *rbuf = (char *) need_result_buf(hwid, RBUF_VAL);
long ssize = (signed)sig->value_size(); long ssize = (signed)sig->value_size();
long end = base + (signed)wid; long end = base + (signed)wid;
@ -366,7 +366,7 @@ static void format_vpiStringVal(vvp_signal_value*sig, int base, unsigned wid,
/* The result will use a character for each 8 bits of the /* The result will use a character for each 8 bits of the
vector. Add one extra character for the highest bits that vector. Add one extra character for the highest bits that
don't form an 8 bit group. */ don't form an 8 bit group. */
char *rbuf = need_result_buf(wid/8 + ((wid&7)!=0) + 1, RBUF_VAL); char *rbuf = (char *) need_result_buf(wid/8 + ((wid&7)!=0) + 1, RBUF_VAL);
char *cp = rbuf; char *cp = rbuf;
char tmp = 0; char tmp = 0;

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2012 Stephen Williams (steve@icarus.com) * Copyright (c) 2012-2014 Stephen Williams (steve@icarus.com)
* *
* This source code is free software; you can redistribute it * This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU * and/or modify it in source code form under the terms of the GNU
@ -63,7 +63,7 @@ void __vpiStringVar::vpi_get_value(p_vpi_value val)
string str = fun->get_string(); string str = fun->get_string();
if (val->format == vpiStringVal || val->format == vpiObjTypeVal) { if (val->format == vpiStringVal || val->format == vpiObjTypeVal) {
char*rbuf = need_result_buf(str.size()+1, RBUF_VAL); char*rbuf = (char *) need_result_buf(str.size()+1, RBUF_VAL);
strcpy(rbuf, str.c_str()); strcpy(rbuf, str.c_str());
val->format = vpiStringVal; val->format = vpiStringVal;
val->value.str = rbuf; val->value.str = rbuf;

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2001-2012 Stephen Williams (steve@icarus.com) * Copyright (c) 2001-2014 Stephen Williams (steve@icarus.com)
* *
* This source code is free software; you can redistribute it * This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU * and/or modify it in source code form under the terms of the GNU
@ -106,7 +106,7 @@ static void timevar_get_value(vpiHandle ref, s_vpi_value*vp, bool is_int_func,
vvp_time64_t x, simtime = schedule_simtime(); vvp_time64_t x, simtime = schedule_simtime();
int units = rfp->scope? rfp->scope->time_units : vpi_time_precision; int units = rfp->scope? rfp->scope->time_units : vpi_time_precision;
char*rbuf = need_result_buf(128, RBUF_VAL); char*rbuf = (char *) need_result_buf(128, RBUF_VAL);
/* Calculate the divisor needed to scale the simulation time /* Calculate the divisor needed to scale the simulation time
(in time_precision units) to time units of the scope. */ (in time_precision units) to time units of the scope. */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2001-2013 Stephen Williams (steve@icarus.com) * Copyright (c) 2001-2014 Stephen Williams (steve@icarus.com)
* Copyright (c) 2001 Stephan Boettcher <stephan@nevis.columbia.edu> * Copyright (c) 2001 Stephan Boettcher <stephan@nevis.columbia.edu>
* *
* This source code is free software; you can redistribute it * This source code is free software; you can redistribute it
@ -124,7 +124,7 @@ static char* vthr_vec_get_str(int code, vpiHandle ref)
static void vthr_vec_DecStrVal(struct __vpiVThrVec*rfp, s_vpi_value*vp) static void vthr_vec_DecStrVal(struct __vpiVThrVec*rfp, s_vpi_value*vp)
{ {
int nbuf = (rfp->wid+2)/3 + 1; int nbuf = (rfp->wid+2)/3 + 1;
char *rbuf = need_result_buf(nbuf, RBUF_VAL); char *rbuf = (char *) need_result_buf(nbuf, RBUF_VAL);
vvp_vector4_t tmp (rfp->wid); vvp_vector4_t tmp (rfp->wid);
for (unsigned idx = 0 ; idx < rfp->wid ; idx += 1) for (unsigned idx = 0 ; idx < rfp->wid ; idx += 1)
@ -139,7 +139,7 @@ static void vthr_vec_DecStrVal(struct __vpiVThrVec*rfp, s_vpi_value*vp)
static void vthr_vec_StringVal(struct __vpiVThrVec*rfp, s_vpi_value*vp) static void vthr_vec_StringVal(struct __vpiVThrVec*rfp, s_vpi_value*vp)
{ {
char tmp = 0; char tmp = 0;
char *rbuf = need_result_buf((rfp->wid / 8) + 1, RBUF_VAL); char *rbuf = (char *) need_result_buf((rfp->wid / 8) + 1, RBUF_VAL);
char *cp = rbuf; char *cp = rbuf;
for(int bitnr=rfp->wid-1; bitnr>=0; bitnr--){ for(int bitnr=rfp->wid-1; bitnr>=0; bitnr--){
@ -186,7 +186,7 @@ static void vthr_vec_get_value(vpiHandle ref, s_vpi_value*vp)
switch (vp->format) { switch (vp->format) {
case vpiBinStrVal: case vpiBinStrVal:
rbuf = need_result_buf(wid+1, RBUF_VAL); rbuf = (char *) need_result_buf(wid+1, RBUF_VAL);
for (unsigned idx = 0 ; idx < wid ; idx += 1) { for (unsigned idx = 0 ; idx < wid ; idx += 1) {
rbuf[wid-idx-1] = vvp_bit4_to_ascii(get_bit(rfp, idx)); rbuf[wid-idx-1] = vvp_bit4_to_ascii(get_bit(rfp, idx));
} }
@ -197,7 +197,7 @@ static void vthr_vec_get_value(vpiHandle ref, s_vpi_value*vp)
case vpiHexStrVal: { case vpiHexStrVal: {
unsigned hval, hwid; unsigned hval, hwid;
hwid = (wid + 3) / 4; hwid = (wid + 3) / 4;
rbuf = need_result_buf(hwid+1, RBUF_VAL); rbuf = (char *) need_result_buf(hwid+1, RBUF_VAL);
rbuf[hwid] = 0; rbuf[hwid] = 0;
hval = 0; hval = 0;
for (unsigned idx = 0 ; idx < wid ; idx += 1) { for (unsigned idx = 0 ; idx < wid ; idx += 1) {
@ -237,7 +237,7 @@ static void vthr_vec_get_value(vpiHandle ref, s_vpi_value*vp)
case vpiOctStrVal: { case vpiOctStrVal: {
unsigned hval, hwid; unsigned hval, hwid;
hwid = (wid + 2) / 3; hwid = (wid + 2) / 3;
rbuf = need_result_buf(hwid+1, RBUF_VAL); rbuf = (char *) need_result_buf(hwid+1, RBUF_VAL);
rbuf[hwid] = 0; rbuf[hwid] = 0;
hval = 0; hval = 0;
for (unsigned idx = 0 ; idx < wid ; idx += 1) { for (unsigned idx = 0 ; idx < wid ; idx += 1) {
@ -521,7 +521,7 @@ static int vthr_word_get(int code, vpiHandle ref)
static void vthr_real_get_value(vpiHandle ref, s_vpi_value*vp) static void vthr_real_get_value(vpiHandle ref, s_vpi_value*vp)
{ {
struct __vpiVThrWord*obj = dynamic_cast<__vpiVThrWord*>(ref); struct __vpiVThrWord*obj = dynamic_cast<__vpiVThrWord*>(ref);
char *rbuf = need_result_buf(66, RBUF_VAL); char *rbuf = (char *) need_result_buf(66, RBUF_VAL);
double val = 0.0; double val = 0.0;
@ -689,7 +689,7 @@ void __vpiVThrStrStack::vpi_get_value(p_vpi_value vp)
case vpiObjTypeVal: case vpiObjTypeVal:
vp->format = vpiStringVal; vp->format = vpiStringVal;
case vpiStringVal: case vpiStringVal:
rbuf = need_result_buf(val.size()+1, RBUF_VAL); rbuf = (char *) need_result_buf(val.size()+1, RBUF_VAL);
strcpy(rbuf, val.c_str()); strcpy(rbuf, val.c_str());
vp->value.str = rbuf; vp->value.str = rbuf;
break; break;