]> AND Private Git Repository - blast.git/blobdiff - AbstractInterface.cpp
Logo AND Algorithmique Numérique Distribuée

Private GIT Repository
finalized analysis with clkconvert + started testbench gen.
[blast.git] / AbstractInterface.cpp
index 3295dc8eb99bde841b9351b1a44575ffc8c57366..3fdd87ad152912f9a850b4ea96799c8f9a2ff6db 100644 (file)
@@ -2,10 +2,11 @@
 #include "BlockParameterPort.h"
 #include "AbstractBlock.h"
 #include "Parameters.h"
 #include "BlockParameterPort.h"
 #include "AbstractBlock.h"
 #include "Parameters.h"
+#include "Graph.h"
 
 AbstractInterface::AbstractInterface(AbstractBlock* _owner) {
 
 
 AbstractInterface::AbstractInterface(AbstractBlock* _owner) {
 
-  owner = _owner;
+  owner = _owner;  
   name = "";
   width = "1";
   direction = Input;
   name = "";
   width = "1";
   direction = Input;
@@ -192,36 +193,6 @@ QString AbstractInterface::getDirectionString() {
     return str;
 }
 
     return str;
 }
 
-double AbstractInterface::getDoubleWidth() throw(QException) {
-
-  static QString fctName = "AbstractInterface::getDoubleWidth()";
- #ifdef DEBUG_FCTNAME
-   cout << "call to " << qPrintable(fctName) << endl;
- #endif
-
-   /*
-    cout << "start AbstractInterface::getDoubleWidth()" << endl;
-    bool ok;
-    double width = getWidth().toDouble(&ok);
-
-    if(!ok){
-      ArithmeticEvaluator *evaluator = new ArithmeticEvaluator;
-      cout << "evaluator created!" << endl;
-      evaluator->setExpression(getWidth());
-      cout << "expression defined!" << endl;
-      foreach(BlockParameter *param, getOwner()->getParameters()){
-        evaluator->setVariableValue(param->getName(), param->getIntValue());
-        cout << "param : " << param->getName().toStdString() << " evaluated!" << endl;
-      }
-      width = evaluator->evaluate();
-      cout << "expression evaluated succefully!" << endl;
-    }
-    cout << "real width : " << width << endl;
-    return width;
-    */
-
-   return 1.0;
-}
 
 void AbstractInterface::setPurpose(int _purpose) {
   if ((_purpose>=Data) && (_purpose <= Wishbone)) {
 
 void AbstractInterface::setPurpose(int _purpose) {
   if ((_purpose>=Data) && (_purpose <= Wishbone)) {
@@ -250,6 +221,32 @@ AbstractInterface* AbstractInterface::getClockIface() {
   return NULL;
 }
 
   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
 bool AbstractInterface::setClockIface(QString name) {
   /* 2 cases :
    *  - this is a Data interface