forked from steveicarus/iverilog
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Creation of implicit nets requires knowledge of whether an identifier has been declared before it is used. Currently implicit nets are created during elaboration, but by this stage the order of declaration and use is not known. This patch moves the creation of implicit nets into the parser stage.
- Loading branch information
1 parent
9fbb12d
commit f955937
Showing
15 changed files
with
146 additions
and
231 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* Copyright (c) 1998-2009 Stephen Williams ([email protected]) | ||
* Copyright (c) 1998-2010 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 | ||
|
@@ -33,7 +33,6 @@ Module::Module(perm_string n) | |
library_flag = false; | ||
is_cell = false; | ||
uc_drive = UCD_NONE; | ||
default_nettype = NetNet::NONE; | ||
timescale_warn_done = false; | ||
} | ||
|
||
|
@@ -105,4 +104,3 @@ const list<PGate*>& Module::get_gates() const | |
{ | ||
return gates_; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
#ifndef __Module_H | ||
#define __Module_H | ||
/* | ||
* Copyright (c) 1998-2009 Stephen Williams ([email protected]) | ||
* Copyright (c) 1998-2010 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 | ||
|
@@ -79,8 +79,6 @@ class Module : public PScope, public LineInfo { | |
enum UCDriveType { UCD_NONE, UCD_PULL0, UCD_PULL1 }; | ||
UCDriveType uc_drive; | ||
|
||
NetNet::Type default_nettype; | ||
|
||
/* specparams are simpler then other params, in that they have | ||
no type information. They are merely constant | ||
expressions. */ | ||
|
@@ -118,11 +116,7 @@ class Module : public PScope, public LineInfo { | |
map<perm_string,PTask*> tasks; | ||
map<perm_string,PFunction*> funcs; | ||
|
||
/* The module has a list of genvars that may be used in | ||
various generate schemes. */ | ||
map<perm_string,LineInfo*> genvars; | ||
|
||
/* the module has a list of generate schemes that appear in | ||
/* The module has a list of generate schemes that appear in | ||
the module definition. These are used at elaboration time. */ | ||
list<PGenerate*> generate_schemes; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* Copyright (c) 1998-2008 Stephen Williams <[email protected]> | ||
* Copyright (c) 1998-2008,2010 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 | ||
|
@@ -23,6 +23,7 @@ | |
|
||
# include "compiler.h" | ||
# include "PExpr.h" | ||
# include "PWire.h" | ||
# include "Module.h" | ||
# include "netmisc.h" | ||
# include <typeinfo> | ||
|
@@ -36,6 +37,10 @@ PExpr::~PExpr() | |
{ | ||
} | ||
|
||
void PExpr::declare_implicit_nets(LexicalScope*scope, NetNet::Type type) | ||
{ | ||
} | ||
|
||
bool PExpr::has_aa_term(Design*, NetScope*) const | ||
{ | ||
return false; | ||
|
@@ -70,6 +75,13 @@ PEBinary::~PEBinary() | |
{ | ||
} | ||
|
||
void PEBinary::declare_implicit_nets(LexicalScope*scope, NetNet::Type type) | ||
{ | ||
assert(left_ && right_); | ||
left_->declare_implicit_nets(scope, type); | ||
right_->declare_implicit_nets(scope, type); | ||
} | ||
|
||
bool PEBinary::has_aa_term(Design*des, NetScope*scope) const | ||
{ | ||
assert(left_ && right_); | ||
|
@@ -160,6 +172,13 @@ PECallFunction::~PECallFunction() | |
{ | ||
} | ||
|
||
void PECallFunction::declare_implicit_nets(LexicalScope*scope, NetNet::Type type) | ||
{ | ||
for (unsigned idx = 0 ; idx < parms_.size() ; idx += 1) { | ||
parms_[idx]->declare_implicit_nets(scope, type); | ||
} | ||
} | ||
|
||
bool PECallFunction::has_aa_term(Design*des, NetScope*scope) const | ||
{ | ||
bool flag = false; | ||
|
@@ -179,6 +198,13 @@ PEConcat::~PEConcat() | |
delete repeat_; | ||
} | ||
|
||
void PEConcat::declare_implicit_nets(LexicalScope*scope, NetNet::Type type) | ||
{ | ||
for (unsigned idx = 0 ; idx < parms_.count() ; idx += 1) { | ||
parms_[idx]->declare_implicit_nets(scope, type); | ||
} | ||
} | ||
|
||
bool PEConcat::has_aa_term(Design*des, NetScope*scope) const | ||
{ | ||
bool flag = false; | ||
|
@@ -245,6 +271,46 @@ PEIdent::~PEIdent() | |
{ | ||
} | ||
|
||
void PEIdent::declare_implicit_nets(LexicalScope*scope, NetNet::Type type) | ||
{ | ||
/* We create an implicit wire if this is a simple identifier and | ||
if an identifier of that name has not already been declared in | ||
any enclosing scope. */ | ||
if ((path_.size() == 1) && (path_.front().index.size() == 0)) { | ||
perm_string name = path_.front().name; | ||
LexicalScope*ss = scope; | ||
while (ss) { | ||
if (ss->wires.find(name) != ss->wires.end()) | ||
return; | ||
if (ss->localparams.find(name) != ss->localparams.end()) | ||
return; | ||
if (ss->parameters.find(name) != ss->parameters.end()) | ||
return; | ||
if (ss->genvars.find(name) != ss->genvars.end()) | ||
return; | ||
if (ss->events.find(name) != ss->events.end()) | ||
return; | ||
/* Strictly speaking, we should also check for name clashes | ||
with tasks, functions, named blocks, module instances, | ||
and generate blocks. However, this information is not | ||
readily available. As these names would not be legal in | ||
this context, we can declare implicit nets here and rely | ||
on later checks for name clashes to report the error. */ | ||
|
||
ss = ss->parent_scope(); | ||
} | ||
PWire*net = new PWire(name, type, NetNet::NOT_A_PORT, IVL_VT_LOGIC); | ||
net->set_file(get_file()); | ||
net->set_lineno(get_lineno()); | ||
net->set_range(0, 0, SR_NET, true); | ||
scope->wires[name] = net; | ||
if (warn_implicit) { | ||
cerr << get_fileline() << ": warning: implicit " | ||
"definition of wire '" << name << "'." << endl; | ||
} | ||
} | ||
} | ||
|
||
bool PEIdent::has_aa_term(Design*des, NetScope*scope) const | ||
{ | ||
NetNet* net = 0; | ||
|
@@ -310,6 +376,14 @@ PETernary::~PETernary() | |
{ | ||
} | ||
|
||
void PETernary::declare_implicit_nets(LexicalScope*scope, NetNet::Type type) | ||
{ | ||
assert(expr_ && tru_ && fal_); | ||
expr_->declare_implicit_nets(scope, type); | ||
tru_->declare_implicit_nets(scope, type); | ||
fal_->declare_implicit_nets(scope, type); | ||
} | ||
|
||
bool PETernary::has_aa_term(Design*des, NetScope*scope) const | ||
{ | ||
assert(expr_ && tru_ && fal_); | ||
|
@@ -327,6 +401,12 @@ PEUnary::~PEUnary() | |
{ | ||
} | ||
|
||
void PEUnary::declare_implicit_nets(LexicalScope*scope, NetNet::Type type) | ||
{ | ||
assert(expr_); | ||
expr_->declare_implicit_nets(scope, type); | ||
} | ||
|
||
bool PEUnary::has_aa_term(Design*des, NetScope*scope) const | ||
{ | ||
assert(expr_); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
#ifndef __compiler_H | ||
#define __compiler_H | ||
/* | ||
* Copyright (c) 1999-2009 Stephen Williams ([email protected]) | ||
* Copyright (c) 1999-2010 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 | ||
|
@@ -74,7 +74,6 @@ extern unsigned recursive_mod_limit; | |
|
||
/* Implicit definitions of wires. */ | ||
extern bool warn_implicit; | ||
extern bool error_implicit; | ||
|
||
/* inherit timescales across files. */ | ||
extern bool warn_timescale; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.