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:
parent
12ddc34277
commit
be67199177
15
PExpr.cc
15
PExpr.cc
|
|
@ -258,11 +258,12 @@ const verireal& PEFNumber::value() const
|
||||||
}
|
}
|
||||||
|
|
||||||
PEIdent::PEIdent(const pform_name_t&that)
|
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));
|
path_.push_back(name_component_t(s));
|
||||||
}
|
}
|
||||||
|
|
@ -273,9 +274,13 @@ PEIdent::~PEIdent()
|
||||||
|
|
||||||
void PEIdent::declare_implicit_nets(LexicalScope*scope, NetNet::Type type)
|
void PEIdent::declare_implicit_nets(LexicalScope*scope, NetNet::Type type)
|
||||||
{
|
{
|
||||||
/* We create an implicit wire if this is a simple identifier and
|
/* We create an implicit wire if:
|
||||||
if an identifier of that name has not already been declared in
|
- this is a simple identifier
|
||||||
any enclosing scope. */
|
- 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)) {
|
if ((path_.size() == 1) && (path_.front().index.size() == 0)) {
|
||||||
perm_string name = path_.front().name;
|
perm_string name = path_.front().name;
|
||||||
LexicalScope*ss = scope;
|
LexicalScope*ss = scope;
|
||||||
|
|
|
||||||
3
PExpr.h
3
PExpr.h
|
|
@ -255,7 +255,7 @@ class PEFNumber : public PExpr {
|
||||||
class PEIdent : public PExpr {
|
class PEIdent : public PExpr {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit PEIdent(perm_string);
|
explicit PEIdent(perm_string, bool no_implicit_sig=false);
|
||||||
explicit PEIdent(const pform_name_t&);
|
explicit PEIdent(const pform_name_t&);
|
||||||
~PEIdent();
|
~PEIdent();
|
||||||
|
|
||||||
|
|
@ -298,6 +298,7 @@ class PEIdent : public PExpr {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
pform_name_t path_;
|
pform_name_t path_;
|
||||||
|
bool no_implicit_sig_;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Common functions to calculate parts of part/bit
|
// Common functions to calculate parts of part/bit
|
||||||
|
|
|
||||||
8
parse.y
8
parse.y
|
|
@ -3101,6 +3101,14 @@ port_name
|
||||||
delete[]$2;
|
delete[]$2;
|
||||||
$$ = tmp;
|
$$ = 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
|
port_name_list
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue