Skip to content

Commit

Permalink
Infrastructure for elaborating analog statements.
Browse files Browse the repository at this point in the history
Put together the infrastructure for elaborating analog statements,
including create the NetAnalogTop objects that hold analog statements
and are in turn held by the design.

While doing this, clean up the various unique initial/always enumerations
to use the ivl_process_type_t type.
  • Loading branch information
steveicarus committed Oct 22, 2008
1 parent 365960d commit 5aa810d
Show file tree
Hide file tree
Showing 21 changed files with 219 additions and 115 deletions.
20 changes: 16 additions & 4 deletions AStatement.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -20,11 +20,15 @@
*/ */


# include <map> # include <map>
# include "ivl_target.h"
# include "StringHeap.h" # include "StringHeap.h"
# include "LineInfo.h" # include "LineInfo.h"
# include "PExpr.h" # include "PExpr.h"


class PExpr; class PExpr;
class NetAnalog;
class NetScope;
class Design;


class AStatement : public LineInfo { class AStatement : public LineInfo {


Expand All @@ -33,6 +37,11 @@ class AStatement : public LineInfo {
virtual ~AStatement() =0; virtual ~AStatement() =0;


virtual void dump(ostream&out, unsigned ind) const; virtual void dump(ostream&out, unsigned ind) const;
virtual NetAnalog* elaborate(Design*des, NetScope*scope) const;
virtual void elaborate_scope(Design*des, NetScope*scope) const;
virtual void elaborate_sig(Design*des, NetScope*scope) const;

map<perm_string,PExpr*> attributes;


private: // not implemented private: // not implemented
AStatement(const AStatement&); AStatement(const AStatement&);
Expand Down Expand Up @@ -65,20 +74,23 @@ class AContrib : public AStatement {
class AProcess : public LineInfo { class AProcess : public LineInfo {


public: public:
enum Type { PR_INITIAL, PR_ALWAYS }; AProcess(ivl_process_type_t t, AStatement*st)

AProcess(Type t, AStatement*st)
: type_(t), statement_(st) { } : type_(t), statement_(st) { }


~AProcess(); ~AProcess();


bool elaborate(Design*des, NetScope*scope) const;

ivl_process_type_t type() const { return type_; }
AStatement*statement() { return statement_; }

map<perm_string,PExpr*> attributes; map<perm_string,PExpr*> attributes;


// Dump the analog process // Dump the analog process
void dump(ostream&out, unsigned ind) const; void dump(ostream&out, unsigned ind) const;


private: private:
Type type_; ivl_process_type_t type_;
AStatement*statement_; AStatement*statement_;


private: // not implemented private: // not implemented
Expand Down
5 changes: 3 additions & 2 deletions Makefile.in
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -116,9 +116,10 @@ distclean: clean
TT = t-dll.o t-dll-api.o t-dll-expr.o t-dll-proc.o TT = t-dll.o t-dll-api.o t-dll-expr.o t-dll-proc.o
FF = cprop.o nodangle.o synth.o synth2.o syn-rules.o FF = cprop.o nodangle.o synth.o synth2.o syn-rules.o


O = main.o async.o design_dump.o discipline.o dup_expr.o elaborate.o elab_expr.o \ O = main.o async.o design_dump.o discipline.o dup_expr.o \
elaborate.o elab_expr.o elaborate_analog.o \
elab_lval.o elab_net.o elab_pexpr.o elab_scope.o \ elab_lval.o elab_net.o elab_pexpr.o elab_scope.o \
elab_sig.o emit.o eval.o eval_attrib.o \ elab_sig.o elab_sig_analog.o emit.o eval.o eval_attrib.o \
eval_tree.o expr_synth.o functor.o lexor.o lexor_keyword.o link_const.o \ eval_tree.o expr_synth.o functor.o lexor.o lexor_keyword.o link_const.o \
load_module.o netlist.o netmisc.o net_assign.o \ load_module.o netlist.o netmisc.o net_assign.o \
net_design.o net_event.o net_expr.o net_func.o \ net_design.o net_event.o net_expr.o net_func.o \
Expand Down
9 changes: 4 additions & 5 deletions Statement.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
*/ */


# include <string> # include <string>
# include "ivl_target.h"
# include "svector.h" # include "svector.h"
# include "StringHeap.h" # include "StringHeap.h"
# include "PDelays.h" # include "PDelays.h"
Expand All @@ -46,24 +47,22 @@ class NetScope;
class PProcess : public LineInfo { class PProcess : public LineInfo {


public: public:
enum Type { PR_INITIAL, PR_ALWAYS }; PProcess(ivl_process_type_t t, Statement*st)

PProcess(Type t, Statement*st)
: type_(t), statement_(st) { } : type_(t), statement_(st) { }


virtual ~PProcess(); virtual ~PProcess();


bool elaborate(Design*des, NetScope*scope) const; bool elaborate(Design*des, NetScope*scope) const;


Type type() const { return type_; } ivl_process_type_t type() const { return type_; }
Statement*statement() { return statement_; } Statement*statement() { return statement_; }


map<perm_string,PExpr*> attributes; map<perm_string,PExpr*> attributes;


virtual void dump(ostream&out, unsigned ind) const; virtual void dump(ostream&out, unsigned ind) const;


private: private:
Type type_; ivl_process_type_t type_;
Statement*statement_; Statement*statement_;
}; };


Expand Down
33 changes: 2 additions & 31 deletions async.cc
Original file line number Original file line Diff line number Diff line change
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2002 Stephen Williams (steve@icarus.com) * Copyright (c) 2002-2008 Stephen Williams (steve@icarus.com)
* *
* This source code is free software; you can redistribute it * This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU * and/or modify it in source code form under the terms of the GNU
Expand All @@ -16,9 +16,6 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#ifdef HAVE_CVS_IDENT
#ident "$Id: async.cc,v 1.7 2004/01/18 23:26:54 steve Exp $"
#endif


# include "config.h" # include "config.h"


Expand Down Expand Up @@ -87,34 +84,8 @@ bool NetProc::is_asynchronous()


bool NetProcTop::is_asynchronous() bool NetProcTop::is_asynchronous()
{ {
if (type_ == NetProcTop::KINITIAL) if (type_ == IVL_PR_INITIAL)
return false; return false;


return statement_->is_asynchronous(); return statement_->is_asynchronous();
} }

/*
* $Log: async.cc,v $
* Revision 1.7 2004/01/18 23:26:54 steve
* The is_combinational function really need not recurse.
*
* Revision 1.6 2003/12/20 00:33:39 steve
* More thorough check that NetEvWait is asynchronous.
*
* Revision 1.5 2003/09/04 20:28:05 steve
* Support time0 resolution of combinational threads.
*
* Revision 1.4 2002/08/18 22:07:16 steve
* Detect temporaries in sequential block synthesis.
*
* Revision 1.3 2002/08/12 01:34:58 steve
* conditional ident string using autoconfig.
*
* Revision 1.2 2002/07/04 00:24:16 steve
* initial statements are not asynchronous.
*
* Revision 1.1 2002/06/30 02:21:31 steve
* Add structure for asynchronous logic synthesis.
*
*/

4 changes: 2 additions & 2 deletions design_dump.cc
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -702,11 +702,11 @@ void NetUDP::dump_node(ostream&o, unsigned ind) const
void NetProcTop::dump(ostream&o, unsigned ind) const void NetProcTop::dump(ostream&o, unsigned ind) const
{ {
switch (type_) { switch (type_) {
case NetProcTop::KINITIAL: case IVL_PR_INITIAL:
o << "initial /* " << get_fileline() << " in " o << "initial /* " << get_fileline() << " in "
<< scope_path(scope_) << " */" << endl; << scope_path(scope_) << " */" << endl;
break; break;
case NetProcTop::KALWAYS: case IVL_PR_ALWAYS:
o << "always /* " << get_fileline() << " in " o << "always /* " << get_fileline() << " in "
<< scope_path(scope_) << " */" << endl; << scope_path(scope_) << " */" << endl;
break; break;
Expand Down
10 changes: 10 additions & 0 deletions elab_scope.cc
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
# include "PTask.h" # include "PTask.h"
# include "PWire.h" # include "PWire.h"
# include "Statement.h" # include "Statement.h"
# include "AStatement.h"
# include "netlist.h" # include "netlist.h"
# include "util.h" # include "util.h"
# include <typeinfo> # include <typeinfo>
Expand Down Expand Up @@ -1242,3 +1243,12 @@ void PWhile::elaborate_scope(Design*des, NetScope*scope) const
if (statement_) if (statement_)
statement_ -> elaborate_scope(des, scope); statement_ -> elaborate_scope(des, scope);
} }

/*
* The base statement does not have sub-statements and does not
* introduce any scope, so this is a no-op.
*/
void AStatement::elaborate_scope(Design*, NetScope*) const
{
}

30 changes: 30 additions & 0 deletions elab_sig_analog.cc
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright (c) 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
* General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/

# include "config.h"

# include "AStatement.h"

# include <cstdlib>
# include <iostream>

void AStatement::elaborate_sig(Design*des, NetScope*scope) const
{
}

20 changes: 9 additions & 11 deletions elaborate.cc
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -3502,15 +3502,7 @@ bool PProcess::elaborate(Design*des, NetScope*scope) const
return false; return false;
} }


NetProcTop*top=0; NetProcTop*top=new NetProcTop(scope, type(), cur);
switch (type()) {
case PProcess::PR_INITIAL:
top = new NetProcTop(scope, NetProcTop::KINITIAL, cur);
break;
case PProcess::PR_ALWAYS:
top = new NetProcTop(scope, NetProcTop::KALWAYS, cur);
break;
}
ivl_assert(*this, top); ivl_assert(*this, top);


// Evaluate the attributes for this process, if there // Evaluate the attributes for this process, if there
Expand All @@ -3535,7 +3527,7 @@ bool PProcess::elaborate(Design*des, NetScope*scope) const
gets into its wait statement before non-combinational gets into its wait statement before non-combinational
code is executed. */ code is executed. */
do { do {
if (top->type() != NetProcTop::KALWAYS) if (top->type() != IVL_PR_ALWAYS)
break; break;


NetEvWait*st = dynamic_cast<NetEvWait*>(top->statement()); NetEvWait*st = dynamic_cast<NetEvWait*>(top->statement());
Expand Down Expand Up @@ -3958,6 +3950,12 @@ bool PScope::elaborate_behaviors_(Design*des, NetScope*scope) const
result_flag &= (*st)->elaborate(des, scope); result_flag &= (*st)->elaborate(des, scope);
} }


for (list<AProcess*>::const_iterator st = analog_behaviors.begin()
; st != analog_behaviors.end() ; st ++ ) {

result_flag &= (*st)->elaborate(des, scope);
}

return result_flag; return result_flag;
} }


Expand Down Expand Up @@ -4045,7 +4043,7 @@ bool Design::check_always_delay() const
* a runtime infinite loop will happen. If we possible have some * a runtime infinite loop will happen. If we possible have some
* delay then print a warning that an infinite loop is possible. * delay then print a warning that an infinite loop is possible.
*/ */
if (pr->type() == NetProcTop::KALWAYS) { if (pr->type() == IVL_PR_ALWAYS) {
DelayType dly_type = pr->statement()->delay_type(); DelayType dly_type = pr->statement()->delay_type();


if (dly_type == NO_DELAY || dly_type == ZERO_DELAY) { if (dly_type == NO_DELAY || dly_type == ZERO_DELAY) {
Expand Down
60 changes: 60 additions & 0 deletions elaborate_analog.cc
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* Copyright (c) 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
* General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/

# include "config.h"

# include "AStatement.h"
# include "util.h"

# include <typeinfo>

NetAnalog* AStatement::elaborate(Design*des, NetScope*scope) const
{
cerr << get_fileline() << ": sorry: I don't yet know how to elaborate"
<< " his kind of analog statement." << endl;
cerr << get_fileline() << ": : typeid = " << typeid(*this).name() << endl;
return 0;
}

bool AProcess::elaborate(Design*des, NetScope*scope) const
{
NetAnalog*statement = statement_->elaborate(des, scope);
if (statement == 0)
return false;

NetAnalogTop*top = new NetAnalogTop(scope, type_, statement);

// Evaluate the attributes for this process, if there
// are any. These attributes are to be attached to the
// NetProcTop object.
struct attrib_list_t*attrib_list = 0;
unsigned attrib_list_n = 0;
attrib_list = evaluate_attributes(attributes, attrib_list_n, des, scope);

for (unsigned adx = 0 ; adx < attrib_list_n ; adx += 1)
top->attribute(attrib_list[adx].key,
attrib_list[adx].val);

delete[]attrib_list;

top->set_line(*this);
des->add_process(top);

return true;
}
7 changes: 6 additions & 1 deletion net_design.cc
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
# include "ivl_assert.h" # include "ivl_assert.h"


Design:: Design() Design:: Design()
: errors(0), nodes_(0), procs_(0), lcounter_(0) : errors(0), nodes_(0), procs_(0), aprocs_(0), lcounter_(0)
{ {
procs_idx_ = 0; procs_idx_ = 0;
des_precision_ = 0; des_precision_ = 0;
Expand Down Expand Up @@ -764,6 +764,11 @@ void Design::add_process(NetProcTop*pro)
procs_ = pro; procs_ = pro;
} }


void Design::add_process(NetAnalogTop*pro)
{
pro->next_ = aprocs_;
aprocs_ = pro;
}
void Design::delete_process(NetProcTop*top) void Design::delete_process(NetProcTop*top)
{ {
assert(top); assert(top);
Expand Down
12 changes: 11 additions & 1 deletion netlist.cc
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -850,7 +850,7 @@ NetProc::~NetProc()
{ {
} }


NetProcTop::NetProcTop(NetScope*s, Type t, NetProc*st) NetProcTop::NetProcTop(NetScope*s, ivl_process_type_t t, NetProc*st)
: type_(t), statement_(st), scope_(s) : type_(t), statement_(st), scope_(s)
{ {
} }
Expand All @@ -875,6 +875,16 @@ NetScope* NetProcTop::scope()
return scope_; return scope_;
} }


NetAnalogTop::NetAnalogTop(NetScope*scope, ivl_process_type_t t, NetAnalog*st)
: type_(t), statement_(st), scope_(scope)
{
next_ = 0;
}

NetAnalogTop::~NetAnalogTop()
{
}

const NetScope* NetProcTop::scope() const const NetScope* NetProcTop::scope() const
{ {
return scope_; return scope_;
Expand Down
Loading

0 comments on commit 5aa810d

Please sign in to comment.