X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/blast.git/blobdiff_plain/6e2b3026c6a496e81642c373796bd39dad33d2a6..3fb762e7042d9b4a1cf78556ad9ed7f117cc53ba:/AbstractInterface.cpp?ds=sidebyside diff --git a/AbstractInterface.cpp b/AbstractInterface.cpp index 6c51907..d040598 100644 --- a/AbstractInterface.cpp +++ b/AbstractInterface.cpp @@ -5,7 +5,7 @@ AbstractInterface::AbstractInterface(AbstractBlock* _owner) { - owner = _owner; + owner = _owner; name = ""; width = "1"; direction = Input; @@ -13,6 +13,8 @@ AbstractInterface::AbstractInterface(AbstractBlock* _owner) { type = Boolean; endianess = LittleEndian; associatedIface = NULL; + clkIface = ""; + clkIfaceType = 0; } @@ -26,6 +28,8 @@ AbstractInterface::AbstractInterface(AbstractBlock* _owner, const QString& _name type = typeFromString(_type); endianess = _endianess; associatedIface = NULL; + clkIface = ""; + clkIfaceType = 0; } AbstractInterface::AbstractInterface(AbstractInterface* other) { @@ -37,6 +41,8 @@ AbstractInterface::AbstractInterface(AbstractInterface* other) { purpose = other->purpose; endianess = LittleEndian; associatedIface = NULL; + clkIface = other->clkIface; + clkIfaceType = other->clkIfaceType; } void AbstractInterface::setName(const QString& _name) { @@ -237,6 +243,53 @@ bool AbstractInterface::setAssociatedIface(AbstractInterface* iface) { return true; } +AbstractInterface* AbstractInterface::getClockIface() { + if (clkIfaceType == ClockName) { + return owner->getIfaceFromName(clkIface); + } + return NULL; +} + +bool AbstractInterface::setClockIface(QString name) { + /* 2 cases : + * - this is a Data interface + * - this is a Clock output (from a clkrstgen) + * + * iface must correspond to an existing clock interface name + * or a user parameter prepend with a $. + */ + if ((purpose == Data) || ((purpose == Clock) && (direction == Output))) { + if (name.at(0) == '$') { + name.remove(0,1); + QList params = owner->getUserParameters(); + foreach(BlockParameter* p, params) { + if (p->getName() == name) { + clkIface = name; + clkIfaceType = ParameterName; + return true; + } + } + // error case: cannot found the input clock + return false; + } + else { + QList clocks = owner->getInterfaces(Input, Clock); + foreach(AbstractInterface* iface, clocks) { + if (iface->getName() == name) { + clkIface = name; + clkIfaceType = ClockName; + return true; + } + } + // error case: cannot found the user paramter + return false; + } + } + clkIface = ""; + clkIfaceType = NoName; + return true; +} + int AbstractInterface::getIntDirection(QString str) { if(str == "input") return Input; @@ -288,7 +341,7 @@ int AbstractInterface::typeFromString(const QString &_type) { return ret; } -QString AbstractInterface::toVHDL(int context, int flags) throw(Exception) { +QString AbstractInterface::toVHDL(IfaceVHDLContext context, int flags) throw(Exception) { if (isReferenceInterface()) throw(Exception(IFACE_INVALID_TYPE)); @@ -298,7 +351,17 @@ QString AbstractInterface::toVHDL(int context, int flags) throw(Exception) { QString ret=""; bool ok; - cout << "iface " << qPrintable(name) << " must be evaluated to vhdl :" << qPrintable(width) << " with type = " << qPrintable(getTypeString()) << endl; + //cout << "iface " << qPrintable(name) << " must be evaluated to vhdl :" << qPrintable(width) << " with type = " << qPrintable(getTypeString()) << endl; + + if (context == Instance) { + if (direction == Output) { + ret = "from_"+owner->getName()+"_"+name; + } + else if (direction == InOut) { + ret = "fromto_"+owner->getName()+"_"+name; + } + return ret; + } // create the width part QString widthStr = ""; @@ -411,10 +474,15 @@ QString AbstractInterface::toVHDL(int context, int flags) throw(Exception) { ret += widthStr; } else if (context == Signal) { - ret = widthStr; - } - else if (context == Architecture) { - + if (direction == Output) { + ret = "from_"+owner->getName()+"_"+name+" : "+widthStr; + } + else if (direction == InOut) { + ret = "fromto_"+owner->getName()+"_"+name+" : "+widthStr; + } + else if (direction == Input) { + ret = owner->getName()+"_"+name+" : "+widthStr; + } } return ret;