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

Private GIT Repository
finished VHDL gen. (but have to test further
[blast.git] / GroupInterface.cpp
index e87c14ab4541eea789c6f74f291c2d2a35140c37..c611ecfbb22f03796fc4aec3d097d9a424bfd8f8 100644 (file)
@@ -6,6 +6,10 @@ GroupInterface::GroupInterface(AbstractBlock* _owner, const QString& _name, int
   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() {
@@ -18,6 +22,27 @@ AbstractInterface *GroupInterface::clone() {
     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) {