On Fri, 11 Feb 2005, Nikolay V. Pyatkov wrote:
> Is there another lxt viewer to at least identify which program is broken?
Nikolay,
That was an excellent find on your part. It's an obscure bug in the
writer. Basically, here's what's going on: the writer does a mathematical
induction to determine two different sequences of numbers of this form
a, a+n, a+2*n, a+3*n, ...
and
a, b, a, b, ...
in order to compress them down to an equation when long runs of them are
encountered with equal time spacing. Interestingly, I was missing a case
in there where:
a, b, a+n, b, a+2*n, b, a+3*n, b, ...
slipped through the cracks and is stored as the alternating a, b case.
Patch is attached. Type
patch -p0 <patch
in the directory that has your lxt_write.c file and recompile icarus.
I'll post a revamped version of gtkwave (1.3.54) up on sunsite now. The
patch only affects vcd2lxt in that tarball; the viewer is unaffected so
all old versions of the viewer out there will function OK once the
simulator is recompiled.
Regards,
Tony
*** lxt_write.c Sun Oct 3 21:10:57 2004
--- /tmp/gtkwave-1.3.53/src/helpers/lxt_write.c Fri Feb 11 02:09:31 2005
***************
*** 655,662 ****
lt->zfacname_predec_size = lt->zpackcount;
gzclose(lt->zhandle);
! fseek(lt->handle, 0L, SEEK_END);
! lt->position=ftell(lt->handle);
lt->zfacname_size = lt->position - lt->zfacname_size;
lt->zhandle = gzdopen(dup(fileno(lt->handle)), "wb9");
--- 655,662 ----
lt->zfacname_predec_size = lt->zpackcount;
gzclose(lt->zhandle);
! fseeko(lt->handle, 0L, SEEK_END);
! lt->position=ftello(lt->handle);
lt->zfacname_size = lt->position - lt->zfacname_size;
lt->zhandle = gzdopen(dup(fileno(lt->handle)), "wb9");
***************
*** 681,688 ****
}
gzclose(lt->zhandle);
! fseek(lt->handle, 0L, SEEK_END);
! lt->position=ftell(lt->handle);
lt->zfacgeometry_size = lt->position - lt->facgeometry_offset;
if(is_interlaced_trace)
--- 681,688 ----
}
gzclose(lt->zhandle);
! fseeko(lt->handle, 0L, SEEK_END);
! lt->position=ftello(lt->handle);
lt->zfacgeometry_size = lt->position - lt->facgeometry_offset;
if(is_interlaced_trace)
***************
*** 696,703 ****
}
gzclose(lt->zhandle); lt->zhandle = NULL;
! fseek(lt->handle, 0L, SEEK_END);
! lt->position=ftell(lt->handle);
lt->zsync_table_size = lt->position -
lt->sync_table_offset;
}
}
--- 696,703 ----
}
gzclose(lt->zhandle); lt->zhandle = NULL;
! fseeko(lt->handle, 0L, SEEK_END);
! lt->position=ftello(lt->handle);
lt->zsync_table_size = lt->position -
lt->sync_table_offset;
}
}
***************
*** 706,712 ****
/*
! * initialize the trace and get back and lt context
*/
struct lt_trace *lt_init(const char *name)
{
--- 706,712 ----
/*
! * initialize the trace and get back an lt context
*/
struct lt_trace *lt_init(const char *name)
{
***************
*** 1002,1009 ****
}
gzclose(lt->zhandle);
! fseek(lt->handle, 0L, SEEK_END);
! lt->position=ftell(lt->handle);
lt->zdictionary_size = lt->position - lt->zdictionary_size;
free(lt->sorted_dict); lt->sorted_dict = NULL;
--- 1002,1009 ----
}
gzclose(lt->zhandle);
! fseeko(lt->handle, 0L, SEEK_END);
! lt->position=ftello(lt->handle);
lt->zdictionary_size = lt->position - lt->zdictionary_size;
free(lt->sorted_dict); lt->sorted_dict = NULL;
***************
*** 1057,1064 ****
case LT_ZMODE_BZIP2: BZ2_bzclose(lt->zhandle); break;
}
lt->zhandle = NULL;
! fseek(lt->handle, 0L, SEEK_END);
! lt->position=ftell(lt->handle);
lt_set_zmode(lt, LT_ZMODE_NONE);
lt->zchg_table_size = lt->position - lt->change_field_offset;
--- 1057,1064 ----
case LT_ZMODE_BZIP2: BZ2_bzclose(lt->zhandle); break;
}
lt->zhandle = NULL;
! fseeko(lt->handle, 0L, SEEK_END);
! lt->position=ftello(lt->handle);
lt_set_zmode(lt, LT_ZMODE_NONE);
lt->zchg_table_size = lt->position - lt->change_field_offset;
***************
*** 1132,1139 ****
}
gzclose(lt->zhandle); lt->zhandle = NULL;
! fseek(lt->handle, 0L, SEEK_END);
! lt->position=ftell(lt->handle);
lt->ztime_table_size = lt->position - lt->ztime_table_size;
}
--- 1132,1139 ----
}
gzclose(lt->zhandle); lt->zhandle = NULL;
! fseeko(lt->handle, 0L, SEEK_END);
! lt->position=ftello(lt->handle);
lt->ztime_table_size = lt->position - lt->ztime_table_size;
}
***************
*** 1609,1615 ****
len--;
! for(i=0;i<len;i++)
{
*(p++) = '0' | ((value & (1<<(len-i)))!=0);
}
--- 1609,1615 ----
len--;
! for(i=0;i<=len;i++)
{
*(p++) = '0' | ((value & (1<<(len-i)))!=0);
}
***************
*** 1642,1652 ****
if((len>1)&&(len<=32))
{
int ivalue = value;
s->clk_mask <<= 1;
s->clk_mask |= 1;
! if(((s->clk_mask&0x1f)==0x1f) && ((ivalue -
s->clk_prevval1)==(s->clk_prevval1 - s->clk_prevval3)) &&
! ((s->clk_prevval - s->clk_prevval2)==(s->clk_prevval2 -
s->clk_prevval4)))
{
if(s->clk_prevtrans==ULLDescriptor(~0))
{
--- 1642,1656 ----
if((len>1)&&(len<=32))
{
int ivalue = value;
+ int delta1, delta2;
s->clk_mask <<= 1;
s->clk_mask |= 1;
! if( ((s->clk_mask&0x1f)==0x1f) &&
! ( (delta1=(ivalue - s->clk_prevval1) &
lt_optimask[s->len]) == ((s->clk_prevval1 - s->clk_prevval3) &
lt_optimask[s->len]) ) &&
! ( (delta2=(s->clk_prevval - s->clk_prevval2) &
lt_optimask[s->len]) == ((s->clk_prevval2 - s->clk_prevval4) &
lt_optimask[s->len]) ) &&
! ( (delta1==delta2) || ((!delta1)&&(!delta2)) )
! )
{
if(s->clk_prevtrans==ULLDescriptor(~0))
{
***************
*** 2247,2252 ****
--- 2251,2257 ----
int ivalue = 0;
int i;
char *pnt = value;
+ int delta1, delta2;
for(i=0;i<len;i++)
{
***************
*** 2271,2278 ****
s->clk_mask <<= 1;
s->clk_mask |= legal;
! if(((s->clk_mask&0x1f)==0x1f) && ((ivalue -
s->clk_prevval1)==(s->clk_prevval1 - s->clk_prevval3)) &&
! ((s->clk_prevval - s->clk_prevval2)==(s->clk_prevval2 -
s->clk_prevval4)))
{
if(s->clk_prevtrans==ULLDescriptor(~0))
{
--- 2276,2286 ----
s->clk_mask <<= 1;
s->clk_mask |= legal;
! if( ((s->clk_mask&0x1f)==0x1f) &&
! ( (delta1=(ivalue - s->clk_prevval1) &
lt_optimask[s->len]) == ((s->clk_prevval1 - s->clk_prevval3) &
lt_optimask[s->len]) ) &&
! ( (delta2=(s->clk_prevval - s->clk_prevval2) &
lt_optimask[s->len]) == ((s->clk_prevval2 - s->clk_prevval4) &
lt_optimask[s->len]) ) &&
! ( (delta1==delta2) || ((!delta1)&&(!delta2)) )
! )
{
if(s->clk_prevtrans==ULLDescriptor(~0))
{