Catch parallel blocks in vvm emit.

This commit is contained in:
steve 1999-09-22 16:57:23 +00:00
parent 12b9071f49
commit 0955058fbe
8 changed files with 125 additions and 73 deletions

70
emit.cc
View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: emit.cc,v 1.22 1999/09/20 02:21:10 steve Exp $"
#ident "$Id: emit.cc,v 1.23 1999/09/22 16:57:23 steve Exp $"
#endif
/*
@ -75,59 +75,68 @@ void NetBUFZ::emit_node(ostream&o, struct target_t*tgt) const
tgt->bufz(o, this);
}
void NetProcTop::emit(ostream&o, struct target_t*tgt) const
bool NetProcTop::emit(ostream&o, struct target_t*tgt) const
{
tgt->process(o, this);
return tgt->process(o, this);
}
void NetProc::emit_proc(ostream&o, struct target_t*tgt) const
bool NetProc::emit_proc(ostream&o, struct target_t*tgt) const
{
cerr << "EMIT: Proc type? " << typeid(*this).name() << endl;
return false;
}
void NetAssign::emit_proc(ostream&o, struct target_t*tgt) const
bool NetAssign::emit_proc(ostream&o, struct target_t*tgt) const
{
tgt->proc_assign(o, this);
return true;
}
void NetAssignNB::emit_proc(ostream&o, struct target_t*tgt) const
bool NetAssignNB::emit_proc(ostream&o, struct target_t*tgt) const
{
tgt->proc_assign_nb(o, this);
return true;
}
void NetAssignMem::emit_proc(ostream&o, struct target_t*tgt) const
bool NetAssignMem::emit_proc(ostream&o, struct target_t*tgt) const
{
tgt->proc_assign_mem(o, this);
return true;
}
void NetAssignMemNB::emit_proc(ostream&o, struct target_t*tgt) const
bool NetAssignMemNB::emit_proc(ostream&o, struct target_t*tgt) const
{
tgt->proc_assign_mem_nb(o, this);
return true;
}
void NetBlock::emit_proc(ostream&o, struct target_t*tgt) const
bool NetBlock::emit_proc(ostream&o, struct target_t*tgt) const
{
tgt->proc_block(o, this);
return tgt->proc_block(o, this);
}
void NetCase::emit_proc(ostream&o, struct target_t*tgt) const
bool NetCase::emit_proc(ostream&o, struct target_t*tgt) const
{
tgt->proc_case(o, this);
return true;
}
void NetCondit::emit_proc(ostream&o, struct target_t*tgt) const
bool NetCondit::emit_proc(ostream&o, struct target_t*tgt) const
{
tgt->proc_condit(o, this);
return true;
}
void NetForever::emit_proc(ostream&o, struct target_t*tgt) const
bool NetForever::emit_proc(ostream&o, struct target_t*tgt) const
{
tgt->proc_forever(o, this);
return true;
}
void NetPDelay::emit_proc(ostream&o, struct target_t*tgt) const
bool NetPDelay::emit_proc(ostream&o, struct target_t*tgt) const
{
tgt->proc_delay(o, this);
return true;
}
void NetPDelay::emit_proc_recurse(ostream&o, struct target_t*tgt) const
@ -135,9 +144,10 @@ void NetPDelay::emit_proc_recurse(ostream&o, struct target_t*tgt) const
if (statement_) statement_->emit_proc(o, tgt);
}
void NetPEvent::emit_proc(ostream&o, struct target_t*tgt) const
bool NetPEvent::emit_proc(ostream&o, struct target_t*tgt) const
{
tgt->proc_event(o, this);
return true;
}
void NetPEvent::emit_proc_recurse(ostream&o, struct target_t*tgt) const
@ -145,24 +155,28 @@ void NetPEvent::emit_proc_recurse(ostream&o, struct target_t*tgt) const
if (statement_) statement_->emit_proc(o, tgt);
}
void NetRepeat::emit_proc(ostream&o, struct target_t*tgt) const
bool NetRepeat::emit_proc(ostream&o, struct target_t*tgt) const
{
tgt->proc_repeat(o, this);
return true;
}
void NetSTask::emit_proc(ostream&o, struct target_t*tgt) const
bool NetSTask::emit_proc(ostream&o, struct target_t*tgt) const
{
tgt->proc_stask(o, this);
return true;
}
void NetUTask::emit_proc(ostream&o, struct target_t*tgt) const
bool NetUTask::emit_proc(ostream&o, struct target_t*tgt) const
{
tgt->proc_utask(o, this);
return true;
}
void NetWhile::emit_proc(ostream&o, struct target_t*tgt) const
bool NetWhile::emit_proc(ostream&o, struct target_t*tgt) const
{
tgt->proc_while(o, this);
return true;
}
void NetBlock::emit_recurse(ostream&o, struct target_t*tgt) const
@ -206,8 +220,9 @@ void NetWhile::emit_proc_recurse(ostream&o, struct target_t*tgt) const
proc_->emit_proc(o, tgt);
}
void Design::emit(ostream&o, struct target_t*tgt) const
bool Design::emit(ostream&o, struct target_t*tgt) const
{
bool rc = true;
tgt->start_design(o, this);
// emit signals
@ -257,9 +272,10 @@ void Design::emit(ostream&o, struct target_t*tgt) const
// emit the processes
for (const NetProcTop*idx = procs_ ; idx ; idx = idx->next_)
idx->emit(o, tgt);
rc = rc && idx->emit(o, tgt);
tgt->end_design(o, this);
return rc;
}
void NetEBinary::expr_scan(struct expr_scan_t*tgt) const
@ -323,20 +339,22 @@ void NetEUnary::expr_scan(struct expr_scan_t*tgt) const
tgt->expr_unary(this);
}
void emit(ostream&o, const Design*des, const char*type)
bool emit(ostream&o, const Design*des, const char*type)
{
for (unsigned idx = 0 ; target_table[idx] ; idx += 1) {
const struct target*tgt = target_table[idx];
if (tgt->name == type) {
des->emit(o, tgt->meth);
return;
}
if (tgt->name == type)
return des->emit(o, tgt->meth);
}
}
/*
* $Log: emit.cc,v $
* Revision 1.23 1999/09/22 16:57:23 steve
* Catch parallel blocks in vvm emit.
*
* Revision 1.22 1999/09/20 02:21:10 steve
* Elaborate parameters in phases.
*

16
main.cc
View File

@ -19,7 +19,7 @@ const char COPYRIGHT[] =
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: main.cc,v 1.22 1999/08/03 04:14:49 steve Exp $"
#ident "$Id: main.cc,v 1.23 1999/09/22 16:57:23 steve Exp $"
#endif
const char NOTICE[] =
@ -75,7 +75,6 @@ static void parm_to_flagmap(const string&flag)
extern Design* elaborate(const map<string,Module*>&modules,
const map<string,PUdp*>&primitives,
const string&root);
extern void emit(ostream&o, const Design*, const char*);
extern void cprop(Design*des);
extern void propinit(Design*des);
@ -252,6 +251,7 @@ int main(int argc, char*argv[])
}
bool emit_rc;
if (out_path) {
ofstream out;
out.open(out_path);
@ -261,10 +261,15 @@ int main(int argc, char*argv[])
return 1;
}
emit(out, des, target);
emit_rc = emit(out, des, target);
} else {
emit(cout, des, target);
emit_rc = emit(cout, des, target);
}
if (!emit_rc) {
cerr << "internal error: Code generation had errors." << endl;
return 1;
}
return 0;
@ -272,6 +277,9 @@ int main(int argc, char*argv[])
/*
* $Log: main.cc,v $
* Revision 1.23 1999/09/22 16:57:23 steve
* Catch parallel blocks in vvm emit.
*
* Revision 1.22 1999/08/03 04:14:49 steve
* Parse into pform arbitrarily complex module
* port declarations.

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: netlist.h,v 1.68 1999/09/21 00:13:40 steve Exp $"
#ident "$Id: netlist.h,v 1.69 1999/09/22 16:57:23 steve Exp $"
#endif
/*
@ -589,7 +589,10 @@ class NetProc {
explicit NetProc() : next_(0) { }
virtual ~NetProc();
virtual void emit_proc(ostream&, struct target_t*) const;
// This method is called to emit the statement to the
// target. The target returns true if OK, false for errors.
virtual bool emit_proc(ostream&, struct target_t*) const;
virtual void dump(ostream&, unsigned ind) const;
private:
@ -628,7 +631,7 @@ class NetAssign : public NetAssign_ {
void find_lval_range(const NetNet*&net, unsigned&msb,
unsigned&lsb) const;
virtual void emit_proc(ostream&, struct target_t*) const;
virtual bool emit_proc(ostream&, struct target_t*) const;
virtual void emit_node(ostream&, struct target_t*) const;
virtual void dump(ostream&, unsigned ind) const;
virtual void dump_node(ostream&, unsigned ind) const;
@ -656,7 +659,7 @@ class NetAssignNB : public NetAssign_ {
// the pin that gets the value.
const NetExpr*bmux() const { return bmux_; }
virtual void emit_proc(ostream&, struct target_t*) const;
virtual bool emit_proc(ostream&, struct target_t*) const;
virtual void emit_node(ostream&, struct target_t*) const;
virtual void dump(ostream&, unsigned ind) const;
virtual void dump_node(ostream&, unsigned ind) const;
@ -694,7 +697,7 @@ class NetAssignMem : public NetAssignMem_ {
explicit NetAssignMem(NetMemory*, NetExpr*idx, NetExpr*rv);
~NetAssignMem();
virtual void emit_proc(ostream&, struct target_t*) const;
virtual bool emit_proc(ostream&, struct target_t*) const;
virtual void dump(ostream&, unsigned ind) const;
private:
@ -706,7 +709,7 @@ class NetAssignMemNB : public NetAssignMem_ {
explicit NetAssignMemNB(NetMemory*, NetExpr*idx, NetExpr*rv);
~NetAssignMemNB();
virtual void emit_proc(ostream&, struct target_t*) const;
virtual bool emit_proc(ostream&, struct target_t*) const;
virtual void dump(ostream&, unsigned ind) const;
private:
@ -731,7 +734,7 @@ class NetBlock : public NetProc {
void append(NetProc*);
void emit_recurse(ostream&, struct target_t*) const;
virtual void emit_proc(ostream&, struct target_t*) const;
virtual bool emit_proc(ostream&, struct target_t*) const;
virtual void dump(ostream&, unsigned ind) const;
private:
@ -758,7 +761,7 @@ class NetCase : public NetProc {
const NetExpr*expr(unsigned idx) const { return items_[idx].guard;}
const NetProc*stat(unsigned idx) const { return items_[idx].statement; }
virtual void emit_proc(ostream&, struct target_t*) const;
virtual bool emit_proc(ostream&, struct target_t*) const;
virtual void dump(ostream&, unsigned ind) const;
private:
@ -791,7 +794,7 @@ class NetCondit : public NetProc {
void emit_recurse_if(ostream&, struct target_t*) const;
void emit_recurse_else(ostream&, struct target_t*) const;
virtual void emit_proc(ostream&, struct target_t*) const;
virtual bool emit_proc(ostream&, struct target_t*) const;
virtual void dump(ostream&, unsigned ind) const;
private:
@ -812,7 +815,7 @@ class NetForever : public NetProc {
void emit_recurse(ostream&, struct target_t*) const;
virtual void emit_proc(ostream&, struct target_t*) const;
virtual bool emit_proc(ostream&, struct target_t*) const;
virtual void dump(ostream&, unsigned ind) const;
private:
@ -855,7 +858,7 @@ class NetPDelay : public NetProc {
unsigned long delay() const { return delay_; }
virtual void emit_proc(ostream&, struct target_t*) const;
virtual bool emit_proc(ostream&, struct target_t*) const;
virtual void dump(ostream&, unsigned ind) const;
void emit_proc_recurse(ostream&, struct target_t*) const;
@ -885,7 +888,7 @@ class NetPEvent : public NetProc, public sref_back<NetPEvent,NetNEvent> {
NetProc* statement();
const NetProc* statement() const;
virtual void emit_proc(ostream&, struct target_t*) const;
virtual bool emit_proc(ostream&, struct target_t*) const;
virtual void dump(ostream&, unsigned ind) const;
void emit_proc_recurse(ostream&, struct target_t*) const;
@ -935,7 +938,7 @@ class NetRepeat : public NetProc {
const NetExpr*expr() const;
void emit_recurse(ostream&, struct target_t*) const;
virtual void emit_proc(ostream&, struct target_t*) const;
virtual bool emit_proc(ostream&, struct target_t*) const;
virtual void dump(ostream&, unsigned ind) const;
private:
@ -961,7 +964,7 @@ class NetSTask : public NetProc {
const NetExpr* parm(unsigned idx) const;
virtual void emit_proc(ostream&, struct target_t*) const;
virtual bool emit_proc(ostream&, struct target_t*) const;
virtual void dump(ostream&, unsigned ind) const;
private:
@ -1050,7 +1053,7 @@ class NetUTask : public NetProc {
const string& name() const { return task_->name(); }
virtual void emit_proc(ostream&, struct target_t*) const;
virtual bool emit_proc(ostream&, struct target_t*) const;
virtual void dump(ostream&, unsigned ind) const;
private:
@ -1072,7 +1075,7 @@ class NetWhile : public NetProc {
void emit_proc_recurse(ostream&, struct target_t*) const;
virtual void emit_proc(ostream&, struct target_t*) const;
virtual bool emit_proc(ostream&, struct target_t*) const;
virtual void dump(ostream&, unsigned ind) const;
private:
@ -1081,9 +1084,11 @@ class NetWhile : public NetProc {
};
/* The is the top of any process. It carries the type (initial or
always) and a pointer to the statement, probably a block, that
makes up the process. */
/*
* The is the top of any process. It carries the type (initial or
* always) and a pointer to the statement, probably a block, that
* makes up the process.
*/
class NetProcTop : public LineInfo {
public:
@ -1097,7 +1102,7 @@ class NetProcTop : public LineInfo {
const NetProc*statement() const;
void dump(ostream&, unsigned ind) const;
void emit(ostream&, struct target_t*tgt) const;
bool emit(ostream&, struct target_t*tgt) const;
private:
const Type type_;
@ -1524,7 +1529,7 @@ class Design {
// Iterate over the design...
void dump(ostream&) const;
void functor(struct functor_t*);
void emit(ostream&, struct target_t*) const;
bool emit(ostream&, struct target_t*) const;
void clear_node_marks();
NetNode*find_node(bool (*test)(const NetNode*));
@ -1613,6 +1618,9 @@ extern ostream& operator << (ostream&, NetNet::Type);
/*
* $Log: netlist.h,v $
* Revision 1.69 1999/09/22 16:57:23 steve
* Catch parallel blocks in vvm emit.
*
* Revision 1.68 1999/09/21 00:13:40 steve
* Support parameters that reference other paramters.
*

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: t-null.cc,v 1.5 1999/09/17 02:06:26 steve Exp $"
#ident "$Id: t-null.cc,v 1.6 1999/09/22 16:57:24 steve Exp $"
#endif
# include "netlist.h"
@ -35,7 +35,7 @@ static class target_null_t : public target_t {
void task_def(ostream&, const NetTaskDef*) { }
void net_esignal(ostream&, const NetESignal*) { }
void net_event(ostream&, const NetNEvent*) { }
void proc_block(ostream&, const NetBlock*) { }
bool proc_block(ostream&, const NetBlock*) { return true; }
void proc_condit(ostream&, const NetCondit*) { }
void proc_delay(ostream&, const NetPDelay*) { }
void proc_event(ostream&, const NetPEvent*) { }
@ -48,6 +48,9 @@ static class target_null_t : public target_t {
extern const struct target tgt_null = { "null", &target_null_obj };
/*
* $Log: t-null.cc,v $
* Revision 1.6 1999/09/22 16:57:24 steve
* Catch parallel blocks in vvm emit.
*
* Revision 1.5 1999/09/17 02:06:26 steve
* Handle unconnected module ports.
*

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: t-verilog.cc,v 1.7 1999/08/01 16:34:50 steve Exp $"
#ident "$Id: t-verilog.cc,v 1.8 1999/09/22 16:57:24 steve Exp $"
#endif
/*
@ -43,7 +43,7 @@ class target_verilog : public target_t {
virtual void logic(ostream&os, const NetLogic*);
virtual void bufz(ostream&os, const NetBUFZ*);
virtual void start_process(ostream&os, const NetProcTop*);
virtual void proc_block(ostream&os, const NetBlock*);
virtual bool proc_block(ostream&os, const NetBlock*);
virtual void proc_delay(ostream&os, const NetPDelay*);
virtual void proc_event(ostream&os, const NetPEvent*);
virtual void proc_stask(ostream&os, const NetSTask*);
@ -173,13 +173,14 @@ void target_verilog::emit_expr_(ostream&os, const NetExpr*expr)
}
}
void target_verilog::proc_block(ostream&os, const NetBlock*net)
bool target_verilog::proc_block(ostream&os, const NetBlock*net)
{
os << setw(indent_) << "" << "begin" << endl;
indent_ += 4;
net->emit_recurse(os, this);
indent_ -= 4;
os << setw(indent_) << "" << "end" << endl;
return true;
}
void target_verilog::proc_delay(ostream&os, const NetPDelay*net)
@ -271,6 +272,9 @@ const struct target tgt_verilog = {
/*
* $Log: t-verilog.cc,v $
* Revision 1.8 1999/09/22 16:57:24 steve
* Catch parallel blocks in vvm emit.
*
* Revision 1.7 1999/08/01 16:34:50 steve
* Parse and elaborate rise/fall/decay times
* for gates, and handle the rules for partial

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: t-vvm.cc,v 1.43 1999/09/22 04:30:04 steve Exp $"
#ident "$Id: t-vvm.cc,v 1.44 1999/09/22 16:57:24 steve Exp $"
#endif
# include <iostream>
@ -54,11 +54,11 @@ class target_vvm : public target_t {
virtual void net_const(ostream&os, const NetConst*);
virtual void net_esignal(ostream&os, const NetESignal*);
virtual void net_event(ostream&os, const NetNEvent*);
virtual void process(ostream&os, const NetProcTop*);
virtual bool process(ostream&os, const NetProcTop*);
virtual void proc_assign(ostream&os, const NetAssign*);
virtual void proc_assign_mem(ostream&os, const NetAssignMem*);
virtual void proc_assign_nb(ostream&os, const NetAssignNB*);
virtual void proc_block(ostream&os, const NetBlock*);
virtual bool proc_block(ostream&os, const NetBlock*);
virtual void proc_case(ostream&os, const NetCase*net);
virtual void proc_condit(ostream&os, const NetCondit*);
virtual void proc_forever(ostream&os, const NetForever*);
@ -508,11 +508,12 @@ void target_vvm::end_design(ostream&os, const Design*mod)
os << "}" << endl;
}
void target_vvm::process(ostream&os, const NetProcTop*top)
bool target_vvm::process(ostream&os, const NetProcTop*top)
{
start_process(os, top);
top->statement()->emit_proc(os, this);
bool rc = top->statement()->emit_proc(os, this);
end_process(os, top);
return rc;
}
void target_vvm::signal(ostream&os, const NetNet*sig)
@ -1075,14 +1076,14 @@ void target_vvm::proc_assign_nb(ostream&os, const NetAssignNB*net)
}
}
void target_vvm::proc_block(ostream&os, const NetBlock*net)
bool target_vvm::proc_block(ostream&os, const NetBlock*net)
{
if (net->type() == NetBlock::PARA) {
cerr << "internal error: vvm cannot emit parallel blocks."
<< endl;
return;
cerr << "sorry: vvm cannot emit parallel blocks." << endl;
return false;
}
net->emit_recurse(os, this);
return true;
}
/*
@ -1447,6 +1448,9 @@ extern const struct target tgt_vvm = {
};
/*
* $Log: t-vvm.cc,v $
* Revision 1.44 1999/09/22 16:57:24 steve
* Catch parallel blocks in vvm emit.
*
* Revision 1.43 1999/09/22 04:30:04 steve
* Parse and elaborate named for/join blocks.
*

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: target.cc,v 1.19 1999/09/15 01:55:06 steve Exp $"
#ident "$Id: target.cc,v 1.20 1999/09/22 16:57:24 steve Exp $"
#endif
# include "target.h"
@ -105,9 +105,9 @@ void target_t::net_event(ostream&os, const NetNEvent*net)
net->dump_node(cerr, 4);
}
void target_t::process(ostream&os, const NetProcTop*top)
bool target_t::process(ostream&os, const NetProcTop*top)
{
top->statement()->emit_proc(os, this);
return top->statement()->emit_proc(os, this);
}
void target_t::proc_assign(ostream&os, const NetAssign*)
@ -134,10 +134,11 @@ void target_t::proc_assign_mem_nb(ostream&os, const NetAssignMemNB*)
"Unhandled non-blocking memory assignment." << endl;
}
void target_t::proc_block(ostream&os, const NetBlock*)
bool target_t::proc_block(ostream&os, const NetBlock*)
{
cerr << "target (" << typeid(*this).name() << "): "
"Unhandled proc_block." << endl;
return false;
}
void target_t::proc_case(ostream&os, const NetCase*cur)
@ -268,6 +269,9 @@ void expr_scan_t::expr_binary(const NetEBinary*ex)
/*
* $Log: target.cc,v $
* Revision 1.20 1999/09/22 16:57:24 steve
* Catch parallel blocks in vvm emit.
*
* Revision 1.19 1999/09/15 01:55:06 steve
* Elaborate non-blocking assignment to memories.
*

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: target.h,v 1.18 1999/09/15 01:55:06 steve Exp $"
#ident "$Id: target.h,v 1.19 1999/09/22 16:57:24 steve Exp $"
#endif
# include "netlist.h"
@ -80,14 +80,14 @@ struct target_t {
/* Output a process (called for each process). It is up to the
target to recurse if desired. */
virtual void process(ostream&os, const NetProcTop*);
virtual bool process(ostream&os, const NetProcTop*);
/* Various kinds of process nodes are dispatched through these. */
virtual void proc_assign(ostream&os, const NetAssign*);
virtual void proc_assign_mem(ostream&os, const NetAssignMem*);
virtual void proc_assign_nb(ostream&os, const NetAssignNB*);
virtual void proc_assign_mem_nb(ostream&os, const NetAssignMemNB*);
virtual void proc_block(ostream&os, const NetBlock*);
virtual bool proc_block(ostream&os, const NetBlock*);
virtual void proc_case(ostream&os, const NetCase*);
virtual void proc_condit(ostream&os, const NetCondit*);
virtual void proc_forever(ostream&os, const NetForever*);
@ -123,7 +123,7 @@ struct expr_scan_t {
/* The emit functions take a design and emit it to the output stream
using the specified target. If the target is given by name, it is
located in the target_table and used. */
extern void emit(ostream&o, const Design*des, const char*type);
extern bool emit(ostream&o, const Design*des, const char*type);
/* This function takes a fully qualified verilog name (which may have,
for example, dots in it) and produces a mangled version that can be
@ -136,6 +136,9 @@ extern const struct target *target_table[];
/*
* $Log: target.h,v $
* Revision 1.19 1999/09/22 16:57:24 steve
* Catch parallel blocks in vvm emit.
*
* Revision 1.18 1999/09/15 01:55:06 steve
* Elaborate non-blocking assignment to memories.
*