00001 /***************************************************************************** 00002 * Copyright (C) 1997-2007, Mark Hummel 00003 * This file is part of Vrq. 00004 * 00005 * Vrq is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU General Public 00007 * License as published by the Free Software Foundation; either 00008 * version 2 of the License, or (at your option) any later version. 00009 * 00010 * Vrq is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 * General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public 00016 * License along with this library; if not, write to the Free Software 00017 * Foundation, Inc., 51 Franklin Street, Fifth Floor, 00018 * Boston, MA 02110-1301 USA 00019 ***************************************************************************** 00020 */ 00021 /****************************************************************************** 00022 * 00023 * 00024 * cmodule.hpp 00025 * - class definition of module, macromodules, and primitive 00026 * definition nodes 00027 * 00028 ****************************************************************************** 00029 */ 00030 00031 #ifndef CMODULE_HPP 00032 #define CMODULE_HPP 00033 00034 #include <stdio.h> 00035 #include <vector> 00036 #include "glue.h" 00037 #include "cdecl.h" 00038 #include "csymtab.h" 00039 #include "cblock.h" 00040 #include "cnode.h" 00041 extern "C" { 00042 #include "vpi_user.h" 00043 } 00044 00045 00046 class CInstance; 00047 class CParam; 00048 class CVar; 00049 class CPortDir; 00050 class CFref; 00051 class CNode; 00052 00053 00054 class CModule: public CBlock 00055 { 00056 private: 00057 int isMacroModule; 00058 int isPrimitive; 00059 vector<CInstance*> instanceList; 00060 vector<CFunction*> functionList; 00061 vector<CFref*> frefList; 00062 int portListValid; 00063 00064 vector<CPort*> portList; 00065 int portDirListValid; 00066 00067 vector<CPortDir*> portDirList; 00068 CNode* ports; 00069 int defined; 00070 00071 CSymtab<CDecl> frefSymtab; 00072 CSymtab<CDecl> portSymtab; 00073 int moduleDirectlyDefined; 00074 00075 00076 int moduleIncluded; 00077 00078 int cell; 00079 int protect; 00080 int hasTimescale; 00081 int precision; 00082 int unit; 00083 int defaultNetType; 00084 00085 int unconnectedDrive; 00086 00087 int inlineParamDecls; 00088 00089 int inlinePortDecls; 00090 00091 public: 00098 static CModule* LookupModule( CSymtab<CDecl>& symtab, char* aName ); 00104 CModule( CSymbol* symbol, Coord_t* aLoc ); 00110 virtual CDecl* Clone( CObstack* heap ) { MASSERT(FALSE); } 00115 void InlineParamDecls( int v ) { inlineParamDecls = v; } 00120 int InlineParamDecls() { return inlineParamDecls; } 00125 void InlinePortDecls( int v ) { inlinePortDecls = v; } 00130 int InlinePortDecls() { return inlinePortDecls; } 00136 void ModuleDirectlyDefined( int v ) { moduleDirectlyDefined = v; } 00142 int ModuleDirectlyDefined() { return moduleDirectlyDefined; } 00147 int IsDefined( void ) { return defined; } 00152 void SetDefined( int flag ) { defined = flag; } 00158 void ModuleIncluded( int v ) { moduleIncluded = v; } 00164 int ModuleIncluded() { return moduleIncluded; } 00169 int IsMacroModule( void ); 00174 void SetMacroModule( int flag ); 00179 int IsPrimitive( void ); 00184 void SetPrimitive( int flag ); 00189 virtual void Dump( FILE* f ); 00194 void SetPorts( CNode* ports ); 00199 CNode* GetPorts() { return ports; } 00204 virtual vector<CFunction*>* GetFunctionList(); 00209 virtual vector<CInstance*>* GetInstanceList(); 00214 virtual vector<CPort*>* GetPortList(); 00219 virtual vector<CPortDir*>* GetPortDirList(); 00225 CDecl* FindDecl( CSymbol* sym ); 00226 00231 int Cell() { return cell; } 00236 void Cell( int v ) { cell = v; } 00241 int Protect() { return protect; } 00246 void Protect( int v ) { protect = v; } 00251 int Precision() { return precision; } 00256 void Precision( int v ) { precision = v; hasTimescale = TRUE; } 00261 int Unit() { return unit; } 00266 void Unit( int v ) { unit = v; hasTimescale = TRUE; } 00271 int HasTimescale() { return hasTimescale; } 00277 int DefaultNetType() { return defaultNetType; } 00283 void DefaultNetType( int v ) { defaultNetType = v; } 00288 int UnconnectedDrive() { return unconnectedDrive; } 00293 void UnconnectedDrive( int v ) { unconnectedDrive = v; } 00302 virtual void Add( CFunction* function ); 00311 virtual void Add( CInstance* instance ); 00320 virtual void Add( CFref* fref ); 00329 virtual void Add( CVar* var ) { CBlock::Add(var); } 00338 virtual void Add( CNet* net ) { CBlock::Add(net); } 00347 virtual void Add( CNode* n ); 00356 virtual void Add( CParam* param ) { CBlock::Add(param); } 00357 00362 void PreVisit1( int (*func)(CNode*,void*), void* data ); 00363 void PostVisit1( void (*func)(CNode*, void*), void* data ); 00364 void PostSubVisit1( CNode* (*func)(CNode*, void*), void* data ); 00365 void FixupPorts( void ); 00366 void SetFrefSymtab( CSymtab<CDecl>& symtab ); 00367 void SetPortSymtab( CSymtab<CDecl>& symtab ); 00368 CSymtab<CDecl>& GetPortSymtab() { return portSymtab; } 00369 private: 00370 virtual void CodeListChanged() { portDirListValid = FALSE; } 00371 CModule( const CModule& ); 00375 }; 00376 00377 #endif // CMODULE_HPP