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,7 +2228,8 @@ 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,
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), res, ivl_parameter_lineno(par), res,

View File

@ -56,7 +56,7 @@
#include <windows.h> #include <windows.h>
#endif #endif
#if HAVE_ALLOCA_H #ifdef HAVE_ALLOCA_H
#include <alloca.h> #include <alloca.h>
#elif defined(__GNUC__) #elif defined(__GNUC__)
#ifndef __MINGW32__ #ifndef __MINGW32__
@ -379,7 +379,7 @@ static uint64_t fstReaderUint64(FILE *f)
{ {
uint64_t val = 0; uint64_t val = 0;
unsigned char buf[sizeof(uint64_t)]; unsigned char buf[sizeof(uint64_t)];
int i; unsigned int i;
fstFread(buf, sizeof(uint64_t), 1, f); fstFread(buf, sizeof(uint64_t), 1, f);
for(i=0;i<sizeof(uint64_t);i++) for(i=0;i<sizeof(uint64_t);i++)
@ -1227,7 +1227,7 @@ static void fstWriterFlushContextPrivate(void *ctx)
#ifdef FST_DEBUG #ifdef FST_DEBUG
int cnt = 0; int cnt = 0;
#endif #endif
int i; unsigned int i;
unsigned char *vchg_mem; unsigned char *vchg_mem;
FILE *f; FILE *f;
off_t fpos, indxpos, endpos; off_t fpos, indxpos, endpos;
@ -1284,7 +1284,7 @@ for(i=0;i<xc->maxhandle;i++)
{ {
uint32_t offs = vm4ip[2]; uint32_t offs = vm4ip[2];
uint32_t next_offs; uint32_t next_offs;
int wrlen; unsigned int wrlen;
vm4ip[2] = fpos; vm4ip[2] = fpos;
@ -1304,7 +1304,7 @@ for(i=0;i<xc->maxhandle;i++)
next_offs = fstGetUint32(vchg_mem + offs); next_offs = fstGetUint32(vchg_mem + offs);
offs += 4; offs += 4;
time_delta = fstGetVarint32(vchg_mem + offs, &wrlen); time_delta = fstGetVarint32(vchg_mem + offs, (int *)&wrlen);
val = vchg_mem[offs+wrlen]; val = vchg_mem[offs+wrlen];
offs = next_offs; offs = next_offs;
@ -1340,9 +1340,9 @@ for(i=0;i<xc->maxhandle;i++)
offs += 4; offs += 4;
pnt = vchg_mem + offs; pnt = vchg_mem + offs;
offs = next_offs; offs = next_offs;
time_delta = fstGetVarint32(pnt, &wrlen); time_delta = fstGetVarint32(pnt, (int *)&wrlen);
pnt += wrlen; pnt += wrlen;
record_len = fstGetVarint32(pnt, &wrlen); record_len = fstGetVarint32(pnt, (int *)&wrlen);
pnt += wrlen; pnt += wrlen;
scratchpnt -= record_len; scratchpnt -= record_len;
@ -1361,7 +1361,7 @@ for(i=0;i<xc->maxhandle;i++)
#endif #endif
while(offs) while(offs)
{ {
int idx; unsigned int idx;
char is_binary = 1; char is_binary = 1;
unsigned char *pnt; unsigned char *pnt;
uint32_t time_delta; uint32_t time_delta;
@ -1369,7 +1369,7 @@ for(i=0;i<xc->maxhandle;i++)
next_offs = fstGetUint32(vchg_mem + offs); next_offs = fstGetUint32(vchg_mem + offs);
offs += 4; offs += 4;
time_delta = fstGetVarint32(vchg_mem + offs, &wrlen); time_delta = fstGetVarint32(vchg_mem + offs, (int *)&wrlen);
pnt = vchg_mem+offs+wrlen; pnt = vchg_mem+offs+wrlen;
offs = next_offs; offs = next_offs;
@ -1441,7 +1441,7 @@ for(i=0;i<xc->maxhandle;i++)
{ {
unsigned long destlen = wrlen; unsigned long destlen = wrlen;
unsigned char *dmem; unsigned char *dmem;
int rc; unsigned int rc;
if(!xc->fastpack) if(!xc->fastpack)
{ {
@ -1696,7 +1696,7 @@ if(tmem)
unsigned char *dmem = malloc(compressBound(destlen)); unsigned char *dmem = malloc(compressBound(destlen));
int rc = compress2(dmem, &destlen, tmem, tlen, 9); int rc = compress2(dmem, &destlen, tmem, tlen, 9);
if((rc == Z_OK) && (destlen < tlen)) if((rc == Z_OK) && (((off_t)destlen) < tlen))
{ {
fstFwrite(dmem, destlen, 1, xc->handle); fstFwrite(dmem, destlen, 1, xc->handle);
} }
@ -1744,7 +1744,7 @@ fstWriterFseeko(xc, xc->handle, endpos, SEEK_SET); /* seek to end of file */
xc2->section_header_truncpos = endpos; /* cache in case of need to truncate */ xc2->section_header_truncpos = endpos; /* cache in case of need to truncate */
if(xc->dump_size_limit) if(xc->dump_size_limit)
{ {
if(endpos >= xc->dump_size_limit) if(endpos >= ((off_t)xc->dump_size_limit))
{ {
xc2->skip_writing_section_hdr = 1; xc2->skip_writing_section_hdr = 1;
xc2->size_limit_locked = 1; xc2->size_limit_locked = 1;
@ -1793,7 +1793,7 @@ struct fstWriterContext *xc = (struct fstWriterContext *)ctx;
if(xc->parallel_enabled) if(xc->parallel_enabled)
{ {
struct fstWriterContext *xc2 = malloc(sizeof(struct fstWriterContext)); struct fstWriterContext *xc2 = malloc(sizeof(struct fstWriterContext));
int i; unsigned int i;
pthread_mutex_lock(&xc->mutex); pthread_mutex_lock(&xc->mutex);
pthread_mutex_unlock(&xc->mutex); pthread_mutex_unlock(&xc->mutex);
@ -1926,7 +1926,7 @@ if(xc && !xc->already_in_close && !xc->already_in_flush)
unsigned char *dmem = malloc(compressBound(destlen)); unsigned char *dmem = malloc(compressBound(destlen));
int rc = compress2(dmem, &destlen, tmem, tlen, 9); int rc = compress2(dmem, &destlen, tmem, tlen, 9);
if((rc != Z_OK) || (destlen > tlen)) if((rc != Z_OK) || (((off_t)destlen) > tlen))
{ {
destlen = tlen; destlen = tlen;
} }
@ -1937,7 +1937,7 @@ if(xc && !xc->already_in_close && !xc->already_in_flush)
fstWriterUint64(xc->handle, tlen); /* uncompressed */ fstWriterUint64(xc->handle, tlen); /* uncompressed */
/* compressed len is section length - 24 */ /* compressed len is section length - 24 */
fstWriterUint64(xc->handle, xc->maxhandle); /* maxhandle */ fstWriterUint64(xc->handle, xc->maxhandle); /* maxhandle */
fstFwrite((destlen != tlen) ? dmem : tmem, destlen, 1, xc->handle); fstFwrite((((off_t)destlen) != tlen) ? dmem : tmem, destlen, 1, xc->handle);
fflush(xc->handle); fflush(xc->handle);
fstWriterFseeko(xc, xc->handle, fixup_offs, SEEK_SET); fstWriterFseeko(xc, xc->handle, fixup_offs, SEEK_SET);
@ -2542,7 +2542,8 @@ 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)
{ {
struct fstWriterContext *xc = (struct fstWriterContext *)ctx; struct fstWriterContext *xc = (struct fstWriterContext *)ctx;
int i, nlen, is_real; unsigned int i;
int nlen, is_real;
if(xc && nam) if(xc && nam)
{ {
@ -2893,7 +2894,7 @@ if((xc) && (handle <= xc->maxhandle))
void fstWriterEmitTimeChange(void *ctx, uint64_t tim) void fstWriterEmitTimeChange(void *ctx, uint64_t tim)
{ {
struct fstWriterContext *xc = (struct fstWriterContext *)ctx; struct fstWriterContext *xc = (struct fstWriterContext *)ctx;
int i; unsigned int i;
int skip = 0; int skip = 0;
if(xc) if(xc)
{ {
@ -3715,7 +3716,7 @@ if(!xc->fh)
uclen2 = fstGetVarint64(lz4_cmem, &skiplen2); uclen2 = fstGetVarint64(lz4_cmem, &skiplen2);
lz4_ucmem2 = malloc(uclen2); lz4_ucmem2 = malloc(uclen2);
pass_status = (uclen2 == LZ4_decompress_safe_partial ((char *)lz4_cmem + skiplen2, (char *)lz4_ucmem2, clen - skiplen2, uclen2, uclen2)); pass_status = (uclen2 == (uint64_t)LZ4_decompress_safe_partial ((char *)lz4_cmem + skiplen2, (char *)lz4_ucmem2, clen - skiplen2, uclen2, uclen2));
if(pass_status) if(pass_status)
{ {
pass_status = (uclen == LZ4_decompress_safe_partial ((char *)lz4_ucmem2, (char *)lz4_ucmem, uclen2, uclen, uclen)); pass_status = (uclen == LZ4_decompress_safe_partial ((char *)lz4_ucmem2, (char *)lz4_ucmem, uclen2, uclen, uclen));
@ -3950,7 +3951,7 @@ int ch, scopetype;
int vartype; int vartype;
uint32_t len, alias; uint32_t len, alias;
/* uint32_t maxvalpos=0; */ /* uint32_t maxvalpos=0; */
int num_signal_dyn = 65536; unsigned int num_signal_dyn = 65536;
int attrtype, subtype; int attrtype, subtype;
uint64_t attrarg; uint64_t attrarg;
fstHandle maxhandle_scanbuild; fstHandle maxhandle_scanbuild;
@ -4416,7 +4417,7 @@ if(gzread_pass_status)
uint64_t uclen = fstReaderUint64(xc->f); uint64_t uclen = fstReaderUint64(xc->f);
unsigned char *ucdata = malloc(uclen); unsigned char *ucdata = malloc(uclen);
unsigned char *pnt = ucdata; unsigned char *pnt = ucdata;
int i; unsigned int i;
xc->contains_geom_section = 1; xc->contains_geom_section = 1;
xc->maxhandle = fstReaderUint64(xc->f); xc->maxhandle = fstReaderUint64(xc->f);
@ -4670,7 +4671,7 @@ struct fstReaderContext *xc = (struct fstReaderContext *)ctx;
uint64_t previous_time = UINT64_MAX; uint64_t previous_time = UINT64_MAX;
uint64_t *time_table = NULL; uint64_t *time_table = NULL;
uint64_t tsec_nitems; uint64_t tsec_nitems;
int secnum = 0; unsigned int secnum = 0;
int blocks_skipped = 0; int blocks_skipped = 0;
off_t blkpos = 0; off_t blkpos = 0;
uint64_t seclen, beg_tim; uint64_t seclen, beg_tim;
@ -4780,7 +4781,7 @@ for(;;)
int rc; int rc;
unsigned char *tpnt; unsigned char *tpnt;
uint64_t tpval; uint64_t tpval;
int ti; unsigned int ti;
if(fstReaderFseeko(xc, xc->f, blkpos + seclen - 24, SEEK_SET) != 0) break; if(fstReaderFseeko(xc, xc->f, blkpos + seclen - 24, SEEK_SET) != 0) break;
tsec_uclen = fstReaderUint64(xc->f); tsec_uclen = fstReaderUint64(xc->f);
@ -5112,7 +5113,7 @@ for(;;)
{ {
uint64_t val = fstGetVarint32(pnt, &skiplen); uint64_t val = fstGetVarint32(pnt, &skiplen);
int loopcnt = val >> 1; fstHandle loopcnt = val >> 1;
for(i=0;i<loopcnt;i++) for(i=0;i<loopcnt;i++)
{ {
chain_table[idx++] = 0; chain_table[idx++] = 0;
@ -5145,7 +5146,7 @@ for(;;)
} }
else else
{ {
int loopcnt = val >> 1; fstHandle loopcnt = val >> 1;
for(i=0;i<loopcnt;i++) for(i=0;i<loopcnt;i++)
{ {
chain_table[idx++] = 0; chain_table[idx++] = 0;
@ -5217,7 +5218,7 @@ for(;;)
switch(packtype) switch(packtype)
{ {
case '4': rc = (destlen == LZ4_decompress_safe_partial((char *)mc, (char *)mu, sourcelen, destlen, destlen)) ? Z_OK : Z_DATA_ERROR; case '4': rc = (destlen == (unsigned long)LZ4_decompress_safe_partial((char *)mc, (char *)mu, sourcelen, destlen, destlen)) ? Z_OK : Z_DATA_ERROR;
break; break;
case 'F': fastlz_decompress(mc, sourcelen, mu, destlen); /* rc appears unreliable */ case 'F': fastlz_decompress(mc, sourcelen, mu, destlen); /* rc appears unreliable */
break; break;
@ -5433,7 +5434,7 @@ for(;;)
{ {
int byte = 0; int byte = 0;
int bit; int bit;
int j; unsigned int j;
for(j=0;j<len;j++) for(j=0;j<len;j++)
{ {
@ -5691,7 +5692,7 @@ struct fstReaderContext *xc = (struct fstReaderContext *)ctx;
off_t blkpos = 0, prev_blkpos; off_t blkpos = 0, prev_blkpos;
uint64_t beg_tim, end_tim, beg_tim2, end_tim2; uint64_t beg_tim, end_tim, beg_tim2, end_tim2;
int sectype; int sectype;
int secnum = 0; unsigned int secnum = 0;
uint64_t seclen; uint64_t seclen;
uint64_t tsec_uclen = 0, tsec_clen = 0; uint64_t tsec_uclen = 0, tsec_clen = 0;
uint64_t tsec_nitems; uint64_t tsec_nitems;
@ -5809,7 +5810,7 @@ unsigned long sourcelen /* = tsec_clen */; /* scan-build */
int rc; int rc;
unsigned char *tpnt; unsigned char *tpnt;
uint64_t tpval; uint64_t tpval;
int ti; unsigned int ti;
fstReaderFseeko(xc, xc->f, blkpos + seclen - 24, SEEK_SET); fstReaderFseeko(xc, xc->f, blkpos + seclen - 24, SEEK_SET);
tsec_uclen = fstReaderUint64(xc->f); tsec_uclen = fstReaderUint64(xc->f);
@ -5935,7 +5936,7 @@ do
} }
else else
{ {
int loopcnt = val >> 1; fstHandle loopcnt = val >> 1;
for(i=0;i<loopcnt;i++) for(i=0;i<loopcnt;i++)
{ {
xc->rvat_chain_table[idx++] = 0; xc->rvat_chain_table[idx++] = 0;
@ -6040,7 +6041,7 @@ if(!xc->rvat_chain_mem)
uint32_t tidx = 0, ptidx = 0; uint32_t tidx = 0, ptidx = 0;
uint32_t tdelta; uint32_t tdelta;
int skiplen; int skiplen;
int iprev = xc->rvat_chain_len; unsigned int iprev = xc->rvat_chain_len;
uint32_t pvli = 0; uint32_t pvli = 0;
int pskip = 0; int pskip = 0;
@ -6149,7 +6150,7 @@ if(xc->signal_lens[facidx] == 1)
{ {
int byte = 0; int byte = 0;
int bit; int bit;
int j; unsigned int j;
for(j=0;j<xc->signal_lens[facidx];j++) for(j=0;j<xc->signal_lens[facidx];j++)
{ {

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;
/* Is this a two or one argument function call? */
if (minval) {
vpi_get_value(minval, &val); vpi_get_value(minval, &val);
i_minval = val.value.integer; 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;