📄 shint.h
字号:
/**CFile**************************************************************** FileName [shInt.h] PackageName [MVSIS 2.0: Multi-valued logic synthesis system.] Synopsis [Internal declarations of structural hashing package.] Author [MVSIS Group] Affiliation [UC Berkeley] Date [Ver. 1.0. Started - February 1, 2003.] Revision [$Id: shInt.h,v 1.3 2003/05/27 23:14:51 alanmi Exp $]***********************************************************************/#ifndef __SH_INT_H__#define __SH_INT_H__/////////////////////////////////////////////////////////////////////////// INCLUDES ///////////////////////////////////////////////////////////////////////////#include "mvtypes.h"#include "util.h"#include "extra.h"#include "vm.h"#include "vmx.h"#include "sh.h"/////////////////////////////////////////////////////////////////////////// PARAMETERS ///////////////////////////////////////////////////////////////////////////#define shNodeIsAnd( p ) ((Sh_Regular(p))->pOne && (Sh_Regular(p))->pTwo)//#define shNodeIsVar( p ) ((Sh_Regular(p))->pOne == NULL)#define shNodeIsVar( p ) ((Sh_Regular(p))->fVar)#define shNodeIsConst( p ) ((Sh_Regular(p))->pOne == (Sh_Node_t *)1)#define shNodeReadOne( p ) ((Sh_Regular(p))->pOne)#define shNodeReadTwo( p ) ((Sh_Regular(p))->pTwo)// temporarily do not use reference counting//#define shNodeRef( p ) ((Sh_Regular(p))->nRefs++)//#define shNodeDeref( p ) ((Sh_Regular(p))->nRefs--)#define shNodeRef( p ) #define shNodeDeref( p ) // uncomment this macro to switch to standard memory management#define USE_SYSTEM_MEMORY_MANAGEMENT /////////////////////////////////////////////////////////////////////////// STRUCTURE DEFINITIONS ///////////////////////////////////////////////////////////////////////////typedef struct ShTableStruct Sh_Table_t; struct ShManagerStruct{ // various types of nodes Sh_Node_t ** pVars; int nVars; // constant node Sh_Node_t * pConst1; // hashing AND gates Sh_Table_t * pTable; // hash table of two-input AND nodes // canonicity short * pCanTable; // the canonicity table (2^14 entries) // the traversal IDs int nTravIds; // the counter of traversals // memory management for the nodes mm_fixed * pMem;};struct ShNetworkStruct { Sh_Manager_t * pMan; // the manager of this network // various types of nodes int nInputs; int nOutputs; Sh_Node_t ** ppOutputs; int nInputsCore; Sh_Node_t ** ppInputsCore; int nOutputsCore; Sh_Node_t ** ppOutputsCore; int nSpecials; Sh_Node_t ** ppSpecials; // statistics int nNodes; // the total number of nodes Sh_Node_t ** ppNodes; // the temporary array of nodes // the special linked list Sh_Node_t * pOrder; // special ordering of nodes (such as DFS) Sh_Node_t ** ppTail; // the pointer to the place where next entry is added (internal use only) // MV variable maps Vm_VarMap_t * pVmL; Vm_VarMap_t * pVmR; Vm_VarMap_t * pVmS; Vm_VarMap_t * pVmLC; Vm_VarMap_t * pVmRC;};struct ShNodeStruct // 64 byte{ Sh_Node_t * pNext; // the next pointer in the hash table of AND gates Sh_Node_t * pOrder; // used for DFS linking, levelizing, etc Sh_Node_t * pOne; // the left child Sh_Node_t * pTwo; // the right child unsigned pData; // user's data unsigned pData2; // user's data int TravId; // the current traversal ID of the node char fVar; // the flag to mark trivial node char nRefs; // the reference counter short Num; // the temporary number of the node};/////////////////////////////////////////////////////////////////////////// ITERATORS ///////////////////////////////////////////////////////////////////////////// specialized iterator through the ordered nodes#define Sh_NetworkForEachNodeSpecial( Net, Node ) \ for ( Node = Net->pOrder; \ Node; \ Node = Node->pOrder )#define Sh_NetworkForEachNodeSpecialSafe( Net, Node, Node2 ) \ for ( Node = Sh_NetworkReadOrder(Net), \ Node2 = (Node? Node->pOrder: NULL); \ Node; \ Node = Node2, \ Node2 = (Node? Node->pOrder: NULL) )/////////////////////////////////////////////////////////////////////////// MACRO DEFITIONS ///////////////////////////////////////////////////////////////////////////// get the polarities of AND gates in the comb#define St_SignReadPolR( s ) ((s) & 1)#define St_SignReadPolL( s ) (((s)>>1) & 1)#define St_SignReadPolRR( s ) (((s)>>2) & 1)#define St_SignReadPolRL( s ) (((s)>>3) & 1)#define St_SignReadPolLR( s ) (((s)>>4) & 1)#define St_SignReadPolLL( s ) (((s)>>5) & 1)// macros to get the signs of AND-gates from the sign of comb #define St_SignReadAnd2( s ) (((s) >> 6) & 15)#define St_SignReadAnd1( s ) ((s) >> 10)// macros to get the signs of inputs from the sign of AND gate#define St_SignReadAndInput2( s ) ((s) & 3)#define St_SignReadAndInput1( s ) (((s) >> 2) & 3)// macros to set the same things#define St_SignWritePolR( s, i ) ((s) |= (i))#define St_SignWritePolL( s, i ) ((s) |= ((i)<<1))#define St_SignWritePolRR( s, i ) ((s) |= ((i)<<2))#define St_SignWritePolRL( s, i ) ((s) |= ((i)<<3))#define St_SignWritePolLR( s, i ) ((s) |= ((i)<<4))#define St_SignWritePolLL( s, i ) ((s) |= ((i)<<5))#define St_SignWriteAnd2( s, i ) ((s) |= ((i) << 6))#define St_SignWriteAnd1( s, i ) ((s) |= ((i) << 10))#define St_SignWriteAndInput2( s, i ) ((s) |= (i))#define St_SignWriteAndInput1( s, i ) ((s) |= ((i) << 2))/////////////////////////////////////////////////////////////////////////// FUNCTION DEFITIONS ////////////////////////////////////////////////////////////////////////////*=== shHash.c ===========================================================*/extern Sh_Table_t * Sh_TableAlloc( int nTableSize );extern void Sh_TableFree( Sh_Table_t * p );extern Sh_Node_t * Sh_TableLookup( Sh_Manager_t * p, Sh_Node_t * pNode1, Sh_Node_t * pNode2 );extern Sh_Node_t * Sh_TableInsertUnique( Sh_Manager_t * pMan, Sh_Node_t * pNode );extern int Sh_TableReadNodeNum( Sh_Manager_t * p );extern int Sh_TableReadNodeUniqueNum( Sh_Manager_t * p );extern int Sh_TableIncrementNodes( Sh_Manager_t * p );extern void Sh_TableCleanNodes( Sh_Manager_t * pMan );/*=== shCanon.c ===========================================================*/extern Sh_Node_t * Sh_CanonNodeAnd( Sh_Manager_t * p, Sh_Node_t * pNode1, Sh_Node_t * pNode2 );/*=== shSign.c ===========================================================*/extern short * Sh_SignPrecompute();extern Sh_Node_t * Sh_SignConstructNodes( Sh_Manager_t * p, short Sign, Sh_Node_t * pNodes[], int nNodes );extern char * Sh_SignPrint( short Sign );extern void Sh_SignTablePrint( short * pSign2Sign, unsigned * pSign2True );/*=== shTravId.c =========================================================*/extern int Sh_NetworkReadTravId( Sh_Network_t * pNet );extern void Sh_NetworkIncrementTravId( Sh_Network_t * pNet );extern int Sh_NodeReadTravId( Sh_Node_t * pNode );extern void Sh_NodeSetTravId( Sh_Node_t * pNode, int TravId );extern void Sh_NodeSetTravIdCurrent( Sh_Network_t * pNet, Sh_Node_t * pNode );extern bool Sh_NodeIsTravIdCurrent( Sh_Network_t * pNet, Sh_Node_t * pNode );extern bool Sh_NodeIsTravIdPrevious( Sh_Network_t * pNet, Sh_Node_t * pNode );extern void Sh_NetworkStartSpecial( Sh_Network_t * pNet );extern void Sh_NetworkStopSpecial( Sh_Network_t * pNet );extern void Sh_NetworkAddToSpecial( Sh_Network_t * pNet, Sh_Node_t * pNode );extern void Sh_NetworkMoveSpecial( Sh_Network_t * pNet, Sh_Node_t * pNode );extern void Sh_NetworkResetSpecial( Sh_Network_t * pNet );extern int Sh_NetworkCountSpecial( Sh_Network_t * pNet );extern void Sh_NetworkCreateSpecialFromArray( Sh_Network_t * pNet, Sh_Node_t * ppNodes[], int nNodes );extern int Sh_NetworkCreateArrayFromSpecial( Sh_Network_t * pNet, Sh_Node_t * ppNodes[] );extern void Sh_NetworkPrintSpecial( Sh_Network_t * pNet );/////////////////////////////////////////////////////////////////////////// END OF FILE ///////////////////////////////////////////////////////////////////////////#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -