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

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));

File diff suppressed because it is too large Load Diff

View File

@ -57,9 +57,9 @@ enum fstFileType {
}; };
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,
@ -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

@ -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

@ -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__

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;