Permalink
Browse files

Infrastructure for elaborating analog statements.

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 5aa810dde7e1999fb57e6088c462b31bb51fea8f
Showing with 219 additions and 115 deletions.
  1. +16 −4 AStatement.h
  2. +3 −2 Makefile.in
  3. +4 −5 Statement.h
  4. +2 −31 async.cc
  5. +2 −2 design_dump.cc
  6. +10 −0 elab_scope.cc
  7. +30 −0 elab_sig_analog.cc
  8. +9 −11 elaborate.cc
  9. +60 −0 elaborate_analog.cc
  10. +6 −1 net_design.cc
  11. +11 −1 netlist.cc
  12. +35 −5 netlist.h
  13. +3 −3 parse.y
  14. +2 −2 pform.cc
  15. +2 −2 pform.h
  16. +1 −1 pform_analog.cc
  17. +16 −12 pform_dump.cc
  18. +1 −1 syn-rules.y
  19. +2 −20 sync.cc
  20. +2 −2 synth.cc
  21. +2 −10 t-dll-proc.cc
View
@@ -20,11 +20,15 @@
*/
# include <map>
+# include "ivl_target.h"
# include "StringHeap.h"
# include "LineInfo.h"
# include "PExpr.h"
class PExpr;
+class NetAnalog;
+class NetScope;
+class Design;
class AStatement : public LineInfo {
@@ -33,6 +37,11 @@ class AStatement : public LineInfo {
virtual ~AStatement() =0;
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
AStatement(const AStatement&);
@@ -65,20 +74,23 @@ class AContrib : public AStatement {
class AProcess : public LineInfo {
public:
- enum Type { PR_INITIAL, PR_ALWAYS };
-
- AProcess(Type t, AStatement*st)
+ AProcess(ivl_process_type_t t, AStatement*st)
: type_(t), statement_(st) { }
~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;
// Dump the analog process
void dump(ostream&out, unsigned ind) const;
private:
- Type type_;
+ ivl_process_type_t type_;
AStatement*statement_;
private: // not implemented
View
@@ -116,9 +116,10 @@ distclean: clean
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
-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_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 \
load_module.o netlist.o netmisc.o net_assign.o \
net_design.o net_event.o net_expr.o net_func.o \
View
@@ -20,6 +20,7 @@
*/
# include <string>
+# include "ivl_target.h"
# include "svector.h"
# include "StringHeap.h"
# include "PDelays.h"
@@ -46,24 +47,22 @@ class NetScope;
class PProcess : public LineInfo {
public:
- enum Type { PR_INITIAL, PR_ALWAYS };
-
- PProcess(Type t, Statement*st)
+ PProcess(ivl_process_type_t t, Statement*st)
: type_(t), statement_(st) { }
virtual ~PProcess();
bool elaborate(Design*des, NetScope*scope) const;
- Type type() const { return type_; }
+ ivl_process_type_t type() const { return type_; }
Statement*statement() { return statement_; }
map<perm_string,PExpr*> attributes;
virtual void dump(ostream&out, unsigned ind) const;
private:
- Type type_;
+ ivl_process_type_t type_;
Statement*statement_;
};
View
@@ -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
* 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: async.cc,v 1.7 2004/01/18 23:26:54 steve Exp $"
-#endif
# include "config.h"
@@ -87,34 +84,8 @@ bool NetProc::is_asynchronous()
bool NetProcTop::is_asynchronous()
{
- if (type_ == NetProcTop::KINITIAL)
+ if (type_ == IVL_PR_INITIAL)
return false;
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.
- *
- */
-
View
@@ -702,11 +702,11 @@ void NetUDP::dump_node(ostream&o, unsigned ind) const
void NetProcTop::dump(ostream&o, unsigned ind) const
{
switch (type_) {
- case NetProcTop::KINITIAL:
+ case IVL_PR_INITIAL:
o << "initial /* " << get_fileline() << " in "
<< scope_path(scope_) << " */" << endl;
break;
- case NetProcTop::KALWAYS:
+ case IVL_PR_ALWAYS:
o << "always /* " << get_fileline() << " in "
<< scope_path(scope_) << " */" << endl;
break;
View
@@ -40,6 +40,7 @@
# include "PTask.h"
# include "PWire.h"
# include "Statement.h"
+# include "AStatement.h"
# include "netlist.h"
# include "util.h"
# include <typeinfo>
@@ -1242,3 +1243,12 @@ void PWhile::elaborate_scope(Design*des, NetScope*scope) const
if (statement_)
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
+{
+}
+
View
@@ -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
+{
+}
+
View
@@ -3502,15 +3502,7 @@ bool PProcess::elaborate(Design*des, NetScope*scope) const
return false;
}
- NetProcTop*top=0;
- 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;
- }
+ NetProcTop*top=new NetProcTop(scope, type(), cur);
ivl_assert(*this, top);
// Evaluate the attributes for this process, if there
@@ -3535,7 +3527,7 @@ bool PProcess::elaborate(Design*des, NetScope*scope) const
gets into its wait statement before non-combinational
code is executed. */
do {
- if (top->type() != NetProcTop::KALWAYS)
+ if (top->type() != IVL_PR_ALWAYS)
break;
NetEvWait*st = dynamic_cast<NetEvWait*>(top->statement());
@@ -3958,6 +3950,12 @@ bool PScope::elaborate_behaviors_(Design*des, NetScope*scope) const
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;
}
@@ -4045,7 +4043,7 @@ bool Design::check_always_delay() const
* a runtime infinite loop will happen. If we possible have some
* 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();
if (dly_type == NO_DELAY || dly_type == ZERO_DELAY) {
View
@@ -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;
+}
View
@@ -36,7 +36,7 @@
# include "ivl_assert.h"
Design:: Design()
-: errors(0), nodes_(0), procs_(0), lcounter_(0)
+ : errors(0), nodes_(0), procs_(0), aprocs_(0), lcounter_(0)
{
procs_idx_ = 0;
des_precision_ = 0;
@@ -764,6 +764,11 @@ void Design::add_process(NetProcTop*pro)
procs_ = pro;
}
+void Design::add_process(NetAnalogTop*pro)
+{
+ pro->next_ = aprocs_;
+ aprocs_ = pro;
+}
void Design::delete_process(NetProcTop*top)
{
assert(top);
View
@@ -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)
{
}
@@ -875,6 +875,16 @@ NetScope* NetProcTop::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
{
return scope_;
Oops, something went wrong.

0 comments on commit 5aa810d

Please sign in to comment.