Carry some line info to the netlist,

Dump line numbers for processes.
 Elaborate prints errors about port vector
 width mismatch
 Emit better handles null statements.
This commit is contained in:
steve 1999-02-01 00:26:48 +00:00
parent 8e73ccf8f8
commit a7ad8985ac
7 changed files with 127 additions and 31 deletions

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) #if !defined(WINNT)
#ident "$Id: LineInfo.h,v 1.1 1999/01/25 05:45:56 steve Exp $" #ident "$Id: LineInfo.h,v 1.2 1999/02/01 00:26:48 steve Exp $"
#endif #endif
# include <cstdio> # include <cstdio>
@ -34,6 +34,11 @@ class LineInfo {
return file_ + ":" + buf; return file_ + ":" + buf;
} }
void set_line(const LineInfo&that)
{ file_ = that.file_;
lineno_ = that.lineno_;
}
void set_file(const string&f) { file_ = f; } void set_file(const string&f) { file_ = f; }
void set_lineno(unsigned n) { lineno_ = n; } void set_lineno(unsigned n) { lineno_ = n; }
@ -44,6 +49,13 @@ class LineInfo {
/* /*
* $Log: LineInfo.h,v $ * $Log: LineInfo.h,v $
* Revision 1.2 1999/02/01 00:26:48 steve
* Carry some line info to the netlist,
* Dump line numbers for processes.
* Elaborate prints errors about port vector
* width mismatch
* Emit better handles null statements.
*
* Revision 1.1 1999/01/25 05:45:56 steve * Revision 1.1 1999/01/25 05:45:56 steve
* Add the LineInfo class to carry the source file * Add the LineInfo class to carry the source file
* location of things. PGate, Statement and PProcess. * location of things. PGate, Statement and PProcess.

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) #if !defined(WINNT)
#ident "$Id: design_dump.cc,v 1.9 1998/12/20 02:05:41 steve Exp $" #ident "$Id: design_dump.cc,v 1.10 1999/02/01 00:26:48 steve Exp $"
#endif #endif
/* /*
@ -260,10 +260,10 @@ void NetProcTop::dump(ostream&o, unsigned ind) const
{ {
switch (type_) { switch (type_) {
case NetProcTop::KINITIAL: case NetProcTop::KINITIAL:
o << "initial" << endl; o << "initial /* " << get_line() << " */" << endl;
break; break;
case NetProcTop::KALWAYS: case NetProcTop::KALWAYS:
o << "always" << endl; o << "always /* " << get_line() << " */" << endl;
break; break;
} }
@ -338,9 +338,13 @@ void NetPEvent::dump(ostream&o, unsigned ind) const
o << "wait (" << name() << ")"; o << "wait (" << name() << ")";
break; break;
} }
o << endl;
if (statement_) {
o << endl;
statement_->dump(o, ind+2); statement_->dump(o, ind+2);
} else {
o << " /* noop */;" << endl;
}
} }
@ -464,6 +468,13 @@ void Design::dump(ostream&o) const
/* /*
* $Log: design_dump.cc,v $ * $Log: design_dump.cc,v $
* Revision 1.10 1999/02/01 00:26:48 steve
* Carry some line info to the netlist,
* Dump line numbers for processes.
* Elaborate prints errors about port vector
* width mismatch
* Emit better handles null statements.
*
* Revision 1.9 1998/12/20 02:05:41 steve * Revision 1.9 1998/12/20 02:05:41 steve
* Function to calculate wire initial value. * Function to calculate wire initial value.
* *

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) #if !defined(WINNT)
#ident "$Id: elaborate.cc,v 1.11 1999/01/25 05:45:56 steve Exp $" #ident "$Id: elaborate.cc,v 1.12 1999/02/01 00:26:49 steve Exp $"
#endif #endif
/* /*
@ -226,6 +226,7 @@ void PGModule::elaborate_mod_(Design*des, Module*rmod, const string&path) const
"of parameters. Expecting " << rmod->ports.size() << "of parameters. Expecting " << rmod->ports.size() <<
", got " << pin_count() << "." ", got " << pin_count() << "."
<< endl; << endl;
des->errors += 1;
return; return;
} }
@ -246,6 +247,17 @@ void PGModule::elaborate_mod_(Design*des, Module*rmod, const string&path) const
rmod->ports[idx]->name); rmod->ports[idx]->name);
assert(prt); assert(prt);
// Check that the parts have matching pin counts. If
// not, they are different widths.
if (prt->pin_count() != sig->pin_count()) {
cerr << get_line() << ": Port " <<
rmod->ports[idx]->name << " of " << type_ <<
" expects " << prt->pin_count() << " pins, got " <<
sig->pin_count() << " from " << sig->name() << endl;
des->errors += 1;
continue;
}
assert(prt->pin_count() == sig->pin_count()); assert(prt->pin_count() == sig->pin_count());
switch (prt->port_type()) { switch (prt->port_type()) {
// INPUT and OUTPUT ports are directional. Handle // INPUT and OUTPUT ports are directional. Handle
@ -672,14 +684,21 @@ NetProc* PDelayStatement::elaborate(Design*des, const string&path) const
/* /*
* An event statement gets elaborated as a gate net that drives a * An event statement gets elaborated as a gate net that drives a
* special node, the NetPEvent. The NetPEvent is also a NetProc class * special node, the NetPEvent. The NetPEvent is also a NetProc class
* becuase execution flows through it. Thus, the NetPEvent connects * because execution flows through it. Thus, the NetPEvent connects
* the structural and the behavioral. * the structural and the behavioral.
*
* Note that it is possible for the statement_ pointer to be 0. This
* happens when the source has something like "@(E) ;". Note the null
* statement.
*/ */
NetProc* PEventStatement::elaborate(Design*des, const string&path) const NetProc* PEventStatement::elaborate(Design*des, const string&path) const
{ {
NetProc*enet = statement_->elaborate(des, path); NetProc*enet = 0;
if (statement_) {
enet = statement_->elaborate(des, path);
if (enet == 0) if (enet == 0)
return 0; return 0;
}
NetPEvent*ev = new NetPEvent(des->local_symbol(path), type_, enet); NetPEvent*ev = new NetPEvent(des->local_symbol(path), type_, enet);
@ -794,6 +813,7 @@ bool Module::elaborate(Design*des, const string&path) const
break; break;
} }
top->set_line(*(*st));
des->add_process(top); des->add_process(top);
} }
@ -831,6 +851,13 @@ Design* elaborate(const map<string,Module*>&modules,
/* /*
* $Log: elaborate.cc,v $ * $Log: elaborate.cc,v $
* Revision 1.12 1999/02/01 00:26:49 steve
* Carry some line info to the netlist,
* Dump line numbers for processes.
* Elaborate prints errors about port vector
* width mismatch
* Emit better handles null statements.
*
* Revision 1.11 1999/01/25 05:45:56 steve * Revision 1.11 1999/01/25 05:45:56 steve
* Add the LineInfo class to carry the source file * Add the LineInfo class to carry the source file
* location of things. PGate, Statement and PProcess. * location of things. PGate, Statement and PProcess.

14
emit.cc
View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) #if !defined(WINNT)
#ident "$Id: emit.cc,v 1.4 1998/12/01 00:42:14 steve Exp $" #ident "$Id: emit.cc,v 1.5 1999/02/01 00:26:49 steve Exp $"
#endif #endif
/* /*
@ -67,6 +67,7 @@ void NetBUFZ::emit_node(ostream&o, struct target_t*tgt) const
void NetProcTop::emit(ostream&o, struct target_t*tgt) const void NetProcTop::emit(ostream&o, struct target_t*tgt) const
{ {
assert(statement_);
tgt->start_process(o, this); tgt->start_process(o, this);
statement_->emit_proc(o, tgt); statement_->emit_proc(o, tgt);
@ -101,7 +102,7 @@ void NetPDelay::emit_proc(ostream&o, struct target_t*tgt) const
void NetPDelay::emit_proc_recurse(ostream&o, struct target_t*tgt) const void NetPDelay::emit_proc_recurse(ostream&o, struct target_t*tgt) const
{ {
statement_->emit_proc(o, tgt); if (statement_) statement_->emit_proc(o, tgt);
} }
void NetPEvent::emit_proc(ostream&o, struct target_t*tgt) const void NetPEvent::emit_proc(ostream&o, struct target_t*tgt) const
@ -111,7 +112,7 @@ void NetPEvent::emit_proc(ostream&o, struct target_t*tgt) const
void NetPEvent::emit_proc_recurse(ostream&o, struct target_t*tgt) const void NetPEvent::emit_proc_recurse(ostream&o, struct target_t*tgt) const
{ {
statement_->emit_proc(o, tgt); if (statement_) statement_->emit_proc(o, tgt);
} }
void NetTask::emit_proc(ostream&o, struct target_t*tgt) const void NetTask::emit_proc(ostream&o, struct target_t*tgt) const
@ -223,6 +224,13 @@ void emit(ostream&o, const Design*des, const char*type)
/* /*
* $Log: emit.cc,v $ * $Log: emit.cc,v $
* Revision 1.5 1999/02/01 00:26:49 steve
* Carry some line info to the netlist,
* Dump line numbers for processes.
* Elaborate prints errors about port vector
* width mismatch
* Emit better handles null statements.
*
* Revision 1.4 1998/12/01 00:42:14 steve * Revision 1.4 1998/12/01 00:42:14 steve
* Elaborate UDP devices, * Elaborate UDP devices,
* Support UDP type attributes, and * Support UDP type attributes, and

13
main.cc
View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) #if !defined(WINNT)
#ident "$Id: main.cc,v 1.12 1999/01/24 01:35:36 steve Exp $" #ident "$Id: main.cc,v 1.13 1999/02/01 00:26:49 steve Exp $"
#endif #endif
# include <stdio.h> # include <stdio.h>
@ -188,6 +188,10 @@ int main(int argc, char*argv[])
cerr << "Unable to elaborate design." << endl; cerr << "Unable to elaborate design." << endl;
return 1; return 1;
} }
if (des->errors) {
cerr << des->errors << " error(s) elaborating design." << endl;
return des->errors;
}
des->set_flags(flags); des->set_flags(flags);
@ -224,6 +228,13 @@ int main(int argc, char*argv[])
/* /*
* $Log: main.cc,v $ * $Log: main.cc,v $
* Revision 1.13 1999/02/01 00:26:49 steve
* Carry some line info to the netlist,
* Dump line numbers for processes.
* Elaborate prints errors about port vector
* width mismatch
* Emit better handles null statements.
*
* Revision 1.12 1999/01/24 01:35:36 steve * Revision 1.12 1999/01/24 01:35:36 steve
* Support null target for generating no output. * Support null target for generating no output.
* *

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) #if !defined(WINNT)
#ident "$Id: netlist.h,v 1.15 1998/12/20 02:05:41 steve Exp $" #ident "$Id: netlist.h,v 1.16 1999/02/01 00:26:49 steve Exp $"
#endif #endif
/* /*
@ -31,6 +31,7 @@
# include <string> # include <string>
# include <map> # include <map>
# include "verinum.h" # include "verinum.h"
# include "LineInfo.h"
class NetNode; class NetNode;
class NetProc; class NetProc;
@ -662,7 +663,7 @@ class NetWhile : public NetProc {
/* The is the top of any process. It carries the type (initial or /* The is the top of any process. It carries the type (initial or
always) and a pointer to the statement, probably a block, that always) and a pointer to the statement, probably a block, that
makes up the process. */ makes up the process. */
class NetProcTop { class NetProcTop : public LineInfo {
public: public:
enum Type { KINITIAL, KALWAYS }; enum Type { KINITIAL, KALWAYS };
@ -819,7 +820,7 @@ class NetESignal : public NetExpr {
class Design { class Design {
public: public:
Design() : signals_(0), nodes_(0), procs_(0), lcounter_(0) { } Design() : errors(0), signals_(0), nodes_(0), procs_(0), lcounter_(0) { }
/* The flags are a generic way of accepting command line /* The flags are a generic way of accepting command line
parameters/flags and passing them to the processing steps parameters/flags and passing them to the processing steps
@ -856,6 +857,9 @@ class Design {
void clear_signal_marks(); void clear_signal_marks();
NetNet*find_signal(bool (*test)(const NetNet*)); NetNet*find_signal(bool (*test)(const NetNet*));
// This is incremented by elaboration when an error is
// detected. It prevents code being emitted.
unsigned errors;
public: public:
string local_symbol(const string&path); string local_symbol(const string&path);
@ -921,6 +925,13 @@ extern ostream& operator << (ostream&, NetNet::Type);
/* /*
* $Log: netlist.h,v $ * $Log: netlist.h,v $
* Revision 1.16 1999/02/01 00:26:49 steve
* Carry some line info to the netlist,
* Dump line numbers for processes.
* Elaborate prints errors about port vector
* width mismatch
* Emit better handles null statements.
*
* Revision 1.15 1998/12/20 02:05:41 steve * Revision 1.15 1998/12/20 02:05:41 steve
* Function to calculate wire initial value. * Function to calculate wire initial value.
* *

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) #if !defined(WINNT)
#ident "$Id: pform_dump.cc,v 1.7 1998/12/01 00:42:14 steve Exp $" #ident "$Id: pform_dump.cc,v 1.8 1999/02/01 00:26:49 steve Exp $"
#endif #endif
/* /*
@ -119,7 +119,7 @@ void PWire::dump(ostream&out) const
out << " [" << *msb << ":" << *lsb << "]"; out << " [" << *msb << ":" << *lsb << "]";
} }
out << name << ";" << endl; out << " " << name << ";" << endl;
for (map<string,string>::const_iterator idx = attributes.begin() for (map<string,string>::const_iterator idx = attributes.begin()
; idx != attributes.end() ; idx != attributes.end()
; idx ++) { ; idx ++) {
@ -182,13 +182,15 @@ void Statement::dump(ostream&out, unsigned ind) const
so just print the C++ typeid and let the user figure so just print the C++ typeid and let the user figure
it out. */ it out. */
out << setw(ind) << ""; out << setw(ind) << "";
out << "/* " << typeid(*this) .name() << " */ ;" << endl; out << "/* " << get_line() << ": " << typeid(*this).name()
<< " */ ;" << endl;
} }
void PAssign::dump(ostream&out, unsigned ind) const void PAssign::dump(ostream&out, unsigned ind) const
{ {
out << setw(ind) << ""; out << setw(ind) << "";
out << to_name_ << " = " << *expr_ << ";" << endl; out << to_name_ << " = " << *expr_ << ";";
out << " /* " << get_line() << " */" << endl;
} }
void PBlock::dump(ostream&out, unsigned ind) const void PBlock::dump(ostream&out, unsigned ind) const
@ -254,9 +256,14 @@ void PEventStatement::dump(ostream&out, unsigned ind) const
out << "positive "; out << "positive ";
break; break;
} }
out << *expr_ << ")" << endl; out << *expr_ << ")";
if (statement_) {
out << endl;
statement_->dump(out, ind+2); statement_->dump(out, ind+2);
} else {
out << " ;" << endl;
}
} }
void PForStatement::dump(ostream&out, unsigned ind) const void PForStatement::dump(ostream&out, unsigned ind) const
@ -277,13 +284,15 @@ void PProcess::dump(ostream&out, unsigned ind) const
{ {
switch (type_) { switch (type_) {
case PProcess::PR_INITIAL: case PProcess::PR_INITIAL:
out << setw(ind) << "" << "initial" << endl; out << setw(ind) << "" << "initial";
break; break;
case PProcess::PR_ALWAYS: case PProcess::PR_ALWAYS:
out << setw(ind) << "" << "always" << endl; out << setw(ind) << "" << "always";
break; break;
} }
out << " /* " << get_line() << " */" << endl;
statement_->dump(out, ind+2); statement_->dump(out, ind+2);
} }
@ -364,6 +373,13 @@ void PUdp::dump(ostream&out) const
/* /*
* $Log: pform_dump.cc,v $ * $Log: pform_dump.cc,v $
* Revision 1.8 1999/02/01 00:26:49 steve
* Carry some line info to the netlist,
* Dump line numbers for processes.
* Elaborate prints errors about port vector
* width mismatch
* Emit better handles null statements.
*
* Revision 1.7 1998/12/01 00:42:14 steve * Revision 1.7 1998/12/01 00:42:14 steve
* Elaborate UDP devices, * Elaborate UDP devices,
* Support UDP type attributes, and * Support UDP type attributes, and