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

Private GIT Repository
changes in output pattern comput
authorstephane Domas <stephane.domas@univ-fcomte.fr>
Fri, 8 Dec 2017 16:50:39 +0000 (17:50 +0100)
committerstephane Domas <stephane.domas@univ-fcomte.fr>
Fri, 8 Dec 2017 16:50:39 +0000 (17:50 +0100)
22 files changed:
AbstractInterface.cpp
AbstractInterface.h
ConnectedInterface.cpp
ConnectedInterface.h
Dispatcher.cpp
FunctionalBlock.cpp
FunctionalBlock.h
FunctionalInterface.cpp
GroupInterface.cpp
GroupScene.cpp
GroupScene.h
ReferenceBlock.cpp
ReferenceInterface.cpp
ReferenceInterface.h
VHDLConverter.cpp
VHDLConverter.h
blast.creator.user
blast.files
lib/implementations/average-Nx3_impl.xml
lib/implementations/impls.bmf
lib/implementations/rgb216bits_impl.xml [deleted file]
object-files.txt

index bdf342d0af7c487ee792fada86dccb33e446aec1..76654ff84ec03669c748138dd6b0e1ef448f7aa5 100644 (file)
@@ -10,11 +10,12 @@ AbstractInterface::AbstractInterface(AbstractBlock* _owner) {
   direction = Input;
   purpose = Data;  
   type = Boolean;
+  endianess = LittleEndian;
   associatedIface = NULL;
 
 }
 
-AbstractInterface::AbstractInterface(AbstractBlock* _owner, const QString& _name, const QString& _type, const QString& _width, int _direction, int _purpose) {
+AbstractInterface::AbstractInterface(AbstractBlock* _owner, const QString& _name, int _direction, int _purpose, const QString& _type, const QString& _width, int _endianess) {
 
   owner = _owner;  
   name = _name;
@@ -22,6 +23,7 @@ AbstractInterface::AbstractInterface(AbstractBlock* _owner, const QString& _name
   direction = _direction;
   purpose = _purpose;
   type = typeFromString(_type);
+  endianess = _endianess;
   associatedIface = NULL;
 }
 
@@ -32,6 +34,7 @@ AbstractInterface::AbstractInterface(AbstractInterface* other) {
   width = other->width;
   direction = other->direction;
   purpose = other->purpose;
+  endianess = LittleEndian;
   associatedIface = NULL;
 }
 
@@ -51,23 +54,42 @@ bool AbstractInterface::isGroupInterface() {
   return false;
 }
 
+QString AbstractInterface::getEndianessString() {
+  QString str="unknown";
+  switch(endianess){
+  case AbstractInterface::LittleEndian:
+    str = QString("little");
+    break;
+  case AbstractInterface::BigEndian:
+    str = QString("big");
+    break;
+  }
+  return str;
+}
+
 QString AbstractInterface::getPurposeString() {
-    QString str;
-    switch(purpose){
-        case AbstractInterface::Data:
-            str = QString("data");
-            break;
-        case AbstractInterface::Clock:
-            str = QString("clock");
-            break;
-        case AbstractInterface::Reset:
-            str = QString("reset");
-            break;
-        case AbstractInterface::Wishbone:
-            str = QString("wishbone");
-            break;
-    }
-    return str;
+  QString str;
+  switch(purpose){
+  case AbstractInterface::AnyPurpose:
+    str = QString("any");
+    break;
+  case AbstractInterface::Data:
+    str = QString("data");
+    break;
+  case AbstractInterface::Control:
+    str = QString("control");
+    break;
+  case AbstractInterface::Clock:
+    str = QString("clock");
+    break;
+  case AbstractInterface::Reset:
+    str = QString("reset");
+    break;
+  case AbstractInterface::Wishbone:
+    str = QString("wishbone");
+    break;
+  }
+  return str;
 }
 
 QString AbstractInterface::getDirectionString() {
index 2c914d482883a4e0b3fa450ce3677f73ad56c3ff..b318f92b879174b95579a1d1617bf8d14b5b1948 100644 (file)
@@ -25,6 +25,7 @@ class AbstractInterface {
 public :
 
   enum IfaceWidthType { Expression = 1, Boolean, Natural, Inherited}; //! Inherited is only for Group interface 
+  enum IfaceWidthDir { LittleEndian = 1, BigEndian}; //! LittleEndian = X downto 0, BigEndian = 0 to X
   enum IfacePurpose { AnyPurpose = 0, Data = 1, Control, Clock, Reset, Wishbone };
   enum IfaceDirection { AnyDirection = 0, Input = 1, Output = 2, InOut = 3 };  
   enum IfaceVHDLContext {AnyContext = 0, Entity = 1, Component = 2, Architecture = 3 }; // NB : 3 is when creating an instance of the block that owns this iface
@@ -34,7 +35,7 @@ public :
   static int getIntPurpose(QString str);
 
   AbstractInterface(AbstractBlock* _owner);
-  AbstractInterface(AbstractBlock* _owner, const QString& _name, const QString& _type, const QString& _width, int _direction, int _purpose);
+  AbstractInterface(AbstractBlock* _owner, const QString& _name, int _direction, int _purpose, const QString& _type, const QString& _width, int _endianess = LittleEndian);
   AbstractInterface(AbstractInterface* other);
   virtual ~AbstractInterface();
 
@@ -42,6 +43,8 @@ public :
   inline QString getName() { return name;}
   inline int getType() { return type; }
   QString getTypeString();
+  inline int getEndianess() { return endianess; }
+  QString getEndianessString();
   inline QString getWidth() { return width;}
   inline int getPurpose() { return purpose;}
   QString getPurposeString();
@@ -58,6 +61,7 @@ public :
   inline void setName(const QString& _name) { name = _name; }
   inline void setWidth(const QString& _width) { width = _width; }
   inline void setType(int _type) { type = _type;}
+  inline void setEndianess(int _endianess) { endianess = _endianess;}
   inline void setType(const QString& _type) { type = typeFromString(_type);}
   void setPurpose(int _purpose);
   void setDirection(int _direction);
@@ -77,10 +81,12 @@ public :
 
 protected:
   QString name;
-  int type;
-  QString width;
   int purpose;
   int direction;
+  int type;
+  QString width;
+  int endianess;
+
 
   AbstractBlock* owner;
   /*!
index 948388add9821dd50e0e7a5e3d88abeb56d2e9c0..017401a6409d6e56b1d9a0218f452b77424817b0 100644 (file)
@@ -10,7 +10,7 @@ ConnectedInterface::ConnectedInterface(AbstractBlock* _owner) : AbstractInterfac
       \r
 }\r
 \r
-ConnectedInterface::ConnectedInterface(AbstractBlock* _owner, const QString& _name, const QString& _type, const QString& _width, int _direction, int _purpose) : AbstractInterface(_owner, _name, _type, _width, _direction, _purpose) {\r
+ConnectedInterface::ConnectedInterface(AbstractBlock* _owner, const QString& _name, int _direction, int _purpose, const QString& _type, const QString& _width) : AbstractInterface(_owner, _name, _direction, _purpose, _type, _width) {\r
   connectedFrom = NULL;\r
   outputPattern = NULL;\r
 }\r
index 7866a8fa957370169b8471e0a9cdf704f6e560a1..64afb9e410555c9277edef3c94314b8f3ec89875 100644 (file)
@@ -23,7 +23,7 @@ class ConnectedInterface : public AbstractInterface {
 public :
 
   ConnectedInterface(AbstractBlock* _owner);
-  ConnectedInterface(AbstractBlock* _owner, const QString& _name, const QString& _type, const QString& _width, int _direction, int _purpose);
+  ConnectedInterface(AbstractBlock* _owner, const QString& _name, int _direction, int _purpose, const QString& _type, const QString& _width);
   ~ConnectedInterface();
   
   // getters
index 1df7ded886818894ff2e439f91ba701ae8853515..a416f956083249311fa4679113c952dbcd40348c 100644 (file)
@@ -421,7 +421,7 @@ void Dispatcher::duplicateInterfaceItem(InterfaceItem *item) {
   // creating control interface if needed
   if (refI->getAssociatedIface() != NULL) {
     QString ctlName = cloneIface->getName()+"_enb";
-    ReferenceInterface* ctlIface = new ReferenceInterface(refB,ctlName,"boolean","1",cloneIface->getDirection(), AbstractInterface::Control, 1);
+    ReferenceInterface* ctlIface = new ReferenceInterface(refB,ctlName,cloneIface->getDirection(), AbstractInterface::Control,"boolean","1", AbstractInterface::LittleEndian, 1);
     refB->addInterface(ctlIface);
     if (! ctlIface->setAssociatedIface(cloneIface)) {
       cerr << "Abnormal case while cloning an interface and creating its associated control interface" << endl;
index 534625d06bd0d65cab0e7344c0bf6a6fbb6170a5..7be000ab2466d833a38899deea126a3904176551 100644 (file)
@@ -142,7 +142,15 @@ void FunctionalBlock::createPatterns() throw(Exception) {
   }\r
   catch(Exception e) {\r
     throw(e);\r
-  }  \r
+  }\r
+  cout << "PP of " << qPrintable(name) << endl;\r
+  QMapIterator<AbstractInterface*,QList<char>* > it(productionPattern);\r
+  while (it.hasNext()) {\r
+    it.next();\r
+    QList<char>* pat = it.value();\r
+    foreach(char c, *pat) cout << (int)c;\r
+    cout << endl;\r
+  }\r
 }\r
 \r
 void FunctionalBlock::createDelta() throw(Exception) {\r
@@ -308,7 +316,7 @@ QList<char>* FunctionalBlock::expandPattern(const QString& patternIn) throw(Exce
   int offset = 0;  \r
   QList<char>* patternOut = new QList<char>();\r
   try {\r
-    expandPatternRecur(p,&offset, patternOut); \r
+    patternOut->append(expandPatternRecur(p,&offset));\r
   }\r
   catch(Exception e) {\r
     throw(e);\r
@@ -317,28 +325,30 @@ QList<char>* FunctionalBlock::expandPattern(const QString& patternIn) throw(Exce
   return patternOut;\r
 }\r
 \r
-void FunctionalBlock::expandPatternRecur(const QString& patternIn, int *offset, QList<char>* patternOut) throw(Exception) {  \r
+QList<char> FunctionalBlock::expandPatternRecur(const QString& patternIn, int *offset) throw(Exception) {\r
   \r
+  QList<char> patternOut;\r
+\r
   while ((*offset < patternIn.size()) && (patternIn.at(*offset) != ')')) {\r
     \r
     QChar c = patternIn.at(*offset);\r
     if (c == '(') {\r
       *offset += 1;\r
       try {\r
-        expandPatternRecur(patternIn,offset, patternOut);\r
+        patternOut.append(expandPatternRecur(patternIn,offset));\r
       }\r
       catch(Exception e) {\r
         throw(e);\r
       }\r
     }\r
     else if (c == '0') {\r
-      patternOut->append(0);\r
+      patternOut.append(0);\r
     }\r
     else if (c == '1') {\r
-      patternOut->append(1);\r
+      patternOut.append(1);\r
     }\r
     else if (c == 'X') {\r
-      patternOut->append(-1);\r
+      patternOut.append(-1);\r
     }\r
     else if (c == '{') {\r
       *offset += 1;\r
@@ -358,11 +368,11 @@ void FunctionalBlock::expandPatternRecur(const QString& patternIn, int *offset,
         throw(e);\r
       }\r
       // repeat just the last value in currentGroup\r
-      char last = patternOut->last();      \r
+      char last = patternOut.last();\r
       //cout << "repeat last char " << repeat << " times : " << (int)last << endl;\r
       \r
       for(int i=1;i<(int)repeat;i++) {\r
-        patternOut->append(last);\r
+        patternOut.append(last);\r
       }\r
     }    \r
     *offset += 1;\r
@@ -391,11 +401,12 @@ void FunctionalBlock::expandPatternRecur(const QString& patternIn, int *offset,
     foreach (char c, currentGroup) cout <<(int)c;\r
     cout << endl;  \r
     */\r
-    QList<char> single = *patternOut;\r
+    QList<char> single = patternOut;\r
     for(int i=1;i<(int)repeat;i++) {\r
-      patternOut->append(single);\r
+      patternOut.append(single);\r
     }    \r
   }  \r
+  return patternOut;\r
 }\r
 \r
 double FunctionalBlock::evaluateExpression(const QString& expression) throw(Exception) {\r
@@ -722,6 +733,132 @@ void FunctionalBlock::computeOutputPattern(int nbExec) throw(Exception) {
   }  \r
 }\r
 \r
+/*\r
+\r
+void FunctionalBlock::computeOutputPattern(int nbExec) throw(Exception) {\r
+  static QString fctName = "FunctionalBlock::computeOutputPattern()";\r
+#ifdef DEBUG_FCTNAME\r
+  cout << "call to " << qPrintable(fctName) << endl;\r
+#endif\r
+\r
+  // case 1: the block is a generator for which output pattern\r
+  //   must be computed for a nbExec following executions\r
+\r
+  if (nbExec > 0) {\r
+    cout << "computing output pattern of " << qPrintable(name) << " for " << nbExec << " executions" << endl;\r
+    foreach(AbstractInterface* iface, getControlOutputs()) {\r
+      FunctionalInterface* connIface = AI_TO_FUN(iface);\r
+      // create output pattern\r
+      QList<char>* pp = productionPattern.value(connIface);\r
+      QList<char>* pattern = new QList<char>(*pp);\r
+      for(int i=1;i<nbExec;i++) pattern->append(*pp);\r
+      // assign pattern to interface\r
+      connIface->setOutputPattern(pattern);\r
+      // store it in QMap\r
+      outputPattern.insert(connIface,pattern);\r
+    }\r
+  }\r
+  else {\r
+    cout << "computing output pattern of " << qPrintable(name) << endl;\r
+\r
+    // in case of inputPattern not created, do it\r
+    if (lengthIP <= 0) {\r
+      // collect the input patterns for each input\r
+      try {\r
+        createInputPattern();\r
+      }\r
+      catch(Exception e) {\r
+        throw(e);\r
+      }\r
+      cout << "input pattern array initialized with min. len " << lengthIP << endl;\r
+    }\r
+\r
+    // initialize the output pattern\r
+    lengthOP = 0;\r
+    foreach(AbstractInterface* iface, getControlOutputs()) {\r
+      FunctionalInterface* connIface = AI_TO_FUN(iface);\r
+      lengthOP = lengthIP+productionPattern.value(connIface)->size();\r
+      QList<char>* pattern = new QList<char>();\r
+      for(int i=0;i<lengthOP;i++) pattern->append(0);\r
+      connIface->setOutputPattern(pattern);\r
+      outputPattern.insert(connIface,pattern);\r
+    }\r
+    cout << "output pattern array initialized" << endl;\r
+\r
+    int clock = 0;\r
+    nbExec = 0;\r
+    // search for the beginning of the first execution.\r
+    while ((clock < lengthIP) && (! isValidDataGroup(inputPattern,clock))) clock++;\r
+    cout << "found 1st exec clock: " << clock << endl;\r
+\r
+    while (clock < lengthIP) {\r
+      // initialize counters for current execution.\r
+      int p = 0; // index in production pattern\r
+      int o = 0; // clock+o will give the clock cycle of each output group\r
+      int cip = 0; // clock+cip give the clock cycle of an input group\r
+      int ccp = 0; // ccp give a column in the consumptio pattern\r
+      int nip = 0; // number of input data groups already consumed during the current execution, used while exploring IP\r
+      int ncp = 0; // number of input data groups already consumed during the current execution, used while exploring CP\r
+      bool cannotCompleteExec = false;\r
+      for(int m=0;m<productionCounter.size();m++) {\r
+        // search for the first production in PP\r
+        while (!isValidDataGroup(productionPattern,p)) {\r
+          p += 1;\r
+          o += 1;\r
+        }\r
+        int gap = 0; // count the number of extra null columns\r
+        // search for PC(m) valid input group in IP\r
+        while (nip < productionCounter.at(m)) {\r
+          if (clock+cip < lengthIP) {\r
+            if (isValidDataGroup(inputPattern,clock+cip)) nip += 1;\r
+            cip += 1;\r
+            gap += 1;\r
+          }\r
+          else {\r
+            cannotCompleteExec = true;\r
+            break;\r
+          }\r
+        }\r
+\r
+        if (cannotCompleteExec) break; // no need to go further since the next search of input data group will lead to go outside inputPattern\r
+\r
+        // search for PC(m) valid input group in IP\r
+        while (ncp < productionCounter.at(m)) {\r
+          if (isValidDataGroup(consumptionPattern,ccp)) ncp += 1;\r
+          ccp += 1;\r
+          gap -= 1;\r
+        }\r
+        o += gap; // to take into acocunt of extra null columns\r
+        combinePatterns(productionPattern,p,outputPattern,clock+o);\r
+        p += 1;\r
+        o += 1;\r
+      }\r
+\r
+      if (cannotCompleteExec) break; // no need to go further since the next search of input data group will lead to go outside inputPattern\r
+\r
+      // current exec. taken into accunt\r
+      nbExec += 1;\r
+\r
+      // search for the next exec.\r
+      clock += 1;\r
+      nip = 0;\r
+      while ((clock < lengthIP) && (nip < delta)) {\r
+        if (isValidDataGroup(inputPattern,clock)) nip += 1;\r
+        if (nip < delta) clock += 1;\r
+      }\r
+      cout << "found exec " << nbExec << " at clock: " << clock << endl;\r
+    }\r
+    // find the last valid output data group\r
+    while(! isValidDataGroup(outputPattern,lengthOP-1)) {\r
+      removeDataGroup(outputPattern,lengthOP-1);\r
+      lengthOP -= 1;\r
+    }\r
+\r
+    // clear input pattern\r
+    clearInputPattern();\r
+  }\r
+}\r
+*/\r
 bool FunctionalBlock::samePatterns(const QMap<AbstractInterface*, QList<char>* >& patternSrc, int srcCol, const QMap<AbstractInterface*, QList<char>* >& patternDest, int destCol) {\r
   \r
   if (patternSrc.size() != patternDest.size()) return false;\r
index 440c1543bd0f3bc7a454ea7148f1bfa09ab0284e..b3cfbc4e85af716f2a0153cc3efdaf98e5c9b654 100644 (file)
@@ -75,7 +75,7 @@ private:
   \r
   double evaluateExpression(const QString& expression) throw(Exception);\r
   QList<char>* expandPattern(const QString& patternIn) throw(Exception);\r
-  void expandPatternRecur(const QString& patternIn, int* offset, QList<char> *patternOut)  throw(Exception);\r
+  QList<char> expandPatternRecur(const QString& patternIn, int* offset)  throw(Exception);\r
   /*!\r
    * \brief samePatterns\r
    * \param patternSrc the pattern that must be tested with patternDest (is patternDest == patternDest)  \r
index 145b86a28dc9fab5f115443402f9a7530827cab3..2fc093e324dc1ecff92335bc973250f6a1a58fe5 100644 (file)
@@ -17,6 +17,7 @@ FunctionalInterface::FunctionalInterface(AbstractBlock* _owner, ReferenceInterfa
   reference = _reference;\r
 \r
   name = reference->getName();\r
+  endianess = reference->getEndianess();\r
   width = reference->getWidth();\r
   direction = reference->getDirection();\r
   purpose = reference->getPurpose();  \r
index ecc6ba72ab6e9235ecc830ec16fa962ac8c1bc95..e87c14ab4541eea789c6f74f291c2d2a35140c37 100644 (file)
@@ -2,7 +2,7 @@
 #include "FunctionalInterface.h"
 #include "GroupBlock.h"
 
-GroupInterface::GroupInterface(AbstractBlock* _owner, const QString& _name, int _direction, int _purpose) throw(Exception) : ConnectedInterface(_owner,_name,"inherited","",_direction,_purpose) {
+GroupInterface::GroupInterface(AbstractBlock* _owner, const QString& _name, int _direction, int _purpose) throw(Exception) : ConnectedInterface(_owner,_name,_direction,_purpose,"inherited","") {
   if (! _owner->isGroupBlock()) throw(Exception(BLOCK_INVALID_TYPE));
 
   connectedFrom = NULL;
index 48de27e6ff76b81a85c5c035337ad98aa3169564..778a0b04a3a7614a8416508c30d6d10915686a62 100644 (file)
@@ -38,6 +38,17 @@ GroupScene::~GroupScene() {
   groupItem = NULL;
 }
 
+/*
+void GroupScene::mouseMoveEvent(QGraphicsSceneMouseEvent *event) {
+
+  //QGraphicsScene::mouseMoveEvent(event);
+  
+  QPointF p = event->scenePos();
+  cout << p.x() << "," << p.y() << endl;
+
+}
+*/
+
 void GroupScene::setSelectedInterface(int id, InterfaceItem* iface) {
   if ((id < 1)|| (id > 2)) return;
   selectedInterfaces[id-1] = iface;
@@ -211,11 +222,11 @@ void GroupScene::unselecteInterfaces() {
 
   if (selectedInterfaces[0] != NULL) {
     selectedInterfaces[0]->selected = false;
-    selectedInterfaces[0] == NULL;
+    selectedInterfaces[0] = NULL;
   }
   if (selectedInterfaces[1] != NULL) {
     selectedInterfaces[1]->selected = false;
-    selectedInterfaces[1] == NULL;
+    selectedInterfaces[1] = NULL;
   }
 }
 
index a691a6dec8d7bdd41fe1590b0023c9e2dcd3ec07..e32dd53509fde5a45c9e7be884e5b27cf5d57bdb 100644 (file)
@@ -47,6 +47,8 @@ public:
   GroupScene(GroupScene* _parentScene, GroupWidget* _window, Dispatcher* _dispatcher, Parameters* _params, bool topScene = false, QObject *parent = 0);
   ~GroupScene();
 
+  //void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
+
   // attributes getters
   inline GroupItem* getGroupItem() {return groupItem;}
   inline QList<BoxItem*> getBoxItems() { return boxItems; }
index a31db67b0f28c807c21b910f6cb979037f70876a..037c64459ff8185ee0f05be5f09fd7c404019c55 100644 (file)
@@ -215,6 +215,7 @@ void ReferenceBlock::loadInterfaces(QDomElement &elt) throw(Exception) {
   QString nameStr;
   QString typeStr;
   QString widthStr;
+  QString endianStr;
   QString purposeStr;
   int purpose;
   QString multStr;
@@ -232,6 +233,17 @@ void ReferenceBlock::loadInterfaces(QDomElement &elt) throw(Exception) {
     nameStr = eltInput.attribute("name","none");
     typeStr = eltInput.attribute("type","none");
     widthStr = eltInput.attribute("width","none");
+    endianStr = eltInput.attribute("endian","none");
+    int endianess;
+    if ((endianStr == "none") || (endianStr == "little")) {
+      endianess = AbstractInterface::LittleEndian;
+    }
+    else if (endianStr == "big") {
+      endianess = AbstractInterface::BigEndian;
+    }
+    else {
+      throw (Exception(BLOCKFILE_CORRUPTED));
+    }
     purposeStr = eltInput.attribute("purpose","none");
     cout << "block : " << this->getName().toStdString() << endl;
     cout << "purpose for " << nameStr.toStdString() << " : " << purposeStr.toStdString() << endl;
@@ -240,7 +252,7 @@ void ReferenceBlock::loadInterfaces(QDomElement &elt) throw(Exception) {
     multStr = eltInput.attribute("multiplicity","none");
     mult = ReferenceInterface::translateMultiplicity(multStr);
 
-    inter = new ReferenceInterface(this,nameStr,typeStr,widthStr,AbstractInterface::Input, purpose, mult);
+    inter = new ReferenceInterface(this,nameStr,AbstractInterface::Input, purpose, typeStr, widthStr, endianess, mult);
     inputs.append(inter);
   }
   // getting each control
@@ -252,7 +264,7 @@ void ReferenceBlock::loadInterfaces(QDomElement &elt) throw(Exception) {
     AbstractInterface* dataIface = getIfaceFromName(nameStr);
     if (dataIface == NULL) throw (Exception(BLOCKFILE_CORRUPTED));
     nameStr = dataIface->getName()+"_enb";
-    inter = new ReferenceInterface(this,nameStr,"boolean","1",AbstractInterface::Input, AbstractInterface::Control, 1);
+    inter = new ReferenceInterface(this,nameStr,AbstractInterface::Input, AbstractInterface::Control,"boolean","1", AbstractInterface::LittleEndian, 1);
     if (!inter->setAssociatedIface(dataIface)) {
       throw (Exception(BLOCKFILE_CORRUPTED));      
     }
@@ -267,12 +279,23 @@ void ReferenceBlock::loadInterfaces(QDomElement &elt) throw(Exception) {
     nameStr = eltOutput.attribute("name","none");
     typeStr = eltOutput.attribute("type","none");
     widthStr = eltOutput.attribute("width","none");
+    endianStr = eltOutput.attribute("endian","none");
+    int endianess;
+    if ((endianStr == "none") || (endianStr == "little")) {
+      endianess = AbstractInterface::LittleEndian;
+    }
+    else if (endianStr == "big") {
+      endianess = AbstractInterface::BigEndian;
+    }
+    else {
+      throw (Exception(BLOCKFILE_CORRUPTED));
+    }
     purposeStr = eltOutput.attribute("purpose","none");
     purpose = ReferenceInterface::translatePurpose(purposeStr);
     multStr = eltOutput.attribute("multiplicity","none");
     mult = ReferenceInterface::translateMultiplicity(multStr);
 
-    inter = new ReferenceInterface(this,nameStr,typeStr,widthStr,AbstractInterface::Output, purpose, mult);
+    inter = new ReferenceInterface(this,nameStr,AbstractInterface::Output, purpose,typeStr,widthStr, endianess, mult);
     outputs.append(inter);
   }
   // getting each control
@@ -284,7 +307,7 @@ void ReferenceBlock::loadInterfaces(QDomElement &elt) throw(Exception) {
     AbstractInterface* dataIface = getIfaceFromName(nameStr);
     if (dataIface == NULL) throw (Exception(BLOCKFILE_CORRUPTED));
     nameStr = dataIface->getName()+"_enb";
-    inter = new ReferenceInterface(this,nameStr,"boolean","1",AbstractInterface::Output, AbstractInterface::Control, 1);
+    inter = new ReferenceInterface(this,nameStr,AbstractInterface::Output, AbstractInterface::Control,"boolean","1",AbstractInterface::LittleEndian, 1);
     if (!inter->setAssociatedIface(dataIface)) {
       throw (Exception(BLOCKFILE_CORRUPTED));      
     }
@@ -300,12 +323,23 @@ void ReferenceBlock::loadInterfaces(QDomElement &elt) throw(Exception) {
     nameStr = eltBidir.attribute("name","none");
     typeStr = eltBidir.attribute("type","none");
     widthStr = eltBidir.attribute("width","none");
+    endianStr = eltBidir.attribute("endian","none");
+    int endianess;
+    if ((endianStr == "none") || (endianStr == "little")) {
+      endianess = AbstractInterface::LittleEndian;
+    }
+    else if (endianStr == "big") {
+      endianess = AbstractInterface::BigEndian;
+    }
+    else {
+      throw (Exception(BLOCKFILE_CORRUPTED));
+    }
     purposeStr = eltBidir.attribute("purpose","none");
     purpose = ReferenceInterface::translatePurpose(purposeStr);
     multStr = eltBidir.attribute("multiplicity","none");
     mult = ReferenceInterface::translateMultiplicity(multStr);
 
-    inter = new ReferenceInterface(this,nameStr,typeStr,widthStr,AbstractInterface::InOut, purpose, mult);
+    inter = new ReferenceInterface(this,nameStr,AbstractInterface::InOut, purpose,typeStr,widthStr, endianess, mult);
     bidirs.append(inter);
   }
 }
@@ -320,11 +354,11 @@ void ReferenceBlock::createInterfaceForParameters() throw(Exception){
       cout << "creating interface for parameter wb " << qPrintable(p->getName()) << endl;
       
       if (p->getWBAccess() == BlockParameter::Read) {
-        iface = new ReferenceInterface(this,p->getName(),p->getTypeString(),p->getWidth(), AbstractInterface::Output, AbstractInterface::Wishbone,1);
+        iface = new ReferenceInterface(this,p->getName(), AbstractInterface::Output, AbstractInterface::Wishbone, p->getTypeString(),p->getWidth(), AbstractInterface::LittleEndian, 1);
         outputs.append(iface);        
       }
       else if (p->getWBAccess() == BlockParameter::Write) {
-        iface = new ReferenceInterface(this,p->getName(),p->getTypeString(),p->getWidth(), AbstractInterface::Input, AbstractInterface::Wishbone,1);
+        iface = new ReferenceInterface(this,p->getName(), AbstractInterface::Input, AbstractInterface::Wishbone,p->getTypeString(),p->getWidth(),AbstractInterface::LittleEndian,1);
         inputs.append(iface);                
       }
       else {
index a0f50cad9cc22018db0cffa8555ac6eaf052a76d..89369525932d8f0aac2afa1f46215b3631f4e41b 100644 (file)
@@ -7,12 +7,14 @@ ReferenceInterface::ReferenceInterface(AbstractBlock* _owner)  throw(Exception)
 }
 
 ReferenceInterface::ReferenceInterface(AbstractBlock* _owner,
-                                       const QString& _name, const QString&_type,
-                                       const QString& _width,
+                                       const QString& _name,
                                        int _direction,
                                        int _purpose,
+                                       const QString& _type,
+                                       const QString& _width,
+                                       int _endianess,
                                        int _multiplicity)
-throw (Exception) : AbstractInterface(_owner, _name, _type, _width, _direction, _purpose) {
+throw (Exception) : AbstractInterface(_owner, _name, _direction, _purpose, _type, _width) {
 
   if (_owner->isReferenceBlock()) throw(Exception(BLOCK_INVALID_TYPE));
 
index d5219b625f8875d30c50f4efa748b4cb07f3bb48..1ba21ed2f295c5977a1630c7bb0b48a01bc07bf1 100644 (file)
@@ -19,7 +19,7 @@ class ReferenceInterface : public AbstractInterface {
 public :  
 
   ReferenceInterface(AbstractBlock *_owner) throw(Exception);
-  ReferenceInterface(AbstractBlock* _owner, const QString& _name, const QString& _type, const QString& _width, int _direction, int _purpose, int _multiplicity=1) throw (Exception);
+  ReferenceInterface(AbstractBlock* _owner, const QString& _name, int _direction, int _purpose, const QString& _type, const QString& _width, int _endianess = LittleEndian, int _multiplicity=1) throw (Exception);
 
   // getters
   inline int getMultiplicity() { return multiplicity; }  
index ea8991e16c80a3d2f784d1e5c8e5a2b78e363f3e..42fff3a7467329d58791e259f6d91b6f8acc37ed 100644 (file)
@@ -1,56 +1,66 @@
 #include "VHDLConverter.h"\r
+#include "BlockParameterGeneric.h"\r
+#include "BlockParameterUser.h"\r
+#include "BlockParameterWishbone.h"\r
+#include "ReferenceInterface.h"\r
 \r
 using namespace std;\r
 using namespace Qt;\r
 \r
 VHDLConverter::VHDLConverter(QWidget *parent) : QWidget(parent) {\r
-    \r
-    QLabel *labelAppli, *lblBrief, *lblDesc, *lblName, *lblPort, *lblGen;\r
-\r
-    loadBut = new QPushButton("load VHDL");\r
-    genBut = new QPushButton("generate XML");\r
-    QHBoxLayout *widgetLayout = new QHBoxLayout;\r
-    QVBoxLayout *left = new QVBoxLayout;\r
-    QVBoxLayout *right = new QVBoxLayout;\r
-\r
-    scrollDataPort = new QScrollArea;\r
-    scrollDataPort->setWidgetResizable(true);\r
-    twDataPort = new QTableWidget(this);\r
-    scrollDataPort->setWidget(twDataPort);\r
-    scrollGenerics = new QScrollArea;\r
-    scrollGenerics->setWidgetResizable(true);\r
-    twGenerics = new QTableWidget(this);\r
-    scrollGenerics->setWidget(twGenerics);\r
-    teName = new QTextEdit;\r
-    teBrief = new QTextEdit;\r
-    teDesc = new QTextEdit;\r
-    lblName = new QLabel("Block name :");\r
-    lblBrief = new QLabel("Enter a brief description : ");\r
-    lblDesc = new QLabel("Enter a detailled description : ");\r
-    lblPort = new QLabel("Ports :");\r
-    lblGen = new QLabel("Generics :");\r
-\r
-    connect(loadBut, SIGNAL(clicked()),this, SLOT(loadVHDLFile()));\r
-    connect(genBut, SIGNAL(clicked()), this, SLOT(generateXml()));\r
-\r
-    left->addWidget(loadBut);\r
-    left->addWidget(lblPort);\r
-    left->addWidget(scrollDataPort);\r
-    left->addWidget(lblGen);\r
-    left->addWidget(scrollGenerics);\r
-\r
-    right->addWidget(lblName);\r
-    right->addWidget(teName);\r
-    right->addWidget(lblBrief);\r
-    right->addWidget(teBrief);\r
-    right->addWidget(lblDesc);\r
-    right->addWidget(teDesc);\r
-    right->addWidget(genBut);\r
-\r
-    widgetLayout->addLayout(left);\r
-    widgetLayout->addLayout(right);\r
-    setLayout(widgetLayout);\r
-    show();\r
+\r
+  QLabel *labelAppli, *lblBrief, *lblDesc, *lblEntName, *lblLongName, *lblPort, *lblGen;\r
+\r
+  loadBut = new QPushButton("load VHDL");\r
+  genBut = new QPushButton("generate XML");\r
+  QHBoxLayout *widgetLayout = new QHBoxLayout;\r
+  QVBoxLayout *left = new QVBoxLayout;\r
+  QVBoxLayout *right = new QVBoxLayout;\r
+\r
+  scrollPorts = new QScrollArea;\r
+  scrollPorts->setWidgetResizable(true);\r
+  twPorts = new QTableWidget(this);\r
+  twPorts->setColumnCount(5);\r
+  scrollPorts->setWidget(twPorts);\r
+  scrollGenerics = new QScrollArea;\r
+  scrollGenerics->setWidgetResizable(true);\r
+  twGenerics = new QTableWidget(this);\r
+  twGenerics->setColumnCount(3);\r
+  scrollGenerics->setWidget(twGenerics);\r
+  editEntityName = new QLineEdit;\r
+  editLongName = new QLineEdit;\r
+  teBrief = new QTextEdit;\r
+  teDesc = new QTextEdit;\r
+  lblEntName = new QLabel("Entity name :");\r
+  lblLongName = new QLabel("Block long name :");\r
+  lblBrief = new QLabel("Enter a brief description : ");\r
+  lblDesc = new QLabel("Enter a detailled description : ");\r
+  lblPort = new QLabel("Ports :");\r
+  lblGen = new QLabel("Generics :");\r
+\r
+  connect(loadBut, SIGNAL(clicked()),this, SLOT(loadVHDLFile()));\r
+  connect(genBut, SIGNAL(clicked()), this, SLOT(generateXml()));\r
+\r
+  left->addWidget(loadBut);\r
+  left->addWidget(lblPort);\r
+  left->addWidget(scrollPorts);\r
+  left->addWidget(lblGen);\r
+  left->addWidget(scrollGenerics);\r
+\r
+  right->addWidget(lblEntName);\r
+  right->addWidget(editEntityName);\r
+  right->addWidget(lblLongName);\r
+  right->addWidget(editLongName);\r
+  right->addWidget(lblBrief);\r
+  right->addWidget(teBrief);\r
+  right->addWidget(lblDesc);\r
+  right->addWidget(teDesc);\r
+  right->addWidget(genBut);\r
+\r
+  widgetLayout->addLayout(left);\r
+  widgetLayout->addLayout(right);\r
+  setLayout(widgetLayout);\r
+  show();\r
 }\r
 \r
 VHDLConverter::~VHDLConverter() {\r
@@ -61,7 +71,7 @@ QString VHDLConverter::skipBlankAndComments(QTextStream &in) {
   \r
   QString line = "";\r
   \r
- // skipping blank/comment lines \r
+  // skipping blank/comment lines\r
   while ( (line.isEmpty()) || ((line.at(0) == '-') && (line.at(1) == '-')) ) {\r
     if (in.atEnd()) {\r
       return "";\r
@@ -82,7 +92,7 @@ QString VHDLConverter::readLibraries(QTextStream &in) throw(Exception) {
   line = skipBlankAndComments(in);\r
   if (line == "") {\r
     throw(Exception(VHDLFILE_CORRUPTED));\r
-  }    \r
+  }\r
   \r
   while (! line.contains("entity",Qt::CaseInsensitive)) {\r
     \r
@@ -94,21 +104,21 @@ QString VHDLConverter::readLibraries(QTextStream &in) throw(Exception) {
       QString libName = matchLib.captured(1);\r
       libName = libName.toLower();\r
       \r
-      cout << "matching library: " << qPrintable(libName) << endl;      \r
+      cout << "matching library: " << qPrintable(libName) << endl;\r
       \r
-      if (!packages.contains(libName)) {        \r
-        packages.insert(libName,new QList<QString>());      \r
-      }      \r
+      if (!packages.contains(libName)) {\r
+        packages.insert(libName,new QList<QString>());\r
+      }\r
     }\r
     else if (matchPack.hasMatch()) {\r
       cout << "matching packages" << endl;\r
       \r
       QString libName = matchPack.captured(1);\r
-      QString packName = matchPack.captured(2);      \r
+      QString packName = matchPack.captured(2);\r
       \r
       libName = libName.toLower();\r
-      packName = packName.toLower();      \r
-            \r
+      packName = packName.toLower();\r
+\r
       if (libName == "work") {\r
         if (!packages.contains("work")) {\r
           packages.insert("work",new QList<QString>());\r
@@ -122,9 +132,8 @@ QString VHDLConverter::readLibraries(QTextStream &in) throw(Exception) {
       else if (!packages.contains(libName)) throw(Exception(VHDLFILE_CORRUPTED));\r
       \r
       QList<QString>* lstPack = packages.value(libName);\r
-      QString s = libName + "." + packName;      \r
-      lstPack->append(s);\r
-      cout << qPrintable(s) << endl;\r
+      lstPack->append(packName);\r
+      cout << qPrintable(packName) << endl;\r
       \r
     }\r
     \r
@@ -150,7 +159,7 @@ QString VHDLConverter::readEntity(QTextStream &in) throw(Exception) {
     throw(Exception(VHDLFILE_CORRUPTED));\r
   }\r
 \r
-  while (! line.contains("architecture",Qt::CaseInsensitive)) {\r
+  while (! line.startsWith("architecture",Qt::CaseInsensitive)) {\r
 \r
     QRegularExpressionMatch matchGen = rxGen.match(line);\r
     QRegularExpressionMatch matchPorts = rxPorts.match(line);\r
@@ -202,8 +211,12 @@ void VHDLConverter::readGenerics(QTextStream &in) throw(Exception) {
       cout << "matching generic value" << endl;\r
       QString genName = matchGen.captured(1);\r
       QString genType = matchGen.captured(2);\r
+      genType = genType.toLower();\r
       QString genValue = matchGen.captured(4);\r
+      genValue = genValue.toLower();\r
       cout << qPrintable(genName) << " " << qPrintable(genType) << " " << qPrintable(genValue) << endl;\r
+      BlockParameter* param = new BlockParameterGeneric(block,genName,genType,genValue);\r
+      block->addParameter(param);\r
     }\r
 \r
     line = skipBlankAndComments(in);\r
@@ -211,13 +224,15 @@ void VHDLConverter::readGenerics(QTextStream &in) throw(Exception) {
       throw(Exception(VHDLFILE_CORRUPTED));\r
     }\r
     line = line.remove(' ');\r
-     cout << "read line = " << qPrintable(line) << endl;\r
+    cout << "read line = " << qPrintable(line) << endl;\r
   }\r
 }\r
 \r
 void VHDLConverter::readPorts(QTextStream &in) throw(Exception) {\r
 \r
-  QRegularExpression rxPort("^([^:]+):(in|out|inout)([a-zA-Z0-9_]+)(\\([^:)]*\\))?(:=)?([^;]*);?$",QRegularExpression::CaseInsensitiveOption);\r
+  QRegularExpression rxPort("^([^ :]+) ?: ?(in|out|inout) ([a-zA-Z0-9_]+) ?(\\([^:)]*\\))? ?(:=)? ?([^;]*) ?;?$",QRegularExpression::CaseInsensitiveOption);\r
+  QRegularExpression rxSizeDownTo("^\\((.*) downto (.*)\\)$",QRegularExpression::CaseInsensitiveOption);\r
+  QRegularExpression rxSizeTo("^\\((.*) to (.*)\\)$",QRegularExpression::CaseInsensitiveOption);\r
 \r
   QString line = "";\r
 \r
@@ -225,10 +240,11 @@ void VHDLConverter::readPorts(QTextStream &in) throw(Exception) {
   if (line == "") {\r
     throw(Exception(VHDLFILE_CORRUPTED));\r
   }\r
-  line = line.remove(' ');\r
 \r
   while (! line.contains(QRegExp("^\\);$"))) {\r
 \r
+    line = line.toLower();\r
+\r
     QRegularExpressionMatch matchPort = rxPort.match(line);\r
 \r
     if (matchPort.hasMatch()) {\r
@@ -238,20 +254,118 @@ void VHDLConverter::readPorts(QTextStream &in) throw(Exception) {
       QString portType = matchPort.captured(3);\r
       QString portSize = matchPort.captured(4);\r
       QString portValue = matchPort.captured(6);\r
-      cout << qPrintable(portName) << " " << qPrintable(portDir) << " " << qPrintable(portType) << " " << qPrintable(portSize) << " " << qPrintable(portValue) << endl;\r
+      cout << qPrintable(portName) << "|" << qPrintable(portDir) << "|" << qPrintable(portType) << "|" << qPrintable(portSize) << "|" << qPrintable(portValue) << endl;\r
+      ReferenceInterface* iface = NULL;\r
+      bool isOk = true;\r
+      int direction = AbstractInterface::AnyDirection;\r
+      int endianess = AbstractInterface::LittleEndian;\r
+      int purpose = AbstractInterface::AnyPurpose;\r
+\r
+      QString widthStr = "a";\r
+\r
+      if (portDir == "in") {\r
+        direction = AbstractInterface::Input;\r
+      }\r
+      else if (portDir == "out") {\r
+        direction = AbstractInterface::Output;\r
+      }\r
+      else if (portDir == "inout") {\r
+        direction = AbstractInterface::InOut;\r
+      }\r
+      else {\r
+        cerr << "Unknown direction for port " << qPrintable(portName) << endl;\r
+        isOk = false;\r
+      }\r
+      QString typeStr="";\r
+      if (portType == "std_logic") {\r
+        typeStr = "boolean";\r
+        widthStr="1";\r
+      }\r
+      else if (portType == "std_logic_vector") {\r
+\r
+        if (portSize.contains("downto")) {\r
+          QRegularExpressionMatch matchSize = rxSizeDownTo.match(portSize);\r
+          endianess = AbstractInterface::LittleEndian;\r
+          if (matchSize.captured(2) != "0") {\r
+            cerr << "invalid size for port " << qPrintable(portName) << endl;\r
+            isOk = false;\r
+          }\r
+          else {\r
+            widthStr = matchSize.captured(1);\r
+          }\r
+        }\r
+        else if (portSize.contains("to")) {\r
+          QRegularExpressionMatch matchSize = rxSizeTo.match(portSize);\r
+          endianess = AbstractInterface::BigEndian;\r
+          if (matchSize.captured(1) != "0") {\r
+            cerr << "invalid size for port " << qPrintable(portName) << endl;\r
+            isOk = false;\r
+          }\r
+          else {\r
+            widthStr = matchSize.captured(2);\r
+          }\r
+        }\r
+        else {\r
+          cerr << "invalid size for port " << qPrintable(portName) << endl;\r
+          isOk = false;\r
+        }\r
+\r
+        QVariant msb(widthStr);\r
+        bool ok;\r
+        int size = msb.toInt(&ok);\r
+        if (ok) {\r
+          typeStr = "natural";\r
+        }\r
+        else {\r
+          typeStr ="expression";\r
+        }\r
+      }\r
+      else {\r
+        cerr << "Unknown type for port " << qPrintable(portName) << endl;\r
+        isOk = false;\r
+      }\r
+\r
+      if (isOk) {\r
+        // trying to guess the purpose from name\r
+        if ((portName.contains("clk"))||(portName.contains("clock"))) {\r
+          purpose = AbstractInterface::Clock;\r
+        }\r
+        else if ((portName.contains("rst"))||(portName.contains("reset"))) {\r
+          purpose = AbstractInterface::Reset;\r
+        }\r
+        else if (portName.endsWith("_enb")) {\r
+          purpose = AbstractInterface::Control;\r
+        }\r
+        else if (portName.startsWith("wb_")) {\r
+          purpose = AbstractInterface::Wishbone;\r
+        }\r
+        else {\r
+          purpose = AbstractInterface::Data;\r
+        }\r
+        iface = new ReferenceInterface(block,portName,direction,purpose,typeStr,widthStr,endianess,1);\r
+        block->addInterface(iface);\r
+      }\r
     }\r
 \r
     line = skipBlankAndComments(in);\r
     if (line == "") {\r
       throw(Exception(VHDLFILE_CORRUPTED));\r
     }\r
-    line = line.remove(' ');\r
-     cout << "read line = " << qPrintable(line) << endl;\r
+    cout << "read line = " << qPrintable(line) << endl;\r
   }\r
 \r
 }\r
 \r
 void VHDLConverter::readArchitecture(QTextStream &in) throw(Exception) {\r
+\r
+  QString line = "";\r
+  QString endLine = "end "+archName;\r
+\r
+  while (!line.startsWith(endLine)) {\r
+    line = in.readLine();\r
+    if (!line.isEmpty()) line = line.simplified();\r
+    archLines.append(line);\r
+  }\r
   \r
 }\r
 \r
@@ -260,258 +374,502 @@ void VHDLConverter::readArchitecture(QTextStream &in) throw(Exception) {
 // You can edit the descriptions in the right, one for the brief description, the other for the detailled.\r
 void VHDLConverter::loadVHDLFile() {\r
 \r
-    QString line, portName, portType, portId, genName, genType, genValue;\r
-    QStringList *portNameList, *portTypeList, *portIdList, *genNameList, *genTypeList, *genValueList;\r
-    cpt = 0;\r
-    twDataPort->setColumnCount(3);\r
-    twDataPort->setRowCount(cpt);\r
-    twGenerics->setColumnCount(3);\r
-    twGenerics->setRowCount(cpt);\r
-    portNameList = new QStringList;\r
-    portTypeList = new QStringList;\r
-    portIdList = new QStringList;\r
-    genNameList = new QStringList;\r
-    genTypeList = new QStringList;\r
-    genValueList = new QStringList;\r
-\r
-\r
-    fileName = QFileDialog::getOpenFileName(this,\r
-                                            tr("Open File"), QDir::homePath() , tr("Files (*.txt *.vhd)"));\r
-    QFile file(fileName);\r
-\r
-    if(!file.open(QIODevice::ReadOnly | QIODevice::Text))\r
-        return;\r
-    QTextStream ts(&file);\r
-    \r
-    QString entityLine = "";\r
-    try {\r
-      entityLine = readLibraries(ts);\r
+  QString fileName = QFileDialog::getOpenFileName(this,\r
+                                                  tr("Open File"), QDir::homePath() , tr("Files (*.txt *.vhd)"));\r
+  QFile file(fileName);\r
+\r
+  if(!file.open(QIODevice::ReadOnly | QIODevice::Text))\r
+    return;\r
+  QTextStream ts(&file);\r
+\r
+  block = new ReferenceBlock(fileName);\r
+\r
+  QString entityLine = "";\r
+  try {\r
+    entityLine = readLibraries(ts);\r
+  }\r
+  catch(Exception e) {\r
+    cerr << "VHDL seems to be malformed" << endl;\r
+    return;\r
+  }\r
+\r
+  QRegularExpression rxEnt("^entity (.+) is$",QRegularExpression::CaseInsensitiveOption);\r
+  QRegularExpressionMatch matchEnt = rxEnt.match(entityLine);\r
+  if (!matchEnt.hasMatch()) {\r
+    cerr << "VHDL seems to be malformed" << endl;\r
+    return;\r
+  }\r
+  entityName = matchEnt.captured(1);\r
+  cout << "found entity " << qPrintable(entityName) << endl;\r
+\r
+  QString archLine = "";\r
+  try {\r
+    archLine = readEntity(ts);\r
+  }\r
+  catch(Exception e) {\r
+    cerr << "VHDL seems to be malformed" << endl;\r
+    return;\r
+  }\r
+\r
+  QRegularExpression rxArch("^architecture (.+) of (.+) is$",QRegularExpression::CaseInsensitiveOption);\r
+  QRegularExpressionMatch matchArch = rxArch.match(archLine);\r
+  if (!matchArch.hasMatch()) {\r
+    cerr << "VHDL seems to be malformed" << endl;\r
+    return;\r
+  }\r
+  archName = matchArch.captured(1);\r
+  cout << "found arch " << qPrintable(archName) << " for entity " << qPrintable(matchArch.captured(2)) << endl;\r
+\r
+  try {\r
+    readArchitecture(ts);\r
+  }\r
+  catch(Exception e) {\r
+    cerr << "VHDL seems to be malformed" << endl;\r
+    return;\r
+  }\r
+  file.close();\r
+\r
+\r
+  QList<BlockParameter*> lstGenerics = block->getGenericParameters();\r
+  twGenerics->setRowCount(lstGenerics.size());\r
+  int i = 0;\r
+  foreach(BlockParameter* param, lstGenerics) {\r
+    twGenerics->setItem(i, 0, new QTableWidgetItem(param->getName()));\r
+    twGenerics->setItem(i, 1, new QTableWidgetItem(param->getTypeString()));\r
+    twGenerics->setItem(i, 2, new QTableWidgetItem(param->getValue().toString()));\r
+    i++;\r
+  }\r
+\r
+  lstIface = block->getInputs();\r
+  lstIface.append(block->getOutputs());\r
+  lstIface.append(block->getBidirs());\r
+\r
+  twPorts->setRowCount(lstIface.size());\r
+  purposeDelegate = new IfacePurposeDelegate();\r
+  twPorts->setItemDelegateForColumn(3,purposeDelegate);\r
+\r
+  i=0;\r
+  foreach(AbstractInterface* iface, lstIface) {\r
+    twPorts->setItem(i, 0, new QTableWidgetItem(iface->getName()));\r
+    twPorts->setItem(i, 1, new QTableWidgetItem(iface->getDirectionString()));\r
+    QString widthStr="";\r
+    if (iface->getType() == AbstractInterface::Boolean) {\r
+      widthStr = "std_logic";\r
     }\r
-    catch(Exception e) {\r
-      cerr << "VHDL seems to be malformed" << endl;\r
-      return;\r
+    else {\r
+      widthStr = "std_logic_vector(";\r
+      if (iface->getEndianess() == AbstractInterface::LittleEndian) {\r
+        widthStr += iface->getWidth();\r
+        widthStr += " downto 0)";\r
+      }\r
+      else {\r
+        widthStr += "0 to ";\r
+        widthStr += iface->getWidth();\r
+        widthStr += ")";\r
+      }\r
+    }\r
+    twPorts->setItem(i, 2, new QTableWidgetItem(widthStr));\r
+\r
+    QTableWidgetItem* item = new QTableWidgetItem(iface->getPurposeString());\r
+    twPorts->setItem(i, 3, item);\r
+\r
+    // trying to find wihch other iface this one controls\r
+    QString assoInter = "N/A";\r
+    if (iface->getPurpose() == AbstractInterface::Control) {\r
+      QString name = iface->getName();\r
+      name.remove(name.size()-4,4); // remove _enb at the end\r
+      foreach(AbstractInterface* inter, lstIface) {\r
+        if ((inter != iface) && (inter->getName().contains(name))) {\r
+          assoInter = inter->getName();\r
+          iface->setAssociatedIface(inter);\r
+        }\r
+      }\r
+    }\r
+    QTableWidgetItem* itemAsso = new QTableWidgetItem(assoInter);\r
+    if (iface->getPurpose() != AbstractInterface::Control) {\r
+      itemAsso->setFlags(Qt::NoItemFlags);\r
     }\r
+    twPorts->setItem(i, 4, itemAsso);\r
 \r
-    QRegularExpression rxEnt("^entity[\\s\\t]+(.+)[\\s\\t]+is$",QRegularExpression::CaseInsensitiveOption);\r
-    QRegularExpressionMatch matchEnt = rxEnt.match(entityLine);\r
-    if (!matchEnt.hasMatch()) {\r
-      cerr << "VHDL seems to be malformed" << endl;\r
-      return;\r
+    i++;\r
+  }\r
+\r
+  connect(twPorts,SIGNAL(itemChanged(QTableWidgetItem*)),this,SLOT(searchAssociatedPort(QTableWidgetItem*)));\r
+\r
+  //file.close();\r
+\r
+  //scrollPorts->setWidget(twPorts);\r
+  editEntityName->setText(entityName);\r
+  editLongName->setText(entityName);\r
+  return;\r
+}\r
+\r
+void VHDLConverter::searchAssociatedPort(QTableWidgetItem *item) {\r
+\r
+  bool ok;\r
+  int col = item->column();\r
+  int row = item->row();\r
+\r
+  // searching for the real interface object linked to the item\r
+  AbstractInterface* iface = NULL;\r
+  QString ifaceName = twPorts->item(row,0)->text();\r
+  foreach(AbstractInterface* inter,lstIface) {\r
+    if (inter->getName() == ifaceName) {\r
+      iface = inter;\r
+      break;\r
     }\r
-    entityName = matchEnt.captured(1);\r
-    cout << "foudn entity " << qPrintable(entityName) << endl;\r
+  }\r
+\r
+  if (col == 3) {\r
 \r
-    QString archLine = "";\r
-    try {\r
-      archLine = readEntity(ts);\r
+    QString assoInter = "N/A";\r
+    iface->setAssociatedIface(NULL);\r
+\r
+    cout << qPrintable(item->text()) << endl;\r
+\r
+    if (item->text() == "data") {\r
+      iface->setPurpose(AbstractInterface::Data);\r
+    }\r
+    else if (item->text() == "control") {\r
+      iface->setPurpose(AbstractInterface::Control);\r
+    }\r
+    else if (item->text() == "clock") {\r
+      iface->setPurpose(AbstractInterface::Clock);\r
+    }\r
+    else if (item->text() == "reset") {\r
+      iface->setPurpose(AbstractInterface::Reset);\r
     }\r
-    catch(Exception e) {\r
-      cerr << "VHDL seems to be malformed" << endl;\r
-      return;\r
+    else if (item->text() == "wishbone") {\r
+      iface->setPurpose(AbstractInterface::Wishbone);\r
     }\r
 \r
-    \r
-    /*\r
-    while (!ts.atEnd())\r
-    {\r
-        line = ts.readLine();\r
-        if(rxComment->indexIn(line) != -1) {\r
-            line = rxComment->cap(1);\r
-        }\r
+    if (item->text() == "control") {\r
 \r
-        if(rxEnt->indexIn(line)!= -1) {\r
-\r
-            entName = rxEnt->cap(1);\r
-            teName->setText(entName);\r
-            QSize size = teName->document()->size().toSize();\r
-            teName->setMaximumSize(size);\r
-\r
-            while(rxEnd->indexIn(line) == -1) {\r
-                line = ts.readLine();\r
-                if(rxComment->indexIn(line) != -1) {\r
-                    line = rxComment->cap(1);\r
-                }\r
-                if(rxComma->indexIn(line) != -1) {\r
-                    line = rxComma->cap(1);\r
-                }\r
-                if(rxGeneric->indexIn(line) != -1) {\r
-                    while(rxEndGen->indexIn(line) == -1) {\r
-                        line = ts.readLine();\r
-                        if(rxComment->indexIn(line) != -1) {\r
-                            line = rxComment->cap(1);\r
-                        }\r
-                        if(rxComma->indexIn(line) != -1) {\r
-                            line = rxComma->cap(1);\r
-                        }\r
-                        if(rxGen->indexIn(line) != -1) {\r
-                            genName = rxGen->cap(1).simplified();\r
-                            genType = rxGen->cap(2).simplified();\r
-                            genValue = rxGen->cap(3).simplified();\r
-\r
-                            genNameList->append(genName);\r
-                            genTypeList->append(genType);\r
-                            genValueList->append(genValue);\r
-                        }\r
-                    }\r
-                }\r
-                if(rxPort->indexIn(line) != -1) {\r
-                    if(rxComment->indexIn(line) != -1) {\r
-                        line = rxComment->cap(1);\r
-                    }\r
-                    if(rxComma->indexIn(line) != -1) {\r
-                        line = rxComma->cap(1);\r
-                    }\r
-                    portName = rxPort->cap(1).simplified();\r
-                    portId = rxPort->cap(2).simplified();\r
-                    portType = rxPort->cap(3).simplified();\r
-                    portNameList->append(portName);\r
-                    portIdList->append(portId);\r
-                    portTypeList->append(portType);\r
-                }\r
-            }\r
+      QString name = twPorts->item(row,0)->text();\r
+      name.remove(name.size()-4,4); // remove _enb at the end\r
+      int i=0;\r
+      foreach(AbstractInterface* inter, lstIface) {\r
+        if ((i != row) && (inter->getName().contains(name))) {\r
+          assoInter = inter->getName();\r
+          iface->setAssociatedIface(inter);\r
         }\r
+        i++;\r
+      }\r
     }\r
-    */\r
 \r
-    twGenerics->setRowCount(genNameList->size());\r
-    for(int i = 0; i < genNameList->size(); i++) {\r
-        twGenerics->setItem(i, 0, new QTableWidgetItem(genNameList->at(i)));\r
-        twGenerics->setItem(i, 1, new QTableWidgetItem(genTypeList->at(i)));\r
-        twGenerics->setItem(i, 2, new QTableWidgetItem(genValueList->at(i)));\r
+    QTableWidgetItem* itemAsso = twPorts->item(row,4);\r
+    itemAsso->setText(assoInter);\r
+\r
+    if (item->text() == "control") {\r
+      itemAsso->setFlags(Qt::ItemIsEnabled|Qt::ItemIsEditable);\r
     }\r
-    twDataPort->setRowCount(portNameList->size());\r
-    for(int i = 0; i < portNameList->size(); i++) {\r
-        twDataPort->setItem(i, 0, new QTableWidgetItem(portIdList->at(i)));\r
-        twDataPort->setItem(i, 1, new QTableWidgetItem(portNameList->at(i)));\r
-        twDataPort->setItem(i, 2, new QTableWidgetItem(portTypeList->at(i)));\r
+    else {\r
+      itemAsso->setFlags(Qt::NoItemFlags);\r
     }\r
+  }\r
+  else if (col == 4) {\r
 \r
-    file.close();\r
-    scrollDataPort->setWidget(twDataPort);\r
-    return;\r
+    QString nameAsso = item->text();\r
+    if (nameAsso == "N/A") return;\r
+\r
+    bool found = false;\r
+\r
+    int i=0;\r
+    foreach(AbstractInterface* inter, lstIface) {\r
+      if ((i != row) && (inter->getName().contains(nameAsso))) {\r
+        found = true;\r
+        iface->setAssociatedIface(inter);\r
+      }\r
+    }\r
+    if (!found) {\r
+      QTableWidgetItem* itemAsso = twPorts->item(row,4);\r
+      itemAsso->setText("N/A");\r
+    }\r
+  }\r
 }\r
 \r
-// This function gets the informations in the table and the descriptions, and creates a XML file with this content\r
-void VHDLConverter::generateXml() {\r
-/*\r
-    QString portName, portType, portId, genName, genType, genValue;\r
-    QStringList *portNameList, *portTypeList, *portIdList, *genNameList, *genTypeList, *genValueList;\r
-    int x, y, width;\r
-    brief = teBrief->toPlainText();\r
-    desc = teDesc->toPlainText();\r
-    entName = teName->toPlainText();\r
-\r
-    portNameList = new QStringList;\r
-    portTypeList = new QStringList;\r
-    portIdList = new QStringList;\r
-    genNameList = new QStringList;\r
-    genTypeList = new QStringList;\r
-    genValueList = new QStringList;\r
-    for(int i = 0; i < twGenerics->rowCount(); i++) {\r
-        genNameList->append(twGenerics->item(i,0)->text());\r
-        genTypeList->append(twGenerics->item(i,1)->text());\r
-        genValueList->append(twGenerics->item(i,2)->text());\r
-    }\r
-\r
-    for(int i = 0; i < twDataPort->rowCount(); i++) {\r
-        portIdList->append(twDataPort->item(i,0)->text());\r
-        portNameList->append(twDataPort->item(i,1)->text());\r
-        portTypeList->append(twDataPort->item(i,2)->text());\r
-    }\r
-\r
-    QDomDocument doc (entName);\r
-    QDomElement block = doc.createElement("block");\r
-    block.setAttribute("name",entName);\r
-    block.setAttribute("version", "0.1");\r
-    doc.appendChild(block);\r
-\r
-    QDomElement comments = doc.createElement("comments");\r
-    QDomElement category = doc.createElement("caterory");\r
-    category.setAttribute("ids","");\r
-    comments.appendChild(category);\r
-\r
-    QDomElement eBrief = doc.createElement("brief");\r
-    if(!brief.isEmpty()) {\r
-        QDomText txtBrief = doc.createTextNode(brief);\r
-        eBrief.appendChild(txtBrief);\r
-        comments.appendChild(eBrief);\r
-    }\r
-    QDomElement eDesc = doc.createElement("description");\r
-    if(!desc.isEmpty()) {\r
-        QDomText txtDesc = doc.createTextNode(desc);\r
-        eDesc.appendChild(txtDesc);\r
-        comments.appendChild(eDesc);\r
-    }\r
-    block.appendChild(comments);\r
-\r
-    QDomElement parameters = doc.createElement("parameters");\r
-    QDomElement interfaces = doc.createElement("interfaces");\r
+void VHDLConverter::generateRefXml(QDomDocument& doc) {\r
+\r
+  QDomElement eBlock = doc.createElement("block");\r
+  eBlock.setAttribute("version", "0.1");\r
+  doc.appendChild(eBlock);\r
+\r
+  // creating infos\r
+  QDomElement infos = doc.createElement("informations");\r
+  eBlock.appendChild(infos);\r
+\r
+  QDomElement eName = doc.createElement("name");\r
+  QDomText tName = doc.createTextNode(editLongName->text());\r
+  eName.appendChild(tName);\r
+  infos.appendChild(eName);\r
+\r
+  QDomElement category = doc.createElement("category");\r
+  category.setAttribute("ids","");\r
+  infos.appendChild(category);\r
+\r
+  QDomElement eDesc = doc.createElement("description");\r
+  QString brief = teBrief->toPlainText();\r
+  QString detailed = teDesc->toPlainText();\r
+  QDomElement eBrief = doc.createElement("brief");\r
+  if(!brief.isEmpty()) {\r
+    QDomText txtBrief = doc.createTextNode(brief);\r
+    eBrief.appendChild(txtBrief);\r
+    eDesc.appendChild(eBrief);\r
+  }\r
+  QDomElement eDetailed = doc.createElement("detailed");\r
+  if(!detailed.isEmpty()) {\r
+    QDomText txtDetailed = doc.createTextNode(detailed);\r
+    eDetailed.appendChild(txtDetailed);\r
+    eDesc.appendChild(eDetailed);\r
+  }\r
+  infos.appendChild(eDesc);\r
+\r
+\r
+\r
+  QDomElement parameters = doc.createElement("parameters");\r
+  eBlock.appendChild(parameters);\r
+\r
+  QList<BlockParameter*> lstGenerics = block->getGenericParameters();\r
+  foreach(BlockParameter* param, lstGenerics) {\r
+    QDomElement parameter = doc.createElement("parameter");\r
+    parameter.setAttribute("name",param->getName());\r
+    parameter.setAttribute("type",param->getTypeString());\r
+    parameter.setAttribute("value",param->getValue().toString());\r
+    parameter.setAttribute("context","generic");\r
+    parameters.appendChild(parameter);\r
+  }\r
+\r
+  QDomElement interfaces = doc.createElement("interfaces");\r
+  eBlock.appendChild(interfaces);\r
+\r
+  if (block->getInputs().size() > 0) {\r
     QDomElement inputs = doc.createElement("inputs");\r
-    QDomElement outputs = doc.createElement("outputs");\r
-    QDomElement bidirs = doc.createElement("bidirs");\r
-    block.appendChild(parameters);\r
-    block.appendChild(interfaces);\r
     interfaces.appendChild(inputs);\r
+    foreach(AbstractInterface* iface, block->getInputs()) {\r
+\r
+      if (iface->getPurpose() != AbstractInterface::Control) {\r
+        QDomElement input = doc.createElement("input");\r
+        input.setAttribute("name",iface->getName());\r
+        input.setAttribute("type",iface->getTypeString());\r
+        input.setAttribute("width",iface->getWidth());\r
+        input.setAttribute("multiplicity","1");\r
+        input.setAttribute("purpose",iface->getPurposeString());\r
+        input.setAttribute("endian",iface->getEndianessString());\r
+        inputs.appendChild(input);\r
+      }\r
+      else {\r
+        QDomElement ctl = doc.createElement("control");\r
+        ctl.setAttribute("iface",iface->getAssociatedIface()->getName());\r
+        inputs.appendChild(ctl);\r
+      }\r
+    }\r
+  }\r
+\r
+  if (block->getOutputs().size() > 0) {\r
+    QDomElement outputs = doc.createElement("outputs");\r
     interfaces.appendChild(outputs);\r
+    foreach(AbstractInterface* iface, block->getOutputs()) {\r
+      if (iface->getPurpose() != AbstractInterface::Control) {\r
+        QDomElement output = doc.createElement("output");\r
+        output.setAttribute("name",iface->getName());\r
+        output.setAttribute("type",iface->getTypeString());\r
+        output.setAttribute("width",iface->getWidth());\r
+        output.setAttribute("multiplicity","1");\r
+        output.setAttribute("purpose",iface->getPurposeString());\r
+        output.setAttribute("endian",iface->getEndianessString());\r
+        outputs.appendChild(output);\r
+      }\r
+      else {\r
+        QDomElement ctl = doc.createElement("control");\r
+        ctl.setAttribute("iface",iface->getAssociatedIface()->getName());\r
+        outputs.appendChild(ctl);\r
+      }\r
+    }\r
+  }\r
+\r
+  if (block->getBidirs().size() > 0) {\r
+    QDomElement bidirs = doc.createElement("bidirs");\r
     interfaces.appendChild(bidirs);\r
+    foreach(AbstractInterface* iface, block->getBidirs()) {\r
+      if (iface->getPurpose() != AbstractInterface::Control) {\r
+        QDomElement bidir = doc.createElement("bidir");\r
+        bidir.setAttribute("name",iface->getName());\r
+        bidir.setAttribute("type",iface->getTypeString());\r
+        bidir.setAttribute("width",iface->getWidth());\r
+        bidir.setAttribute("multiplicity","1");\r
+        bidir.setAttribute("purpose",iface->getPurposeString());\r
+        bidir.setAttribute("endian",iface->getEndianessString());\r
+        bidirs.appendChild(bidir);\r
+      }\r
+      else {\r
+        QDomElement ctl = doc.createElement("control");\r
+        ctl.setAttribute("iface",iface->getAssociatedIface()->getName());\r
+        bidirs.appendChild(ctl);\r
+      }\r
+    }\r
+  }\r
+}\r
 \r
-    for(int i = 0; i < twGenerics->rowCount(); i++) {\r
-        genName = genNameList->at(i);\r
-        genType = genTypeList->at(i);\r
-        genValue = genValueList->at(i);\r
-        QDomElement parameter = doc.createElement("parameter");\r
-        parameter.setAttribute("name",genName);\r
-        parameter.setAttribute("type",genType);\r
-        parameter.setAttribute("value",genValue);\r
-        parameter.setAttribute("context","generic");\r
-        parameters.appendChild(parameter);\r
-    }\r
-\r
-    for(int i = 0; i < portIdList->size(); i++) {\r
-        portId = portIdList->at(i);\r
-        portName = portNameList->at(i);\r
-        portType = portTypeList->at(i);\r
-        if(rxWidth->indexIn(portType) != -1) {\r
-            x = rxWidth->cap(1).toInt();\r
-            y = rxWidth->cap(3).toInt();\r
-            if(x < y)\r
-                width = y - x + 1;\r
-            else if(x > y)\r
-                width = x - y + 1;\r
-            else\r
-                width = 1;\r
-        }\r
+void VHDLConverter::generateImplXml(QDomDocument& doc) {\r
 \r
-        if(portId.compare("in", CaseInsensitive) == 0) {\r
-            QDomElement input = doc.createElement("input");\r
-            input.setAttribute("name",portName);\r
-            input.setAttribute("width", width);\r
-            inputs.appendChild(input);\r
-        }\r
-        else if(portId.compare("out", CaseInsensitive) == 0) {\r
-            QDomElement output = doc.createElement("output");\r
-            output.setAttribute("name",portName);\r
-            output.setAttribute("width", width);\r
-            outputs.appendChild(output);\r
-        }\r
-        else if(portId.compare("inout", CaseInsensitive) == 0) {\r
-            QDomElement bidir = doc.createElement("bidir");\r
-            bidir.setAttribute("name",portName);\r
-            bidir.setAttribute("width", width);\r
-            bidirs.appendChild(bidir);\r
-        }\r
+  QRegularExpression rxPack("^([^.]+)[.](.+)$",QRegularExpression::CaseInsensitiveOption);\r
+\r
+  QDomElement eBlock = doc.createElement("block_impl");\r
+  eBlock.setAttribute("ref_name", entityName+".xml");\r
+  eBlock.setAttribute("ref_md5", "");\r
+  doc.appendChild(eBlock);\r
+\r
+  // creating infos\r
+  QDomElement comments = doc.createElement("comments");\r
+  eBlock.appendChild(comments);\r
+\r
+  QDomElement author = doc.createElement("author");\r
+  author.setAttribute("firstname","");\r
+  author.setAttribute("lastname","");\r
+  author.setAttribute("mail","");\r
+  comments.appendChild(author);\r
+\r
+  QDomElement date = doc.createElement("date");\r
+  date.setAttribute("creation","");\r
+  comments.appendChild(date);\r
+\r
+  QString brief = teBrief->toPlainText();\r
+  QString detailed = teDesc->toPlainText();\r
+  QDomElement eDesc = doc.createElement("description");\r
+  if(!brief.isEmpty()) {\r
+    QDomText txtBrief = doc.createTextNode(brief);\r
+    eDesc.appendChild(txtBrief);\r
+    comments.appendChild(eDesc);\r
+  }\r
+  QDomElement eNotes = doc.createElement("notes");\r
+  if(!detailed.isEmpty()) {\r
+    QDomText txtDetailed = doc.createTextNode(detailed);\r
+    eNotes.appendChild(txtDetailed);\r
+    comments.appendChild(eNotes);\r
+  }\r
+\r
+  QDomElement libs = doc.createElement("libraries");\r
+  eBlock.appendChild(libs);\r
+\r
+  QHashIterator<QString,QList<QString>* > it(packages);\r
+\r
+  while (it.hasNext()) {\r
+    it.next();\r
+    QString libName = it.key();\r
+    cout << qPrintable(libName) << endl;\r
+    QList<QString>* packList = it.value();\r
+    QDomElement lib = doc.createElement("library");\r
+    lib.setAttribute("name", libName);\r
+    libs.appendChild(lib);\r
+\r
+    foreach(QString packName, *packList) {\r
+      QDomElement pack = doc.createElement("package");\r
+      lib.appendChild(pack);\r
+      QRegularExpressionMatch matchPack = rxPack.match(packName);\r
+      if (matchPack.hasMatch()) {\r
+        QString name = matchPack.captured(1);\r
+        QString subName = matchPack.captured(2);\r
+        name = name.toLower();\r
+        subName = subName.toLower();\r
+        pack.setAttribute("name",name);\r
+        pack.setAttribute("use",subName);\r
+      }\r
+    }\r
+  }\r
+\r
+  QDomElement archi = doc.createElement("architecture");\r
+  eBlock.appendChild(archi);\r
+  QDomText tName = doc.createTextNode("");\r
+  foreach(QString line, archLines) {\r
+    tName.appendData(line+"\n");\r
+  }\r
+  archi.appendChild(tName);\r
+\r
+  QDomElement patterns = doc.createElement("patterns");\r
+  eBlock.appendChild(patterns);\r
+  QDomElement delta = doc.createElement("delta");\r
+  delta.setAttribute("value","to_define");\r
+  patterns.appendChild(delta);\r
+  QDomElement cons = doc.createElement("consumption");\r
+  foreach(AbstractInterface* iface, lstIface) {\r
+    if ((iface->getDirection() == AbstractInterface::Input) && (iface->getPurpose() == AbstractInterface::Control)) {\r
+      QDomElement input = doc.createElement("input");\r
+      input.setAttribute("name",iface->getName());\r
+      input.setAttribute("pattern","to_define");\r
+      cons.appendChild(input);\r
+    }\r
+  }\r
+  patterns.appendChild(cons);\r
+  QDomElement prod = doc.createElement("production");\r
+  prod.setAttribute("counter","to_define");\r
+  foreach(AbstractInterface* iface, lstIface) {\r
+    if ((iface->getDirection() == AbstractInterface::Output) && (iface->getPurpose() == AbstractInterface::Control)) {\r
+      QDomElement output = doc.createElement("output");\r
+      output.setAttribute("name",iface->getName());\r
+      output.setAttribute("pattern","to_define");\r
+      prod.appendChild(output);\r
     }\r
+  }\r
+  patterns.appendChild(prod);\r
+}\r
 \r
-    fileName = QFileDialog::getOpenFileName(this, tr("Open File"),\r
-                                            "C:", tr("Files (*.xml)"));\r
-    QFile file(fileName);\r
-    if(!file.open(QIODevice::WriteOnly | QIODevice::Text))\r
-        return;\r
-    QTextStream ts(&file);\r
-    doc.save(ts,QDomNode::EncodingFromTextStream);\r
-    file.close();\r
+void VHDLConverter::replaceSignalNames(QString& line) {\r
+  foreach(AbstractInterface* iface, lstIface) {\r
+    QString pattern = iface->getName() + "([^a-zA-Z0-9_])";\r
+    QString repl = "@{"+iface->getName()+"}\\1";\r
+    QRegularExpression rxPort(pattern,QRegularExpression::CaseInsensitiveOption);\r
+    line.replace(rxPort,repl);\r
+  }\r
+\r
+}\r
+\r
+void VHDLConverter::updateArchitecture() {\r
+  QRegularExpression rxLT("<=",QRegularExpression::CaseInsensitiveOption);\r
+  QRegularExpression rxGT("=>",QRegularExpression::CaseInsensitiveOption);\r
+  foreach(QString line, archLines) {\r
+    replaceSignalNames(line);\r
+    line.replace(rxLT,"&lt;=");\r
+    line.replace(rxGT,"=&gt;");\r
+\r
+    cout << qPrintable(line) << endl;\r
+  }\r
+}\r
+\r
+// This function gets the informations in the table and the descriptions, and creates a XML file with this content\r
+void VHDLConverter::generateXml() {\r
+\r
+\r
+  updateArchitecture();\r
+\r
+  // creating reference xml\r
+  QDomDocument docRef(entityName);\r
+  generateRefXml(docRef);\r
+\r
+  // creating implementation xml\r
+  QDomDocument docImpl(entityName);\r
+  generateImplXml(docImpl);\r
+\r
+  QString dir = QFileDialog::getExistingDirectory(this,tr("Save file in"),".",QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);\r
+\r
+  QString fileName = dir + "/"+ entityName + ".xml";\r
+\r
+  QFile fileRef(fileName);\r
+  if(!fileRef.open(QIODevice::WriteOnly | QIODevice::Text)) {\r
+    cerr << "Cannot save in " << qPrintable(fileName) << endl;\r
+    return;\r
+  }\r
+  QTextStream tsRef(&fileRef);\r
+  docRef.save(tsRef,QDomNode::EncodingFromTextStream);\r
+  fileRef.close();\r
+\r
+  fileName = dir + "/"+ entityName + "_impl.xml";\r
+  QFile fileImpl(fileName);\r
+  if(!fileImpl.open(QIODevice::WriteOnly | QIODevice::Text)) {\r
+    cerr << "Cannot save in " << qPrintable(fileName) << endl;\r
+    return;\r
+  }\r
+  QTextStream tsImpl(&fileImpl);\r
+  docImpl.save(tsImpl,QDomNode::EncodingFromTextStream);\r
+  fileImpl.close();\r
 \r
-    QLabel *popup = new QLabel("Votre fichier XML est rempli");\r
-    popup->show();\r
-    */\r
 }\r
index ff9defe91b8c26a9d72fd978fc1e344cb9f0f07c..fd576497e31514f59c0d147e2b047619a7fe9fbb 100644 (file)
@@ -12,6 +12,8 @@
 \r
 #include "Parameters.h"\r
 #include "Exception.h"\r
+#include "ReferenceBlock.h"\r
+#include "IfacePurposeDelegate.h"\r
 \r
 class VHDLConverter : public QWidget {\r
     Q_OBJECT\r
@@ -25,33 +27,31 @@ private:
 \r
     // entity related\r
     QString entityName;\r
+    QString longName;\r
+    QLineEdit* editEntityName;\r
+    QLineEdit* editLongName;\r
 \r
-    // clk & rst ports related\r
-    QTextEdit* clkNameEdit;\r
-    QTextEdit* rstNameEdit;\r
-    QComboBox* clkCombo;\r
-    QComboBox* rstCombo;\r
-    \r
     // data ports related\r
-    QScrollArea *scrollDataPort;        \r
-    QTableWidget* twDataPort;\r
-    \r
-    // wishbone ports related\r
-    QScrollArea *scrollWBPort;        \r
-    QTableWidget* twWBPort;\r
+    QScrollArea *scrollPorts;\r
+    QTableWidget* twPorts;\r
+    IfacePurposeDelegate* purposeDelegate;\r
     \r
     // generics related\r
     QScrollArea* scrollGenerics;    \r
     QTableWidget* twGenerics;\r
+        \r
+    // arch related\r
+    QString archName;\r
+    QList<QString> archLines;\r
     \r
-    int cptIn, cptOut, cptInout, cpt;        \r
-    QString fileName, txt, s, entName, brief, desc;        \r
-    \r
-    QHash<QString,QList<QString>* > packages;\r
+    // libraries related\r
+    QHash<QString,QList<QString>* > packages;        \r
     \r
-    QWidget *wid;\r
-    \r
-    QTextEdit *teBrief, *teDesc, *teName;\r
+    QTextEdit *teBrief, *teDesc;\r
+\r
+    ReferenceBlock* block;\r
+\r
+    QList<AbstractInterface*> lstIface;\r
 \r
     QString readLibraries(QTextStream& in) throw(Exception);\r
     QString readEntity(QTextStream& in) throw(Exception);\r
@@ -60,12 +60,21 @@ private:
     void readArchitecture(QTextStream& in) throw(Exception);\r
     \r
     QString skipBlankAndComments(QTextStream& in);\r
-    \r
+\r
+    void generateRefXml(QDomDocument& doc);\r
+    void generateImplXml(QDomDocument& doc);\r
+    void replaceSignalNames(QString& line);\r
+\r
+    void updateArchitecture();\r
+\r
 signals:\r
 \r
 public slots:\r
     void loadVHDLFile();\r
     void generateXml();\r
+\r
+private slots:\r
+    void searchAssociatedPort(QTableWidgetItem* item);\r
 };\r
 \r
 #endif // __VHDLCONVERTER_H__\r
index 8b995819353205c0ec27fb5ff04f0daa2d55f54e..25bfe7cfa782d237429da8c5614a5e4020f99f0e 100755 (executable)
@@ -1,10 +1,10 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE QtCreatorProject>
-<!-- Written by QtCreator 4.2.0, 2017-10-15T20:15:50. -->
+<!-- Written by QtCreator 4.2.0, 2017-12-08T17:50:18. -->
 <qtcreator>
  <data>
   <variable>EnvironmentId</variable>
-  <value type="QByteArray">{c8006d66-d34f-42be-ad10-d0207752286d}</value>
+  <value type="QByteArray">{3701e197-5b6c-48ea-9e98-a6cf6de18672}</value>
  </data>
  <data>
   <variable>ProjectExplorer.Project.ActiveTarget</variable>
@@ -61,7 +61,7 @@
   <valuemap type="QVariantMap">
    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop</value>
    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop</value>
-   <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{2c9bf876-3476-44eb-8065-1f0844704dda}</value>
+   <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{ed04208c-8774-456b-99b9-4a02094ca7a4}</value>
    <value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
    <value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
    <value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
index 1dbb3f165ea95e168b25ae18a013c4c68022c46b..22c212e7e4f75507f96e83920e13fe52ade83c1e 100755 (executable)
@@ -12,6 +12,8 @@ BlockImplementation.h
 BlockImplementation.cpp
 GroupScene.cpp
 GroupScene.h
+IfacePurposeDelegate.cpp
+IfacePurposeDelegate.h
 ReferenceBlock.cpp
 ReferenceBlock.h
 AbstractInterface.h
index 981529b9c41d5e2a3318a9f04c92a6269645b35f..a19842c413a39d9e986c6bfc4931ee56df87b6eb 100644 (file)
@@ -28,7 +28,7 @@
     <consumption>
       <input name="data_i_enb" pattern="1{$nb_data}" />
     </consumption>
-    <production counter="{2:$nb_data-1:1},$nb_data-1">
+    <production counter="{2:$nb_data-1:1},$nb_data">
       <output name="data_o_enb" pattern="0001{$nb_data}" />
     </production>
   </patterns>
index 8d7e2961d56bd85ffbb01b9c46757ecec06b736a..7ae3752f89f21899892faa7c712aebefe21a0e54 100644 (file)
Binary files a/lib/implementations/impls.bmf and b/lib/implementations/impls.bmf differ
diff --git a/lib/implementations/rgb216bits_impl.xml b/lib/implementations/rgb216bits_impl.xml
deleted file mode 100644 (file)
index d5203d5..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
-<block_impl ref_name="rgb216bits.xml" ref_md5="">
-  <comments>
-    <author firstname="stephane" lastname="Domas" mail="sdomas@univ-fcomte.fr" />
-    <date creation="2015-04-27" />
-    <related_files list=""/>
-    <description>
-      This component converts a RGB pixel into a 16 bits pixel
-    </description>
-    <notes>
-      No notes
-    </notes>
-  </comments>
-
-  <libraries>
-    <library name="IEEE">
-      <package name="std_logic_1164" use="all"/>
-      <package name="numeric_std" use="all"/>
-    </library>
-  </libraries>
-
-  <architecture>
-    
-  </architecture>
-
-  <patterns>
-    <delta value="1" />
-    <consumption>
-      <input name="r_i_enb" pattern="1" />
-      <input name="g_i_enb" pattern="1" />
-      <input name="b_i_enb" pattern="1" />      
-    </consumption>
-    <production counter="1">
-      <output name="pix_o_enb" pattern="01" />
-    </production>
-  </patterns>
-</block_impl>
index b46c2d8876b7dfe40050871fcc0e8c5419c405cb..47af6ade9ba435ed8390fbeaf9ba0b178a2eb8c9 100644 (file)
@@ -33,6 +33,8 @@ COMMON-OBJ = $(BUILDPATH)/AbstractBlock.o \
           $(BUILDPATH)/ArithmeticEvaluator.o \
           $(BUILDPATH)/VHDLConverter.o \
           $(BUILDPATH)/moc_VHDLConverter.o \
+          $(BUILDPATH)/IfacePurposeDelegate.o \
+          $(BUILDPATH)/moc_IfacePurposeDelegate.o \
           $(BUILDPATH)/GroupWidget.o \
           $(BUILDPATH)/moc_GroupWidget.o \
           $(BUILDPATH)/Parameters.o \