+AbstractInterface* AbstractInterface::getClockIface() {
+ if (clkIfaceType == ClockName) {
+ return owner->getIfaceFromName(clkIface);
+ }
+ return NULL;
+}
+
+
+double AbstractInterface::getClockFrequency() throw(Exception) {
+
+ int idClock = -1;
+
+ if (clkIfaceType == ParameterName) {
+ BlockParameter* param = owner->getParameterFromName(clkIface);
+ if (!param->isUserParameter()) throw(Exception(IFACE_INVALID_CLKFREQ,this));
+ bool ok;
+ double freq = param->getDoubleValue(&ok);
+ if (!ok) throw(Exception(IFACE_INVALID_CLKFREQ,this));
+ return freq;
+ }
+ else {
+ try {
+ idClock = getClockDomain();
+ }
+ catch(Exception e) {
+ throw(e);
+ }
+ return owner->getGraph()->getClock(idClock);
+ }
+ return 0.0;
+}
+
+
+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<BlockParameter* > 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<AbstractInterface*> 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;
+}
+