Support carrying the scope of named begin-end

blocks down to the code generator, and have
 the vvp code generator use that to support disable.
This commit is contained in:
steve 2002-05-27 00:08:45 +00:00
parent bfad382fd1
commit 422754f36f
10 changed files with 146 additions and 29 deletions

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: elaborate.cc,v 1.250 2002/05/26 01:39:02 steve Exp $"
#ident "$Id: elaborate.cc,v 1.251 2002/05/27 00:08:45 steve Exp $"
#endif
# include "config.h"
@ -1078,7 +1078,7 @@ NetProc* PAssign::elaborate(Design*des, NetScope*scope) const
}
/* And build up the complex statement. */
NetBlock*bl = new NetBlock(NetBlock::SEQU);
NetBlock*bl = new NetBlock(NetBlock::SEQU, 0);
bl->append(a1);
bl->append(st);
@ -1194,10 +1194,8 @@ NetProc* PBlock::elaborate(Design*des, NetScope*scope) const
NetBlock::Type type = (bl_type_==PBlock::BL_PAR)
? NetBlock::PARA
: NetBlock::SEQU;
NetBlock*cur = new NetBlock(type);
bool fail_flag = false;
NetScope*nscope;
NetScope*nscope = 0;
if (name_.length()) {
nscope = scope->child(name_);
if (nscope == 0) {
@ -1205,16 +1203,19 @@ NetProc* PBlock::elaborate(Design*des, NetScope*scope) const
"unable to find block scope " << scope->name()
<< "<" << name_ << ">" << endl;
des->errors += 1;
delete cur;
return 0;
}
assert(nscope);
} else {
nscope = scope;
}
NetBlock*cur = new NetBlock(type, nscope);
bool fail_flag = false;
if (nscope == 0)
nscope = scope;
// Handle the special case that the block contains only one
// statement. There is no need to keep the block node.
if (list_.count() == 1) {
@ -1370,7 +1371,7 @@ NetProc* PCondit::elaborate(Design*des, NetScope*scope) const
else if (else_)
return else_->elaborate(des, scope);
else
return new NetBlock(NetBlock::SEQU);
return new NetBlock(NetBlock::SEQU, 0);
}
// If the condition expression is more then 1 bits, then
@ -1503,7 +1504,7 @@ NetProc* PCallTask::elaborate_usr(Design*des, NetScope*scope) const
return cur;
}
NetBlock*block = new NetBlock(NetBlock::SEQU);
NetBlock*block = new NetBlock(NetBlock::SEQU, 0);
/* Detect the case where the definition of the task is known
@ -1899,7 +1900,7 @@ NetProc* PEventStatement::elaborate_st(Design*des, NetScope*scope,
block to join the wait and the statement. */
if (enet) {
NetBlock*bl = new NetBlock(NetBlock::SEQU);
NetBlock*bl = new NetBlock(NetBlock::SEQU, 0);
bl->set_line(*this);
bl->append(co);
bl->append(enet);
@ -2126,7 +2127,7 @@ NetProc* PForStatement::elaborate(Design*des, NetScope*scope) const
const PEIdent*id2 = dynamic_cast<const PEIdent*>(name2_);
assert(id2);
NetBlock*top = new NetBlock(NetBlock::SEQU);
NetBlock*top = new NetBlock(NetBlock::SEQU, 0);
/* make the expression, and later the initial assignment to
the condition variable. The statement in the for loop is
@ -2150,7 +2151,7 @@ NetProc* PForStatement::elaborate(Design*des, NetScope*scope) const
top->append(init);
NetBlock*body = new NetBlock(NetBlock::SEQU);
NetBlock*body = new NetBlock(NetBlock::SEQU, 0);
/* Elaborate the statement that is contained in the for
loop. If there is an error, this will return 0 and I should
@ -2280,7 +2281,7 @@ NetProc* PRepeat::elaborate(Design*des, NetScope*scope) const
case 0:
delete expr;
delete stat;
return new NetBlock(NetBlock::SEQU);
return new NetBlock(NetBlock::SEQU, 0);
case 1:
delete expr;
return stat;
@ -2331,7 +2332,7 @@ void PTask::elaborate(Design*des, NetScope*task) const
NetProc*st;
if (statement_ == 0) {
cerr << get_line() << ": warning: task has no statement." << endl;
st = new NetBlock(NetBlock::SEQU);
st = new NetBlock(NetBlock::SEQU, 0);
} else {
@ -2568,6 +2569,11 @@ Design* elaborate(list<const char*>roots)
/*
* $Log: elaborate.cc,v $
* Revision 1.251 2002/05/27 00:08:45 steve
* Support carrying the scope of named begin-end
* blocks down to the code generator, and have
* the vvp code generator use that to support disable.
*
* Revision 1.250 2002/05/26 01:39:02 steve
* Carry Verilog 2001 attributes with processes,
* all the way through to the ivl_target API.

View File

@ -140,6 +140,7 @@ ivl_process_type
ivl_statement_type
ivl_stmt_block_count
ivl_stmt_block_scope
ivl_stmt_block_stmt
ivl_stmt_call
ivl_stmt_case_count

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: ivl_target.h,v 1.97 2002/05/26 01:39:02 steve Exp $"
#ident "$Id: ivl_target.h,v 1.98 2002/05/27 00:08:45 steve Exp $"
#endif
#ifdef __cplusplus
@ -968,11 +968,18 @@ extern ivl_statement_type_t ivl_statement_type(ivl_statement_t net);
* make up the statement. Many of these functions apply to more then
* one type of statement, so the comment in front of them tells which
* statement types can be passed to the function.
*
* ivl_stmt_block_scope
* If the block is named, then there is a scope associated with
* this. The code generator may need to know this in order to
* handle disable statements.
*/
/* IVL_ST_BLOCK, IVL_ST_FORK */
extern unsigned ivl_stmt_block_count(ivl_statement_t net);
/* IVL_ST_BLOCK, IVL_ST_FORK */
extern ivl_scope_t ivl_stmt_block_scope(ivl_statement_t net);
/* IVL_ST_BLOCK, IVL_ST_FORK */
extern ivl_statement_t ivl_stmt_block_stmt(ivl_statement_t net, unsigned i);
/* IVL_ST_UTASK IVL_ST_DISABLE */
extern ivl_scope_t ivl_stmt_call(ivl_statement_t net);
@ -1043,6 +1050,11 @@ _END_DECL
/*
* $Log: ivl_target.h,v $
* Revision 1.98 2002/05/27 00:08:45 steve
* Support carrying the scope of named begin-end
* blocks down to the code generator, and have
* the vvp code generator use that to support disable.
*
* Revision 1.97 2002/05/26 01:39:02 steve
* Carry Verilog 2001 attributes with processes,
* all the way through to the ivl_target API.

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: netlist.cc,v 1.187 2002/05/26 01:39:02 steve Exp $"
#ident "$Id: netlist.cc,v 1.188 2002/05/27 00:08:45 steve Exp $"
#endif
# include "config.h"
@ -1484,6 +1484,11 @@ NetAssignMemNB::~NetAssignMemNB()
}
NetBlock::NetBlock(Type t, NetScope*ss)
: type_(t), subscope_(ss), last_(0)
{
}
NetBlock::~NetBlock()
{
}
@ -2352,6 +2357,11 @@ const NetProc*NetTaskDef::proc() const
/*
* $Log: netlist.cc,v $
* Revision 1.188 2002/05/27 00:08:45 steve
* Support carrying the scope of named begin-end
* blocks down to the code generator, and have
* the vvp code generator use that to support disable.
*
* Revision 1.187 2002/05/26 01:39:02 steve
* Carry Verilog 2001 attributes with processes,
* all the way through to the ivl_target API.

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: netlist.h,v 1.238 2002/05/26 01:39:02 steve Exp $"
#ident "$Id: netlist.h,v 1.239 2002/05/27 00:08:45 steve Exp $"
#endif
/*
@ -1385,10 +1385,11 @@ class NetBlock : public NetProc {
public:
enum Type { SEQU, PARA };
NetBlock(Type t) : type_(t), last_(0) { }
NetBlock(Type t, NetScope*subscope);
~NetBlock();
const Type type() const { return type_; }
Type type() const { return type_; }
NetScope* subscope() const { return subscope_; }
void append(NetProc*);
@ -1407,6 +1408,7 @@ class NetBlock : public NetProc {
private:
const Type type_;
NetScope*subscope_;
NetProc*last_;
};
@ -2973,6 +2975,11 @@ extern ostream& operator << (ostream&, NetNet::Type);
/*
* $Log: netlist.h,v $
* Revision 1.239 2002/05/27 00:08:45 steve
* Support carrying the scope of named begin-end
* blocks down to the code generator, and have
* the vvp code generator use that to support disable.
*
* Revision 1.238 2002/05/26 01:39:02 steve
* Carry Verilog 2001 attributes with processes,
* all the way through to the ivl_target API.

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: t-dll-api.cc,v 1.80 2002/05/26 01:39:03 steve Exp $"
#ident "$Id: t-dll-api.cc,v 1.81 2002/05/27 00:08:45 steve Exp $"
#endif
# include "config.h"
@ -1210,6 +1210,18 @@ extern "C" ivl_statement_type_t ivl_statement_type(ivl_statement_t net)
return net->type_;
}
extern "C" ivl_scope_t ivl_stmt_block_scope(ivl_statement_t net)
{
switch (net->type_) {
case IVL_ST_BLOCK:
case IVL_ST_FORK:
return net->u_.block_.scope;
default:
assert(0);
return 0;
}
}
extern "C" unsigned ivl_stmt_block_count(ivl_statement_t net)
{
switch (net->type_) {
@ -1531,6 +1543,11 @@ extern "C" ivl_statement_t ivl_stmt_sub_stmt(ivl_statement_t net)
/*
* $Log: t-dll-api.cc,v $
* Revision 1.81 2002/05/27 00:08:45 steve
* Support carrying the scope of named begin-end
* blocks down to the code generator, and have
* the vvp code generator use that to support disable.
*
* Revision 1.80 2002/05/26 01:39:03 steve
* Carry Verilog 2001 attributes with processes,
* all the way through to the ivl_target API.

View File

@ -18,7 +18,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: t-dll-proc.cc,v 1.43 2002/05/26 01:39:03 steve Exp $"
#ident "$Id: t-dll-proc.cc,v 1.44 2002/05/27 00:08:45 steve Exp $"
#endif
# include "config.h"
@ -326,6 +326,11 @@ bool dll_target::proc_block(const NetBlock*net)
stmt_cur_->u_.block_.stmt_ = (struct ivl_statement_s*)
calloc(count, sizeof(struct ivl_statement_s));
if (net->subscope())
stmt_cur_->u_.block_.scope = lookup_scope_(net->subscope());
else
stmt_cur_->u_.block_.scope = 0;
struct ivl_statement_s*save_cur_ = stmt_cur_;
unsigned idx = 0;
bool flag = true;
@ -808,6 +813,11 @@ void dll_target::proc_while(const NetWhile*net)
/*
* $Log: t-dll-proc.cc,v $
* Revision 1.44 2002/05/27 00:08:45 steve
* Support carrying the scope of named begin-end
* blocks down to the code generator, and have
* the vvp code generator use that to support disable.
*
* Revision 1.43 2002/05/26 01:39:03 steve
* Carry Verilog 2001 attributes with processes,
* all the way through to the ivl_target API.

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: t-dll.h,v 1.79 2002/05/26 01:39:03 steve Exp $"
#ident "$Id: t-dll.h,v 1.80 2002/05/27 00:08:45 steve Exp $"
#endif
# include "target.h"
@ -534,6 +534,7 @@ struct ivl_statement_s {
struct { /* IVL_ST_BLOCK, IVL_ST_FORK */
struct ivl_statement_s*stmt_;
unsigned nstmt_;
ivl_scope_t scope;
} block_;
struct { /* IVL_ST_CASE, IVL_ST_CASEX, IVL_ST_CASEZ */
@ -603,6 +604,11 @@ struct ivl_statement_s {
/*
* $Log: t-dll.h,v $
* Revision 1.80 2002/05/27 00:08:45 steve
* Support carrying the scope of named begin-end
* blocks down to the code generator, and have
* the vvp code generator use that to support disable.
*
* Revision 1.79 2002/05/26 01:39:03 steve
* Carry Verilog 2001 attributes with processes,
* all the way through to the ivl_target API.

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: stub.c,v 1.60 2002/05/26 01:39:03 steve Exp $"
#ident "$Id: stub.c,v 1.61 2002/05/27 00:08:45 steve Exp $"
#endif
# include "config.h"
@ -273,7 +273,13 @@ static void show_statement(ivl_statement_t net, unsigned ind)
case IVL_ST_BLOCK: {
unsigned cnt = ivl_stmt_block_count(net);
ivl_scope_t sscope = ivl_stmt_block_scope(net);
if (sscope)
fprintf(out, "%*sbegin : %s\n", ind, "",
ivl_scope_name(sscope));
else
fprintf(out, "%*sbegin\n", ind, "");
for (idx = 0 ; idx < cnt ; idx += 1) {
ivl_statement_t cur = ivl_stmt_block_stmt(net, idx);
show_statement(cur, ind+4);
@ -682,6 +688,11 @@ int target_design(ivl_design_t des)
/*
* $Log: stub.c,v $
* Revision 1.61 2002/05/27 00:08:45 steve
* Support carrying the scope of named begin-end
* blocks down to the code generator, and have
* the vvp code generator use that to support disable.
*
* Revision 1.60 2002/05/26 01:39:03 steve
* Carry Verilog 2001 attributes with processes,
* all the way through to the ivl_target API.

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: vvp_process.c,v 1.57 2002/04/22 02:41:30 steve Exp $"
#ident "$Id: vvp_process.c,v 1.58 2002/05/27 00:08:45 steve Exp $"
#endif
# include "vvp_priv.h"
@ -33,6 +33,8 @@ static int show_statement(ivl_statement_t net, ivl_scope_t sscope);
unsigned local_count = 0;
unsigned thread_count = 0;
static unsigned transient_id = 0;
/*
* This file includes the code needed to generate VVP code for
* processes. Scopes are already declared, we generate here the
@ -388,6 +390,34 @@ static int show_stmt_block(ivl_statement_t net, ivl_scope_t sscope)
return rc;
}
/*
* This draws an invocation of a named block. This is a little
* different because a subscope is created. We do that by creating
* a thread to deal with this.
*/
static int show_stmt_block_named(ivl_statement_t net, ivl_scope_t scope)
{
int rc;
int out_id, sub_id;
ivl_scope_t subscope = ivl_stmt_block_scope(net);
out_id = transient_id++;
sub_id = transient_id++;
fprintf(vvp_out, " %%fork t_%u, S_%s;\n",
sub_id, vvp_mangle_id(ivl_scope_name(subscope)));
fprintf(vvp_out, " %%jmp t_%u;\n", out_id);
fprintf(vvp_out, "t_%u ;\n", sub_id);
rc = show_stmt_block(net, subscope);
fprintf(vvp_out, " %%end;\n");
fprintf(vvp_out, "t_%u %%join;\n", out_id);
return rc;
}
static int show_stmt_case(ivl_statement_t net, ivl_scope_t sscope)
{
ivl_expr_t exp = ivl_stmt_cond_expr(net);
@ -661,10 +691,9 @@ static int show_stmt_fork(ivl_statement_t net, ivl_scope_t sscope)
{
unsigned idx;
int rc = 0;
static int transient_id = 0;
unsigned cnt = ivl_stmt_block_count(net);
int out = transient_id++;
unsigned out = transient_id++;
/* Draw a fork statement for all but one of the threads of the
fork/join. Send the threads off to a bit of code where they
@ -999,6 +1028,9 @@ static int show_statement(ivl_statement_t net, ivl_scope_t sscope)
break;
case IVL_ST_BLOCK:
if (ivl_stmt_block_scope(net))
rc += show_stmt_block_named(net, sscope);
else
rc += show_stmt_block(net, sscope);
break;
@ -1168,6 +1200,11 @@ int draw_func_definition(ivl_scope_t scope)
/*
* $Log: vvp_process.c,v $
* Revision 1.58 2002/05/27 00:08:45 steve
* Support carrying the scope of named begin-end
* blocks down to the code generator, and have
* the vvp code generator use that to support disable.
*
* Revision 1.57 2002/04/22 02:41:30 steve
* Reduce the while loop expression if needed.
*