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

Private GIT Repository
finished VHDL gen
[blast.git] / GroupInterface.cpp
index 67577900b5bb85c22261ff96d2d779b430924b25..c611ecfbb22f03796fc4aec3d097d9a424bfd8f8 100644 (file)
@@ -2,10 +2,14 @@
 #include "FunctionalInterface.h"
 #include "GroupBlock.h"
 
 #include "FunctionalInterface.h"
 #include "GroupBlock.h"
 
-GroupInterface::GroupInterface(AbstractBlock* _owner, const QString& _name, int _direction, int _purpose) throw(Exception) : ConnectedInterface(_owner,_name,AbstractInterface::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;
   if (! _owner->isGroupBlock()) throw(Exception(BLOCK_INVALID_TYPE));
 
   connectedFrom = NULL;
+  // force clock and reset to boolean width type instead of inherited
+  if ((purpose == Clock) || (purpose == Reset)) {
+    type = Boolean;
+  }
 }
 
 bool GroupInterface::isGroupInterface() {
 }
 
 bool GroupInterface::isGroupInterface() {
@@ -14,12 +18,31 @@ bool GroupInterface::isGroupInterface() {
 
 AbstractInterface *GroupInterface::clone() {
     GroupInterface *inter = new GroupInterface(owner,name,direction, purpose);
 
 AbstractInterface *GroupInterface::clone() {
     GroupInterface *inter = new GroupInterface(owner,name,direction, purpose);
-    inter->setWidth(width);    
-    inter->connectFrom(NULL);
-
+    inter->setWidth(width);        
     return inter;
 }
 
     return inter;
 }
 
+int GroupInterface::getWidth() {
+
+  bool ok;
+  int w = -1;
+
+  QString expr = width;
+
+  if (type == Boolean) {
+    return 1;
+  }
+  else if (type == Inherited) {
+    // must search from which iface it is connected.
+    ConnectedInterface* fromIface = connectedFrom;
+    while ((fromIface != NULL) && (fromIface->getType() == Inherited)) {
+      fromIface = fromIface->getConnectedFrom();
+    }
+    if (fromIface == NULL) return -1;
+    w = fromIface->getWidth();
+  }
+  return w;
+}
 
 bool GroupInterface::canConnectTo(AbstractInterface *iface) {
 
 
 bool GroupInterface::canConnectTo(AbstractInterface *iface) {
 
@@ -43,7 +66,8 @@ bool GroupInterface::canConnectTo(AbstractInterface *iface) {
 
   */
   if (iface->isReferenceInterface()) return false;
 
   */
   if (iface->isReferenceInterface()) return false;
-  if (iface->getConnectedFrom() != NULL) return false;
+  ConnectedInterface* connIface = AI_TO_CON(iface);
+  if (connIface->getConnectedFrom() != NULL) return false;
 
   if (this->getOwner() == iface->getOwner()->getParent()) {
     if ((direction == Input) && (iface->getDirection() == Input)) return true;
 
   if (this->getOwner() == iface->getOwner()->getParent()) {
     if ((direction == Input) && (iface->getDirection() == Input)) return true;