--- oldsrc/index.cpp	2010-02-18 10:42:54.000000000 -0800
+++ doxy/src/index.cpp	2010-02-18 13:08:40.000000000 -0800
@@ -317,8 +317,20 @@
 
 static bool classHasVisibleChildren(ClassDef *cd)
 {
+ bool vhdl=Config_getBool("OPTIMIZE_OUTPUT_VHDL");
+
+  BaseClassList *bcl;
+
+  if(vhdl)
+  {
+    if (cd->baseClasses()==0) return FALSE;
+    bcl=cd->baseClasses();
+  }
+  else {
   if (cd->subClasses()==0) return FALSE;
-  BaseClassList *bcl=cd->subClasses();
+          bcl=cd->subClasses();
+       }
+
   BaseClassListIterator bcli(*bcl);
   for ( ; bcli.current() ; ++bcli)
   {
@@ -332,13 +345,21 @@
 
 void writeClassTree(OutputList &ol,BaseClassList *bcl,bool hideSuper,int level,FTVHelp* ftv)
 {
+  bool vhdl=Config_getBool("OPTIMIZE_OUTPUT_VHDL");
+
   if (bcl==0) return;
   BaseClassListIterator bcli(*bcl);
   bool started=FALSE;
   for ( ; bcli.current() ; ++bcli)
   {
     ClassDef *cd=bcli.current()->classDef;
-    if (cd->isVisibleInHierarchy() && hasVisibleRoot(cd->baseClasses()))
+    bool b;
+	if(vhdl)
+	    b=hasVisibleRoot(cd->subClasses());
+	else
+		b=hasVisibleRoot(cd->baseClasses());
+
+	if (cd->isVisibleInHierarchy() && b) // hasVisibleRoot(cd->baseClasses()))
     {
       if (!started)
       {
@@ -382,7 +403,10 @@
         //printf("Class %s at %p visited=%d\n",cd->name().data(),cd,cd->visited);
         bool wasVisited=cd->visited;
         cd->visited=TRUE;
+	  if(!vhdl)	
         writeClassTree(ol,cd->subClasses(),wasVisited,level+1,ftv);
+	  else       
+	    writeClassTree(ol,cd->baseClasses(),wasVisited,level+1,ftv);
       }
       ol.endIndexListItem();
     }
@@ -441,7 +466,9 @@
 void writeClassTreeNode(ClassDef *cd,bool &started,int level)
 {
   //printf("writeClassTreeNode(%s) visited=%d\n",cd->name().data(),cd->visited);
-  if (cd->isVisibleInHierarchy() && !cd->visited)
+  bool vhdl=Config_getBool("OPTIMIZE_OUTPUT_VHDL");
+
+if (cd->isVisibleInHierarchy() && !cd->visited)
   {
     if (!started)
     {
@@ -455,6 +482,9 @@
     }
     if (hasChildren)
     {
+      if(vhdl)
+	    writeClassTree(cd->baseClasses(),level+1);
+	  else
       writeClassTree(cd->subClasses(),level+1);
     }
     cd->visited=TRUE;
@@ -495,6 +525,7 @@
 
 static void writeClassTreeForList(OutputList &ol,ClassSDict *cl,bool &started,FTVHelp* ftv)
 {
+ bool vhdl=Config_getBool("OPTIMIZE_OUTPUT_VHDL");
   ClassSDict::Iterator cli(*cl);
   for (;cli.current(); ++cli)
   {
@@ -504,7 +535,17 @@
     //              hasVisibleRoot(cd->baseClasses()),
     //              cd->isVisibleInHierarchy()
     //      );
-    if (!hasVisibleRoot(cd->baseClasses())) // filter on root classes
+    bool b;
+	if (vhdl)
+		{
+		 if ((VhdlDocGen::VhdlClasses)cd->protection()==VhdlDocGen::PACKAGECLASS || (VhdlDocGen::VhdlClasses)cd->protection()==VhdlDocGen::PACKBODYCLASS)
+         continue;
+ 		 b=!hasVisibleRoot(cd->subClasses());
+		}
+	 else
+		b=!hasVisibleRoot(cd->baseClasses());
+	
+	if (b)  //filter on root classes
     {
       if (cd->isVisibleInHierarchy()) // should it be visible
       {
@@ -543,7 +584,12 @@
           if (ftv)
             ftv->addContentsItem(hasChildren,cd->displayName(),0,0,0); 
         }
-        if (hasChildren) 
+        if (vhdl && hasChildren) 
+        {
+		  writeClassTree(ol,cd->baseClasses(),cd->visited,1,ftv);
+          cd->visited=TRUE;
+        }
+		else if(hasChildren)
         {
           writeClassTree(ol,cd->subClasses(),cd->visited,1,ftv);
           cd->visited=TRUE;
@@ -1073,6 +1121,12 @@
     {
       QCString type=cd->compoundTypeString();
       ol.startIndexKey();
+      if(Config_getBool("OPTIMIZE_OUTPUT_VHDL"))
+	  {
+	    QCString prot= VhdlDocGen::getProtectionName((VhdlDocGen::VhdlClasses)cd->protection());
+		ol.docify(prot.data());
+		ol.insertMemberAlign();
+	 }
       ol.writeObjectLink(0,cd->getOutputFileBase(),0,cd->displayName());
       ol.endIndexKey();
       bool hasBrief = !cd->briefDescription().isEmpty();
--- oldsrc/doxygen.cpp	2010-02-18 10:44:04.000000000 -0800
+++ doxy/src/doxygen.cpp	2010-02-18 10:54:42.000000000 -0800
@@ -10025,14 +10026,12 @@
   msg("Computing class relations...\n");
   computeTemplateClassRelations(); 
   flushUnresolvedRelations();
+
+   computeClassRelations();        
+
   if (Config_getBool("OPTIMIZE_OUTPUT_VHDL"))
-  {
     VhdlDocGen::computeVhdlComponentRelations();
-  }
-  else
-  {
-    computeClassRelations();        
-  }
+
   g_classEntries.clear();          
 
   msg("Add enum values to enums...\n");
--- oldsrc/vhdldocgen.cpp	2010-02-18 10:43:14.000000000 -0800
+++ doxy/src/vhdldocgen.cpp	2010-02-18 13:13:14.000000000 -0800
@@ -213,17 +213,19 @@
   {
     cli.current()->visited=FALSE;
     ClassDef * cd = cli.current();
-    if ((VhdlDocGen::VhdlClasses)cd->protection()==VhdlDocGen::ARCHITECTURECLASS)
+	if ((VhdlDocGen::VhdlClasses)cd->protection()==VhdlDocGen::ARCHITECTURECLASS || (VhdlDocGen::VhdlClasses)cd->protection()==VhdlDocGen::PACKBODYCLASS)
     {
       QCString bName=cd->name();
       int i=bName.find("::");
       if (i>0)
       {
         QCString entityName=bName.left(i);
+		entityName.stripPrefix("_");
         ClassDef *classEntity=Doxygen::classSDict->find(entityName);
         // entity for architecutre ?
         if (classEntity)
         {
+		 // printf("\n entity %s  arch %s",entityName.data(),bName.data());
           classEntity->insertBaseClass(cd,bName,Public,Normal,0);
           cd->insertSubClass(classEntity,Public,Normal,0);
         }
@@ -1163,7 +1165,19 @@
   }//while
 } // getFuncName
 
+QCString VhdlDocGen::getProtectionName(int prot)
+{
+        if(prot==VhdlDocGen::ENTITYCLASS)
+	      return "entity";
+		else if(prot==VhdlDocGen::ARCHITECTURECLASS)
+	      return "architecture";
+		else if(prot==VhdlDocGen::PACKAGECLASS)
+	      return "package";
+		else if(prot==VhdlDocGen::PACKBODYCLASS)
+	      return "package body";
 
+		return "";
+}
 QCString VhdlDocGen::trTypeString(int type)
 {
   switch(type)
--- oldsrc/vhdldocgen.h	2010-02-18 13:06:14.000000000 -0800
+++ doxy/src/vhdldocgen.h	2010-02-18 12:54:06.000000000 -0800
@@ -264,7 +264,7 @@
     static bool membersHaveSpecificType(MemberList *ml,int type);
     static void startFonts(const QCString& q, const char *keyword,OutputList& ol);
     static bool isNumber(const QCString& s);
-
+    static QCString getProtectionName(int prot);
   private:
     static void getFuncParams(QList<Argument>&, const char* str);
     static bool compareArgList(ArgumentList*,ArgumentList*);
--- oldsrc/dot.cpp	2010-02-18 10:45:24.000000000 -0800
+++ doxy/src/dot.cpp	2010-02-18 10:53:18.000000000 -0800
@@ -35,7 +35,7 @@
 #include "pagedef.h"
 #include "portable.h"
 #include "dirdef.h"
-
+#include "vhdldocgen.h"
 #include <qdir.h>
 #include <qfile.h>
 #include <qtextstream.h>
@@ -720,6 +721,19 @@
   {
     if (!Config_getBool("DOT_TRANSPARENT"))
     {
+	ClassDef* ccd=this->m_classDef;
+
+	if(ccd && Config_getBool("OPTIMIZE_OUTPUT_VHDL") && ccd->protection()==VhdlDocGen::ARCHITECTURECLASS)
+	 t << ",color=\"" << labCol << "\", fillcolor=\"khaki\", style=\"filled\"";	
+	/*
+		{
+		 if(ccd->protection()==VhdlDocGen::ARCHITECTURECLASS)
+	     t << ",color=\"" << labCol << "\", fillcolor=\"khaki\", style=\"filled\"";		
+		 else
+		  t << ",color=\"" << labCol << "\", fillcolor=\"white\", style=\"filled\"";
+		}
+	*/
+	else
       t << ",color=\"" << labCol << "\", fillcolor=\"white\", style=\"filled\"";
     }
     else
--- oldsrc/vhdlscanner.l	2010-02-18 13:06:26.000000000 -0800
+++ doxy/src/vhdlscanner.l	2010-02-18 10:20:18.000000000 -0800
@@ -875,6 +875,11 @@
   current->name=QCString(qsl[0]);
   if (lastCompound)
   {
+     if (!VhdlDocGen::foundInsertedComponent(current->type,lastCompound))
+     {   
+        BaseInfo *bb=new BaseInfo(current->type,Public,Normal);
+        lastCompound->extends->append(bb);
+     }
     lastCompound->addSubEntry(current);
     current = new Entry;
     initEntry(current);
@@ -973,8 +978,8 @@
       // inherit private inheritance relation between entity and architecture
       if (!VhdlDocGen::foundInsertedComponent(current->name,lastEntity))
       {
-	BaseInfo *bb=new BaseInfo(current->name,Private,Normal);
-	lastEntity->extends->append(bb);    
+//	BaseInfo *bb=new BaseInfo(current->name,Private,Normal);
+//	lastEntity->extends->append(bb);    
       }
     }
 
