Merge branch 'master' of ssh://steve-icarus@icarus.com/home/u/icarus/steve/git/verilog

This commit is contained in:
Stephen Williams 2008-01-07 16:26:17 -08:00
commit ca50991eeb
50 changed files with 505 additions and 302 deletions

View File

@ -23,8 +23,9 @@
# include "config.h"
# include "HName.h"
# include <iostream>
# include <string.h>
# include <stdlib.h>
# include <cstring>
# include <cstdlib>
# include <climits>
#ifdef HAVE_MALLOC_H
# include <malloc.h>
#endif

View File

@ -27,8 +27,9 @@ PWire::PWire(const pform_name_t&n,
NetNet::PortType pt,
ivl_variable_type_t dt)
: hname_(n), type_(t), port_type_(pt), data_type_(dt),
signed_(false), isint_(false), port_set_(false), net_set_(false),
port_msb_(0), port_lsb_(0), net_msb_(0), net_lsb_(0), error_cnt_(0),
signed_(false), isint_(false),
port_msb_(0), port_lsb_(0), port_set_(false),
net_msb_(0), net_lsb_(0), net_set_(false), error_cnt_(0),
lidx_(0), ridx_(0)
{
if (t == NetNet::INTEGER) {
@ -113,6 +114,11 @@ bool PWire::set_data_type(ivl_variable_type_t dt)
return true;
}
ivl_variable_type_t PWire::get_data_type() const
{
return data_type_;
}
void PWire::set_signed(bool flag)
{
signed_ = flag;

View File

@ -19,6 +19,7 @@
# include "config.h"
# include <cstdlib>
# include "netlist.h"
# include "netmisc.h"
# include "functor.h"

View File

@ -1,4 +1,6 @@
%option nounput
%{
/*
* Copyright (c) 2001 Stephen Williams (steve@icarus.com)

View File

@ -18,6 +18,9 @@
*/
# include "config.h"
# include <typeinfo>
# include <cstdlib>
# include <cstring>
# include "compiler.h"
# include "pform.h"

View File

@ -23,6 +23,7 @@
# include "netlist.h"
# include "netmisc.h"
# include "compiler.h"
# include <cstdlib>
# include <iostream>
# include "ivl_assert.h"

View File

@ -24,6 +24,8 @@
# include "netmisc.h"
# include "compiler.h"
# include <cstdlib>
# include <cstring>
# include <iostream>
# include "ivl_assert.h"
@ -2274,7 +2276,7 @@ bool PEIdent::eval_part_select_(Design*des, NetScope*scope, NetNet*sig,
case index_component_t::SEL_PART: {
long msb, lsb;
bool flag = calculate_parts_(des, scope, msb, lsb);
/* bool flag = */ calculate_parts_(des, scope, msb, lsb);
lidx = sig->sb_to_idx(lsb);
midx = sig->sb_to_idx(msb);

View File

@ -24,6 +24,7 @@
# include "util.h"
# include "netmisc.h"
# include <cstdlib>
# include <iostream>
# include "ivl_assert.h"

View File

@ -20,6 +20,7 @@
# include "config.h"
# include "compiler.h"
# include "netmisc.h"
# include <cstring>
# include <iostream>
# include <stdio.h>

View File

@ -19,6 +19,7 @@
# include "config.h"
# include <cstdlib>
# include <iostream>
# include "Module.h"

View File

@ -30,6 +30,7 @@
*/
# include <typeinfo>
# include <cstdlib>
# include <sstream>
# include <list>
# include "pform.h"

View File

@ -29,6 +29,7 @@
# include "netlist.h"
# include <typeinfo>
# include <cassert>
# include <cstring>
bool NetNode::emit_node(struct target_t*tgt) const
{

View File

@ -19,6 +19,7 @@
# include "config.h"
# include <cstring>
# include <iostream>
# include "PExpr.h"

View File

@ -21,6 +21,7 @@
# include "compiler.h"
# include <iostream>
# include <cstdlib>
# include "netlist.h"
# include "ivl_assert.h"

View File

@ -58,7 +58,7 @@ ivlpp@EXEEXT@: $O
$(CC) $(LDFLAGS) $O -o ivlpp@EXEEXT@ @EXTRALIBS@
lexor.c: lexor.lex
flex -s -olexor.c $(srcdir)/lexor.lex
flex -olexor.c $(srcdir)/lexor.lex
parse.h parse.c: parse.y
bison --verbose -t -d -o parse.c $(srcdir)/parse.y

View File

@ -158,6 +158,8 @@ static int ma_parenthesis_level = 0;
%}
%option stack
%option nounput
%option noyy_top_state
%x PPINCLUDE
%x DEF_NAME

View File

@ -25,6 +25,8 @@
# include <stdio.h>
static void yyerror(const char*msg);
extern int yylex (void);
%}
%%

View File

@ -1,5 +1,6 @@
%option never-interactive
%option nounput
%{
/*
@ -390,8 +391,9 @@ W [ \t\b\f\r]+
error_count += 1; }
/* Final catchall. something got lost or mishandled. */
/* XXX Should we tell the luser something about the lexical state? */
. { cerr << yylloc.text << ":" << yylloc.first_line
<*>.|\n { cerr << yylloc.text << ":" << yylloc.first_line
<< ": error: unmatched character (";
if (isgraph(yytext[0]))
cerr << yytext[0];

View File

@ -26,6 +26,8 @@
# include "compiler.h"
# include <iostream>
# include <map>
# include <cstdlib>
# include <cstring>
# include <string>
# include <sys/types.h>
# include <dirent.h>

View File

@ -44,6 +44,7 @@ const char NOTICE[] =
# include <iostream>
# include <fstream>
# include <queue>
# include <cstring>
# include <list>
# include <map>
# include <unistd.h>

View File

@ -26,6 +26,7 @@
# include "netlist.h"
# include <sstream>
# include <cstring>
# include <string>
# include <typeinfo>
#ifdef HAVE_MALLOC_H

View File

@ -24,6 +24,7 @@
# include "compiler.h"
# include "netlist.h"
# include <cstring>
# include <sstream>
/*

View File

@ -22,6 +22,7 @@
# include <iostream>
# include <typeinfo>
# include <cstdlib>
# include "compiler.h"
# include "netlist.h"
# include "netmisc.h"

View File

@ -19,6 +19,7 @@
# include "config.h"
# include <cstdlib>
# include "netlist.h"
# include "netmisc.h"
# include "PExpr.h"

View File

@ -26,6 +26,7 @@
# include "pform.h"
# include "Statement.h"
# include "PSpec.h"
# include <cstring>
# include <sstream>
class PSpecPath;

View File

@ -33,6 +33,10 @@
# include <stack>
# include <typeinfo>
# include <sstream>
# include <cstring>
# include <cstdlib>
# include "ivl_assert.h"
map<perm_string,Module*> pform_modules;
map<perm_string,PUdp*> pform_primitives;
@ -1313,9 +1317,17 @@ void pform_makewire(const vlltype&li, const char*nm,
FILE_NAME(cur, li.text, li.first_line);
bool flag;
switch (dt) {
case IVL_VT_REAL:
cur->set_data_type(dt);
flag = cur->set_data_type(dt);
if (flag == false) {
cerr << cur->get_fileline() << ": internal error: "
<< " wire data type handling mismatch. Cannot change "
<< cur->get_data_type()
<< " to " << dt << "." << endl;
}
ivl_assert(*cur, flag);
cur->set_range(0, 0, SR_NET);
cur->set_signed(true);
break;
@ -1417,7 +1429,7 @@ void pform_set_port_type(perm_string nm, NetNet::PortType pt,
pform_name_t name = hier_name(nm);
PWire*cur = pform_cur_module->get_wire(name);
if (cur == 0) {
cur = new PWire(name, NetNet::IMPLICIT, NetNet::PIMPLICIT, IVL_VT_LOGIC);
cur = new PWire(name, NetNet::IMPLICIT, NetNet::PIMPLICIT, IVL_VT_NO_TYPE);
FILE_NAME(cur, file, lineno);
pform_cur_module->add_wire(cur);
}

View File

@ -23,6 +23,8 @@
# include "config.h"
# include "compiler.h"
# include <stdio.h>
# include <cstring>
# include <cstdlib>
/*
* Manage the information about system functions. This information is

View File

@ -21,6 +21,7 @@
# include <iostream>
# include <cstring>
# include "t-dll.h"
# include "netlist.h"
# include <assert.h>

View File

@ -25,6 +25,7 @@
# include <iostream>
# include <cstring>
# include "target.h"
# include "ivl_target.h"
# include "compiler.h"

View File

@ -21,6 +21,7 @@
# include <iostream>
# include <cstring>
# include <stdio.h> // sprintf()
# include "compiler.h"
# include "t-dll.h"

View File

@ -731,8 +731,8 @@ static struct vector_info draw_binary_expr_le(ivl_expr_t exp,
assert(ivl_expr_value(re) == IVL_VT_LOGIC
|| ivl_expr_value(re) == IVL_VT_BOOL);
lv.wid = 0;
rv.wid = 0;
lv.wid = 0; lv.base=0;
rv.wid = 0; rv.base=0;
switch (ivl_expr_opcode(exp)) {
case 'G':

View File

@ -1613,7 +1613,10 @@ static void draw_lpm_add(ivl_lpm_t net)
switch (ivl_lpm_type(net)) {
case IVL_LPM_ADD:
type = "sum";
if (dto == IVL_VT_REAL)
type = "sum.r";
else
type = "sum";
break;
case IVL_LPM_SUB:
if (dto == IVL_VT_REAL)
@ -1622,7 +1625,10 @@ static void draw_lpm_add(ivl_lpm_t net)
type = "sub";
break;
case IVL_LPM_MULT:
type = "mult";
if (dto == IVL_VT_REAL)
type = "mult.r";
else
type = "mult";
break;
case IVL_LPM_DIVIDE:
if (dto == IVL_VT_REAL)
@ -1633,7 +1639,10 @@ static void draw_lpm_add(ivl_lpm_t net)
type = "div";
break;
case IVL_LPM_MOD:
type = "mod";
if (dto == IVL_VT_REAL)
assert(0); /* Not supported for reals, */
else
type = "mod";
break;
default:
assert(0);

View File

@ -29,6 +29,7 @@
# include <iostream>
# include <math.h>
# include <assert.h>
# include <cstring>
verireal::verireal()
{

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003-2004 Tony Bybell.
* Copyright (c) 2003-2007 Tony Bybell.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@ -20,23 +20,28 @@
* DEALINGS IN THE SOFTWARE.
*/
#ifdef _AIX
#pragma alloca
#endif
#include <config.h>
#include "lxt2_write.h"
static char *lxt2_wr_vcd_truncate_bitvec(char *s)
{
char l, r;
char l, r;
r=*s;
if(r=='1')
if(r=='1')
{
return s;
}
}
else
{
s++;
}
for(;;s++)
{
l=r; r=*s;
@ -45,11 +50,60 @@ for(;;s++)
if(l!=r)
{
return(((l=='0')&&(r=='1'))?s:s-1);
}
}
}
}
/*
* in-place sort to keep chained facs from migrating...
*/
static void wave_mergesort(struct lxt2_wr_symbol **a, struct lxt2_wr_symbol **b, int lo, int hi)
{
int i, j, k;
if (lo<hi)
{
int mid=(lo+hi)/2;
wave_mergesort(a, b, lo, mid);
wave_mergesort(a, b, mid+1, hi);
i=0; j=lo;
while (j<=mid)
{
b[i++]=a[j++];
}
i=0; k=lo;
while ((k<j)&&(j<=hi))
{
if (strcmp(b[i]->name, a[j]->name) <= 0)
{
a[k++]=b[i++];
}
else
{
a[k++]=a[j++];
}
}
while (k<j)
{
a[k++]=b[i++];
}
}
}
static void wave_msort(struct lxt2_wr_symbol **a, int num)
{
struct lxt2_wr_symbol **b = malloc(((num/2)+1) * sizeof(struct lxt2_wr_symbol *));
wave_mergesort(a, b, 0, num-1);
free(b);
}
/************************ splay ************************/
static lxt2_wr_ds_Tree * lxt2_wr_ds_splay (granmsk_t i, lxt2_wr_ds_Tree * t) {
@ -101,7 +155,7 @@ static lxt2_wr_ds_Tree * lxt2_wr_ds_insert(granmsk_t i, lxt2_wr_ds_Tree * t, int
/* Insert i into the tree t, unless it's already there. */
/* Return a pointer to the resulting tree. */
lxt2_wr_ds_Tree * n;
n = (lxt2_wr_ds_Tree *) calloc (1, sizeof (lxt2_wr_ds_Tree));
if (n == NULL) {
fprintf(stderr, "ds_insert: ran out of memory, exiting.\n");
@ -191,7 +245,7 @@ static lxt2_wr_dslxt_Tree * lxt2_wr_dslxt_insert(char *i, lxt2_wr_dslxt_Tree * t
/* Return a pointer to the resulting tree. */
lxt2_wr_dslxt_Tree * n;
int dir;
n = (lxt2_wr_dslxt_Tree *) calloc (1, sizeof (lxt2_wr_dslxt_Tree));
if (n == NULL) {
fprintf(stderr, "dslxt_insert: ran out of memory, exiting.\n");
@ -227,7 +281,7 @@ static lxt2_wr_dslxt_Tree * lxt2_wr_dslxt_insert(char *i, lxt2_wr_dslxt_Tree * t
/*
* functions which emit various big endian
* data to a file
*/
*/
static int lxt2_wr_emit_u8(struct lxt2_wr_trace *lt, int value)
{
unsigned char buf[1];
@ -286,7 +340,7 @@ return(rc);
* data to a file. (lt->position needs to be
* fixed up on gzclose so the tables don't
* get out of sync!)
*/
*/
static int gzwrite_buffered(struct lxt2_wr_trace *lt)
{
int rc = 1;
@ -392,7 +446,7 @@ return(rc);
static int lxt2_wr_emit_stringz(struct lxt2_wr_trace *lt, char *value)
{
int rc=1;
do
do
{
rc&=lxt2_wr_emit_u8z(lt, *value);
} while(*(value++));
@ -419,7 +473,7 @@ for(p=s;*p;p++)
{
h=h^(g>>24);
h=h^g;
}
}
}
h^=h2; /* combine the two hashes */
@ -446,17 +500,17 @@ struct lxt2_wr_symbol *temp;
hv=lxt2_wr_hash(s);
if(!(temp=lt->sym[hv])) return(NULL); /* no hash entry, add here wanted to add */
while(temp)
{
if(!strcmp(temp->name,s))
{
return(temp); /* in table already */
return(temp); /* in table already */
}
if(!temp->next) break;
temp=temp->next;
}
return(NULL); /* not found, add here if you want to add*/
}
@ -481,13 +535,13 @@ if(lt->compress_fac_str)
lxt2_wr_emit_u16z(lt, i);
lxt2_wr_emit_stringz(lt, str+i);
free(lt->compress_fac_str);
}
}
else
{
lxt2_wr_emit_u16z(lt, 0);
lxt2_wr_emit_stringz(lt, str);
}
lt->compress_fac_str = (char *) malloc((lt->compress_fac_len=len)+1);
strcpy(lt->compress_fac_str, str);
}
@ -497,21 +551,6 @@ strcpy(lt->compress_fac_str, str);
* emit facs in sorted order along with geometry
* and sync table info
*/
static int lxt2_wr_compare(const void *v1, const void *v2)
{
struct lxt2_wr_symbol *s1 = *(struct lxt2_wr_symbol **)v1;
struct lxt2_wr_symbol *s2 = *(struct lxt2_wr_symbol **)v2;
int rc = strcmp(s1->name, s2->name);
if(rc)
{
return(rc);
}
else
{
return(s1->msb - s2->msb);
}
}
static void strip_brack(struct lxt2_wr_symbol *s)
{
@ -521,12 +560,17 @@ if(s->namlen<3) return;
lastch--;
while(lastch!=s->name)
{
if(*lastch=='.')
{
return; /* MTI SV [0.3] notation for implicit vars */
}
if(*lastch=='[')
{
*lastch=0x00;
*lastch=0x00;
return;
}
lastch--;
lastch--;
}
return;
}
@ -539,7 +583,7 @@ int i;
if((lt)&&(lt->numfacs))
{
struct lxt2_wr_symbol *s = lt->symchain;
struct lxt2_wr_symbol **aliascache = calloc(lt->numalias, sizeof(struct lxt2_wr_symbol *));
struct lxt2_wr_symbol **aliascache = calloc(lt->numalias ? lt->numalias : 1, sizeof(struct lxt2_wr_symbol *));
int aliases_encountered, facs_encountered;
lt->sorted_facs = (struct lxt2_wr_symbol **)calloc(lt->numfacs, sizeof(struct lxt2_wr_symbol *));
@ -549,23 +593,23 @@ if((lt)&&(lt->numfacs))
if(lt->do_strip_brackets)
for(i=0;i<lt->numfacs;i++)
{
lt->sorted_facs[i] = s;
lt->sorted_facs[lt->numfacs - i - 1] = s; /* facs were chained backwards so reverse to restore bitslicing */
strip_brack(s);
s=s->symchain;
}
else
else
for(i=0;i<lt->numfacs;i++)
{
lt->sorted_facs[i] = s;
lt->sorted_facs[lt->numfacs - i - 1] = s; /* facs were chained backwards so reverse to restore bitslicing */
s=s->symchain;
}
qsort((void *)lt->sorted_facs, lt->numfacs, sizeof(struct lxt2_wr_symbol *), lxt2_wr_compare);
}
wave_msort(lt->sorted_facs, lt->numfacs);
if(lt->partial_preference)
{
/* move preferenced facs up */
struct lxt2_wr_symbol **prefcache = aliascache;
int prefs_encountered = 0;
int prefs_encountered = 0;
facs_encountered = 0;
for(i=0;i<lt->numfacs;i++)
@ -643,7 +687,7 @@ if((lt)&&(lt->numfacs))
free(lt->compress_fac_str); lt->compress_fac_str=NULL;
lt->compress_fac_len=0;
lt->zfacname_predec_size = lt->zpackcount;
gzflush_buffered(lt, 1);
fseeko(lt->handle, 0L, SEEK_END);
lt->position=ftello(lt->handle);
@ -689,8 +733,8 @@ if((lt)&&(lt->numfacs))
}
/*
* initialize the trace and get back and lt context
/*
* initialize the trace and get back an lt context
*/
struct lxt2_wr_trace *lxt2_wr_init(const char *name)
{
@ -748,15 +792,15 @@ if(lt)
{
lt->partial = 1;
lt->partial_zip = (zipmode != 0);
lt->partial_iter = LXT2_WR_PARTIAL_SIZE;
lt->partial_iter = LXT2_WR_PARTIAL_SIZE;
}
}
void lxt2_wr_set_partial_preference(struct lxt2_wr_trace *lt, const char *name)
{
struct lxt2_wr_symbol *s;
if((lt)&&(name)&&(!lt->sorted_facs))
if((lt)&&(name)&&(!lt->sorted_facs))
{
s=lxt2_wr_symfind(lt, name);
if(s)
@ -795,8 +839,8 @@ if(lt)
/*
* set initial value of trace (0, 1, x, z) only legal vals
*/
void lxt2_wr_set_initial_value(struct lxt2_wr_trace *lt, char value)
{
void lxt2_wr_set_initial_value(struct lxt2_wr_trace *lt, char value)
{
if(lt)
{
switch(value)
@ -934,7 +978,7 @@ return(sa);
}
/*
/*
* set current time/granule updating
*/
int lxt2_wr_inc_time_by_delta(struct lxt2_wr_trace *lt, unsigned int timeval)
@ -1005,8 +1049,10 @@ for(cnt = 0; cnt < lt->break_header_size; cnt += sizeof(buf))
seg = sizeof(buf);
}
fread(buf, seg, 1, clone);
fwrite(buf, seg, 1, f2);
if(fread(buf, seg, 1, clone))
{
if(!fwrite(buf, seg, 1, f2)) break; /* write error! */
}
}
fclose(clone);
@ -1162,7 +1208,7 @@ if(using_partial)
lxt2_wr_emit_u32(lt, partial_length+9); /* size of this section (uncompressed) */
lxt2_wr_emit_u32(lt, iter); /* begin iter of section */
fflush(lt->handle);
lt->zhandle = gzdopen(dup(fileno(lt->handle)), lt->zmode);
lt->zpackcount = 0;
}
@ -1272,7 +1318,7 @@ if((lt->timegranule>=lt->maxgranule)||(do_finalize)||(early_flush))
lxt2_wr_emit_u32(lt, 0); /* size of this section (uncompressed) */
lxt2_wr_emit_u32(lt, ~0); /* control section */
fflush(lt->handle);
lt->zhandle = gzdopen(dup(fileno(lt->handle)), lt->zmode);
lt->zpackcount = 0;
}
@ -1295,9 +1341,9 @@ if((lt->timegranule>=lt->maxgranule)||(do_finalize)||(early_flush))
exit(255);
}
lxt2_wr_emit_stringz(lt, ds->item);
lxt2_wr_emit_stringz(lt, ds->item);
ds2 = ds->next;
free(ds->item);
free(ds->item);
free(ds);
ds = ds2;
}
@ -1323,7 +1369,7 @@ if((lt->timegranule>=lt->maxgranule)||(do_finalize)||(early_flush))
#endif
dt2 = dt->next;
free(dt);
free(dt);
dt = dt2;
}
lt->mapdict_head = lt->mapdict_curr = lt->mapdict = NULL;
@ -1340,11 +1386,11 @@ if((lt->timegranule>=lt->maxgranule)||(do_finalize)||(early_flush))
if(using_partial_zip)
{
off_t clen;
gzflush_buffered(lt, 1);
fseeko(lt->handle, 0L, SEEK_END);
lt->position=ftello(lt->handle);
clen = lt->position - current_iter_pos - 12;
fseeko(lt->handle, current_iter_pos, SEEK_SET);
@ -1380,7 +1426,7 @@ if((lt->timegranule>=lt->maxgranule)||(do_finalize)||(early_flush))
lxt2_wr_emit_u64(lt, (lt->firsttime>>32)&0xffffffff, lt->firsttime&0xffffffff);
lxt2_wr_emit_u64(lt, (lt->lasttime>>32)&0xffffffff, lt->lasttime&0xffffffff);
/* fprintf(stderr, "start: %Ld, end %Ld\n", lt->firsttime, lt->lasttime); */
/* fprintf(stderr, "start: %lld, end %lld\n", lt->firsttime, lt->lasttime); */
lt->timegranule=0;
lt->numblock++;
@ -1408,7 +1454,7 @@ if(lt)
{
lt->bumptime = 0;
if(!lt->flush_valid)
if(!lt->flush_valid)
{
lt->timepos++;
}
@ -1416,7 +1462,7 @@ if(lt)
{
lt->flush_valid = 0;
}
if(lt->timepos == LXT2_WR_GRANULE_SIZE)
{
/* fprintf(stderr, "flushing granule to disk at time %d\n", (unsigned int)timeval); */
@ -1425,7 +1471,7 @@ if(lt)
}
/* fprintf(stderr, "updating time to %d (%d dict entries/%d bytes)\n", (unsigned int)timeval, lt->num_dict_entries, lt->dict_string_mem_required); */
lt->timetable[lt->timepos] = timeval;
lt->timetable[lt->timepos] = timeval;
lt->lasttime = timeval;
}
}
@ -1434,7 +1480,7 @@ if(lt)
lt->timeset = 1;
lt->mintime = lt->maxtime = timeval;
lt->timetable[lt->timepos] = timeval;
lt->timetable[lt->timepos] = timeval;
}
if( (!lt->timepos) && (!lt->timegranule) )
@ -1466,9 +1512,10 @@ if(lt)
}
else if (s->flags&LXT2_WR_SYM_F_DOUBLE)
{
double value;
double value = 0;
sscanf(s->value, "%lg", &value);
errno = 0;
lxt2_wr_emit_value_double(lt, s, 0, value);
}
else if (s->flags&LXT2_WR_SYM_F_STRING)
@ -1567,7 +1614,7 @@ int rc=0;
if((!lt)||(lt->blackout)||(!s)||(row)) return(rc);
if(!lt->emitted)
if(!lt->emitted)
{
lxt2_wr_emitfacs(lt);
lt->emitted = 1;
@ -1608,7 +1655,7 @@ if(s->flags&LXT2_WR_SYM_F_DOUBLE)
if(lt->dict_curr)
{
lt->dict_curr->next = lt->dict;
lt->dict_curr->next = lt->dict;
lt->dict_curr = lt->dict;
}
else
@ -1649,7 +1696,7 @@ int rc=0;
if((!lt)||(lt->blackout)||(!s)||(!value)||(row)) return(rc);
if(!lt->emitted)
if(!lt->emitted)
{
lxt2_wr_emitfacs(lt);
lt->emitted = 1;
@ -1688,7 +1735,7 @@ if(s->flags&LXT2_WR_SYM_F_STRING)
if(lt->dict_curr)
{
lt->dict_curr->next = lt->dict;
lt->dict_curr->next = lt->dict;
lt->dict_curr = lt->dict;
}
else
@ -1733,7 +1780,7 @@ int i;
if((!lt)||(lt->blackout)||(!s)||(!value)||(!*value)||(row)) return(rc);
if(!lt->emitted)
if(!lt->emitted)
{
lxt2_wr_emitfacs(lt);
lt->emitted = 1;
@ -1752,13 +1799,13 @@ while(s->aliased_to) /* find root alias if exists */
valuelen = strlen(value); /* ensure string is proper length */
if(valuelen == s->len)
{
vfix = alloca(s->len+1);
vfix = wave_alloca(s->len+1);
strcpy(vfix, value);
value = vfix;
}
else
{
vfix = alloca(s->len+1);
vfix = wave_alloca(s->len+1);
if(valuelen < s->len)
{
@ -1798,12 +1845,12 @@ if(!(s->flags&(LXT2_WR_SYM_F_DOUBLE|LXT2_WR_SYM_F_STRING)))
prevch = *vpnt;
while(*vpnt)
{
if(prevch == *vpnt)
if(prevch == *vpnt)
{
vpnt++;
}
else
{
{
prevch = 0;
break;
}
@ -1910,7 +1957,7 @@ idxchk: if(idx<0)
if(lt->dict_curr)
{
lt->dict_curr->next = lt->dict;
lt->dict_curr->next = lt->dict;
lt->dict_curr = lt->dict;
}
else
@ -1958,30 +2005,33 @@ struct lxt2_wr_symbol *s;
if((lt)&&(!lt->blackout))
{
if(!lt->emitted)
if(!lt->emitted)
{
lxt2_wr_emitfacs(lt);
lt->emitted = 1;
if(!lt->timeset)
{
lxt2_wr_set_time(lt, 0);
}
}
}
s = lt->symchain;
while(s)
{
if((s->msk & (LXT2_WR_GRAN_1VAL<<lt->timepos)) == LXT2_WR_GRAN_0VAL)
if(!(s->flags&LXT2_WR_SYM_F_ALIAS))
{
s->msk |= (LXT2_WR_GRAN_1VAL<<lt->timepos);
s->chg[s->chgpos] = LXT2_WR_ENC_BLACKOUT;
s->chgpos++;
}
else
{
s->chg[s->chgpos-1] = LXT2_WR_ENC_BLACKOUT;
if((s->msk & (LXT2_WR_GRAN_1VAL<<lt->timepos)) == LXT2_WR_GRAN_0VAL)
{
s->msk |= (LXT2_WR_GRAN_1VAL<<lt->timepos);
s->chg[s->chgpos] = LXT2_WR_ENC_BLACKOUT;
s->chgpos++;
}
else
{
s->chg[s->chgpos-1] = LXT2_WR_ENC_BLACKOUT;
}
}
s=s->symchain;
@ -2006,26 +2056,29 @@ if((lt)&&(lt->blackout))
s = lt->symchain;
while(s)
{
if(s->flags&LXT2_WR_SYM_F_DOUBLE)
{
free(s->value);
s->value = strdup("0"); /* will cause mismatch then flush */
}
else
{
if(!(s->flags&LXT2_WR_SYM_F_STRING))
{
s->value[0] = '-'; /* will cause mismatch then flush */
for(i=1;i<s->len;i++)
{
s->value[i] = 'x'; /* initial value */
}
s->value[i]=0;
}
else
{
if(!(s->flags&LXT2_WR_SYM_F_ALIAS))
{
if(s->flags&LXT2_WR_SYM_F_DOUBLE)
{
free(s->value);
s->value = calloc(1, 1*sizeof(char));
s->value = strdup("0"); /* will cause mismatch then flush */
}
else
{
if(!(s->flags&LXT2_WR_SYM_F_STRING))
{
s->value[0] = '-'; /* will cause mismatch then flush */
for(i=1;i<s->len;i++)
{
s->value[i] = 'x'; /* initial value */
}
s->value[i]=0;
}
else
{
free(s->value);
s->value = calloc(1, 1*sizeof(char));
}
}
}
@ -2094,7 +2147,7 @@ if(lt)
{
struct lxt2_wr_symbol *s = lt->symchain;
struct lxt2_wr_symbol *s2;
while(s)
{
if(s->name) { free(s->name); }
@ -2106,7 +2159,8 @@ if(lt)
lt->symchain=NULL;
}
free(lt->lxtname);
free(lt->sorted_facs);
fclose(lt->handle);
free(lt);

View File

@ -37,6 +37,7 @@
#define ftello ftell
#endif
#define wave_alloca alloca
#define LXT2_WR_HDRID (0x1380)
#define LXT2_WR_VERSION (0x0001)

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2001-3 Tony Bybell.
* Copyright (c) 2001-7 Tony Bybell.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@ -20,8 +20,58 @@
* DEALINGS IN THE SOFTWARE.
*/
#include <config.h>
#include "lxt_write.h"
/*
* in-place sort to keep chained facs from migrating...
*/
static void wave_mergesort(struct lt_symbol **a, struct lt_symbol **b, int lo, int hi)
{
int i, j, k;
if (lo<hi)
{
int mid=(lo+hi)/2;
wave_mergesort(a, b, lo, mid);
wave_mergesort(a, b, mid+1, hi);
i=0; j=lo;
while (j<=mid)
{
b[i++]=a[j++];
}
i=0; k=lo;
while ((k<j)&&(j<=hi))
{
if (strcmp(b[i]->name, a[j]->name) <= 0)
{
a[k++]=b[i++];
}
else
{
a[k++]=a[j++];
}
}
while (k<j)
{
a[k++]=b[i++];
}
}
}
static void wave_msort(struct lt_symbol **a, int num)
{
struct lt_symbol **b = malloc(((num/2)+1) * sizeof(struct lt_symbol *));
wave_mergesort(a, b, 0, num-1);
free(b);
}
/************************ splay ************************/
static int dslxt_success;
@ -82,7 +132,7 @@ static dslxt_Tree * dslxt_insert(char *i, dslxt_Tree * t, unsigned int val) {
/* Return a pointer to the resulting tree. */
dslxt_Tree * n;
int dir;
n = (dslxt_Tree *) calloc (1, sizeof (dslxt_Tree));
if (n == NULL) {
fprintf(stderr, "dslxt_insert: ran out of memory, exiting.\n");
@ -140,7 +190,7 @@ static dslxt_Tree * dslxt_delete(char *i, dslxt_Tree * t) {
/*
* functions which emit various big endian
* data to a file
*/
*/
static int lt_emit_u8(struct lt_trace *lt, int value)
{
unsigned char buf[1];
@ -221,7 +271,7 @@ return(nmemb);
static int lt_emit_string(struct lt_trace *lt, char *value)
{
int rc=1;
do
do
{
rc&=lt_emit_u8(lt, *value);
} while(*(value++));
@ -234,7 +284,7 @@ return(rc);
* data to a file. (lt->position needs to be
* fixed up on gzclose so the tables don't
* get out of sync!)
*/
*/
static int lt_emit_u8z(struct lt_trace *lt, int value)
{
unsigned char buf[1];
@ -321,7 +371,7 @@ return(nmemb);
static int lt_emit_stringz(struct lt_trace *lt, char *value)
{
int rc=1;
do
do
{
rc&=lt_emit_u8z(lt, *value);
} while(*(value++));
@ -333,7 +383,7 @@ return(rc);
* data to a file. (lt->position needs to be
* fixed up on BZ2_bzclose so the tables don't
* get out of sync!)
*/
*/
static int lt_emit_u8bz(struct lt_trace *lt, int value)
{
unsigned char buf[1];
@ -420,7 +470,7 @@ return(nmemb);
static int lt_emit_stringbz(struct lt_trace *lt, char *value)
{
int rc=1;
do
do
{
rc&=lt_emit_u8bz(lt, *value);
} while(*(value++));
@ -487,7 +537,7 @@ for(p=s;*p;p++)
{
h=h^(g>>24);
h=h^g;
}
}
}
h^=h2; /* combine the two hashes */
@ -514,17 +564,17 @@ struct lt_symbol *temp;
hv=lt_hash(s);
if(!(temp=lt->sym[hv])) return(NULL); /* no hash entry, add here wanted to add */
while(temp)
{
if(!strcmp(temp->name,s))
{
return(temp); /* in table already */
return(temp); /* in table already */
}
if(!temp->next) break;
temp=temp->next;
}
return(NULL); /* not found, add here if you want to add*/
}
@ -549,38 +599,18 @@ if(lt->compress_fac_str)
lt_emit_u16z(lt, i);
lt_emit_stringz(lt, str+i);
free(lt->compress_fac_str);
}
}
else
{
lt_emit_u16z(lt, 0);
lt_emit_stringz(lt, str);
}
lt->compress_fac_str = (char *) malloc((lt->compress_fac_len=len)+1);
strcpy(lt->compress_fac_str, str);
}
/*
* emit facs in sorted order along with geometry
* and sync table info
*/
static int lt_compare(const void *v1, const void *v2)
{
struct lt_symbol *s1 = *(struct lt_symbol **)v1;
struct lt_symbol *s2 = *(struct lt_symbol **)v2;
int rc = strcmp(s1->name, s2->name);
if(rc)
{
return(rc);
}
else
{
return(s1->msb - s2->msb);
}
}
static void strip_brack(struct lt_symbol *s)
{
char *lastch = s->name+s->namlen - 1;
@ -589,12 +619,17 @@ if(s->namlen<3) return;
lastch--;
while(lastch!=s->name)
{
if(*lastch=='.')
{
return; /* MTI SV [0.3] notation for implicit vars */
}
if(*lastch=='[')
{
*lastch=0x00;
*lastch=0x00;
return;
}
lastch--;
lastch--;
}
return;
}
@ -616,17 +651,17 @@ if((lt)&&(lt->numfacs))
if(lt->do_strip_brackets)
for(i=0;i<lt->numfacs;i++)
{
lt->sorted_facs[i] = s;
lt->sorted_facs[lt->numfacs - i - 1] = s; /* facs were chained backwards so reverse to restore bitslicing */
strip_brack(s);
s=s->symchain;
}
else
else
for(i=0;i<lt->numfacs;i++)
{
lt->sorted_facs[i] = s;
lt->sorted_facs[lt->numfacs - i - 1] = s; /* facs were chained backwards so reverse to restore bitslicing*/
s=s->symchain;
}
qsort((void *)lt->sorted_facs, lt->numfacs, sizeof(struct lt_symbol *), lt_compare);
}
wave_msort(lt->sorted_facs, lt->numfacs);
for(i=0;i<lt->numfacs;i++)
{
@ -653,7 +688,7 @@ if((lt)&&(lt->numfacs))
free(lt->compress_fac_str); lt->compress_fac_str=NULL;
lt->compress_fac_len=0;
lt->zfacname_predec_size = lt->zpackcount;
gzclose(lt->zhandle);
fseeko(lt->handle, 0L, SEEK_END);
lt->position=ftello(lt->handle);
@ -688,13 +723,13 @@ if((lt)&&(lt->numfacs))
if(is_interlaced_trace)
{
lt->zhandle = gzdopen(dup(fileno(lt->handle)), "wb9");
lt->sync_table_offset = lt->position;
for(i=0;i<lt->numfacs;i++)
{
lt_emit_u32z(lt, lt->sorted_facs[i]->last_change);
}
gzclose(lt->zhandle); lt->zhandle = NULL;
fseeko(lt->handle, 0L, SEEK_END);
lt->position=ftello(lt->handle);
@ -705,7 +740,7 @@ if((lt)&&(lt->numfacs))
}
/*
/*
* initialize the trace and get back an lt context
*/
struct lt_trace *lt_init(const char *name)
@ -831,7 +866,7 @@ switch(numbytes_trans&3)
case 3: lt->lt_emit_u32(lt, numtrans); break;
}
/* printf("Clock finish for '%s' at %Ld ending with '%c' for %d repeats over a switch delta of %d\n",
/* printf("Clock finish for '%s' at %lld ending with '%c' for %d repeats over a switch delta of %d\n",
s->name, lt->timeval, s->clk_prevval, s->clk_numtrans - LT_CLKPACK, s->clk_delta); */
s->clk_prevtrans = ULLDescriptor(~0);
s->clk_numtrans = 0;
@ -932,7 +967,7 @@ switch(numbytes_trans&3)
case 3: lt->lt_emit_u32(lt, numtrans); break;
}
/* printf("Clock finish for '%s' at %Ld ending with '%08x' for %d repeats over a switch delta of %Ld\n",
/* printf("Clock finish for '%s' at %lld ending with '%08x' for %d repeats over a switch delta of %lld\n",
s->name, lt->timeval, s->clk_prevval, s->clk_numtrans - LT_CLKPACK_M, s->clk_delta); */
s->clk_prevtrans = ULLDescriptor(~0);
s->clk_numtrans = 0;
@ -1000,7 +1035,7 @@ for(i=0;i<lt->num_dict_entries;i++)
/* fprintf(stderr, "%8d) '%s'\n", ds->val, ds->item); */
lt_emit_stringz(lt, ds->item+1);
}
gzclose(lt->zhandle);
fseeko(lt->handle, 0L, SEEK_END);
lt->position=ftello(lt->handle);
@ -1037,13 +1072,13 @@ if(lt)
if(s->clk_numtrans > LT_CLKPACK_M) lt_flushclock_m(lt, s);
}
else
{
{
if(s->clk_numtrans > LT_CLKPACK) lt_flushclock(lt, s);
}
}
s=s->symchain;
}
}
lt_set_dumpon(lt); /* in case it was turned off */
@ -1101,7 +1136,7 @@ if(lt)
while(t)
{
lt_emit_u32z(lt, t->position - lastposition); lastposition = t->position;
t=t->next;
t=t->next;
}
t=lt->timehead;
@ -1111,9 +1146,9 @@ if(lt)
{
lxttime_t delta = t->timeval - lasttime;
lt_emit_u64z(lt, (int)(delta>>32), (int)delta); lasttime = t->timeval;
t2=t->next;
free(t);
free(t);
t=t2;
}
}
@ -1122,12 +1157,12 @@ if(lt)
while(t)
{
lt_emit_u32z(lt, (int)(t->timeval - lasttime)); lasttime = t->timeval;
t2=t->next;
free(t);
free(t);
t=t2;
}
lt->timehead = lt->timecurr = NULL;
}
@ -1137,7 +1172,7 @@ if(lt)
lt->ztime_table_size = lt->position - lt->ztime_table_size;
}
if(lt->initial_value>=0)
if(lt->initial_value>=0)
{
lt->initial_value_offset = lt->position;
lt_emit_u8(lt, lt->initial_value);
@ -1152,7 +1187,7 @@ if(lt)
if(lt->double_used)
{
lt->double_test_offset = lt->position;
lt_emit_double(lt, 3.14159);
lt_emit_double(lt, 3.14159);
}
if(lt->dumpoffcount)
@ -1168,7 +1203,7 @@ if(lt)
lt_emit_u64(lt, (int)((ltt->timeval)>>32), (int)ltt->timeval);
ltt2 = ltt;
ltt=ltt->next;
free(ltt2);
free(ltt2);
}
lt->dumpoffhead = lt->dumpoffcurr = NULL;
@ -1211,7 +1246,7 @@ if(lt)
{
struct lt_symbol *s = lt->symchain;
struct lt_symbol *s2;
while(s)
{
free(s->name);
@ -1220,7 +1255,7 @@ if(lt)
s=s2;
}
}
free(lt->sorted_facs);
fclose(lt->handle);
free(lt);
@ -1326,7 +1361,7 @@ return(sa);
}
/*
/*
* set current time
*/
int lt_inc_time_by_delta(struct lt_trace *lt, unsigned int timeval)
@ -1365,7 +1400,7 @@ if(lt)
else
{
free(trl);
goto bail;
goto bail;
}
}
else
@ -1446,7 +1481,7 @@ if((lt)&&(!lt->emitted))
}
/*
* sets change interlace
* sets change interlace
*/
void lt_set_no_interlace(struct lt_trace *lt)
{
@ -1467,17 +1502,17 @@ if((lt)&&(!lt->emitted)&&(!lt->sorted_facs))
if(lt->do_strip_brackets)
for(i=0;i<lt->numfacs;i++)
{
lt->sorted_facs[i] = s;
lt->sorted_facs[lt->numfacs - i - 1] = s; /* facs were chained backwards so reverse to restore bitslicing */
strip_brack(s);
s=s->symchain;
}
else
else
for(i=0;i<lt->numfacs;i++)
{
lt->sorted_facs[i] = s;
lt->sorted_facs[lt->numfacs - i - 1] = s; /* facs were chained backwards so reverse to restore bitslicing */
s=s->symchain;
}
qsort((void *)lt->sorted_facs, lt->numfacs, sizeof(struct lt_symbol *), lt_compare);
}
wave_msort(lt->sorted_facs, lt->numfacs);
for(i=0;i<lt->numfacs;i++)
{
@ -1516,12 +1551,12 @@ if(lt)
{
int tag;
switch(value)
{
{
case '0': tag = 0; break;
case '1': tag = 1; break;
case 'Z':
case 'Z':
case 'z': tag = 2; break;
case 'X':
case 'X':
case 'x': tag = 3; break;
case 'H':
case 'h': tag = 4; break;
@ -1639,6 +1674,7 @@ if(!(s->flags&(LT_SYM_F_DOUBLE|LT_SYM_F_STRING)))
unsigned int last_change_delta;
if((lt->clock_compress)&&(s->rows==0))
{
if((len>1)&&(len<=32))
{
int ivalue = value;
@ -1678,7 +1714,7 @@ if(!(s->flags&(LT_SYM_F_DOUBLE|LT_SYM_F_STRING)))
s->clk_prevval1 = s->clk_prevval;
s->clk_prevval = ivalue;
/* printf("Clock value '%08x' for '%s' at %Ld (#%d)\n", ivalue, s->name, lt->timeval, s->clk_numtrans); */
/* printf("Clock value '%08x' for '%s' at %lld (#%d)\n", ivalue, s->name, lt->timeval, s->clk_numtrans); */
return(1);
}
}
@ -1779,6 +1815,7 @@ if(!(s->flags&(LT_SYM_F_DOUBLE|LT_SYM_F_STRING)))
s->clk_prevval = ivalue + '0';
}
}
/* normal trace handling */
@ -1821,7 +1858,7 @@ if(!(s->flags&(LT_SYM_F_DOUBLE|LT_SYM_F_STRING)))
{
tag = (numbytes<<4);
}
lt->lt_emit_u8(lt, tag);
switch(numbytes&3)
{
@ -1842,7 +1879,7 @@ if(!(s->flags&(LT_SYM_F_DOUBLE|LT_SYM_F_STRING)))
}
lt->lt_emit_u8(lt, optimized ? (3+optimized1) : 0);
}
s->last_change = start_position;
if(s->rows>0)
@ -1908,7 +1945,7 @@ if(!(s->flags&(LT_SYM_F_DOUBLE|LT_SYM_F_STRING)))
{
if(lt->num_dict_entries==(256*65536)) lt->dict32_offset = lt->position;
}
lt->num_dict_entries++;
}
@ -1953,14 +1990,14 @@ if(!(s->flags&(LT_SYM_F_DOUBLE|LT_SYM_F_STRING)))
value <<= (24-len);
rc=lt->lt_emit_u24(lt, value);
}
else
else
{
value <<= (32-len);
rc=lt->lt_emit_u32(lt, value);
}
}
}
}
if(lt->timebuff)
{
lt->timechangecount++;
@ -2022,7 +2059,7 @@ if((s->flags)&LT_SYM_F_DOUBLE)
{
numbytes = 0;
}
start_position = lt->position;
s->last_change = start_position;
@ -2078,7 +2115,7 @@ if((s->flags)&LT_SYM_F_DOUBLE)
}
rc=lt->lt_emit_double(lt, value);
if(lt->timebuff)
{
lt->timechangecount++;
@ -2120,7 +2157,7 @@ if((s->flags)&LT_SYM_F_STRING)
int numbytes; /* number of bytes to store value minus one */
unsigned int last_change_delta = lt->position - s->last_change - 2;
if(lt->numfacs_bytes)
if(!lt->numfacs_bytes)
{
if(last_change_delta >= 256*65536)
{
@ -2140,7 +2177,7 @@ if((s->flags)&LT_SYM_F_STRING)
{
numbytes = 0;
}
start_position = lt->position;
s->last_change = start_position;
@ -2196,7 +2233,7 @@ if((s->flags)&LT_SYM_F_STRING)
}
rc=lt->lt_emit_string(lt, value);
if(lt->timebuff)
{
lt->timechangecount++;
@ -2245,6 +2282,7 @@ if(!(s->flags&(LT_SYM_F_DOUBLE|LT_SYM_F_STRING)))
int len = ((s->flags)&LT_SYM_F_INTEGER) ? 32 : s->len;
if((lt->clock_compress)&&(s->rows==0))
{
if((len>1)&&(len<=32))
{
int legal = 0;
@ -2308,7 +2346,7 @@ if(!(s->flags&(LT_SYM_F_DOUBLE|LT_SYM_F_STRING)))
s->clk_prevval1 = s->clk_prevval;
s->clk_prevval = ivalue;
/* printf("Clock value '%08x' for '%s' [len=%d] at %Ld (#%d)\n",
/* printf("Clock value '%08x' for '%s' [len=%d] at %lld (#%d)\n",
ivalue, s->name, len, lt->timeval, s->clk_numtrans); */
return(1);
}
@ -2374,7 +2412,7 @@ if(!(s->flags&(LT_SYM_F_DOUBLE|LT_SYM_F_STRING)))
{
s->clk_prevval = value[0];
/* printf("Clock value '%c' for '%s' at %Ld (#%d)\n", value[0], s->name, lt->timeval, s->clk_numtrans); */
/* printf("Clock value '%c' for '%s' at %lld (#%d)\n", value[0], s->name, lt->timeval, s->clk_numtrans); */
return(1);
}
}
@ -2408,6 +2446,7 @@ if(!(s->flags&(LT_SYM_F_DOUBLE|LT_SYM_F_STRING)))
s->clk_prevval = value[0];
}
}
/* normal trace handling */
@ -2437,12 +2476,12 @@ if(!(s->flags&(LT_SYM_F_DOUBLE|LT_SYM_F_STRING)))
while((ch=*(pnt++)))
{
switch(ch)
{
{
case '0':
case '1': mvl|=LT_MVL_2; break;
case 'Z':
case 'z':
case 'X':
case 'Z':
case 'z':
case 'X':
case 'x': mvl|=LT_MVL_4; break;
default: mvl|=LT_MVL_9; break;
}
@ -2451,13 +2490,13 @@ if(!(s->flags&(LT_SYM_F_DOUBLE|LT_SYM_F_STRING)))
}
switch(prevch)
{
{
case 0x00: tagadd = 0; break;
case '0': tagadd = 3; break;
case '1': tagadd = 4; break;
case 'Z':
case 'Z':
case 'z': tagadd = 5; break;
case 'X':
case 'X':
case 'x': tagadd = 6; break;
case 'H':
case 'h': tagadd = 7; break;
@ -2554,7 +2593,7 @@ if(!(s->flags&(LT_SYM_F_DOUBLE|LT_SYM_F_STRING)))
int outval = 0;
int thisval= 0;
pnt = value;
pnt = value;
if((lt->dictmode)&&(len>lt->mindictwidth))
{
@ -2585,7 +2624,7 @@ if(!(s->flags&(LT_SYM_F_DOUBLE|LT_SYM_F_STRING)))
{
if(lt->num_dict_entries==(256*65536)) lt->dict32_offset = lt->position;
}
lt->num_dict_entries++;
}
@ -2623,8 +2662,8 @@ if(!(s->flags&(LT_SYM_F_DOUBLE|LT_SYM_F_STRING)))
outval |= (thisval<<bitpos);
bitpos--;
if((bitpos==-1)||(i==len-1))
{
lt->lt_emit_u8(lt, outval);
{
lt->lt_emit_u8(lt, outval);
outval = 0;
bitpos = 7;
}
@ -2638,7 +2677,7 @@ if(!(s->flags&(LT_SYM_F_DOUBLE|LT_SYM_F_STRING)))
int outval = 0;
int thisval= 0;
pnt = value;
pnt = value;
for(i=0;i<len;i++)
{
@ -2657,8 +2696,8 @@ if(!(s->flags&(LT_SYM_F_DOUBLE|LT_SYM_F_STRING)))
outval |= (thisval<<bitpos);
bitpos-=2;
if((bitpos==-2)||(i==len-1))
{
lt->lt_emit_u8(lt, outval);
{
lt->lt_emit_u8(lt, outval);
outval = 0;
bitpos = 6;
}
@ -2672,7 +2711,7 @@ if(!(s->flags&(LT_SYM_F_DOUBLE|LT_SYM_F_STRING)))
int outval = 0;
int thisval= 0;
pnt = value;
pnt = value;
for(i=0;i<len;i++)
{
@ -2701,8 +2740,8 @@ if(!(s->flags&(LT_SYM_F_DOUBLE|LT_SYM_F_STRING)))
outval |= (thisval<<bitpos);
bitpos-=4;
if((bitpos==-4)||(i==len-1))
{
lt->lt_emit_u8(lt, outval);
{
lt->lt_emit_u8(lt, outval);
outval = 0;
bitpos = 4;
}
@ -2712,7 +2751,7 @@ if(!(s->flags&(LT_SYM_F_DOUBLE|LT_SYM_F_STRING)))
rc=1;
}
if(lt->timebuff)
{
lt->timechangecount++;

View File

@ -1,5 +1,6 @@
%option never-interactive
%option nounput
%{
/*

View File

@ -1,4 +1,6 @@
%option nounput
%{
/*
* Copyright (c) 1999 Stephen Williams (steve@icarus.com)

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2001-2005 Stephen Williams (steve@icarus.com)
* Copyright (c) 2001-2008 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
@ -16,9 +16,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: arith.cc,v 1.50 2007/01/20 02:09:54 steve Exp $"
#endif
# include "arith.h"
# include "schedule.h"
@ -756,6 +753,24 @@ void vvp_arith_real_::dispatch_operand_(vvp_net_ptr_t ptr, double bit)
}
/* Real multiplication. */
vvp_arith_mult_real::vvp_arith_mult_real()
{
}
vvp_arith_mult_real::~vvp_arith_mult_real()
{
}
void vvp_arith_mult_real::recv_real(vvp_net_ptr_t ptr, double bit)
{
dispatch_operand_(ptr, bit);
double val = op_a_ * op_b_;
vvp_send_real(ptr.ptr()->out, val);
}
/* Real division. */
vvp_arith_div_real::vvp_arith_div_real()
{
}
@ -772,6 +787,24 @@ void vvp_arith_div_real::recv_real(vvp_net_ptr_t ptr, double bit)
vvp_send_real(ptr.ptr()->out, val);
}
/* Real summation. */
vvp_arith_sum_real::vvp_arith_sum_real()
{
}
vvp_arith_sum_real::~vvp_arith_sum_real()
{
}
void vvp_arith_sum_real::recv_real(vvp_net_ptr_t ptr, double bit)
{
dispatch_operand_(ptr, bit);
double val = op_a_ + op_b_;
vvp_send_real(ptr.ptr()->out, val);
}
/* Real subtraction. */
vvp_arith_sub_real::vvp_arith_sub_real()
{
}

View File

@ -1,7 +1,7 @@
#ifndef __arith_H
#define __arith_H
/*
* Copyright (c) 2001-2005 Stephen Williams (steve@icarus.com)
* Copyright (c) 2001-2008 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
@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: arith.h,v 1.34 2006/07/30 02:51:36 steve Exp $"
#endif
# include "vvp_net.h"
@ -218,6 +215,14 @@ class vvp_arith_real_ : public vvp_net_fun_t {
};
class vvp_arith_sum_real : public vvp_arith_real_ {
public:
explicit vvp_arith_sum_real();
~vvp_arith_sum_real();
void recv_real(vvp_net_ptr_t ptr, double bit);
};
class vvp_arith_div_real : public vvp_arith_real_ {
public:
@ -226,6 +231,14 @@ class vvp_arith_div_real : public vvp_arith_real_ {
void recv_real(vvp_net_ptr_t ptr, double bit);
};
class vvp_arith_mult_real : public vvp_arith_real_ {
public:
explicit vvp_arith_mult_real();
~vvp_arith_mult_real();
void recv_real(vvp_net_ptr_t ptr, double bit);
};
class vvp_arith_sub_real : public vvp_arith_real_ {
public:
@ -234,54 +247,4 @@ class vvp_arith_sub_real : public vvp_arith_real_ {
void recv_real(vvp_net_ptr_t ptr, double bit);
};
/*
* $Log: arith.h,v $
* Revision 1.34 2006/07/30 02:51:36 steve
* Fix/implement signed right shift.
*
* Revision 1.33 2006/01/03 06:19:31 steve
* Support wide divide nodes.
*
* Revision 1.32 2005/07/06 04:29:25 steve
* Implement real valued signals and arith nodes.
*
* Revision 1.31 2005/06/22 00:04:48 steve
* Reduce vvp_vector4 copies by using const references.
*
* Revision 1.30 2005/06/11 18:11:18 steve
* Remove unneeded references to functor.h
*
* Revision 1.29 2005/03/19 06:23:49 steve
* Handle LPM shifts.
*
* Revision 1.28 2005/03/12 06:42:28 steve
* Implement .arith/mod.
*
* Revision 1.27 2005/03/09 05:52:04 steve
* Handle case inequality in netlists.
*
* Revision 1.26 2005/02/19 01:32:52 steve
* Implement .arith/div.
*
* Revision 1.25 2005/02/04 05:13:02 steve
* Add wide .arith/mult, and vvp_vector2_t vectors.
*
* Revision 1.24 2005/01/28 05:34:25 steve
* Add vector4 implementation of .arith/mult.
*
* Revision 1.23 2005/01/22 16:21:11 steve
* Implement vectored CMP_EQ and NE
*
* Revision 1.22 2005/01/22 01:06:20 steve
* Implement the .cmp/eeq LPM node.
*
* Revision 1.21 2005/01/16 04:19:08 steve
* Reimplement comparators as vvp_vector4_t nodes.
*
* Revision 1.20 2004/12/11 02:31:29 steve
* Rework of internals to carry vectors through nexus instead
* of single bits. Make the ivl, tgt-vvp and vvp initial changes
* down this path.
*
*/
#endif

View File

@ -414,7 +414,7 @@ void compile_real_array(char*label, char*name, int last, int first,
void compile_net_array(char*label, char*name, int last, int first)
{
vpiHandle obj = common_array_build(label, name, last, first);
/* vpiHandle obj = */ common_array_build(label, name, last, first);
free(label);
free(name);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2001-2007 Stephen Williams (steve@icarus.com)
* Copyright (c) 2001-2008 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
@ -941,12 +941,24 @@ void compile_arith_mult(char*label, long wid,
make_arith(arith, label, argc, argv);
}
void compile_arith_mult_r(char*label, unsigned argc, struct symb_s*argv)
{
if (argc != 2) {
fprintf(stderr, "%s .arith/mult.r has wrong number of symbols\n", label);
compile_errors += 1;
return;
}
vvp_arith_real_ *arith = new vvp_arith_mult_real;
make_arith(arith, label, argc, argv);
}
void compile_arith_sub(char*label, long wid, unsigned argc, struct symb_s*argv)
{
assert( wid > 0 );
if (argc != 2) {
fprintf(stderr, "%s .arith has wrong number of symbols\n", label);
fprintf(stderr, "%s .arith/sub has wrong number of symbols\n", label);
compile_errors += 1;
return;
}
@ -972,7 +984,7 @@ void compile_arith_sum(char*label, long wid, unsigned argc, struct symb_s*argv)
assert( wid > 0 );
if (argc != 2) {
fprintf(stderr, "%s .arith has wrong number of symbols\n", label);
fprintf(stderr, "%s .arith/sum has wrong number of symbols\n", label);
compile_errors += 1;
return;
}
@ -981,6 +993,18 @@ void compile_arith_sum(char*label, long wid, unsigned argc, struct symb_s*argv)
make_arith(arith, label, argc, argv);
}
void compile_arith_sum_r(char*label, unsigned argc, struct symb_s*argv)
{
if (argc != 2) {
fprintf(stderr, "%s .arith/sum.r has wrong number of symbols\n", label);
compile_errors += 1;
return;
}
vvp_arith_real_ *arith = new vvp_arith_sum_real;
make_arith(arith, label, argc, argv);
}
void compile_cmp_eeq(char*label, long wid,
unsigned argc, struct symb_s*argv)
{

View File

@ -1,7 +1,7 @@
#ifndef __compile_H
#define __compile_H
/*
* Copyright (c) 2001-2007 Stephen Williams (steve@icarus.com)
* Copyright (c) 2001-2008 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
@ -169,7 +169,10 @@ extern void compile_cmp_ge(char*label, long width, bool signed_flag,
extern void compile_cmp_gt(char*label, long width, bool signed_flag,
unsigned argc, struct symb_s*argv);
extern void compile_arith_mult_r(char*label, unsigned argc,
struct symb_s*argv);
extern void compile_arith_div_r(char*label, unsigned argc, struct symb_s*argv);
extern void compile_arith_sum_r(char*label, unsigned argc, struct symb_s*argv);
extern void compile_arith_sub_r(char*label, unsigned argc, struct symb_s*argv);
extern void compile_dff(char*label,

View File

@ -21,6 +21,7 @@
#include "schedule.h"
#include "vpi_priv.h"
#include <iostream>
#include <cstdlib>
#include <assert.h>
void vvp_delay_t::calculate_min_delay_()
@ -653,7 +654,7 @@ static void modpath_src_get_delays ( vpiHandle ref, p_vpi_delay delays )
vpip_time_to_timestruct(delays->da+idx, tmp[idx]);
}
} else {
int units = src->dest->scope->time_units;
/* int units = src->dest->scope->time_units; */
for (idx = 0; idx < 12; idx += 1) {
delays->da[idx].real = vpip_time_to_scaled_real(tmp[idx], src->dest->scope);
}

View File

@ -1,9 +1,10 @@
%option never-interactive
%option nounput
%{
/*
* Copyright (c) 2001-2007 Stephen Williams (steve@icarus.com)
* Copyright (c) 2001-2008 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
@ -91,9 +92,11 @@
".arith/div.s" { return K_ARITH_DIV_S; }
".arith/mod" { return K_ARITH_MOD; }
".arith/mult" { return K_ARITH_MULT; }
".arith/mult.r" { return K_ARITH_MULT_R; }
".arith/sub" { return K_ARITH_SUB; }
".arith/sub.r" { return K_ARITH_SUB_R; }
".arith/sum" { return K_ARITH_SUM; }
".arith/sum.r" { return K_ARITH_SUM_R; }
".array" { return K_ARRAY; }
".array/i" { return K_ARRAY_I; }
".array/real" { return K_ARRAY_R; }

View File

@ -1,7 +1,7 @@
%{
/*
* Copyright (c) 2001-2007 Stephen Williams (steve@icarus.com)
* Copyright (c) 2001-2008 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
@ -67,8 +67,8 @@ static struct __vpiModPath*modpath_dst = 0;
%token K_ALIAS K_ALIAS_S K_ALIAS_R
%token K_ARITH_DIV K_ARITH_DIV_R K_ARITH_DIV_S K_ARITH_MOD K_ARITH_MULT
%token K_ARITH_SUB K_ARITH_SUB_R K_ARITH_SUM K_ARRAY K_ARRAY_I K_ARRAY_R
%token K_ARRAY_S K_ARRAY_PORT
%token K_ARITH_MULT_R K_ARITH_SUB K_ARITH_SUB_R K_ARITH_SUM K_ARITH_SUM_R
%token K_ARRAY K_ARRAY_I K_ARRAY_R K_ARRAY_S K_ARRAY_PORT
%token K_CMP_EEQ K_CMP_EQ K_CMP_NEE K_CMP_NE
%token K_CMP_GE K_CMP_GE_S K_CMP_GT K_CMP_GT_S
%token K_CONCAT K_DEBUG K_DELAY K_DFF
@ -275,6 +275,11 @@ statement
compile_arith_mult($1, $3, obj.cnt, obj.vect);
}
| T_LABEL K_ARITH_MULT_R T_NUMBER ',' symbols ';'
{ struct symbv_s obj = $5;
compile_arith_mult_r($1, obj.cnt, obj.vect);
}
| T_LABEL K_ARITH_SUB T_NUMBER ',' symbols ';'
{ struct symbv_s obj = $5;
compile_arith_sub($1, $3, obj.cnt, obj.vect);
@ -290,6 +295,11 @@ statement
compile_arith_sum($1, $3, obj.cnt, obj.vect);
}
| T_LABEL K_ARITH_SUM_R T_NUMBER ',' symbols ';'
{ struct symbv_s obj = $5;
compile_arith_sum_r($1, obj.cnt, obj.vect);
}
| T_LABEL K_CMP_EEQ T_NUMBER ',' symbols ';'
{ struct symbv_s obj = $5;
compile_cmp_eeq($1, $3, obj.cnt, obj.vect);

View File

@ -399,8 +399,10 @@ PLI_INT32 vpi_get_vlog_info(p_vpi_vlog_info vlog_info_p)
void vpi_set_vlog_info(int argc, char** argv)
{
vpi_vlog_info.product = "Icarus Verilog";
vpi_vlog_info.version = "$Name: $";
static char icarus_product[] = "Icarus Verilog";
static char icarus_version[] = "$Name: $";
vpi_vlog_info.product = icarus_product;
vpi_vlog_info.version = icarus_version;
vpi_vlog_info.argc = argc;
vpi_vlog_info.argv = argv;

View File

@ -40,7 +40,7 @@ struct __vpiVThrVec {
unsigned bas;
unsigned wid;
unsigned signed_flag : 1;
char *name;
const char *name;
};
inline static
@ -427,14 +427,14 @@ vpiHandle vpip_make_vthr_vector(unsigned base, unsigned wid, bool signed_flag)
assert(wid < 65536);
obj->wid = wid;
obj->signed_flag = signed_flag? 1 : 0;
obj->name = "T<>";
obj->name = vpip_name_string("T<>");
return &obj->base;
}
struct __vpiVThrWord {
struct __vpiHandle base;
char* name;
const char* name;
int subtype;
unsigned index;
};
@ -545,7 +545,7 @@ vpiHandle vpip_make_vthr_word(unsigned base, const char*type)
assert(type[0] == 'r');
obj->base.vpi_type = &vpip_vthr_const_real_rt;
obj->name = "W<>";
obj->name = vpip_name_string("W<>");
obj->subtype = vpiRealConst;
assert(base < 65536);
obj->index = base;

View File

@ -30,6 +30,7 @@
#ifdef HAVE_MALLOC_H
# include <malloc.h>
#endif
# include <typeinfo>
# include <stdlib.h>
# include <limits.h>
# include <string.h>

View File

@ -22,6 +22,8 @@
# include "schedule.h"
# include "statistics.h"
# include <stdio.h>
# include <cstring>
# include <cstdlib>
# include <iostream>
# include <typeinfo>
# include <limits.h>