From 14e3a886bdb84a5e2bc888b9a2bdb965bc00340a Mon Sep 17 00:00:00 2001 From: Stephen Williams Date: Sun, 23 Mar 2008 17:52:48 -0700 Subject: [PATCH] Find implicit nets in expressions passed to ports. It is questionable, but probably legal, for expressions passed as arguments to input ports of various kinds of gates to implicitly declare nets. This patch allows the scan through different types of expressions for implicit nets. The elaborate_sig handling here does not test for the legality of having a non-trivial expression as argument to a port. For example, it is definitely NOT legal to have r-value expressions passed to output or inout ports. But that will be checked for later when the instance is elaborated for real. --- PExpr.h | 6 ++++++ elab_sig.cc | 22 ++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/PExpr.h b/PExpr.h index 3481351aa..7f82b1c6b 100644 --- a/PExpr.h +++ b/PExpr.h @@ -474,6 +474,8 @@ class PEUnary : public PExpr { virtual void dump(ostream&out) const; + virtual bool elaborate_sig(Design*des, NetScope*scope) const; + virtual NetNet* elaborate_net(Design*des, NetScope*scope, unsigned width, const NetExpr* rise, @@ -533,6 +535,8 @@ class PEBinary : public PExpr { unsigned min, unsigned lval, bool&unsized_flag) const; + virtual bool elaborate_sig(Design*des, NetScope*scope) const; + virtual NetNet* elaborate_net(Design*des, NetScope*scope, unsigned width, const NetExpr* rise, @@ -648,6 +652,8 @@ class PETernary : public PExpr { unsigned min, unsigned lval, bool&unsized_flag) const; + virtual bool elaborate_sig(Design*des, NetScope*scope) const; + virtual NetNet* elaborate_net(Design*des, NetScope*scope, unsigned width, const NetExpr* rise, diff --git a/elab_sig.cc b/elab_sig.cc index dbbda62a4..95a9fa032 100644 --- a/elab_sig.cc +++ b/elab_sig.cc @@ -267,6 +267,28 @@ bool PEIdent::elaborate_sig(Design*des, NetScope*scope) const return sig != 0; } +bool PEBinary::elaborate_sig(Design*des, NetScope*scope) const +{ + bool flag = true; + + flag = left_->elaborate_sig(des, scope) && flag; + flag = right_->elaborate_sig(des, scope) && flag; + return flag; +} + +bool PETernary::elaborate_sig(Design*des, NetScope*scope) const +{ + bool flag = true; + flag = tru_->elaborate_sig(des, scope) && flag; + flag = fal_->elaborate_sig(des, scope) && flag; + return flag; +} + +bool PEUnary::elaborate_sig(Design*des, NetScope*scope) const +{ + return expr_->elaborate_sig(des, scope); +} + bool PGate::elaborate_sig(Design*des, NetScope*scope) const { return true;