?? mvc.h
字號:
/**CFile**************************************************************** FileName [mvc.h] PackageName [MVSIS 2.0: Multi-valued logic synthesis system.] Synopsis [Data structure for MV cube/cover manipulation.] Author [MVSIS Group] Affiliation [UC Berkeley] Date [Ver. 1.0. Started - February 1, 2003.] Revision [$Id: mvc.h,v 1.19 2003/05/27 23:15:10 alanmi Exp $]***********************************************************************/#ifndef __MVC_H__#define __MVC_H__/////////////////////////////////////////////////////////////////////////// INCLUDES ///////////////////////////////////////////////////////////////////////////#include "util.h"#include "extra.h"#include "vm.h"/////////////////////////////////////////////////////////////////////////// PARAMETERS ///////////////////////////////////////////////////////////////////////////// this is the only part of Mvc package, which should be modified// when compiling the package for other platforms// these parameters can be computed but setting them manually makes it faster#define BITS_PER_WORD 32 // sizeof(Mvc_CubeWord_t) * 8 #define BITS_PER_WORD_MINUS 31 // the same minus 1#define BITS_PER_WORD_LOG 5 // log2(sizeof(Mvc_CubeWord_t) * 8)#define BITS_DISJOINT ((Mvc_CubeWord_t)0x55555555) // the mask of the type "01010101"#define BITS_FULL ((Mvc_CubeWord_t)0xffffffff) // the mask of the type "11111111"// uncomment this macro to switch to standard memory management//#define USE_SYSTEM_MEMORY_MANAGEMENT /////////////////////////////////////////////////////////////////////////// STRUCTURE DEFINITIONS ///////////////////////////////////////////////////////////////////////////// cube/list/cover/datatypedef unsigned long Mvc_CubeWord_t;typedef struct MvcCubeStruct Mvc_Cube_t;typedef struct MvcListStruct Mvc_List_t;typedef struct MvcCoverStruct Mvc_Cover_t;typedef struct MvcDataStruct Mvc_Data_t;typedef struct MvcManagerStruct Mvc_Manager_t;// the cube data structurestruct MvcCubeStruct{ Mvc_Cube_t * pNext; // the next cube in the linked list unsigned iLast : 8; // the index of the last word unsigned nUnused : 6; // the number of unused bits in the last word unsigned fPrime : 1; // marks the prime cube unsigned fEssen : 1; // marks the essential cube unsigned nOnes : 16; // the number of 1's in the bit data Mvc_CubeWord_t pData[1]; // the first Mvc_CubeWord_t filled with bit data};// the single-linked list of cubes in the coverstruct MvcListStruct{ Mvc_Cube_t * pHead; // the first cube in the list Mvc_Cube_t * pTail; // the last cube in the list int nItems; // the number of cubes in the list};// the cover data structurestruct MvcCoverStruct{ char nWords; // the number of machine words char nUnused; // the number of unused bits in the last word short nBits; // the number of used data bits in the cube Mvc_List_t lCubes; // the single-linked list of cubes Mvc_Cube_t ** pCubes; // the array of cubes (for sorting) int nCubesAlloc; // the size of allocated storage int * pLits; // the counter of lit occurrances in cubes Mvc_Cube_t * pMask; // the multipurpose mask Mvc_Manager_t * pMem; // the memory manager};// data structure to store information about MV variablesstruct MvcDataStruct{ Mvc_Manager_t * pMan; // the memory manager Vm_VarMap_t * pVm; // the MV variable data int nBinVars; // the number of binary variables Mvc_Cube_t * pMaskBin; // the mask to select the binary bits only Mvc_Cube_t ** ppMasks; // the mask to select each MV variable Mvc_Cube_t * ppTemp[3]; // the temporary cubes};// the manager of covers and cubes (as of today, only managing memory)struct MvcManagerStruct{ mm_fixed * pManC; // the manager for covers mm_fixed * pMan1; // the manager for 1-word cubes mm_fixed * pMan2; // the manager for 2-word cubes mm_fixed * pMan4; // the manager for 3-word cubes};/////////////////////////////////////////////////////////////////////////// MACRO DEFITIONS ///////////////////////////////////////////////////////////////////////////// reading data from the header of the cube#define Mvc_CubeReadNext(Cube) ((Cube)->pNext)#define Mvc_CubeReadNextP(Cube) (&(Cube)->pNext)#define Mvc_CubeReadLast(Cube) ((Cube)->iLast)#define Mvc_CubeReadSize(Cube) ((Cube)->nOnes)// setting data to the header of the cube#define Mvc_CubeSetNext(Cube,Next) ((Cube)->pNext = (Next))#define Mvc_CubeSetLast(Cube,Last) ((Cube)->iLast = (Last))#define Mvc_CubeSetSize(Cube,Size) ((Cube)->nOnes = (Size))// checking the number of words#define Mvc_Cube1Words(Cube) ((Cube)->iLast == 0) #define Mvc_Cube2Words(Cube) ((Cube)->iLast == 1) #define Mvc_CubeNWords(Cube) ((Cube)->iLast > 1) // getting one data bit#define Mvc_CubeWhichWord(Bit) ((Bit) >> BITS_PER_WORD_LOG)#define Mvc_CubeWhichBit(Bit) ((Bit) & BITS_PER_WORD_MINUS)// accessing individual bits#define Mvc_CubeBitValue(Cube, Bit) (((Cube)->pData[Mvc_CubeWhichWord(Bit)] & (((Mvc_CubeWord_t)1)<<(Mvc_CubeWhichBit(Bit)))) > 0)#define Mvc_CubeBitInsert(Cube, Bit) ((Cube)->pData[Mvc_CubeWhichWord(Bit)] |= (((Mvc_CubeWord_t)1)<<(Mvc_CubeWhichBit(Bit))))#define Mvc_CubeBitRemove(Cube, Bit) ((Cube)->pData[Mvc_CubeWhichWord(Bit)] &= ~(((Mvc_CubeWord_t)1)<<(Mvc_CubeWhichBit(Bit))))// various macros// cleaning the data bits of the cube#define Mvc_Cube1BitClean( Cube )\ ((Cube)->pData[0] = 0)#define Mvc_Cube2BitClean( Cube )\ (((Cube)->pData[0] = 0),\ ((Cube)->pData[1] = 0))#define Mvc_CubeNBitClean( Cube )\{\ int _i_;\ for( _i_ = (Cube)->iLast; _i_ >= 0; _i_--)\ (Cube)->pData[_i_] = 0;\}// filling the used data bits with 1's#define Mvc_Cube1BitFill( Cube )\ (Cube)->pData[0] = (BITS_FULL >> (Cube)->nUnused);#define Mvc_Cube2BitFill( Cube )\ (((Cube)->pData[0] = BITS_FULL),\ ((Cube)->pData[1] = (BITS_FULL >> (Cube)->nUnused))) #define Mvc_CubeNBitFill( Cube )\{\ int _i_;\ (Cube)->pData[(Cube)->iLast] = (BITS_FULL >> (Cube)->nUnused);\ for( _i_ = (Cube)->iLast - 1; _i_ >= 0; _i_-- )\ (Cube)->pData[_i_] = BITS_FULL;\}// complementing the data bits#define Mvc_Cube1BitNot( Cube )\ ((Cube)->pData[0] ^= (BITS_FULL >> (Cube)->nUnused))#define Mvc_Cube2BitNot( Cube )\ (((Cube)->pData[0] ^= BITS_FULL),\ ((Cube)->pData[1] ^= (BITS_FULL >> (Cube)->nUnused)))#define Mvc_CubeNBitNot( Cube )\{\ int _i_;\ (Cube)->pData[(Cube)->iLast] ^= (BITS_FULL >> (Cube)->nUnused);\ for( _i_ = (Cube)->iLast - 1; _i_ >= 0; _i_-- )\ (Cube)->pData[_i_] ^= BITS_FULL;\}#define Mvc_Cube1BitCopy( Cube1, Cube2 )\ (((Cube1)->pData[0]) = ((Cube2)->pData[0]))#define Mvc_Cube2BitCopy( Cube1, Cube2 )\ ((((Cube1)->pData[0]) = ((Cube2)->pData[0])),\ (((Cube1)->pData[1])= ((Cube2)->pData[1])))#define Mvc_CubeNBitCopy( Cube1, Cube2 )\{\ int _i_;\ for (_i_ = (Cube1)->iLast; _i_ >= 0; _i_--)\ ((Cube1)->pData[_i_]) = ((Cube2)->pData[_i_]);\}#define Mvc_Cube1BitOr( CubeR, Cube1, Cube2 )\ (((CubeR)->pData[0]) = ((Cube1)->pData[0] | (Cube2)->pData[0]))#define Mvc_Cube2BitOr( CubeR, Cube1, Cube2 )\ ((((CubeR)->pData[0]) = ((Cube1)->pData[0] | (Cube2)->pData[0])),\ (((CubeR)->pData[1]) = ((Cube1)->pData[1] | (Cube2)->pData[1])))#define Mvc_CubeNBitOr( CubeR, Cube1, Cube2 )\{\ int _i_;\ for (_i_ = (Cube1)->iLast; _i_ >= 0; _i_--)\ (((CubeR)->pData[_i_]) = ((Cube1)->pData[_i_] | (Cube2)->pData[_i_]));\}#define Mvc_Cube1BitExor( CubeR, Cube1, Cube2 )\ (((CubeR)->pData[0]) = ((Cube1)->pData[0] ^ (Cube2)->pData[0]))#define Mvc_Cube2BitExor( CubeR, Cube1, Cube2 )\ ((((CubeR)->pData[0]) = ((Cube1)->pData[0] ^ (Cube2)->pData[0])),\ (((CubeR)->pData[1]) = ((Cube1)->pData[1] ^ (Cube2)->pData[1])))#define Mvc_CubeNBitExor( CubeR, Cube1, Cube2 )\{\ int _i_;\ for (_i_ = (Cube1)->iLast; _i_ >= 0; _i_--)\ (((CubeR)->pData[_i_]) = ((Cube1)->pData[_i_] ^ (Cube2)->pData[_i_]));\}#define Mvc_Cube1BitAnd( CubeR, Cube1, Cube2 )\ (((CubeR)->pData[0]) = ((Cube1)->pData[0] & (Cube2)->pData[0]))#define Mvc_Cube2BitAnd( CubeR, Cube1, Cube2 )\ ((((CubeR)->pData[0]) = ((Cube1)->pData[0] & (Cube2)->pData[0])),\ (((CubeR)->pData[1]) = ((Cube1)->pData[1] & (Cube2)->pData[1])))#define Mvc_CubeNBitAnd( CubeR, Cube1, Cube2 )\{\ int _i_;\ for (_i_ = (Cube1)->iLast; _i_ >= 0; _i_--)\ (((CubeR)->pData[_i_]) = ((Cube1)->pData[_i_] & (Cube2)->pData[_i_]));\}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -