Allow connecting module instance using implicit named port connections.

This is part of the 1800-2009 standard (Section 23.3.2.3) and allows
ports of module instances to be declared like:

modname instance(.foo, .bar);

instead of

modname instead(.foo(foo), .bar(bar));

The only tricky part about this is the implicit port connection shall
not create an implicit net declaration.  To make this happen, the path
of least resistance was to add a bool to PEIdent indicating that it
should not implicitely create a net.

This does not rely on the generation flag to be 2009, following the
trend that new port naming convention (like ANSI style ports) work
regardless of the generation.
This commit is contained in:
Jared Casper 2009-11-25 22:10:53 -08:00 committed by Stephen Williams
parent 12ddc34277
commit be67199177
3 changed files with 20 additions and 6 deletions

View File

@ -258,11 +258,12 @@ const verireal& PEFNumber::value() const
}
PEIdent::PEIdent(const pform_name_t&that)
: path_(that)
: path_(that), no_implicit_sig_(false)
{
}
PEIdent::PEIdent(perm_string s)
PEIdent::PEIdent(perm_string s, bool no_implicit_sig)
: no_implicit_sig_(no_implicit_sig)
{
path_.push_back(name_component_t(s));
}
@ -273,9 +274,13 @@ 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. */
/* We create an implicit wire if:
- this is a simple identifier
- an identifier of that name has not already been declared in
any enclosing scope.
- this is not an implicit named port connection */
if (no_implicit_sig_)
return;
if ((path_.size() == 1) && (path_.front().index.size() == 0)) {
perm_string name = path_.front().name;
LexicalScope*ss = scope;

View File

@ -255,7 +255,7 @@ class PEFNumber : public PExpr {
class PEIdent : public PExpr {
public:
explicit PEIdent(perm_string);
explicit PEIdent(perm_string, bool no_implicit_sig=false);
explicit PEIdent(const pform_name_t&);
~PEIdent();
@ -298,6 +298,7 @@ class PEIdent : public PExpr {
private:
pform_name_t path_;
bool no_implicit_sig_;
private:
// Common functions to calculate parts of part/bit

View File

@ -3101,6 +3101,14 @@ port_name
delete[]$2;
$$ = tmp;
}
| '.' IDENTIFIER
{ named_pexpr_t*tmp = new named_pexpr_t;
tmp->name = lex_strings.make($2);
tmp->parm = new PEIdent(lex_strings.make($2), true);
FILE_NAME(tmp->parm, @1);
delete[]$2;
$$ = tmp;
}
;
port_name_list