Merge branch 'master' of github.com:steveicarus/iverilog
This commit is contained in:
commit
09493a198f
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2003-2010 Stephen Williams (steve@icarus.com)
|
||||
* Copyright (c) 2003-2012 Stephen Williams (steve@icarus.com)
|
||||
*
|
||||
* This source code is free software; you can redistribute it
|
||||
* and/or modify it in source code form under the terms of the GNU
|
||||
|
|
@ -680,7 +680,8 @@ static PLI_INT32 sys_fread_calltf(ICARUS_VPI_CONST PLI_BYTE8*name)
|
|||
vpi_free_object(argv);
|
||||
}
|
||||
|
||||
words = (width+31)/32;
|
||||
assert(width > 0);
|
||||
words = (width - 1)/32 + 1;
|
||||
vector = calloc(words, sizeof(s_vpi_vecval));
|
||||
bpe = (width+7)/8;
|
||||
|
||||
|
|
|
|||
|
|
@ -121,7 +121,7 @@ void __vpiStringConst::vpi_get_value(p_vpi_value vp)
|
|||
{
|
||||
unsigned uint_value;
|
||||
p_vpi_vecval vecp;
|
||||
int size = strlen(value_);
|
||||
unsigned size = strlen(value_);
|
||||
char*rbuf = 0;
|
||||
char*cp;
|
||||
|
||||
|
|
@ -145,7 +145,7 @@ void __vpiStringConst::vpi_get_value(p_vpi_value vp)
|
|||
}
|
||||
rbuf = need_result_buf(size + 1, RBUF_VAL);
|
||||
uint_value = 0;
|
||||
for(int i=0; i<size;i ++){
|
||||
for(unsigned i=0; i<size; i += 1){
|
||||
uint_value <<=8;
|
||||
uint_value += (unsigned char)(value_[i]);
|
||||
}
|
||||
|
|
@ -156,8 +156,8 @@ void __vpiStringConst::vpi_get_value(p_vpi_value vp)
|
|||
case vpiBinStrVal:
|
||||
rbuf = need_result_buf(8 * size + 1, RBUF_VAL);
|
||||
cp = rbuf;
|
||||
for(int i=0; i<size;i ++){
|
||||
for(int bit=7;bit>=0; bit--){
|
||||
for(unsigned i=0; i<size; i += 1){
|
||||
for(int bit=7; bit>=0; bit -= 1){
|
||||
*cp++ = "01"[ (value_[i]>>bit)&1 ];
|
||||
}
|
||||
}
|
||||
|
|
@ -168,8 +168,8 @@ void __vpiStringConst::vpi_get_value(p_vpi_value vp)
|
|||
case vpiHexStrVal:
|
||||
rbuf = need_result_buf(2 * size + 1, RBUF_VAL);
|
||||
cp = rbuf;
|
||||
for(int i=0; i<size;i++){
|
||||
for(int nibble=1;nibble>=0; nibble--){
|
||||
for(unsigned i=0; i<size; i += 1){
|
||||
for(int nibble=1; nibble>=0; nibble -= 1){
|
||||
*cp++ = "0123456789abcdef"[ (value_[i]>>(nibble*4))&15 ];
|
||||
}
|
||||
}
|
||||
|
|
@ -184,8 +184,8 @@ void __vpiStringConst::vpi_get_value(p_vpi_value vp)
|
|||
|
||||
case vpiIntVal:
|
||||
vp->value.integer = 0;
|
||||
for(int i=0; i<size;i ++){
|
||||
for(int bit=7;bit>=0; bit--){
|
||||
for(unsigned i=0; i<size; i += 1){
|
||||
for(int bit=7; bit>=0; bit -= 1){
|
||||
vp->value.integer <<= 1;
|
||||
vp->value.integer += (value_[i]>>bit)&1;
|
||||
}
|
||||
|
|
@ -200,7 +200,7 @@ void __vpiStringConst::vpi_get_value(p_vpi_value vp)
|
|||
uint_value = 0;
|
||||
vecp = vp->value.vector;
|
||||
vecp->aval = vecp->bval = 0;
|
||||
for(int i=0; i<size;i ++){
|
||||
for(unsigned i=0; i<size; i += 1){
|
||||
vecp->aval |= value_[i] << uint_value*8;
|
||||
uint_value += 1;
|
||||
if (uint_value > 3) {
|
||||
|
|
|
|||
|
|
@ -690,7 +690,7 @@ void vpip_vec4_get_value(const vvp_vector4_t&word_val, unsigned width,
|
|||
vp->format = vpiVectorVal;
|
||||
|
||||
case vpiVectorVal: {
|
||||
unsigned hwid = (width - 1)/32 + 1;
|
||||
unsigned hwid = (width + 31)/32;
|
||||
|
||||
rbuf = need_result_buf(hwid * sizeof(s_vpi_vecval), RBUF_VAL);
|
||||
s_vpi_vecval *op = (p_vpi_vecval)rbuf;
|
||||
|
|
@ -755,7 +755,7 @@ void vpip_vec2_get_value(const vvp_vector2_t&word_val, unsigned width,
|
|||
break;
|
||||
|
||||
case vpiVectorVal: {
|
||||
unsigned hwid = (width - 1)/32 + 1;
|
||||
unsigned hwid = (width + 31)/32;
|
||||
|
||||
rbuf = need_result_buf(hwid * sizeof(s_vpi_vecval), RBUF_VAL);
|
||||
s_vpi_vecval *op = (p_vpi_vecval)rbuf;
|
||||
|
|
@ -948,15 +948,54 @@ void vpip_put_value_event::run_run()
|
|||
case vpiStringVal:
|
||||
free(value.value.str);
|
||||
break;
|
||||
/* If these are ever copied then free them too. */
|
||||
/* Free the copied time structure. */
|
||||
case vpiTimeVal:
|
||||
free(value.value.time);
|
||||
break;
|
||||
/* Free the copied vector structure. */
|
||||
case vpiVectorVal:
|
||||
free(value.value.vector);
|
||||
break;
|
||||
/* Free the copied strength structure. */
|
||||
case vpiStrengthVal:
|
||||
free(value.value.strength);
|
||||
break;
|
||||
/* Everything else is static in the structure. */
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Make a copy of a pointer to a time structure. */
|
||||
static t_vpi_time *timedup(t_vpi_time *val)
|
||||
{
|
||||
t_vpi_time *rtn;
|
||||
rtn = (t_vpi_time *) malloc(sizeof(t_vpi_time));
|
||||
*rtn = *val;
|
||||
return rtn;
|
||||
}
|
||||
|
||||
/* Make a copy of a pointer to a vector value structure. */
|
||||
static t_vpi_vecval *vectordup(t_vpi_vecval *val, PLI_INT32 size)
|
||||
{
|
||||
unsigned num_bytes;
|
||||
t_vpi_vecval *rtn;
|
||||
assert(size > 0);
|
||||
num_bytes = ((size + 31)/32)*sizeof(t_vpi_vecval);
|
||||
rtn = (t_vpi_vecval *) malloc(num_bytes);
|
||||
memcpy(rtn, val, num_bytes);
|
||||
return rtn;
|
||||
}
|
||||
|
||||
/* Make a copy of a pointer to a strength structure. */
|
||||
static t_vpi_strengthval *strengthdup(t_vpi_strengthval *val)
|
||||
{
|
||||
t_vpi_strengthval *rtn;
|
||||
rtn = (t_vpi_strengthval *) malloc(sizeof(t_vpi_strengthval));
|
||||
*rtn = *val;
|
||||
return rtn;
|
||||
}
|
||||
|
||||
vpiHandle vpi_put_value(vpiHandle obj, s_vpi_value*vp,
|
||||
s_vpi_time*when, PLI_INT32 flags)
|
||||
{
|
||||
|
|
@ -999,8 +1038,10 @@ vpiHandle vpi_put_value(vpiHandle obj, s_vpi_value*vp,
|
|||
vpip_put_value_event*put = new vpip_put_value_event;
|
||||
put->handle = obj;
|
||||
put->value = *vp;
|
||||
/* Since this is a scheduled put event we must copy any pointer
|
||||
* data to keep it available until the event is actually run. */
|
||||
switch (put->value.format) {
|
||||
/* If this is scheduled make a copy of the string. */
|
||||
/* Copy the string items. */
|
||||
case vpiBinStrVal:
|
||||
case vpiOctStrVal:
|
||||
case vpiDecStrVal:
|
||||
|
|
@ -1008,10 +1049,21 @@ vpiHandle vpi_put_value(vpiHandle obj, s_vpi_value*vp,
|
|||
case vpiStringVal:
|
||||
put->value.value.str = strdup(put->value.value.str);
|
||||
break;
|
||||
/* Do these also need to be copied? */
|
||||
/* Copy a time pointer item. */
|
||||
case vpiTimeVal:
|
||||
put->value.value.time = timedup(put->value.value.time);
|
||||
break;
|
||||
/* Copy a vector pointer item. */
|
||||
case vpiVectorVal:
|
||||
put->value.value.vector = vectordup(put->value.value.vector,
|
||||
vpi_get(vpiSize, obj));
|
||||
break;
|
||||
/* Copy a strength pointer item. */
|
||||
case vpiStrengthVal:
|
||||
put->value.value.strength =
|
||||
strengthdup(put->value.value.strength);
|
||||
break;
|
||||
/* Everything thing else is already in the structure. */
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -467,7 +467,7 @@ static void format_vpiVectorVal(vvp_signal_value*sig, int base, unsigned wid,
|
|||
{
|
||||
long end = base + (signed)wid;
|
||||
unsigned int obit = 0;
|
||||
unsigned hwid = (wid - 1)/32 + 1;
|
||||
unsigned hwid = (wid + 31)/32;
|
||||
|
||||
s_vpi_vecval *op = (p_vpi_vecval)
|
||||
need_result_buf(hwid * sizeof(s_vpi_vecval), RBUF_VAL);
|
||||
|
|
|
|||
Loading…
Reference in New Issue