diff --git a/HName.cc b/HName.cc index 891eb541e..c0db77008 100644 --- a/HName.cc +++ b/HName.cc @@ -23,8 +23,9 @@ # include "config.h" # include "HName.h" # include -# include -# include +# include +# include +# include #ifdef HAVE_MALLOC_H # include #endif diff --git a/PWire.cc b/PWire.cc index 84d1dca71..404e12ef7 100644 --- a/PWire.cc +++ b/PWire.cc @@ -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; diff --git a/cprop.cc b/cprop.cc index 07677be17..b3951ff0b 100644 --- a/cprop.cc +++ b/cprop.cc @@ -19,6 +19,7 @@ # include "config.h" +# include # include "netlist.h" # include "netmisc.h" # include "functor.h" diff --git a/driver/cflexor.lex b/driver/cflexor.lex index 4da101db0..181e52330 100644 --- a/driver/cflexor.lex +++ b/driver/cflexor.lex @@ -1,4 +1,6 @@ +%option nounput + %{ /* * Copyright (c) 2001 Stephen Williams (steve@icarus.com) diff --git a/elab_expr.cc b/elab_expr.cc index 903c69bea..f380659aa 100644 --- a/elab_expr.cc +++ b/elab_expr.cc @@ -18,6 +18,9 @@ */ # include "config.h" +# include +# include +# include # include "compiler.h" # include "pform.h" diff --git a/elab_lval.cc b/elab_lval.cc index 793002a54..659837337 100644 --- a/elab_lval.cc +++ b/elab_lval.cc @@ -23,6 +23,7 @@ # include "netlist.h" # include "netmisc.h" # include "compiler.h" +# include # include # include "ivl_assert.h" diff --git a/elab_net.cc b/elab_net.cc index d1a62a52f..04db2a8e0 100644 --- a/elab_net.cc +++ b/elab_net.cc @@ -24,6 +24,8 @@ # include "netmisc.h" # include "compiler.h" +# include +# include # include # 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); diff --git a/elab_pexpr.cc b/elab_pexpr.cc index fdf2ed544..ab687a8cd 100644 --- a/elab_pexpr.cc +++ b/elab_pexpr.cc @@ -24,6 +24,7 @@ # include "util.h" # include "netmisc.h" +# include # include # include "ivl_assert.h" diff --git a/elab_scope.cc b/elab_scope.cc index 7650a59e5..7dbdbc0b6 100644 --- a/elab_scope.cc +++ b/elab_scope.cc @@ -20,6 +20,7 @@ # include "config.h" # include "compiler.h" # include "netmisc.h" +# include # include # include diff --git a/elab_sig.cc b/elab_sig.cc index 2b1ecdc47..00f0ccb3a 100644 --- a/elab_sig.cc +++ b/elab_sig.cc @@ -19,6 +19,7 @@ # include "config.h" +# include # include # include "Module.h" diff --git a/elaborate.cc b/elaborate.cc index 3e41e17e3..204b49c16 100644 --- a/elaborate.cc +++ b/elaborate.cc @@ -30,6 +30,7 @@ */ # include +# include # include # include # include "pform.h" diff --git a/emit.cc b/emit.cc index 8f01dd97c..828ac47ac 100644 --- a/emit.cc +++ b/emit.cc @@ -29,6 +29,7 @@ # include "netlist.h" # include # include +# include bool NetNode::emit_node(struct target_t*tgt) const { diff --git a/eval.cc b/eval.cc index d2ef7355b..41cb60a5b 100644 --- a/eval.cc +++ b/eval.cc @@ -19,6 +19,7 @@ # include "config.h" +# include # include # include "PExpr.h" diff --git a/eval_tree.cc b/eval_tree.cc index 09017eb78..450de5e49 100644 --- a/eval_tree.cc +++ b/eval_tree.cc @@ -21,6 +21,7 @@ # include "compiler.h" # include +# include # include "netlist.h" # include "ivl_assert.h" diff --git a/ivlpp/Makefile.in b/ivlpp/Makefile.in index 03fb13ea8..37f565893 100644 --- a/ivlpp/Makefile.in +++ b/ivlpp/Makefile.in @@ -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 diff --git a/ivlpp/lexor.lex b/ivlpp/lexor.lex index 496067097..009d8d190 100644 --- a/ivlpp/lexor.lex +++ b/ivlpp/lexor.lex @@ -158,6 +158,8 @@ static int ma_parenthesis_level = 0; %} %option stack +%option nounput +%option noyy_top_state %x PPINCLUDE %x DEF_NAME diff --git a/ivlpp/parse.y b/ivlpp/parse.y index ff722eef7..38745078e 100644 --- a/ivlpp/parse.y +++ b/ivlpp/parse.y @@ -25,6 +25,8 @@ # include static void yyerror(const char*msg); +extern int yylex (void); + %} %% diff --git a/lexor.lex b/lexor.lex index 08a898e52..cfab39360 100644 --- a/lexor.lex +++ b/lexor.lex @@ -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]; diff --git a/load_module.cc b/load_module.cc index 3f282fc84..5dc55cce1 100644 --- a/load_module.cc +++ b/load_module.cc @@ -26,6 +26,8 @@ # include "compiler.h" # include # include +# include +# include # include # include # include diff --git a/main.cc b/main.cc index 7c22ca472..dc2ebb191 100644 --- a/main.cc +++ b/main.cc @@ -44,6 +44,7 @@ const char NOTICE[] = # include # include # include +# include # include # include # include diff --git a/net_link.cc b/net_link.cc index a6275a68f..e7aa09790 100644 --- a/net_link.cc +++ b/net_link.cc @@ -26,6 +26,7 @@ # include "netlist.h" # include +# include # include # include #ifdef HAVE_MALLOC_H diff --git a/net_scope.cc b/net_scope.cc index 75f16e457..82ce8a2a3 100644 --- a/net_scope.cc +++ b/net_scope.cc @@ -24,6 +24,7 @@ # include "compiler.h" # include "netlist.h" +# include # include /* diff --git a/netlist.cc b/netlist.cc index d7a8d8fd8..00c1dae11 100644 --- a/netlist.cc +++ b/netlist.cc @@ -22,6 +22,7 @@ # include # include +# include # include "compiler.h" # include "netlist.h" # include "netmisc.h" diff --git a/netmisc.cc b/netmisc.cc index e4696eb20..87b6e3150 100644 --- a/netmisc.cc +++ b/netmisc.cc @@ -19,6 +19,7 @@ # include "config.h" +# include # include "netlist.h" # include "netmisc.h" # include "PExpr.h" diff --git a/parse.y b/parse.y index 658fdaa8e..b8babd7e5 100644 --- a/parse.y +++ b/parse.y @@ -26,6 +26,7 @@ # include "pform.h" # include "Statement.h" # include "PSpec.h" +# include # include class PSpecPath; diff --git a/pform.cc b/pform.cc index a2798a28d..bdff63f7c 100644 --- a/pform.cc +++ b/pform.cc @@ -33,6 +33,10 @@ # include # include # include +# include +# include + +# include "ivl_assert.h" map pform_modules; map 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); } diff --git a/sys_funcs.cc b/sys_funcs.cc index 0776abddb..498d31a54 100644 --- a/sys_funcs.cc +++ b/sys_funcs.cc @@ -23,6 +23,8 @@ # include "config.h" # include "compiler.h" # include +# include +# include /* * Manage the information about system functions. This information is diff --git a/t-dll-expr.cc b/t-dll-expr.cc index 16e90d91e..4c73e3c44 100644 --- a/t-dll-expr.cc +++ b/t-dll-expr.cc @@ -21,6 +21,7 @@ # include +# include # include "t-dll.h" # include "netlist.h" # include diff --git a/t-dll-proc.cc b/t-dll-proc.cc index b3c998768..5d843e9d4 100644 --- a/t-dll-proc.cc +++ b/t-dll-proc.cc @@ -25,6 +25,7 @@ # include +# include # include "target.h" # include "ivl_target.h" # include "compiler.h" diff --git a/t-dll.cc b/t-dll.cc index 36cebfe01..3c8329c14 100644 --- a/t-dll.cc +++ b/t-dll.cc @@ -21,6 +21,7 @@ # include +# include # include // sprintf() # include "compiler.h" # include "t-dll.h" diff --git a/tgt-vvp/eval_expr.c b/tgt-vvp/eval_expr.c index 3dd12947f..eae28e858 100644 --- a/tgt-vvp/eval_expr.c +++ b/tgt-vvp/eval_expr.c @@ -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': diff --git a/tgt-vvp/vvp_scope.c b/tgt-vvp/vvp_scope.c index 42d7b7e42..ae6cf3ed6 100644 --- a/tgt-vvp/vvp_scope.c +++ b/tgt-vvp/vvp_scope.c @@ -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); diff --git a/verireal.cc b/verireal.cc index fd0292ea6..b07c013a0 100644 --- a/verireal.cc +++ b/verireal.cc @@ -29,6 +29,7 @@ # include # include # include +# include verireal::verireal() { diff --git a/vpi/lxt2_write.c b/vpi/lxt2_write.c index 94dff12b2..55c9d499c 100644 --- a/vpi/lxt2_write.c +++ b/vpi/lxt2_write.c @@ -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 #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 (loname, a[j]->name) <= 0) + { + a[k++]=b[i++]; + } + else + { + a[k++]=a[j++]; + } + } + + while (kposition 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;inumfacs;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;inumfacs;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;inumfacs;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<timepos)) == LXT2_WR_GRAN_0VAL) + if(!(s->flags&LXT2_WR_SYM_F_ALIAS)) { - s->msk |= (LXT2_WR_GRAN_1VAL<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<timepos)) == LXT2_WR_GRAN_0VAL) + { + s->msk |= (LXT2_WR_GRAN_1VAL<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;ilen;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;ilen;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); diff --git a/vpi/lxt2_write.h b/vpi/lxt2_write.h index bd33729fe..98c2fae04 100644 --- a/vpi/lxt2_write.h +++ b/vpi/lxt2_write.h @@ -37,6 +37,7 @@ #define ftello ftell #endif +#define wave_alloca alloca #define LXT2_WR_HDRID (0x1380) #define LXT2_WR_VERSION (0x0001) diff --git a/vpi/lxt_write.c b/vpi/lxt_write.c index 0ae0c49ef..77988f121 100644 --- a/vpi/lxt_write.c +++ b/vpi/lxt_write.c @@ -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 #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 (loname, a[j]->name) <= 0) + { + a[k++]=b[i++]; + } + else + { + a[k++]=a[j++]; + } + } + + while (kposition 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;inumfacs;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;inumfacs;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;inumfacs;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;inumfacs;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;inum_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;inumfacs;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;inumfacs;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;inumfacs;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)<_SYM_F_DOUBLE) { numbytes = 0; } - + start_position = lt->position; s->last_change = start_position; @@ -2078,7 +2115,7 @@ if((s->flags)<_SYM_F_DOUBLE) } rc=lt->lt_emit_double(lt, value); - + if(lt->timebuff) { lt->timechangecount++; @@ -2120,7 +2157,7 @@ if((s->flags)<_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)<_SYM_F_STRING) { numbytes = 0; } - + start_position = lt->position; s->last_change = start_position; @@ -2196,7 +2233,7 @@ if((s->flags)<_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)<_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<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;iflags&(LT_SYM_F_DOUBLE|LT_SYM_F_STRING))) outval |= (thisval<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;iflags&(LT_SYM_F_DOUBLE|LT_SYM_F_STRING))) outval |= (thisval<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++; diff --git a/vpi/sdf_lexor.lex b/vpi/sdf_lexor.lex index f373534f1..cebe3c5c2 100644 --- a/vpi/sdf_lexor.lex +++ b/vpi/sdf_lexor.lex @@ -1,5 +1,6 @@ %option never-interactive +%option nounput %{ /* diff --git a/vpi/sys_readmem_lex.lex b/vpi/sys_readmem_lex.lex index c9a4c18b7..ea34671b0 100644 --- a/vpi/sys_readmem_lex.lex +++ b/vpi/sys_readmem_lex.lex @@ -1,4 +1,6 @@ +%option nounput + %{ /* * Copyright (c) 1999 Stephen Williams (steve@icarus.com) diff --git a/vvp/arith.cc b/vvp/arith.cc index fc3e70706..8c7b74b37 100644 --- a/vvp/arith.cc +++ b/vvp/arith.cc @@ -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() { } diff --git a/vvp/arith.h b/vvp/arith.h index 293cb1ae6..ad16d7b10 100644 --- a/vvp/arith.h +++ b/vvp/arith.h @@ -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 diff --git a/vvp/array.cc b/vvp/array.cc index b984b238a..09b689ded 100644 --- a/vvp/array.cc +++ b/vvp/array.cc @@ -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); diff --git a/vvp/compile.cc b/vvp/compile.cc index c6eb04fdb..d4bb4e6a9 100644 --- a/vvp/compile.cc +++ b/vvp/compile.cc @@ -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) { diff --git a/vvp/compile.h b/vvp/compile.h index 6c8ad9044..4991e33ba 100644 --- a/vvp/compile.h +++ b/vvp/compile.h @@ -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, diff --git a/vvp/delay.cc b/vvp/delay.cc index 151da558b..672d54918 100644 --- a/vvp/delay.cc +++ b/vvp/delay.cc @@ -21,6 +21,7 @@ #include "schedule.h" #include "vpi_priv.h" #include +#include #include 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); } diff --git a/vvp/lexor.lex b/vvp/lexor.lex index cf64f4f3b..8a6769f5e 100644 --- a/vvp/lexor.lex +++ b/vvp/lexor.lex @@ -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; } diff --git a/vvp/parse.y b/vvp/parse.y index 96da52ca8..72ddc1949 100644 --- a/vvp/parse.y +++ b/vvp/parse.y @@ -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); diff --git a/vvp/vpi_priv.cc b/vvp/vpi_priv.cc index a7494cdcf..966567f2f 100644 --- a/vvp/vpi_priv.cc +++ b/vvp/vpi_priv.cc @@ -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; diff --git a/vvp/vpi_vthr_vector.cc b/vvp/vpi_vthr_vector.cc index e8af1d9a2..cc5b87e5a 100644 --- a/vvp/vpi_vthr_vector.cc +++ b/vvp/vpi_vthr_vector.cc @@ -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; diff --git a/vvp/vthread.cc b/vvp/vthread.cc index 855381e96..74ffccdd7 100644 --- a/vvp/vthread.cc +++ b/vvp/vthread.cc @@ -30,6 +30,7 @@ #ifdef HAVE_MALLOC_H # include #endif +# include # include # include # include diff --git a/vvp/vvp_net.cc b/vvp/vvp_net.cc index 16622460c..0a512ee66 100644 --- a/vvp/vvp_net.cc +++ b/vvp/vvp_net.cc @@ -22,6 +22,8 @@ # include "schedule.h" # include "statistics.h" # include +# include +# include # include # include # include