![]() |
![]() |
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 CReg; 00049 class CReal; 00050 class CPortDir; 00051 class CFref; 00052 class CNode; 00053 00054 00055 class CModule: public CBlock 00056 { 00057 private: 00058 int isMacroModule; 00059 int isPrimitive; 00060 vector<CInstance*> instanceList; 00061 vector<CFunction*> functionList; 00062 vector<CFref*> frefList; 00063 int portListValid; 00064 00065 vector<CPort*> portList; 00066 int portDirListValid; 00067 00068 vector<CPortDir*> portDirList; 00069 CNode* ports; 00070 int defined; 00071 00072 CSymtab<CDecl> frefSymtab; 00073 CSymtab<CDecl> portSymtab; 00074 int moduleDirectlyDefined; 00075 00076 00077 int moduleIncluded; 00078 00079 int cell; 00080 int protect; 00081 int hasTimescale; 00082 int precision; 00083 int unit; 00084 int defaultNetType; 00085 00086 int unconnectedDrive; 00087 00088 int inlineParamDecls; 00089 00090 int inlinePortDecls; 00091 00092 public: 00098 static CModule* LookupModule( char* aName ); 00104 CModule( CSymbol* symbol, Coord_t* aLoc ); 00109 void InlineParamDecls( int v ) { inlineParamDecls = v; } 00114 int InlineParamDecls() { return inlineParamDecls; } 00119 void InlinePortDecls( int v ) { inlinePortDecls = v; } 00124 int InlinePortDecls() { return inlinePortDecls; } 00130 void ModuleDirectlyDefined( int v ) { moduleDirectlyDefined = v; } 00136 int ModuleDirectlyDefined() { return moduleDirectlyDefined; } 00141 int IsDefined( void ) { return defined; } 00146 void SetDefined( int flag ) { defined = flag; } 00152 void ModuleIncluded( int v ) { moduleIncluded = v; } 00158 int ModuleIncluded() { return moduleIncluded; } 00163 int IsMacroModule( void ); 00168 void SetMacroModule( int flag ); 00173 int IsPrimitive( void ); 00178 void SetPrimitive( int flag ); 00183 virtual void Dump( FILE* f ); 00188 void SetPorts( CNode* ports ); 00193 CNode* GetPorts() { return ports; } 00198 virtual vector<CFunction*>* GetFunctionList(); 00203 virtual vector<CInstance*>* GetInstanceList(); 00208 virtual vector<CPort*>* GetPortList(); 00213 virtual vector<CPortDir*>* GetPortDirList(); 00219 CDecl* FindDecl( CSymbol* sym ); 00220 00225 int Cell() { return cell; } 00230 void Cell( int v ) { cell = v; } 00235 int Protect() { return protect; } 00240 void Protect( int v ) { protect = v; } 00245 int Precision() { return precision; } 00250 void Precision( int v ) { precision = v; hasTimescale = TRUE; } 00255 int Unit() { return unit; } 00260 void Unit( int v ) { unit = v; hasTimescale = TRUE; } 00265 int HasTimescale() { return hasTimescale; } 00271 int DefaultNetType() { return defaultNetType; } 00277 void DefaultNetType( int v ) { defaultNetType = v; } 00282 int UnconnectedDrive() { return unconnectedDrive; } 00287 void UnconnectedDrive( int v ) { unconnectedDrive = v; } 00296 virtual void Add( CFunction* function ); 00305 virtual void Add( CInstance* instance ); 00314 virtual void Add( CFref* fref ); 00323 virtual void Add( CReal* real ) { CBlock::Add(real); } 00332 virtual void Add( CReg* reg ) { CBlock::Add(reg); } 00341 virtual void Add( CNet* net ) { CBlock::Add(net); } 00350 virtual void Add( CNode* n ); 00359 virtual void Add( CParam* param ) { CBlock::Add(param); } 00360 00365 void PreVisit1( int (*func)(CNode*,void*), void* data ); 00366 void PostVisit1( void (*func)(CNode*, void*), void* data ); 00367 void PostSubVisit1( CNode* (*func)(CNode*, void*), void* data ); 00368 void FixupPorts( void ); 00369 void SetFrefSymtab( CSymtab<CDecl>& symtab ); 00370 void SetPortSymtab( CSymtab<CDecl>& symtab ); 00371 CSymtab<CDecl>& GetPortSymtab() { return portSymtab; } 00372 private: 00373 virtual void CodeListChanged() { portDirListValid = FALSE; } 00377 }; 00378 00379 #endif // CMODULE_HPP