Named events as far as the pform.

This commit is contained in:
steve 2000-04-01 19:31:57 +00:00
parent 26dcecebdb
commit 2dd010dc04
13 changed files with 317 additions and 39 deletions

View File

@ -18,7 +18,7 @@
# 59 Temple Place - Suite 330
# Boston, MA 02111-1307, USA
#
#ident "$Id: Makefile.in,v 1.41 2000/03/29 04:37:10 steve Exp $"
#ident "$Id: Makefile.in,v 1.42 2000/04/01 19:31:57 steve Exp $"
#
#
SHELL = /bin/sh
@ -75,7 +75,8 @@ expr_synth.o functor.o lexor.o lexor_keyword.o mangle.o netlist.o \
net_design.o net_udp.o nexus_from_link.o pad_to_width.o \
parse.o parse_misc.o pform.o pform_dump.o \
set_width.o \
verinum.o verireal.o target.o targets.o Module.o PDelays.o PExpr.o PGate.o \
verinum.o verireal.o target.o targets.o Module.o PDelays.o PEvent.o \
PExpr.o PGate.o \
PTask.o PFunction.o PWire.o Statement.o \
$(FF) $(TT)

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: Module.h,v 1.16 2000/03/12 17:09:40 steve Exp $"
#ident "$Id: Module.h,v 1.17 2000/04/01 19:31:57 steve Exp $"
#endif
# include <list>
@ -27,6 +27,7 @@
# include "svector.h"
# include "named.h"
# include <string>
class PEvent;
class PExpr;
class PGate;
class PTask;
@ -81,6 +82,10 @@ class Module {
a parameter-index to its name. */
list<string> param_names;
/* Keep a table of named events declared in the module. */
map<string,PEvent*>events;
const string&get_name() const { return name_; }
void add_gate(PGate*gate);
@ -130,6 +135,9 @@ class Module {
/*
* $Log: Module.h,v $
* Revision 1.17 2000/04/01 19:31:57 steve
* Named events as far as the pform.
*
* Revision 1.16 2000/03/12 17:09:40 steve
* Support localparam.
*

45
PEvent.cc Normal file
View File

@ -0,0 +1,45 @@
/*
* Copyright (c) 200Stephen 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
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: PEvent.cc,v 1.1 2000/04/01 19:31:57 steve Exp $"
#endif
# include "PEvent.h"
PEvent::PEvent(const string&n)
: name_(n)
{
}
PEvent::~PEvent()
{
}
string PEvent::name() const
{
return name_;
}
/*
* $Log: PEvent.cc,v $
* Revision 1.1 2000/04/01 19:31:57 steve
* Named events as far as the pform.
*
*/

55
PEvent.h Normal file
View File

@ -0,0 +1,55 @@
#ifndef __PEvent_H
#define __PEvent_H
/*
* Copyright (c) 2000 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
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: PEvent.h,v 1.1 2000/04/01 19:31:57 steve Exp $"
#endif
# include "LineInfo.h"
# include <string>
class ostream;
/*
* The PEvent class represents event objects. These are things that
* are declared in Verilog as ``event foo;''
*/
class PEvent : public LineInfo {
public:
explicit PEvent(const string&name);
~PEvent();
string name() const;
private:
string name_;
private: // not implemented
PEvent(const PEvent&);
PEvent& operator= (const PEvent&);
};
/*
* $Log: PEvent.h,v $
* Revision 1.1 2000/04/01 19:31:57 steve
* Named events as far as the pform.
*
*/
#endif

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: PExpr.cc,v 1.14 2000/03/12 18:22:11 steve Exp $"
#ident "$Id: PExpr.cc,v 1.15 2000/04/01 19:31:57 steve Exp $"
#endif
# include "PExpr.h"
@ -83,6 +83,35 @@ PEConcat::~PEConcat()
delete repeat_;
}
PEEvent::PEEvent(NetNEvent::Type t, PExpr*e)
: type_(t), expr_(e)
{
}
PEEvent::PEEvent(const string&n)
: name_(n)
{
}
PEEvent::~PEEvent()
{
}
NetNEvent::Type PEEvent::type() const
{
return type_;
}
PExpr* PEEvent::expr() const
{
return expr_;
}
string PEEvent::name() const
{
return name_;
}
/*
* An identifier can be in a constant expresion if (and only if) it is
* a parameter.
@ -135,6 +164,9 @@ bool PETernary::is_constant(Module*) const
/*
* $Log: PExpr.cc,v $
* Revision 1.15 2000/04/01 19:31:57 steve
* Named events as far as the pform.
*
* Revision 1.14 2000/03/12 18:22:11 steve
* Binary and unary operators in parameter expressions.
*

27
PExpr.h
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: PExpr.h,v 1.32 2000/03/12 18:22:11 steve Exp $"
#ident "$Id: PExpr.h,v 1.33 2000/04/01 19:31:57 steve Exp $"
#endif
# include <string>
@ -112,21 +112,33 @@ class PEConcat : public PExpr {
PExpr*repeat_;
};
/*
* Event expressions are expressions that can be combined with the
* event "or" operator. These include "posedge foo" and similar, and
* also include named events. "edge" events are associated with an
* expression, whereas named events simply have a name, which
* represents an event variable.
*/
class PEEvent : public PExpr {
public:
PEEvent(NetNEvent::Type t, PExpr*e)
: type_(t), expr_(e)
{ }
// Use this constructor to create events based on edges or levels.
PEEvent(NetNEvent::Type t, PExpr*e);
// Use this to create named events.
PEEvent(const string&n);
NetNEvent::Type type() const { return type_; }
PExpr* expr() const { return expr_; }
~PEEvent();
NetNEvent::Type type() const;
PExpr* expr() const;
string name() const;
virtual void dump(ostream&) const;
private:
NetNEvent::Type type_;
PExpr*expr_;
string name_;
};
class PEIdent : public PExpr {
@ -341,6 +353,9 @@ class PECallFunction : public PExpr {
/*
* $Log: PExpr.h,v $
* Revision 1.33 2000/04/01 19:31:57 steve
* Named events as far as the pform.
*
* Revision 1.32 2000/03/12 18:22:11 steve
* Binary and unary operators in parameter expressions.
*

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: Statement.cc,v 1.17 2000/02/23 02:56:54 steve Exp $"
#ident "$Id: Statement.cc,v 1.18 2000/04/01 19:31:57 steve Exp $"
#endif
# include "Statement.h"
@ -129,6 +129,23 @@ PCondit::~PCondit()
delete else_;
}
PEventStatement::PEventStatement(const svector<PEEvent*>&ee)
: expr_(ee), statement_(0)
{
}
PEventStatement::PEventStatement(PEEvent*ee)
: expr_(1), statement_(0)
{
expr_[0] = ee;
}
PEventStatement::~PEventStatement()
{
// delete the events and the statement?
}
PForever::PForever(Statement*s)
: statement_(s)
{
@ -155,6 +172,15 @@ PRepeat::~PRepeat()
delete statement_;
}
PTrigger::PTrigger(const string&e)
: event_(e)
{
}
PTrigger::~PTrigger()
{
}
PWhile::~PWhile()
{
delete cond_;
@ -163,6 +189,9 @@ PWhile::~PWhile()
/*
* $Log: Statement.cc,v $
* Revision 1.18 2000/04/01 19:31:57 steve
* Named events as far as the pform.
*
* Revision 1.17 2000/02/23 02:56:54 steve
* Macintosh compilers do not support ident.
*

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: Statement.h,v 1.22 2000/03/11 03:25:51 steve Exp $"
#ident "$Id: Statement.h,v 1.23 2000/04/01 19:31:57 steve Exp $"
#endif
# include <string>
@ -258,15 +258,21 @@ class PDelayStatement : public Statement {
Statement*statement_;
};
/*
* The event statement represents the event delay in behavioral
* code. It comes from such things as:
*
* @name <statement>;
* @(expr) <statement>;
*/
class PEventStatement : public Statement {
public:
PEventStatement(const svector<PEEvent*>&ee)
: expr_(ee), statement_(0) { }
explicit PEventStatement(const svector<PEEvent*>&ee);
explicit PEventStatement(PEEvent*ee);
PEventStatement(PEEvent*ee)
: expr_(1), statement_(0) { expr_[0] = ee; }
~PEventStatement();
void set_statement(Statement*st) { statement_ = st; }
@ -341,6 +347,23 @@ class PRepeat : public Statement {
Statement*statement_;
};
/*
* The PTrigger statement sends a trigger to a named event. Take the
* name here.
*/
class PTrigger : public Statement {
public:
explicit PTrigger(const string&ev);
~PTrigger();
virtual NetProc* elaborate(Design*des, const string&path) const;
virtual void dump(ostream&out, unsigned ind) const;
private:
string event_;
};
class PWhile : public Statement {
public:
@ -359,6 +382,9 @@ class PWhile : public Statement {
/*
* $Log: Statement.h,v $
* Revision 1.23 2000/04/01 19:31:57 steve
* Named events as far as the pform.
*
* Revision 1.22 2000/03/11 03:25:51 steve
* Locate scopes in statements.
*

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.151 2000/03/29 04:37:11 steve Exp $"
#ident "$Id: elaborate.cc,v 1.152 2000/04/01 19:31:57 steve Exp $"
#endif
/*
@ -1828,6 +1828,14 @@ void PTask::elaborate_2(Design*des, const string&path) const
def->set_proc(st);
}
NetProc* PTrigger::elaborate(Design*des, const string&path) const
{
cerr << get_line() << ": sorry: named event trigger not supported."
<< endl;
des->errors += 1;
return 0;
}
/*
* The while loop is fairly directly represented in the netlist.
*/
@ -2003,6 +2011,9 @@ Design* elaborate(const map<string,Module*>&modules,
/*
* $Log: elaborate.cc,v $
* Revision 1.152 2000/04/01 19:31:57 steve
* Named events as far as the pform.
*
* Revision 1.151 2000/03/29 04:37:11 steve
* New and improved combinational primitives.
*

20
parse.y
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: parse.y,v 1.86 2000/03/12 17:09:41 steve Exp $"
#ident "$Id: parse.y,v 1.87 2000/04/01 19:31:57 steve Exp $"
#endif
# include "parse_misc.h"
@ -388,8 +388,14 @@ dr_strength1 : K_supply1 | K_strong1 | K_pull1 | K_weak1 ;
event_control
: '@' IDENTIFIER
{ yyerror(@1, "sorry: event control not supported.");
$$ = 0;
{ PEEvent*tmpe = new PEEvent($2);
tmpe->set_file(@2.text);
tmpe->set_lineno(@2.first_line);
delete[]$2;
PEventStatement*tmps = new PEventStatement(tmpe);
tmps->set_file(@1.text);
tmps->set_lineno(@1.first_line);
$$ = tmps;
}
| '@' '(' event_expression_list ')'
{ PEventStatement*tmp = new PEventStatement(*$3);
@ -1093,7 +1099,7 @@ module_item
| block_item_decl
| K_defparam defparam_assign_list ';'
| K_event list_of_variables ';'
{ yyerror(@1, "sorry: named events not supported.");
{ pform_make_events($2, @1.text, @1.first_line);
delete $2;
}
| K_parameter parameter_assign_list ';'
@ -1642,8 +1648,10 @@ statement
$$ = 0;
}
| K_TRIGGER IDENTIFIER ';'
{ yyerror(@1, "sorry: event trigger not supported.");
$$ = 0;
{ PTrigger*tmp = new PTrigger($2);
tmp->set_file(@2.text);
tmp->set_lineno(@2.first_line);
$$ = tmp;
}
| K_forever statement
{ PForever*tmp = new PForever($2);

View File

@ -17,12 +17,13 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: pform.cc,v 1.56 2000/03/12 17:09:41 steve Exp $"
#ident "$Id: pform.cc,v 1.57 2000/04/01 19:31:57 steve Exp $"
#endif
# include "compiler.h"
# include "pform.h"
# include "parse_misc.h"
# include "PEvent.h"
# include "PUdp.h"
# include <list>
# include <map>
@ -265,6 +266,25 @@ void pform_make_udp(const char*name, list<string>*parms,
delete init_expr;
}
/*
* This is invoked to make a named event. This is the declaration of
* the event, and not necessarily the use of it.
*/
static void pform_make_event(const string&name, const string&fn, unsigned ln)
{
PEvent*event = new PEvent(name);
event->set_file(fn);
event->set_lineno(ln);
pform_cur_module->events[name] = event;
}
void pform_make_events(const list<string>*names, const string&fn, unsigned ln)
{
list<string>::const_iterator cur;
for (cur = names->begin() ; cur != names->end() ; cur++)
pform_make_event(*cur, fn, ln);
}
/*
* pform_makegates is called when a list of gates (with the same type)
* are ready to be instantiated. The function runs through the list of
@ -833,6 +853,9 @@ int pform_parse(const char*path, map<string,Module*>&modules,
/*
* $Log: pform.cc,v $
* Revision 1.57 2000/04/01 19:31:57 steve
* Named events as far as the pform.
*
* Revision 1.56 2000/03/12 17:09:41 steve
* Support localparam.
*

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: pform.h,v 1.37 2000/03/12 17:09:41 steve Exp $"
#ident "$Id: pform.h,v 1.38 2000/04/01 19:31:57 steve Exp $"
#endif
# include "netlist.h"
@ -141,6 +141,9 @@ extern svector<PWire*>* pform_make_udp_input_ports(list<string>*);
extern bool pform_expression_is_constant(const PExpr*);
extern void pform_make_events(const list<string>*names,
const string&file, unsigned lineno);
/*
* The makegate function creates a new gate (which need not have a
* name) and connects it to the specified wires.
@ -182,6 +185,9 @@ extern void pform_dump(ostream&out, Module*mod);
/*
* $Log: pform.h,v $
* Revision 1.38 2000/04/01 19:31:57 steve
* Named events as far as the pform.
*
* Revision 1.37 2000/03/12 17:09:41 steve
* Support localparam.
*

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: pform_dump.cc,v 1.51 2000/03/12 17:09:41 steve Exp $"
#ident "$Id: pform_dump.cc,v 1.52 2000/04/01 19:31:57 steve Exp $"
#endif
/*
@ -27,6 +27,7 @@
* module in question.
*/
# include "pform.h"
# include "PEvent.h"
# include <iostream>
# include <iomanip>
# include <typeinfo>
@ -80,20 +81,24 @@ void PECallFunction::dump(ostream &out) const
void PEEvent::dump(ostream&out) const
{
switch (type_) {
case NetNEvent::ANYEDGE:
break;
case NetNEvent::POSEDGE:
out << "posedge ";
break;
case NetNEvent::NEGEDGE:
out << "negedge ";
break;
case NetNEvent::POSITIVE:
out << "positive ";
break;
if (expr_) {
switch (type_) {
case NetNEvent::ANYEDGE:
break;
case NetNEvent::POSEDGE:
out << "posedge ";
break;
case NetNEvent::NEGEDGE:
out << "negedge ";
break;
case NetNEvent::POSITIVE:
out << "positive ";
break;
}
out << *expr_;
} else {
out << "<event " << name_ << ">";
}
out << *expr_;
}
void PENumber::dump(ostream&out) const
@ -541,6 +546,10 @@ void PTask::dump(ostream&out, unsigned ind) const
out << setw(ind) << "" << "/* NOOP */" << endl;
}
void PTrigger::dump(ostream&out, unsigned ind) const
{
out << setw(ind) << "" << "-> " << event_ << ";" << endl;
}
void PWhile::dump(ostream&out, unsigned ind) const
{
@ -627,6 +636,13 @@ void Module::dump(ostream&out) const
out << "/* ERROR */;" << endl;
}
for (map<string,PEvent*>::const_iterator cur = events.begin()
; cur != events.end() ; cur ++ ) {
PEvent*ev = (*cur).second;
out << " event " << ev->name() << "; // "
<< ev->get_line() << endl;
}
// Iterate through and display all the wires.
for (map<string,PWire*>::const_iterator wire = wires_.begin()
; wire != wires_.end()
@ -720,6 +736,9 @@ void PUdp::dump(ostream&out) const
/*
* $Log: pform_dump.cc,v $
* Revision 1.52 2000/04/01 19:31:57 steve
* Named events as far as the pform.
*
* Revision 1.51 2000/03/12 17:09:41 steve
* Support localparam.
*