Skip to content

Commit

Permalink
Add support for the default_nettype directive.
Browse files Browse the repository at this point in the history
  • Loading branch information
steve committed Jun 13, 2004
1 parent e8e0cd7 commit 9949040
Show file tree
Hide file tree
Showing 11 changed files with 129 additions and 93 deletions.
6 changes: 5 additions & 1 deletion Module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: Module.cc,v 1.23 2004/02/20 06:22:56 steve Exp $"
#ident "$Id: Module.cc,v 1.24 2004/06/13 04:56:53 steve Exp $"
#endif

# include "config.h"
Expand All @@ -31,6 +31,7 @@
Module::Module(perm_string n)
: name_(n)
{
default_nettype = NetNet::NONE;
}

Module::~Module()
Expand Down Expand Up @@ -149,6 +150,9 @@ const list<PProcess*>& Module::get_behaviors() const

/*
* $Log: Module.cc,v $
* Revision 1.24 2004/06/13 04:56:53 steve
* Add support for the default_nettype directive.
*
* Revision 1.23 2004/02/20 06:22:56 steve
* parameter keys are per_strings.
*
Expand Down
10 changes: 7 additions & 3 deletions Module.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef __Module_H
#define __Module_H
/*
* Copyright (c) 1998-2000 Stephen Williams ([email protected])
* Copyright (c) 1998-2004 Stephen Williams ([email protected])
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
Expand All @@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: Module.h,v 1.36 2004/05/25 19:21:06 steve Exp $"
#ident "$Id: Module.h,v 1.37 2004/06/13 04:56:53 steve Exp $"
#endif

# include <list>
Expand All @@ -29,7 +29,7 @@
# include "HName.h"
# include "named.h"
# include "LineInfo.h"
# include <string>
# include "netlist.h"
class PData;
class PEvent;
class PExpr;
Expand Down Expand Up @@ -67,6 +67,7 @@ class Module : public LineInfo {
explicit Module(perm_string name);
~Module();

NetNet::Type default_nettype;

/* The module has parameters that are evaluated when the
module is elaborated. During parsing, I put the parameters
Expand Down Expand Up @@ -166,6 +167,9 @@ class Module : public LineInfo {

/*
* $Log: Module.h,v $
* Revision 1.37 2004/06/13 04:56:53 steve
* Add support for the default_nettype directive.
*
* Revision 1.36 2004/05/25 19:21:06 steve
* More identifier lists use perm_strings.
*
Expand Down
14 changes: 9 additions & 5 deletions elab_net.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: elab_net.cc,v 1.127 2004/06/01 01:04:57 steve Exp $"
#ident "$Id: elab_net.cc,v 1.128 2004/06/13 04:56:53 steve Exp $"
#endif

# include "config.h"
Expand Down Expand Up @@ -1396,11 +1396,11 @@ NetNet* PEIdent::elaborate_net(Design*des, NetScope*scope,

/* Fallback, this may be an implicitly declared net. */
if (sig == 0) {

NetNet::Type nettype = scope->default_nettype();
sig = new NetNet(scope, lex_strings.make(path_.peek_name(0)),
NetNet::IMPLICIT, 1);
nettype, 1);

if (error_implicit) {
if (error_implicit || (nettype == NetNet::NONE)) {
cerr << get_line() << ": error: "
<< scope->name() << "." << path_.peek_name(0)
<< " not defined in this scope." << endl;
Expand Down Expand Up @@ -1656,8 +1656,9 @@ NetNet* PEIdent::elaborate_lnet(Design*des, NetScope*scope,
}

if (sig == 0) {
NetNet::Type nettype = scope->default_nettype();

if (implicit_net_ok && !error_implicit) {
if (implicit_net_ok && !error_implicit && nettype!=NetNet::NONE) {

sig = new NetNet(scope, lex_strings.make(path_.peek_name(0)),
NetNet::IMPLICIT, 1);
Expand Down Expand Up @@ -2432,6 +2433,9 @@ NetNet* PEUnary::elaborate_net(Design*des, NetScope*scope,

/*
* $Log: elab_net.cc,v $
* Revision 1.128 2004/06/13 04:56:53 steve
* Add support for the default_nettype directive.
*
* Revision 1.127 2004/06/01 01:04:57 steve
* Fix synthesis method for logical and/or
*
Expand Down
6 changes: 5 additions & 1 deletion elab_scope.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: elab_scope.cc,v 1.31 2004/05/25 19:21:06 steve Exp $"
#ident "$Id: elab_scope.cc,v 1.32 2004/06/13 04:56:54 steve Exp $"
#endif

# include "config.h"
Expand Down Expand Up @@ -290,6 +290,7 @@ void PGModule::elaborate_scope_mod_(Design*des, Module*mod, NetScope*sc) const
// Create the new scope as a MODULE with my name.
NetScope*my_scope = new NetScope(sc, get_name(), NetScope::MODULE);
my_scope->set_module_name(mod->mod_name());
my_scope->default_nettype(mod->default_nettype);

// Set time units and precision.
my_scope->time_unit(mod->time_unit);
Expand Down Expand Up @@ -549,6 +550,9 @@ void PWhile::elaborate_scope(Design*des, NetScope*scope) const

/*
* $Log: elab_scope.cc,v $
* Revision 1.32 2004/06/13 04:56:54 steve
* Add support for the default_nettype directive.
*
* Revision 1.31 2004/05/25 19:21:06 steve
* More identifier lists use perm_strings.
*
Expand Down
6 changes: 5 additions & 1 deletion elaborate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: elaborate.cc,v 1.302 2004/05/31 23:34:37 steve Exp $"
#ident "$Id: elaborate.cc,v 1.303 2004/06/13 04:56:54 steve Exp $"
#endif

# include "config.h"
Expand Down Expand Up @@ -2643,6 +2643,7 @@ Design* elaborate(list<perm_string>roots)
NetScope*scope = des->make_root_scope(*root);
scope->time_unit(rmod->time_unit);
scope->time_precision(rmod->time_precision);
scope->default_nettype(rmod->default_nettype);
des->set_precision(rmod->time_precision);
if (! rmod->elaborate_scope(des, scope)) {
delete des;
Expand Down Expand Up @@ -2708,6 +2709,9 @@ Design* elaborate(list<perm_string>roots)

/*
* $Log: elaborate.cc,v $
* Revision 1.303 2004/06/13 04:56:54 steve
* Add support for the default_nettype directive.
*
* Revision 1.302 2004/05/31 23:34:37 steve
* Rewire/generalize parsing an elaboration of
* function return values to allow for better
Expand Down
34 changes: 32 additions & 2 deletions lexor.lex
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: lexor.lex,v 1.85 2003/08/31 21:14:28 steve Exp $"
#ident "$Id: lexor.lex,v 1.86 2004/06/13 04:56:54 steve Exp $"
#endif

# include "config.h"
Expand Down Expand Up @@ -98,6 +98,7 @@ static int comment_enter;
%x CSTRING
%s UDPTABLE
%x PPTIMESCALE
%x PPDEFAULT_NETTYPE

W [ \t\b\f\r]+

Expand Down Expand Up @@ -269,7 +270,6 @@ W [ \t\b\f\r]+
should handle these, not an external preprocessor. */

^{W}?`celldefine{W}?.* { }
^{W}?`default_nettype{W}?.* { }
^{W}?`delay_mode_distributed{W}?.* { }
^{W}?`delay_mode_unit{W}?.* { }
^{W}?`delay_mode_path{W}?.* { }
Expand All @@ -285,6 +285,36 @@ W [ \t\b\f\r]+
^{W}?`unconnected_drive{W}?.* { }
^{W}?`uselib{W}?.* { }

/* Notice and handle the default_nettype directive. The lexor
detects the default_nettype keyword, and the second part of the
rule collects the rest of the line and processes it. We only need
to look for the first work, and interpret it. */

`default_nettype{W}? { BEGIN(PPDEFAULT_NETTYPE); }
<PPDEFAULT_NETTYPE>.* {
NetNet::Type net_type;
size_t wordlen = strcspn(yytext, " \t\f\r\n");
yytext[wordlen] = 0;
if (strcmp(yytext,"wire") == 0) {
net_type = NetNet::WIRE;

} else if (strcmp(yytext,"none") == 0) {
net_type = NetNet::NONE;

} else {
cerr << yylloc.text << ":" << yylloc.first_line
<< " error: Net type " << yytext
<< " is not a valid (and supported)"
<< " default net type." << endl;
net_type = NetNet::WIRE;
error_count += 1;
}
pform_set_default_nettype(net_type, yylloc.text, yylloc.first_line);
}
<PPDEFAULT_NETTYPE>\n {
yylloc.first_line += 1;
BEGIN(0); }


/* These are directives that are not supported by me and should have
been handled by an external preprocessor such as ivlpp. */
Expand Down
15 changes: 14 additions & 1 deletion net_scope.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: net_scope.cc,v 1.31 2004/02/20 06:22:56 steve Exp $"
#ident "$Id: net_scope.cc,v 1.32 2004/06/13 04:56:54 steve Exp $"
#endif

# include "config.h"
Expand Down Expand Up @@ -223,6 +223,16 @@ int NetScope::time_precision() const
return time_prec_;
}

void NetScope::default_nettype(NetNet::Type nt)
{
default_nettype_ = nt;
}

NetNet::Type NetScope::default_nettype() const
{
return default_nettype_;
}

perm_string NetScope::basename() const
{
return name_;
Expand Down Expand Up @@ -457,6 +467,9 @@ string NetScope::local_hsymbol()

/*
* $Log: net_scope.cc,v $
* Revision 1.32 2004/06/13 04:56:54 steve
* Add support for the default_nettype directive.
*
* Revision 1.31 2004/02/20 06:22:56 steve
* parameter keys are per_strings.
*
Expand Down
8 changes: 7 additions & 1 deletion netlist.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: netlist.cc,v 1.223 2004/05/31 23:34:37 steve Exp $"
#ident "$Id: netlist.cc,v 1.224 2004/06/13 04:56:54 steve Exp $"
#endif

# include "config.h"
Expand All @@ -34,6 +34,9 @@
ostream& operator<< (ostream&o, NetNet::Type t)
{
switch (t) {
case NetNet::NONE:
o << "net_none";
break;
case NetNet::IMPLICIT:
o << "wire /*implicit*/";
break;
Expand Down Expand Up @@ -2254,6 +2257,9 @@ const NetProc*NetTaskDef::proc() const

/*
* $Log: netlist.cc,v $
* Revision 1.224 2004/06/13 04:56:54 steve
* Add support for the default_nettype directive.
*
* Revision 1.223 2004/05/31 23:34:37 steve
* Rewire/generalize parsing an elaboration of
* function return values to allow for better
Expand Down
Loading

0 comments on commit 9949040

Please sign in to comment.