![]() |
![]() |
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: 00097 static CModule* LookupModule( char* aName ); 00103 CModule( CSymbol* symbol, Coord_t* aLoc ); 00109 virtual CDecl* Clone( CObstack* heap ) { MASSERT(FALSE); } 00114 void InlineParamDecls( int v ) { inlineParamDecls = v; } 00119 int InlineParamDecls() { return inlineParamDecls; } 00124 void InlinePortDecls( int v ) { inlinePortDecls = v; } 00129 int InlinePortDecls() { return inlinePortDecls; } 00135 void ModuleDirectlyDefined( int v ) { moduleDirectlyDefined = v; } 00141 int ModuleDirectlyDefined() { return moduleDirectlyDefined; } 00146 int IsDefined( void ) { return defined; } 00151 void SetDefined( int flag ) { defined = flag; } 00157 void ModuleIncluded( int v ) { moduleIncluded = v; } 00163 int ModuleIncluded() { return moduleIncluded; } 00168 int IsMacroModule( void ); 00173 void SetMacroModule( int flag ); 00178 int IsPrimitive( void ); 00183 void SetPrimitive( int flag ); 00188 virtual void Dump( FILE* f ); 00193 void SetPorts( CNode* ports ); 00198 CNode* GetPorts() { return ports; } 00203 virtual vector<CFunction*>* GetFunctionList(); 00208 virtual vector<CInstance*>* GetInstanceList(); 00213 virtual vector<CPort*>* GetPortList(); 00218 virtual vector<CPortDir*>* GetPortDirList(); 00224 CDecl* FindDecl( CSymbol* sym ); 00225 00230 int Cell() { return cell; } 00235 void Cell( int v ) { cell = v; } 00240 int Protect() { return protect; } 00245 void Protect( int v ) { protect = v; } 00250 int Precision() { return precision; } 00255 void Precision( int v ) { precision = v; hasTimescale = TRUE; } 00260 int Unit() { return unit; } 00265 void Unit( int v ) { unit = v; hasTimescale = TRUE; } 00270 int HasTimescale() { return hasTimescale; } 00276 int DefaultNetType() { return defaultNetType; } 00282 void DefaultNetType( int v ) { defaultNetType = v; } 00287 int UnconnectedDrive() { return unconnectedDrive; } 00292 void UnconnectedDrive( int v ) { unconnectedDrive = v; } 00301 virtual void Add( CFunction* function ); 00310 virtual void Add( CInstance* instance ); 00319 virtual void Add( CFref* fref ); 00328 virtual void Add( CVar* var ) { CBlock::Add(var); } 00337 virtual void Add( CNet* net ) { CBlock::Add(net); } 00346 virtual void Add( CNode* n ); 00355 virtual void Add( CParam* param ) { CBlock::Add(param); } 00356 00361 void PreVisit1( int (*func)(CNode*,void*), void* data ); 00362 void PostVisit1( void (*func)(CNode*, void*), void* data ); 00363 void PostSubVisit1( CNode* (*func)(CNode*, void*), void* data ); 00364 void FixupPorts( void ); 00365 void SetFrefSymtab( CSymtab<CDecl>& symtab ); 00366 void SetPortSymtab( CSymtab<CDecl>& symtab ); 00367 CSymtab<CDecl>& GetPortSymtab() { return portSymtab; } 00368 private: 00369 virtual void CodeListChanged() { portDirListValid = FALSE; } 00370 CModule( const CModule& ); 00374 }; 00375 00376 #endif // CMODULE_HPP