#include <stdio.h>
#include "extra.h"
Go to the source code of this file.
Data Structures | |
struct | MvcCubeStruct |
struct | MvcListStruct |
struct | MvcCoverStruct |
struct | MvcDataStruct |
struct | MvcManagerStruct |
Defines | |
#define | BITS_PER_WORD 32 |
#define | BITS_PER_WORD_MINUS 31 |
#define | BITS_PER_WORD_LOG 5 |
#define | BITS_DISJOINT ((Mvc_CubeWord_t)0x55555555) |
#define | BITS_FULL ((Mvc_CubeWord_t)0xffffffff) |
#define | Mvc_CubeReadNext(Cube) ((Cube)->pNext) |
#define | Mvc_CubeReadNextP(Cube) (&(Cube)->pNext) |
#define | Mvc_CubeReadLast(Cube) ((Cube)->iLast) |
#define | Mvc_CubeReadSize(Cube) ((Cube)->nOnes) |
#define | Mvc_CubeSetNext(Cube, Next) ((Cube)->pNext = (Next)) |
#define | Mvc_CubeSetLast(Cube, Last) ((Cube)->iLast = (Last)) |
#define | Mvc_CubeSetSize(Cube, Size) ((Cube)->nOnes = (Size)) |
#define | Mvc_Cube1Words(Cube) ((Cube)->iLast == 0) |
#define | Mvc_Cube2Words(Cube) ((Cube)->iLast == 1) |
#define | Mvc_CubeNWords(Cube) ((Cube)->iLast > 1) |
#define | Mvc_CubeWhichWord(Bit) ((Bit) >> BITS_PER_WORD_LOG) |
#define | Mvc_CubeWhichBit(Bit) ((Bit) & BITS_PER_WORD_MINUS) |
#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)))) |
#define | Mvc_CubeVarValue(Cube, Var) (((Cube)->pData[Mvc_CubeWhichWord(2*(Var))] >> (Mvc_CubeWhichBit(2*(Var)))) & ((Mvc_CubeWord_t)3)) |
#define | Mvc_Cube1BitClean(Cube) ((Cube)->pData[0] = 0) |
#define | Mvc_Cube2BitClean(Cube) |
#define | Mvc_CubeNBitClean(Cube) |
#define | Mvc_CubeBitCleanUnused(Cube) ((Cube)->pData[(Cube)->iLast] &= (BITS_FULL >> (Cube)->nUnused)) |
#define | Mvc_Cube1BitFill(Cube) (Cube)->pData[0] = (BITS_FULL >> (Cube)->nUnused); |
#define | Mvc_Cube2BitFill(Cube) |
#define | Mvc_CubeNBitFill(Cube) |
#define | Mvc_Cube1BitNot(Cube) ((Cube)->pData[0] ^= (BITS_FULL >> (Cube)->nUnused)) |
#define | Mvc_Cube2BitNot(Cube) |
#define | Mvc_CubeNBitNot(Cube) |
#define | Mvc_Cube1BitCopy(Cube1, Cube2) (((Cube1)->pData[0]) = ((Cube2)->pData[0])) |
#define | Mvc_Cube2BitCopy(Cube1, Cube2) |
#define | Mvc_CubeNBitCopy(Cube1, Cube2) |
#define | Mvc_Cube1BitOr(CubeR, Cube1, Cube2) (((CubeR)->pData[0]) = ((Cube1)->pData[0] | (Cube2)->pData[0])) |
#define | Mvc_Cube2BitOr(CubeR, Cube1, Cube2) |
#define | Mvc_CubeNBitOr(CubeR, Cube1, Cube2) |
#define | Mvc_Cube1BitExor(CubeR, Cube1, Cube2) (((CubeR)->pData[0]) = ((Cube1)->pData[0] ^ (Cube2)->pData[0])) |
#define | Mvc_Cube2BitExor(CubeR, Cube1, Cube2) |
#define | Mvc_CubeNBitExor(CubeR, Cube1, Cube2) |
#define | Mvc_Cube1BitAnd(CubeR, Cube1, Cube2) (((CubeR)->pData[0]) = ((Cube1)->pData[0] & (Cube2)->pData[0])) |
#define | Mvc_Cube2BitAnd(CubeR, Cube1, Cube2) |
#define | Mvc_CubeNBitAnd(CubeR, Cube1, Cube2) |
#define | Mvc_Cube1BitSharp(CubeR, Cube1, Cube2) (((CubeR)->pData[0]) = ((Cube1)->pData[0] & ~((Cube2)->pData[0]))) |
#define | Mvc_Cube2BitSharp(CubeR, Cube1, Cube2) |
#define | Mvc_CubeNBitSharp(CubeR, Cube1, Cube2) |
#define | Mvc_Cube1BitEmpty(Res, Cube) (Res = ((Cube)->pData[0] == 0)) |
#define | Mvc_Cube2BitEmpty(Res, Cube) (Res = ((Cube)->pData[0] == 0 && (Cube)->pData[1] == 0)) |
#define | Mvc_CubeNBitEmpty(Res, Cube) |
#define | Mvc_Cube1BitEqual(Res, Cube1, Cube2) (Res = (((Cube1)->pData[0]) == ((Cube2)->pData[0]))) |
#define | Mvc_Cube2BitEqual(Res, Cube1, Cube2) |
#define | Mvc_CubeNBitEqual(Res, Cube1, Cube2) |
#define | Mvc_Cube1BitLess(Res, Cube1, Cube2) (Res = (((Cube1)->pData[0]) < ((Cube2)->pData[0]))) |
#define | Mvc_Cube2BitLess(Res, Cube1, Cube2) |
#define | Mvc_CubeNBitLess(Res, Cube1, Cube2) |
#define | Mvc_Cube1BitMore(Res, Cube1, Cube2) (Res = (((Cube1)->pData[0]) > ((Cube2)->pData[0]))) |
#define | Mvc_Cube2BitMore(Res, Cube1, Cube2) |
#define | Mvc_CubeNBitMore(Res, Cube1, Cube2) |
#define | Mvc_Cube1BitNotImpl(Res, Cube1, Cube2) (Res = (((Cube1)->pData[0]) & ~((Cube2)->pData[0]))) |
#define | Mvc_Cube2BitNotImpl(Res, Cube1, Cube2) |
#define | Mvc_CubeNBitNotImpl(Res, Cube1, Cube2) |
#define | Mvc_Cube1BitDisjoint(Res, Cube1, Cube2) (Res = ((((Cube1)->pData[0]) & ((Cube2)->pData[0])) == 0 )) |
#define | Mvc_Cube2BitDisjoint(Res, Cube1, Cube2) |
#define | Mvc_CubeNBitDisjoint(Res, Cube1, Cube2) |
#define | Mvc_Cube1BitEqualUnderMask(Res, Cube1, Cube2, Mask) (Res = ((((Cube1)->pData[0]) & ((Mask)->pData[0])) == (((Cube2)->pData[0]) & ((Mask)->pData[0])))) |
#define | Mvc_Cube2BitEqualUnderMask(Res, Cube1, Cube2, Mask) |
#define | Mvc_CubeNBitEqualUnderMask(Res, Cube1, Cube2, Mask) |
#define | Mvc_Cube1BitEqualOutsideMask(Res, Cube1, Cube2, Mask) (Res = ((((Cube1)->pData[0]) | ((Mask)->pData[0])) == (((Cube2)->pData[0]) | ((Mask)->pData[0])))) |
#define | Mvc_Cube2BitEqualOutsideMask(Res, Cube1, Cube2, Mask) |
#define | Mvc_CubeNBitEqualOutsideMask(Res, Cube1, Cube2, Mask) |
#define | Mvc_Cube1BitIntersectUnderMask(Res, Cube1, Cube2, Mask) (Res = ((((Cube1)->pData[0]) & ((Cube2)->pData[0]) & ((Mask)->pData[0])) > 0)) |
#define | Mvc_Cube2BitIntersectUnderMask(Res, Cube1, Cube2, Mask) |
#define | Mvc_CubeNBitIntersectUnderMask(Res, Cube1, Cube2, Mask) |
#define | Mvc_Cube1BitNotImplUnderMask(Res, Cube1, Cube2, Mask) (Res = (((Mask)->pData[0]) & ((Cube1)->pData[0]) & ~((Cube2)->pData[0]))) |
#define | Mvc_Cube2BitNotImplUnderMask(Res, Cube1, Cube2, Mask) |
#define | Mvc_CubeNBitNotImplUnderMask(Res, Cube1, Cube2, Mask) |
#define | Mvc_CubeBitClean(Cube) |
#define | Mvc_CubeBitFill(Cube) |
#define | Mvc_CubeBitNot(Cube) |
#define | Mvc_CubeBitCopy(Cube1, Cube2) |
#define | Mvc_CubeBitOr(CubeR, Cube1, Cube2) |
#define | Mvc_CubeBitExor(CubeR, Cube1, Cube2) |
#define | Mvc_CubeBitAnd(CubeR, Cube1, Cube2) |
#define | Mvc_CubeBitSharp(CubeR, Cube1, Cube2) |
#define | Mvc_CubeBitEmpty(Res, Cube) |
#define | Mvc_CubeBitEqual(Res, Cube1, Cube2) |
#define | Mvc_CubeBitLess(Res, Cube1, Cube2) |
#define | Mvc_CubeBitMore(Res, Cube1, Cube2) |
#define | Mvc_CubeBitNotImpl(Res, Cube1, Cube2) |
#define | Mvc_CubeBitDisjoint(Res, Cube1, Cube2) |
#define | Mvc_CubeBitEqualUnderMask(Res, Cube1, Cube2, Mask) |
#define | Mvc_CubeBitEqualOutsideMask(Res, Cube1, Cube2, Mask) |
#define | Mvc_CubeBitIntersectUnderMask(Res, Cube1, Cube2, Mask) |
#define | Mvc_CubeBitNotImplUnderMask(Res, Cube1, Cube2, Mask) |
#define | Mvc_ListAddCubeHead(pList, pCube) |
#define | Mvc_ListAddCubeTail(pList, pCube) |
#define | Mvc_ListDeleteCube(pList, pPrev, pCube) |
#define | Mvc_CoverAddCubeHead(pCover, pCube) |
#define | Mvc_CoverAddCubeTail(pCover, pCube) |
#define | Mvc_CoverDeleteCube(pCover, pPrev, pCube) |
#define | Mvc_ListForEachCube(List, Cube) |
#define | Mvc_ListForEachCubeSafe(List, Cube, Cube2) |
#define | Mvc_CoverForEachCube(Cover, Cube) |
#define | Mvc_CoverForEachCubeWithIndex(Cover, Cube, Index) |
#define | Mvc_CoverForEachCubeSafe(Cover, Cube, Cube2) |
#define | Mvc_CoverForEachCubeStart(Start, Cube) |
#define | Mvc_CoverForEachCubeStartSafe(Start, Cube, Cube2) |
#define | Mvc_CubeForEachBit(Cover, Cube, iBit, Value) |
#define | Mvc_CubeForEachVarValue(Cover, Cube, iVar, Value) |
#define | MEM_ALLOC(Manager, Type, Size) ((Type *)malloc( (Size) * sizeof(Type) )) |
#define | MEM_FREE(Manager, Type, Size, Pointer) if ( Pointer ) { free(Pointer); Pointer = NULL; } |
Typedefs | |
typedef unsigned int | 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 |
Functions | |
int | Mvc_CoverReadWordNum (Mvc_Cover_t *pCover) |
int | Mvc_CoverReadBitNum (Mvc_Cover_t *pCover) |
int | Mvc_CoverReadCubeNum (Mvc_Cover_t *pCover) |
Mvc_Cube_t * | Mvc_CoverReadCubeHead (Mvc_Cover_t *pCover) |
Mvc_Cube_t * | Mvc_CoverReadCubeTail (Mvc_Cover_t *pCover) |
Mvc_List_t * | Mvc_CoverReadCubeList (Mvc_Cover_t *pCover) |
int | Mvc_ListReadCubeNum (Mvc_List_t *pList) |
Mvc_Cube_t * | Mvc_ListReadCubeHead (Mvc_List_t *pList) |
Mvc_Cube_t * | Mvc_ListReadCubeTail (Mvc_List_t *pList) |
void | Mvc_CoverSetCubeNum (Mvc_Cover_t *pCover, int nItems) |
void | Mvc_CoverSetCubeHead (Mvc_Cover_t *pCover, Mvc_Cube_t *pCube) |
void | Mvc_CoverSetCubeTail (Mvc_Cover_t *pCover, Mvc_Cube_t *pCube) |
void | Mvc_CoverSetCubeList (Mvc_Cover_t *pCover, Mvc_List_t *pList) |
int | Mvc_CoverIsEmpty (Mvc_Cover_t *pCover) |
int | Mvc_CoverIsTautology (Mvc_Cover_t *pCover) |
int | Mvc_CoverIsBinaryBuffer (Mvc_Cover_t *pCover) |
void | Mvc_CoverMakeEmpty (Mvc_Cover_t *pCover) |
void | Mvc_CoverMakeTautology (Mvc_Cover_t *pCover) |
Mvc_Cover_t * | Mvc_CoverCreateEmpty (Mvc_Cover_t *pCover) |
Mvc_Cover_t * | Mvc_CoverCreateTautology (Mvc_Cover_t *pCover) |
Mvc_Cover_t * | Mvc_CoverAlloc (Mvc_Manager_t *pMem, int nBits) |
Mvc_Cover_t * | Mvc_CoverCreateConst (Mvc_Manager_t *pMem, int nBits, int Phase) |
Mvc_Cover_t * | Mvc_CoverClone (Mvc_Cover_t *pCover) |
Mvc_Cover_t * | Mvc_CoverDup (Mvc_Cover_t *pCover) |
void | Mvc_CoverFree (Mvc_Cover_t *pCover) |
void | Mvc_CoverAllocateMask (Mvc_Cover_t *pCover) |
void | Mvc_CoverAllocateArrayLits (Mvc_Cover_t *pCover) |
void | Mvc_CoverAllocateArrayCubes (Mvc_Cover_t *pCover) |
void | Mvc_CoverDeallocateMask (Mvc_Cover_t *pCover) |
void | Mvc_CoverDeallocateArrayLits (Mvc_Cover_t *pCover) |
Mvc_Cube_t * | Mvc_CubeAlloc (Mvc_Cover_t *pCover) |
Mvc_Cube_t * | Mvc_CubeDup (Mvc_Cover_t *pCover, Mvc_Cube_t *pCube) |
void | Mvc_CubeFree (Mvc_Cover_t *pCover, Mvc_Cube_t *pCube) |
void | Mvc_CubeBitRemoveDcs (Mvc_Cube_t *pCube) |
int | Mvc_CubeCompareInt (Mvc_Cube_t *pC1, Mvc_Cube_t *pC2, Mvc_Cube_t *pMask) |
int | Mvc_CubeCompareSizeAndInt (Mvc_Cube_t *pC1, Mvc_Cube_t *pC2, Mvc_Cube_t *pMask) |
int | Mvc_CubeCompareIntUnderMask (Mvc_Cube_t *pC1, Mvc_Cube_t *pC2, Mvc_Cube_t *pMask) |
int | Mvc_CubeCompareIntOutsideMask (Mvc_Cube_t *pC1, Mvc_Cube_t *pC2, Mvc_Cube_t *pMask) |
int | Mvc_CubeCompareIntOutsideAndUnderMask (Mvc_Cube_t *pC1, Mvc_Cube_t *pC2, Mvc_Cube_t *pMask) |
Mvc_Cover_t * | Mvc_CoverDivisor (Mvc_Cover_t *pCover) |
void | Mvc_CoverDivide (Mvc_Cover_t *pCover, Mvc_Cover_t *pDiv, Mvc_Cover_t **ppQuo, Mvc_Cover_t **ppRem) |
void | Mvc_CoverDivideInternal (Mvc_Cover_t *pCover, Mvc_Cover_t *pDiv, Mvc_Cover_t **ppQuo, Mvc_Cover_t **ppRem) |
void | Mvc_CoverDivideByLiteral (Mvc_Cover_t *pCover, Mvc_Cover_t *pDiv, Mvc_Cover_t **ppQuo, Mvc_Cover_t **ppRem) |
void | Mvc_CoverDivideByCube (Mvc_Cover_t *pCover, Mvc_Cover_t *pDiv, Mvc_Cover_t **ppQuo, Mvc_Cover_t **ppRem) |
void | Mvc_CoverDivideByLiteralQuo (Mvc_Cover_t *pCover, int iLit) |
void | Mvc_ListAddCubeHead_ (Mvc_List_t *pList, Mvc_Cube_t *pCube) |
void | Mvc_ListAddCubeTail_ (Mvc_List_t *pList, Mvc_Cube_t *pCube) |
void | Mvc_ListDeleteCube_ (Mvc_List_t *pList, Mvc_Cube_t *pPrev, Mvc_Cube_t *pCube) |
void | Mvc_CoverAddCubeHead_ (Mvc_Cover_t *pCover, Mvc_Cube_t *pCube) |
void | Mvc_CoverAddCubeTail_ (Mvc_Cover_t *pCover, Mvc_Cube_t *pCube) |
void | Mvc_CoverDeleteCube_ (Mvc_Cover_t *pCover, Mvc_Cube_t *pPrev, Mvc_Cube_t *pCube) |
void | Mvc_CoverAddDupCubeHead (Mvc_Cover_t *pCover, Mvc_Cube_t *pCube) |
void | Mvc_CoverAddDupCubeTail (Mvc_Cover_t *pCover, Mvc_Cube_t *pCube) |
void | Mvc_CoverAddLiteralsOfCube (Mvc_Cover_t *pCover, Mvc_Cube_t *pCube) |
void | Mvc_CoverDeleteLiteralsOfCube (Mvc_Cover_t *pCover, Mvc_Cube_t *pCube) |
void | Mvc_CoverList2Array (Mvc_Cover_t *pCover) |
void | Mvc_CoverArray2List (Mvc_Cover_t *pCover) |
Mvc_Cube_t * | Mvc_ListGetTailFromHead (Mvc_Cube_t *pHead) |
void | Mvc_CoverPrint (Mvc_Cover_t *pCover) |
void | Mvc_CubePrint (Mvc_Cover_t *pCover, Mvc_Cube_t *pCube) |
void | Mvc_CoverPrintMv (Mvc_Data_t *pData, Mvc_Cover_t *pCover) |
void | Mvc_CubePrintMv (Mvc_Data_t *pData, Mvc_Cover_t *pCover, Mvc_Cube_t *pCube) |
void | Mvc_CoverSort (Mvc_Cover_t *pCover, Mvc_Cube_t *pMask, int(*pCompareFunc)(Mvc_Cube_t *, Mvc_Cube_t *, Mvc_Cube_t *)) |
void | Mvc_CoverSupport (Mvc_Cover_t *pCover, Mvc_Cube_t *pSupp) |
int | Mvc_CoverSupportSizeBinary (Mvc_Cover_t *pCover) |
int | Mvc_CoverSupportVarBelongs (Mvc_Cover_t *pCover, int iVar) |
void | Mvc_CoverCommonCube (Mvc_Cover_t *pCover, Mvc_Cube_t *pComCube) |
int | Mvc_CoverIsCubeFree (Mvc_Cover_t *pCover) |
void | Mvc_CoverMakeCubeFree (Mvc_Cover_t *pCover) |
Mvc_Cover_t * | Mvc_CoverCommonCubeCover (Mvc_Cover_t *pCover) |
int | Mvc_CoverCheckSuppContainment (Mvc_Cover_t *pCover1, Mvc_Cover_t *pCover2) |
int | Mvc_CoverSetCubeSizes (Mvc_Cover_t *pCover) |
int | Mvc_CoverGetCubeSize (Mvc_Cube_t *pCube) |
int | Mvc_CoverCountCubePairDiffs (Mvc_Cover_t *pCover, unsigned char pDiffs[]) |
Mvc_Cover_t * | Mvc_CoverRemap (Mvc_Cover_t *pCover, int *pVarsRem, int nVarsRem) |
void | Mvc_CoverInverse (Mvc_Cover_t *pCover) |
Mvc_Cover_t * | Mvc_CoverRemoveDontCareLits (Mvc_Cover_t *pCover) |
Mvc_Cover_t * | Mvc_CoverCofactor (Mvc_Cover_t *pCover, int iValue, int iValueOther) |
Mvc_Cover_t * | Mvc_CoverFlipVar (Mvc_Cover_t *pCover, int iValue0, int iValue1) |
Mvc_Cover_t * | Mvc_CoverUnivQuantify (Mvc_Cover_t *p, int iValueA0, int iValueA1, int iValueB0, int iValueB1) |
Mvc_Cover_t ** | Mvc_CoverCofactors (Mvc_Data_t *pData, Mvc_Cover_t *pCover, int iVar) |
int | Mvr_CoverCountLitsWithValue (Mvc_Data_t *pData, Mvc_Cover_t *pCover, int iVar, int iValue) |
Mvc_Cover_t * | Mvc_CoverTranspose (Mvc_Cover_t *pCover) |
int | Mvc_UtilsCheckUnusedZeros (Mvc_Cover_t *pCover) |
int | Mvc_CoverAnyLiteral (Mvc_Cover_t *pCover, Mvc_Cube_t *pMask) |
int | Mvc_CoverBestLiteral (Mvc_Cover_t *pCover, Mvc_Cube_t *pMask) |
int | Mvc_CoverWorstLiteral (Mvc_Cover_t *pCover, Mvc_Cube_t *pMask) |
Mvc_Cover_t * | Mvc_CoverBestLiteralCover (Mvc_Cover_t *pCover, Mvc_Cover_t *pSimple) |
int | Mvc_CoverFirstCubeFirstLit (Mvc_Cover_t *pCover) |
int | Mvc_CoverCountLiterals (Mvc_Cover_t *pCover) |
int | Mvc_CoverIsOneLiteral (Mvc_Cover_t *pCover) |
Mvc_Cover_t * | Mvc_CoverAlgebraicMultiply (Mvc_Cover_t *pCover1, Mvc_Cover_t *pCover2) |
Mvc_Cover_t * | Mvc_CoverAlgebraicSubtract (Mvc_Cover_t *pCover1, Mvc_Cover_t *pCover2) |
int | Mvc_CoverAlgebraicEqual (Mvc_Cover_t *pCover1, Mvc_Cover_t *pCover2) |
Mvc_Cover_t * | Mvc_CoverBooleanOr (Mvc_Cover_t *pCover1, Mvc_Cover_t *pCover2) |
Mvc_Cover_t * | Mvc_CoverBooleanAnd (Mvc_Data_t *p, Mvc_Cover_t *pCover1, Mvc_Cover_t *pCover2) |
int | Mvc_CoverBooleanEqual (Mvc_Data_t *p, Mvc_Cover_t *pCover1, Mvc_Cover_t *pCover2) |
int | Mvc_CoverContain (Mvc_Cover_t *pCover) |
int | Mvc_CoverTautology (Mvc_Data_t *p, Mvc_Cover_t *pCover) |
Mvc_Cover_t * | Mvc_CoverComplement (Mvc_Data_t *p, Mvc_Cover_t *pCover) |
Mvc_Cover_t * | Mvc_CoverSharp (Mvc_Data_t *p, Mvc_Cover_t *pA, Mvc_Cover_t *pB) |
int | Mvc_CoverDist0Cubes (Mvc_Data_t *pData, Mvc_Cube_t *pA, Mvc_Cube_t *pB) |
void | Mvc_CoverIntersectCubes (Mvc_Data_t *pData, Mvc_Cover_t *pC1, Mvc_Cover_t *pC2) |
int | Mvc_CoverIsIntersecting (Mvc_Data_t *pData, Mvc_Cover_t *pC1, Mvc_Cover_t *pC2) |
void | Mvc_CoverAppendCubes (Mvc_Cover_t *pC1, Mvc_Cover_t *pC2) |
void | Mvc_CoverCopyAndAppendCubes (Mvc_Cover_t *pC1, Mvc_Cover_t *pC2) |
void | Mvc_CoverRemoveCubes (Mvc_Cover_t *pC) |
void | Mvc_CoverMinimizeByReshape (Mvc_Data_t *pData, Mvc_Cover_t *pCover) |
void | Mvc_CoverDist1Merge (Mvc_Data_t *p, Mvc_Cover_t *pCover) |
void | Mvc_ManagerFree (Mvc_Manager_t *p) |
Mvc_Manager_t * | Mvc_ManagerStart () |
Mvc_Manager_t * | Mvc_ManagerAllocCover () |
Mvc_Manager_t * | Mvc_ManagerAllocCube (int nWords) |
Mvc_Manager_t * | Mvc_ManagerFreeCover (Mvc_Cover_t *pCover) |
Mvc_Manager_t * | Mvc_ManagerFreeCube (Mvc_Cover_t *pCube, int nWords) |
#define BITS_DISJOINT ((Mvc_CubeWord_t)0x55555555) |
#define BITS_FULL ((Mvc_CubeWord_t)0xffffffff) |
#define BITS_PER_WORD 32 |
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 [
] INCLUDES /// PARAMETERS ///
#define MEM_ALLOC | ( | Manager, | |||
Type, | |||||
Size | ) | ((Type *)malloc( (Size) * sizeof(Type) )) |
#define MEM_FREE | ( | Manager, | |||
Type, | |||||
Size, | |||||
Pointer | ) | if ( Pointer ) { free(Pointer); Pointer = NULL; } |
#define Mvc_CoverAddCubeHead | ( | pCover, | |||
pCube | ) |
{\ Mvc_List_t * pList = &pCover->lCubes;\ Mvc_ListAddCubeHead( pList, pCube );\ }
#define Mvc_CoverAddCubeTail | ( | pCover, | |||
pCube | ) |
{\ Mvc_List_t * pList = &pCover->lCubes;\ Mvc_ListAddCubeTail( pList, pCube );\ }
#define Mvc_CoverDeleteCube | ( | pCover, | |||
pPrev, | |||||
pCube | ) |
{\ Mvc_List_t * pList = &pCover->lCubes;\ Mvc_ListDeleteCube( pList, pPrev, pCube );\ }
#define Mvc_CoverForEachCube | ( | Cover, | |||
Cube | ) |
#define Mvc_CoverForEachCubeSafe | ( | Cover, | |||
Cube, | |||||
Cube2 | ) |
#define Mvc_CoverForEachCubeStart | ( | Start, | |||
Cube | ) |
#define Mvc_CoverForEachCubeStartSafe | ( | Start, | |||
Cube, | |||||
Cube2 | ) |
#define Mvc_CoverForEachCubeWithIndex | ( | Cover, | |||
Cube, | |||||
Index | ) |
#define Mvc_Cube1BitAnd | ( | CubeR, | |||
Cube1, | |||||
Cube2 | ) | (((CubeR)->pData[0]) = ((Cube1)->pData[0] & (Cube2)->pData[0])) |
#define Mvc_Cube1BitCopy | ( | Cube1, | |||
Cube2 | ) | (((Cube1)->pData[0]) = ((Cube2)->pData[0])) |
#define Mvc_Cube1BitDisjoint | ( | Res, | |||
Cube1, | |||||
Cube2 | ) | (Res = ((((Cube1)->pData[0]) & ((Cube2)->pData[0])) == 0 )) |
#define Mvc_Cube1BitEmpty | ( | Res, | |||
Cube | ) | (Res = ((Cube)->pData[0] == 0)) |
#define Mvc_Cube1BitEqual | ( | Res, | |||
Cube1, | |||||
Cube2 | ) | (Res = (((Cube1)->pData[0]) == ((Cube2)->pData[0]))) |
#define Mvc_Cube1BitEqualOutsideMask | ( | Res, | |||
Cube1, | |||||
Cube2, | |||||
Mask | ) | (Res = ((((Cube1)->pData[0]) | ((Mask)->pData[0])) == (((Cube2)->pData[0]) | ((Mask)->pData[0])))) |
#define Mvc_Cube1BitEqualUnderMask | ( | Res, | |||
Cube1, | |||||
Cube2, | |||||
Mask | ) | (Res = ((((Cube1)->pData[0]) & ((Mask)->pData[0])) == (((Cube2)->pData[0]) & ((Mask)->pData[0])))) |
#define Mvc_Cube1BitExor | ( | CubeR, | |||
Cube1, | |||||
Cube2 | ) | (((CubeR)->pData[0]) = ((Cube1)->pData[0] ^ (Cube2)->pData[0])) |
#define Mvc_Cube1BitFill | ( | Cube | ) | (Cube)->pData[0] = (BITS_FULL >> (Cube)->nUnused); |
#define Mvc_Cube1BitIntersectUnderMask | ( | Res, | |||
Cube1, | |||||
Cube2, | |||||
Mask | ) | (Res = ((((Cube1)->pData[0]) & ((Cube2)->pData[0]) & ((Mask)->pData[0])) > 0)) |
#define Mvc_Cube1BitLess | ( | Res, | |||
Cube1, | |||||
Cube2 | ) | (Res = (((Cube1)->pData[0]) < ((Cube2)->pData[0]))) |
#define Mvc_Cube1BitMore | ( | Res, | |||
Cube1, | |||||
Cube2 | ) | (Res = (((Cube1)->pData[0]) > ((Cube2)->pData[0]))) |
#define Mvc_Cube1BitNot | ( | Cube | ) | ((Cube)->pData[0] ^= (BITS_FULL >> (Cube)->nUnused)) |
#define Mvc_Cube1BitNotImpl | ( | Res, | |||
Cube1, | |||||
Cube2 | ) | (Res = (((Cube1)->pData[0]) & ~((Cube2)->pData[0]))) |
#define Mvc_Cube1BitNotImplUnderMask | ( | Res, | |||
Cube1, | |||||
Cube2, | |||||
Mask | ) | (Res = (((Mask)->pData[0]) & ((Cube1)->pData[0]) & ~((Cube2)->pData[0]))) |
#define Mvc_Cube1BitOr | ( | CubeR, | |||
Cube1, | |||||
Cube2 | ) | (((CubeR)->pData[0]) = ((Cube1)->pData[0] | (Cube2)->pData[0])) |
#define Mvc_Cube1BitSharp | ( | CubeR, | |||
Cube1, | |||||
Cube2 | ) | (((CubeR)->pData[0]) = ((Cube1)->pData[0] & ~((Cube2)->pData[0]))) |
#define Mvc_Cube2BitAnd | ( | CubeR, | |||
Cube1, | |||||
Cube2 | ) |
#define Mvc_Cube2BitClean | ( | Cube | ) |
#define Mvc_Cube2BitCopy | ( | Cube1, | |||
Cube2 | ) |
#define Mvc_Cube2BitDisjoint | ( | Res, | |||
Cube1, | |||||
Cube2 | ) |
#define Mvc_Cube2BitEmpty | ( | Res, | |||
Cube | ) | (Res = ((Cube)->pData[0] == 0 && (Cube)->pData[1] == 0)) |
#define Mvc_Cube2BitEqual | ( | Res, | |||
Cube1, | |||||
Cube2 | ) |
#define Mvc_Cube2BitEqualOutsideMask | ( | Res, | |||
Cube1, | |||||
Cube2, | |||||
Mask | ) |
#define Mvc_Cube2BitEqualUnderMask | ( | Res, | |||
Cube1, | |||||
Cube2, | |||||
Mask | ) |
#define Mvc_Cube2BitExor | ( | CubeR, | |||
Cube1, | |||||
Cube2 | ) |
#define Mvc_Cube2BitFill | ( | Cube | ) |
#define Mvc_Cube2BitIntersectUnderMask | ( | Res, | |||
Cube1, | |||||
Cube2, | |||||
Mask | ) |
#define Mvc_Cube2BitLess | ( | Res, | |||
Cube1, | |||||
Cube2 | ) |
#define Mvc_Cube2BitMore | ( | Res, | |||
Cube1, | |||||
Cube2 | ) |
#define Mvc_Cube2BitNot | ( | Cube | ) |
#define Mvc_Cube2BitNotImpl | ( | Res, | |||
Cube1, | |||||
Cube2 | ) |
#define Mvc_Cube2BitNotImplUnderMask | ( | Res, | |||
Cube1, | |||||
Cube2, | |||||
Mask | ) |
#define Mvc_Cube2BitOr | ( | CubeR, | |||
Cube1, | |||||
Cube2 | ) |
#define Mvc_Cube2BitSharp | ( | CubeR, | |||
Cube1, | |||||
Cube2 | ) |
#define Mvc_CubeBitAnd | ( | CubeR, | |||
Cube1, | |||||
Cube2 | ) |
if ( Mvc_Cube1Words(Cube1) ) { Mvc_Cube1BitAnd( CubeR, Cube1, Cube2 ); }\ else if ( Mvc_Cube2Words(Cube1) ){ Mvc_Cube2BitAnd( CubeR, Cube1, Cube2 ); }\ else { Mvc_CubeNBitAnd( CubeR, Cube1, Cube2 ); }
#define Mvc_CubeBitClean | ( | Cube | ) |
if ( Mvc_Cube1Words(Cube) ) { Mvc_Cube1BitClean( Cube ); }\ else if ( Mvc_Cube2Words(Cube) ) { Mvc_Cube2BitClean( Cube ); }\ else { Mvc_CubeNBitClean( Cube ); }
#define Mvc_CubeBitCleanUnused | ( | Cube | ) | ((Cube)->pData[(Cube)->iLast] &= (BITS_FULL >> (Cube)->nUnused)) |
#define Mvc_CubeBitCopy | ( | Cube1, | |||
Cube2 | ) |
if ( Mvc_Cube1Words(Cube1) ) { Mvc_Cube1BitCopy( Cube1, Cube2 ); }\ else if ( Mvc_Cube2Words(Cube1) ){ Mvc_Cube2BitCopy( Cube1, Cube2 ); }\ else { Mvc_CubeNBitCopy( Cube1, Cube2 ); }
#define Mvc_CubeBitDisjoint | ( | Res, | |||
Cube1, | |||||
Cube2 | ) |
if ( Mvc_Cube1Words(Cube1) ) { Mvc_Cube1BitDisjoint( Res, Cube1, Cube2 ); }\ else if ( Mvc_Cube2Words(Cube1) ){ Mvc_Cube2BitDisjoint( Res, Cube1, Cube2 ); }\ else { Mvc_CubeNBitDisjoint( Res, Cube1, Cube2 ); }
#define Mvc_CubeBitEmpty | ( | Res, | |||
Cube | ) |
if ( Mvc_Cube1Words(Cube) ) { Mvc_Cube1BitEmpty( Res, Cube ); }\ else if ( Mvc_Cube2Words(Cube) ) { Mvc_Cube2BitEmpty( Res, Cube ); }\ else { Mvc_CubeNBitEmpty( Res, Cube ); }
#define Mvc_CubeBitEqual | ( | Res, | |||
Cube1, | |||||
Cube2 | ) |
if ( Mvc_Cube1Words(Cube1) ) { Mvc_Cube1BitEqual( Res, Cube1, Cube2 ); }\ else if ( Mvc_Cube2Words(Cube1) ){ Mvc_Cube2BitEqual( Res, Cube1, Cube2 ); }\ else { Mvc_CubeNBitEqual( Res, Cube1, Cube2 ); }
#define Mvc_CubeBitEqualOutsideMask | ( | Res, | |||
Cube1, | |||||
Cube2, | |||||
Mask | ) |
if ( Mvc_Cube1Words(Cube1) ) { Mvc_Cube1BitEqualOutsideMask( Res, Cube1, Cube2, Mask ); }\ else if ( Mvc_Cube2Words(Cube1) ){ Mvc_Cube2BitEqualOutsideMask( Res, Cube1, Cube2, Mask ); }\ else { Mvc_CubeNBitEqualOutsideMask( Res, Cube1, Cube2, Mask ); }
#define Mvc_CubeBitEqualUnderMask | ( | Res, | |||
Cube1, | |||||
Cube2, | |||||
Mask | ) |
if ( Mvc_Cube1Words(Cube1) ) { Mvc_Cube1BitEqualUnderMask( Res, Cube1, Cube2, Mask ); }\ else if ( Mvc_Cube2Words(Cube1) ){ Mvc_Cube2BitEqualUnderMask( Res, Cube1, Cube2, Mask ); }\ else { Mvc_CubeNBitEqualUnderMask( Res, Cube1, Cube2, Mask ); }
#define Mvc_CubeBitExor | ( | CubeR, | |||
Cube1, | |||||
Cube2 | ) |
if ( Mvc_Cube1Words(Cube1) ) { Mvc_Cube1BitExor( CubeR, Cube1, Cube2 ); }\ else if ( Mvc_Cube2Words(Cube1) ){ Mvc_Cube2BitExor( CubeR, Cube1, Cube2 ); }\ else { Mvc_CubeNBitExor( CubeR, Cube1, Cube2 ); }
#define Mvc_CubeBitFill | ( | Cube | ) |
if ( Mvc_Cube1Words(Cube) ) { Mvc_Cube1BitFill( Cube ); }\ else if ( Mvc_Cube2Words(Cube) ) { Mvc_Cube2BitFill( Cube ); }\ else { Mvc_CubeNBitFill( Cube ); }
#define Mvc_CubeBitInsert | ( | Cube, | |||
Bit | ) | ((Cube)->pData[Mvc_CubeWhichWord(Bit)] |= (((Mvc_CubeWord_t)1)<<(Mvc_CubeWhichBit(Bit)))) |
#define Mvc_CubeBitIntersectUnderMask | ( | Res, | |||
Cube1, | |||||
Cube2, | |||||
Mask | ) |
if ( Mvc_Cube1Words(Cube1) ) { Mvc_Cube1BitIntersectUnderMask( Res, Cube1, Cube2, Mask ); }\ else if ( Mvc_Cube2Words(Cube1) ){ Mvc_Cube2BitIntersectUnderMask( Res, Cube1, Cube2, Mask ); }\ else { Mvc_CubeNBitIntersectUnderMask( Res, Cube1, Cube2, Mask ); }
#define Mvc_CubeBitLess | ( | Res, | |||
Cube1, | |||||
Cube2 | ) |
if ( Mvc_Cube1Words(Cube1) ) { Mvc_Cube1BitLess( Res, Cube1, Cube2 ); }\ else if ( Mvc_Cube2Words(Cube1) ){ Mvc_Cube2BitLess( Res, Cube1, Cube2 ); }\ else { Mvc_CubeNBitLess( Res, Cube1, Cube2 ); }
#define Mvc_CubeBitMore | ( | Res, | |||
Cube1, | |||||
Cube2 | ) |
if ( Mvc_Cube1Words(Cube1) ) { Mvc_Cube1BitMore( Res, Cube1, Cube2 ); }\ else if ( Mvc_Cube2Words(Cube1) ){ Mvc_Cube2BitMore( Res, Cube1, Cube2 ); }\ else { Mvc_CubeNBitMore( Res, Cube1, Cube2 ); }
#define Mvc_CubeBitNot | ( | Cube | ) |
if ( Mvc_Cube1Words(Cube) ) { Mvc_Cube1BitNot( Cube ); }\ else if ( Mvc_Cube2Words(Cube) ) { Mvc_Cube2BitNot( Cube ); }\ else { Mvc_CubeNBitNot( Cube ); }
#define Mvc_CubeBitNotImpl | ( | Res, | |||
Cube1, | |||||
Cube2 | ) |
if ( Mvc_Cube1Words(Cube1) ) { Mvc_Cube1BitNotImpl( Res, Cube1, Cube2 ); }\ else if ( Mvc_Cube2Words(Cube1) ){ Mvc_Cube2BitNotImpl( Res, Cube1, Cube2 ); }\ else { Mvc_CubeNBitNotImpl( Res, Cube1, Cube2 ); }
#define Mvc_CubeBitNotImplUnderMask | ( | Res, | |||
Cube1, | |||||
Cube2, | |||||
Mask | ) |
if ( Mvc_Cube1Words(Cube1) ) { Mvc_Cube1BitNotImplUnderMask( Res, Cube1, Cube2, Mask ); }\ else if ( Mvc_Cube2Words(Cube1) ){ Mvc_Cube2BitNotImplUnderMask( Res, Cube1, Cube2, Mask ); }\ else { Mvc_CubeNBitNotImplUnderMask( Res, Cube1, Cube2, Mask ); }
#define Mvc_CubeBitOr | ( | CubeR, | |||
Cube1, | |||||
Cube2 | ) |
if ( Mvc_Cube1Words(Cube1) ) { Mvc_Cube1BitOr( CubeR, Cube1, Cube2 ); }\ else if ( Mvc_Cube2Words(Cube1) ){ Mvc_Cube2BitOr( CubeR, Cube1, Cube2 ); }\ else { Mvc_CubeNBitOr( CubeR, Cube1, Cube2 ); }
#define Mvc_CubeBitRemove | ( | Cube, | |||
Bit | ) | ((Cube)->pData[Mvc_CubeWhichWord(Bit)] &= ~(((Mvc_CubeWord_t)1)<<(Mvc_CubeWhichBit(Bit)))) |
#define Mvc_CubeBitSharp | ( | CubeR, | |||
Cube1, | |||||
Cube2 | ) |
if ( Mvc_Cube1Words(Cube1) ) { Mvc_Cube1BitSharp( CubeR, Cube1, Cube2 ); }\ else if ( Mvc_Cube2Words(Cube1) ){ Mvc_Cube2BitSharp( CubeR, Cube1, Cube2 ); }\ else { Mvc_CubeNBitSharp( CubeR, Cube1, Cube2 ); }
#define Mvc_CubeBitValue | ( | Cube, | |||
Bit | ) | (((Cube)->pData[Mvc_CubeWhichWord(Bit)] & (((Mvc_CubeWord_t)1)<<(Mvc_CubeWhichBit(Bit)))) > 0) |
#define Mvc_CubeForEachBit | ( | Cover, | |||
Cube, | |||||
iBit, | |||||
Value | ) |
for ( iBit = 0;\ iBit < Cover->nBits && ((Value = Mvc_CubeBitValue(Cube,iBit))>=0);\ iBit++ )
#define Mvc_CubeForEachVarValue | ( | Cover, | |||
Cube, | |||||
iVar, | |||||
Value | ) |
for ( iVar = 0;\ iVar < Cover->nBits/2 && (Value = Mvc_CubeVarValue(Cube,iVar));\ iVar++ )
#define Mvc_CubeNBitAnd | ( | CubeR, | |||
Cube1, | |||||
Cube2 | ) |
#define Mvc_CubeNBitClean | ( | Cube | ) |
#define Mvc_CubeNBitCopy | ( | Cube1, | |||
Cube2 | ) |
#define Mvc_CubeNBitDisjoint | ( | Res, | |||
Cube1, | |||||
Cube2 | ) |
#define Mvc_CubeNBitEmpty | ( | Res, | |||
Cube | ) |
#define Mvc_CubeNBitEqual | ( | Res, | |||
Cube1, | |||||
Cube2 | ) |
#define Mvc_CubeNBitEqualOutsideMask | ( | Res, | |||
Cube1, | |||||
Cube2, | |||||
Mask | ) |
#define Mvc_CubeNBitEqualUnderMask | ( | Res, | |||
Cube1, | |||||
Cube2, | |||||
Mask | ) |
#define Mvc_CubeNBitExor | ( | CubeR, | |||
Cube1, | |||||
Cube2 | ) |
#define Mvc_CubeNBitFill | ( | Cube | ) |
#define Mvc_CubeNBitIntersectUnderMask | ( | Res, | |||
Cube1, | |||||
Cube2, | |||||
Mask | ) |
#define Mvc_CubeNBitLess | ( | Res, | |||
Cube1, | |||||
Cube2 | ) |
#define Mvc_CubeNBitMore | ( | Res, | |||
Cube1, | |||||
Cube2 | ) |
#define Mvc_CubeNBitNot | ( | Cube | ) |
#define Mvc_CubeNBitNotImpl | ( | Res, | |||
Cube1, | |||||
Cube2 | ) |
#define Mvc_CubeNBitNotImplUnderMask | ( | Res, | |||
Cube1, | |||||
Cube2, | |||||
Mask | ) |
#define Mvc_CubeNBitOr | ( | CubeR, | |||
Cube1, | |||||
Cube2 | ) |
#define Mvc_CubeNBitSharp | ( | CubeR, | |||
Cube1, | |||||
Cube2 | ) |
#define Mvc_CubeReadNext | ( | Cube | ) | ((Cube)->pNext) |
#define Mvc_CubeSetLast | ( | Cube, | |||
Last | ) | ((Cube)->iLast = (Last)) |
#define Mvc_CubeSetNext | ( | Cube, | |||
Next | ) | ((Cube)->pNext = (Next)) |
#define Mvc_CubeSetSize | ( | Cube, | |||
Size | ) | ((Cube)->nOnes = (Size)) |
#define Mvc_CubeVarValue | ( | Cube, | |||
Var | ) | (((Cube)->pData[Mvc_CubeWhichWord(2*(Var))] >> (Mvc_CubeWhichBit(2*(Var)))) & ((Mvc_CubeWord_t)3)) |
#define Mvc_CubeWhichBit | ( | Bit | ) | ((Bit) & BITS_PER_WORD_MINUS) |
#define Mvc_CubeWhichWord | ( | Bit | ) | ((Bit) >> BITS_PER_WORD_LOG) |
#define Mvc_ListAddCubeHead | ( | pList, | |||
pCube | ) |
{\ if ( pList->pHead == NULL )\ {\ Mvc_CubeSetNext( pCube, NULL );\ pList->pHead = pCube;\ pList->pTail = pCube;\ }\ else\ {\ Mvc_CubeSetNext( pCube, pList->pHead );\ pList->pHead = pCube;\ }\ pList->nItems++;\ }
#define Mvc_ListAddCubeTail | ( | pList, | |||
pCube | ) |
{\ if ( pList->pHead == NULL )\ pList->pHead = pCube;\ else\ Mvc_CubeSetNext( pList->pTail, pCube );\ pList->pTail = pCube;\ Mvc_CubeSetNext( pCube, NULL );\ pList->nItems++;\ }
#define Mvc_ListDeleteCube | ( | pList, | |||
pPrev, | |||||
pCube | ) |
#define Mvc_ListForEachCube | ( | List, | |||
Cube | ) |
#define Mvc_ListForEachCubeSafe | ( | List, | |||
Cube, | |||||
Cube2 | ) |
typedef struct MvcCoverStruct Mvc_Cover_t |
typedef struct MvcCubeStruct Mvc_Cube_t |
typedef unsigned int Mvc_CubeWord_t |
typedef struct MvcDataStruct Mvc_Data_t |
typedef struct MvcListStruct Mvc_List_t |
typedef struct MvcManagerStruct Mvc_Manager_t |
void Mvc_CoverAddCubeHead_ | ( | Mvc_Cover_t * | pCover, | |
Mvc_Cube_t * | pCube | |||
) |
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 118 of file mvcList.c.
00119 { 00120 Mvc_List_t * pList = &pCover->lCubes; 00121 if ( pList->pHead == NULL ) 00122 { 00123 Mvc_CubeSetNext( pCube, NULL ); 00124 pList->pHead = pCube; 00125 pList->pTail = pCube; 00126 } 00127 else 00128 { 00129 Mvc_CubeSetNext( pCube, pList->pHead ); 00130 pList->pHead = pCube; 00131 } 00132 pList->nItems++; 00133 }
void Mvc_CoverAddCubeTail_ | ( | Mvc_Cover_t * | pCover, | |
Mvc_Cube_t * | pCube | |||
) |
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 146 of file mvcList.c.
00147 { 00148 Mvc_List_t * pList = &pCover->lCubes; 00149 00150 if ( pList->pHead == NULL ) 00151 pList->pHead = pCube; 00152 else 00153 Mvc_CubeSetNext( pList->pTail, pCube ); 00154 pList->pTail = pCube; 00155 Mvc_CubeSetNext( pCube, NULL ); 00156 pList->nItems++; 00157 }
void Mvc_CoverAddDupCubeHead | ( | Mvc_Cover_t * | pCover, | |
Mvc_Cube_t * | pCube | |||
) |
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 199 of file mvcList.c.
00200 { 00201 Mvc_Cube_t * pCubeNew; 00202 pCubeNew = Mvc_CubeAlloc( pCover ); 00203 Mvc_CubeBitCopy( pCubeNew, pCube ); 00204 Mvc_CoverAddCubeHead( pCover, pCubeNew ); 00205 }
void Mvc_CoverAddDupCubeTail | ( | Mvc_Cover_t * | pCover, | |
Mvc_Cube_t * | pCube | |||
) |
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 218 of file mvcList.c.
00219 { 00220 Mvc_Cube_t * pCubeNew; 00221 // copy the cube as part of this cover 00222 pCubeNew = Mvc_CubeAlloc( pCover ); 00223 Mvc_CubeBitCopy( pCubeNew, pCube ); 00224 // clean the last bits of the new cube 00225 // pCubeNew->pData[pCubeNew->iLast] &= (BITS_FULL >> pCubeNew->nUnused); 00226 // add the cube at the end 00227 Mvc_CoverAddCubeTail( pCover, pCubeNew ); 00228 }
void Mvc_CoverAddLiteralsOfCube | ( | Mvc_Cover_t * | pCover, | |
Mvc_Cube_t * | pCube | |||
) |
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
int Mvc_CoverAlgebraicEqual | ( | Mvc_Cover_t * | pCover1, | |
Mvc_Cover_t * | pCover2 | |||
) |
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 131 of file mvcOpAlg.c.
00132 { 00133 Mvc_Cube_t * pCube1, * pCube2; 00134 int fFound; 00135 int CompResult; 00136 00137 // covers should be the same base 00138 assert( pCover1->nBits == pCover2->nBits ); 00139 // iterate through the cubes 00140 Mvc_CoverForEachCube( pCover1, pCube1 ) 00141 { 00142 fFound = 0; 00143 Mvc_CoverForEachCube( pCover2, pCube2 ) 00144 { 00145 Mvc_CubeBitEqual( CompResult, pCube1, pCube2 ); 00146 if ( CompResult ) 00147 { 00148 fFound = 1; 00149 break; 00150 } 00151 } 00152 if ( !fFound ) 00153 return 0; 00154 } 00155 return 1; 00156 }
Mvc_Cover_t* Mvc_CoverAlgebraicMultiply | ( | Mvc_Cover_t * | pCover1, | |
Mvc_Cover_t * | pCover2 | |||
) |
CFile****************************************************************
FileName [mvcOperAlg.c]
PackageName [MVSIS 2.0: Multi-valued logic synthesis system.]
Synopsis [Miscellaneous operations on covers.]
Author [MVSIS Group]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - February 1, 2003.]
Revision [
] DECLARATIONS /// FUNCTION DEFINITIONS ///Function*************************************************************
Synopsis [Multiplies two disjoint-support covers.]
Description []
SideEffects []
SeeAlso []
Definition at line 40 of file mvcOpAlg.c.
00041 { 00042 Mvc_Cover_t * pCover; 00043 Mvc_Cube_t * pCube1, * pCube2, * pCube; 00044 int CompResult; 00045 00046 // covers should be the same base 00047 assert( pCover1->nBits == pCover2->nBits ); 00048 // make sure that supports do not overlap 00049 Mvc_CoverAllocateMask( pCover1 ); 00050 Mvc_CoverAllocateMask( pCover2 ); 00051 Mvc_CoverSupport( pCover1, pCover1->pMask ); 00052 Mvc_CoverSupport( pCover2, pCover2->pMask ); 00053 // check if the cubes are bit-wise disjoint 00054 Mvc_CubeBitDisjoint( CompResult, pCover1->pMask, pCover2->pMask ); 00055 if ( !CompResult ) 00056 printf( "Mvc_CoverMultiply(): Cover supports are not disjoint!\n" ); 00057 00058 // iterate through the cubes 00059 pCover = Mvc_CoverClone( pCover1 ); 00060 Mvc_CoverForEachCube( pCover1, pCube1 ) 00061 Mvc_CoverForEachCube( pCover2, pCube2 ) 00062 { 00063 // create the product cube 00064 pCube = Mvc_CubeAlloc( pCover ); 00065 // set the product cube equal to the product of the two cubes 00066 Mvc_CubeBitOr( pCube, pCube1, pCube2 ); 00067 // add the cube to the cover 00068 Mvc_CoverAddCubeTail( pCover, pCube ); 00069 } 00070 return pCover; 00071 }
Mvc_Cover_t* Mvc_CoverAlgebraicSubtract | ( | Mvc_Cover_t * | pCover1, | |
Mvc_Cover_t * | pCover2 | |||
) |
Function*************************************************************
Synopsis [Subtracts the second cover from the first.]
Description []
SideEffects []
SeeAlso []
Definition at line 85 of file mvcOpAlg.c.
00086 { 00087 Mvc_Cover_t * pCover; 00088 Mvc_Cube_t * pCube1, * pCube2, * pCube; 00089 int fFound; 00090 int CompResult; 00091 00092 // covers should be the same base 00093 assert( pCover1->nBits == pCover2->nBits ); 00094 00095 // iterate through the cubes 00096 pCover = Mvc_CoverClone( pCover1 ); 00097 Mvc_CoverForEachCube( pCover1, pCube1 ) 00098 { 00099 fFound = 0; 00100 Mvc_CoverForEachCube( pCover2, pCube2 ) 00101 { 00102 Mvc_CubeBitEqual( CompResult, pCube1, pCube2 ); 00103 if ( CompResult ) 00104 { 00105 fFound = 1; 00106 break; 00107 } 00108 } 00109 if ( !fFound ) 00110 { 00111 // create the copy of the cube 00112 pCube = Mvc_CubeDup( pCover, pCube1 ); 00113 // add the cube copy to the cover 00114 Mvc_CoverAddCubeTail( pCover, pCube ); 00115 } 00116 } 00117 return pCover; 00118 }
Mvc_Cover_t* Mvc_CoverAlloc | ( | Mvc_Manager_t * | pMem, | |
int | nBits | |||
) |
CFile****************************************************************
FileName [mvcCover.c]
PackageName [MVSIS 2.0: Multi-valued logic synthesis system.]
Synopsis [Basic procedures to manipulate unate cube covers.]
Author [MVSIS Group]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - February 1, 2003.]
Revision [
] DECLARATIONS /// FUNCTION DEFINITIONS ///Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 40 of file mvcCover.c.
00041 { 00042 Mvc_Cover_t * p; 00043 int nBitsInUnsigned; 00044 00045 nBitsInUnsigned = 8 * sizeof(Mvc_CubeWord_t); 00046 #ifdef USE_SYSTEM_MEMORY_MANAGEMENT 00047 p = (Mvc_Cover_t *)malloc( sizeof(Mvc_Cover_t) ); 00048 #else 00049 p = (Mvc_Cover_t *)Extra_MmFixedEntryFetch( pMem->pManC ); 00050 #endif 00051 p->pMem = pMem; 00052 p->nBits = nBits; 00053 p->nWords = nBits / nBitsInUnsigned + (int)(nBits % nBitsInUnsigned > 0); 00054 p->nUnused = p->nWords * nBitsInUnsigned - p->nBits; 00055 p->lCubes.nItems = 0; 00056 p->lCubes.pHead = NULL; 00057 p->lCubes.pTail = NULL; 00058 p->nCubesAlloc = 0; 00059 p->pCubes = NULL; 00060 p->pMask = NULL; 00061 p->pLits = NULL; 00062 return p; 00063 }
void Mvc_CoverAllocateArrayCubes | ( | Mvc_Cover_t * | pCover | ) |
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 199 of file mvcCover.c.
00200 { 00201 if ( pCover->nCubesAlloc < pCover->lCubes.nItems ) 00202 { 00203 if ( pCover->nCubesAlloc > 0 ) 00204 MEM_FREE( pCover->pMem, Mvc_Cube_t *, pCover->nCubesAlloc, pCover->pCubes ); 00205 pCover->nCubesAlloc = pCover->lCubes.nItems; 00206 pCover->pCubes = MEM_ALLOC( pCover->pMem, Mvc_Cube_t *, pCover->nCubesAlloc ); 00207 } 00208 }
void Mvc_CoverAllocateArrayLits | ( | Mvc_Cover_t * | pCover | ) |
void Mvc_CoverAllocateMask | ( | Mvc_Cover_t * | pCover | ) |
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 165 of file mvcCover.c.
00166 { 00167 if ( pCover->pMask == NULL ) 00168 pCover->pMask = Mvc_CubeAlloc( pCover ); 00169 }
int Mvc_CoverAnyLiteral | ( | Mvc_Cover_t * | pCover, | |
Mvc_Cube_t * | pMask | |||
) |
CFile****************************************************************
FileName [mvcLits.c]
PackageName [MVSIS 2.0: Multi-valued logic synthesis system.]
Synopsis [Literal counting/updating procedures.]
Author [MVSIS Group]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - February 1, 2003.]
Revision [
] DECLARATIONS /// FUNCTION DEFINITIONS ///Function*************************************************************
Synopsis [Find the any literal that occurs more than once.]
Description []
SideEffects []
SeeAlso []
Definition at line 40 of file mvcLits.c.
00041 { 00042 Mvc_Cube_t * pCube; 00043 int nWord, nBit, i; 00044 int nLitsCur; 00045 int fUseFirst = 0; 00046 00047 // go through each literal 00048 if ( fUseFirst ) 00049 { 00050 for ( i = 0; i < pCover->nBits; i++ ) 00051 if ( !pMask || Mvc_CubeBitValue(pMask,i) ) 00052 { 00053 // get the word and bit of this literal 00054 nWord = Mvc_CubeWhichWord(i); 00055 nBit = Mvc_CubeWhichBit(i); 00056 // go through all the cubes 00057 nLitsCur = 0; 00058 Mvc_CoverForEachCube( pCover, pCube ) 00059 if ( pCube->pData[nWord] & (1<<nBit) ) 00060 { 00061 nLitsCur++; 00062 if ( nLitsCur > 1 ) 00063 return i; 00064 } 00065 } 00066 } 00067 else 00068 { 00069 for ( i = pCover->nBits - 1; i >=0; i-- ) 00070 if ( !pMask || Mvc_CubeBitValue(pMask,i) ) 00071 { 00072 // get the word and bit of this literal 00073 nWord = Mvc_CubeWhichWord(i); 00074 nBit = Mvc_CubeWhichBit(i); 00075 // go through all the cubes 00076 nLitsCur = 0; 00077 Mvc_CoverForEachCube( pCover, pCube ) 00078 if ( pCube->pData[nWord] & (1<<nBit) ) 00079 { 00080 nLitsCur++; 00081 if ( nLitsCur > 1 ) 00082 return i; 00083 } 00084 } 00085 } 00086 return -1; 00087 }
void Mvc_CoverAppendCubes | ( | Mvc_Cover_t * | pC1, | |
Mvc_Cover_t * | pC2 | |||
) |
void Mvc_CoverArray2List | ( | Mvc_Cover_t * | pCover | ) |
Function*************************************************************
Synopsis [Transfers the cubes from the array into list.]
Description []
SideEffects []
SeeAlso []
Definition at line 307 of file mvcList.c.
00308 { 00309 Mvc_Cube_t * pCube; 00310 int nCubes, i; 00311 00312 assert( pCover->pCubes ); 00313 00314 nCubes = Mvc_CoverReadCubeNum(pCover); 00315 if ( nCubes == 0 ) 00316 return; 00317 if ( nCubes == 1 ) 00318 { 00319 pCube = pCover->pCubes[0]; 00320 pCube->pNext = NULL; 00321 pCover->lCubes.pHead = pCover->lCubes.pTail = pCube; 00322 return; 00323 } 00324 // set up the first cube 00325 pCube = pCover->pCubes[0]; 00326 pCover->lCubes.pHead = pCube; 00327 // set up the last cube 00328 pCube = pCover->pCubes[nCubes-1]; 00329 pCube->pNext = NULL; 00330 pCover->lCubes.pTail = pCube; 00331 00332 // link all cubes starting from the first one 00333 for ( i = 0; i < nCubes - 1; i++ ) 00334 pCover->pCubes[i]->pNext = pCover->pCubes[i+1]; 00335 }
int Mvc_CoverBestLiteral | ( | Mvc_Cover_t * | pCover, | |
Mvc_Cube_t * | pMask | |||
) |
Function*************************************************************
Synopsis [Find the most often occurring literal.]
Description [Find the most often occurring literal among those that occur more than once.]
SideEffects []
SeeAlso []
Definition at line 101 of file mvcLits.c.
00102 { 00103 Mvc_Cube_t * pCube; 00104 int nWord, nBit; 00105 int i, iMax, nLitsMax, nLitsCur; 00106 int fUseFirst = 1; 00107 00108 // go through each literal 00109 iMax = -1; 00110 nLitsMax = -1; 00111 for ( i = 0; i < pCover->nBits; i++ ) 00112 if ( !pMask || Mvc_CubeBitValue(pMask,i) ) 00113 { 00114 // get the word and bit of this literal 00115 nWord = Mvc_CubeWhichWord(i); 00116 nBit = Mvc_CubeWhichBit(i); 00117 // go through all the cubes 00118 nLitsCur = 0; 00119 Mvc_CoverForEachCube( pCover, pCube ) 00120 if ( pCube->pData[nWord] & (1<<nBit) ) 00121 nLitsCur++; 00122 00123 // check if this is the best literal 00124 if ( fUseFirst ) 00125 { 00126 if ( nLitsMax < nLitsCur ) 00127 { 00128 nLitsMax = nLitsCur; 00129 iMax = i; 00130 } 00131 } 00132 else 00133 { 00134 if ( nLitsMax <= nLitsCur ) 00135 { 00136 nLitsMax = nLitsCur; 00137 iMax = i; 00138 } 00139 } 00140 } 00141 00142 if ( nLitsMax > 1 ) 00143 return iMax; 00144 return -1; 00145 }
Mvc_Cover_t* Mvc_CoverBestLiteralCover | ( | Mvc_Cover_t * | pCover, | |
Mvc_Cover_t * | pSimple | |||
) |
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 220 of file mvcLits.c.
00221 { 00222 Mvc_Cover_t * pCoverNew; 00223 Mvc_Cube_t * pCubeNew; 00224 Mvc_Cube_t * pCubeS; 00225 int iLitBest; 00226 00227 // create the new cover 00228 pCoverNew = Mvc_CoverClone( pCover ); 00229 // get the new cube 00230 pCubeNew = Mvc_CubeAlloc( pCoverNew ); 00231 // clean the cube 00232 Mvc_CubeBitClean( pCubeNew ); 00233 00234 // get the first cube of pSimple 00235 assert( Mvc_CoverReadCubeNum(pSimple) == 1 ); 00236 pCubeS = Mvc_CoverReadCubeHead( pSimple ); 00237 // find the best literal among those of pCubeS 00238 iLitBest = Mvc_CoverBestLiteral( pCover, pCubeS ); 00239 00240 // insert this literal into the cube 00241 Mvc_CubeBitInsert( pCubeNew, iLitBest ); 00242 // add the cube to the cover 00243 Mvc_CoverAddCubeTail( pCoverNew, pCubeNew ); 00244 return pCoverNew; 00245 }
Mvc_Cover_t* Mvc_CoverBooleanAnd | ( | Mvc_Data_t * | p, | |
Mvc_Cover_t * | pCover1, | |||
Mvc_Cover_t * | pCover2 | |||
) |
int Mvc_CoverBooleanEqual | ( | Mvc_Data_t * | p, | |
Mvc_Cover_t * | pCover1, | |||
Mvc_Cover_t * | pCover2 | |||
) |
Mvc_Cover_t* Mvc_CoverBooleanOr | ( | Mvc_Cover_t * | pCover1, | |
Mvc_Cover_t * | pCover2 | |||
) |
CFile****************************************************************
FileName [mvcProc.c]
PackageName [MVSIS 2.0: Multi-valued logic synthesis system.]
Synopsis [Various boolean procedures working with covers.]
Author [MVSIS Group]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - February 1, 2003.]
Revision [
] DECLARATIONS /// FUNCTION DEFINITIONS ///Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 40 of file mvcOpBool.c.
00041 { 00042 Mvc_Cover_t * pCover; 00043 Mvc_Cube_t * pCube, * pCubeCopy; 00044 // make sure the covers are compatible 00045 assert( pCover1->nBits == pCover2->nBits ); 00046 // clone the cover 00047 pCover = Mvc_CoverClone( pCover1 ); 00048 // create the cubes by making pair-wise products 00049 // of cubes in pCover1 and pCover2 00050 Mvc_CoverForEachCube( pCover1, pCube ) 00051 { 00052 pCubeCopy = Mvc_CubeDup( pCover, pCube ); 00053 Mvc_CoverAddCubeTail( pCover, pCubeCopy ); 00054 } 00055 Mvc_CoverForEachCube( pCover2, pCube ) 00056 { 00057 pCubeCopy = Mvc_CubeDup( pCover, pCube ); 00058 Mvc_CoverAddCubeTail( pCover, pCubeCopy ); 00059 } 00060 return pCover; 00061 }
int Mvc_CoverCheckSuppContainment | ( | Mvc_Cover_t * | pCover1, | |
Mvc_Cover_t * | pCover2 | |||
) |
Function*************************************************************
Synopsis [Returns 1 if the support of cover2 is contained in the support of cover1.]
Description []
SideEffects []
SeeAlso []
Definition at line 244 of file mvcUtils.c.
00245 { 00246 int Result; 00247 assert( pCover1->nBits == pCover2->nBits ); 00248 // set the supports 00249 Mvc_CoverAllocateMask( pCover1 ); 00250 Mvc_CoverSupport( pCover1, pCover1->pMask ); 00251 Mvc_CoverAllocateMask( pCover2 ); 00252 Mvc_CoverSupport( pCover2, pCover2->pMask ); 00253 // check the containment 00254 Mvc_CubeBitNotImpl( Result, pCover2->pMask, pCover1->pMask ); 00255 return !Result; 00256 }
Mvc_Cover_t* Mvc_CoverClone | ( | Mvc_Cover_t * | p | ) |
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 76 of file mvcCover.c.
00077 { 00078 Mvc_Cover_t * pCover; 00079 #ifdef USE_SYSTEM_MEMORY_MANAGEMENT 00080 pCover = (Mvc_Cover_t *)malloc( sizeof(Mvc_Cover_t) ); 00081 #else 00082 pCover = (Mvc_Cover_t *)Extra_MmFixedEntryFetch( p->pMem->pManC ); 00083 #endif 00084 pCover->pMem = p->pMem; 00085 pCover->nBits = p->nBits; 00086 pCover->nWords = p->nWords; 00087 pCover->nUnused = p->nUnused; 00088 pCover->lCubes.nItems = 0; 00089 pCover->lCubes.pHead = NULL; 00090 pCover->lCubes.pTail = NULL; 00091 pCover->nCubesAlloc = 0; 00092 pCover->pCubes = NULL; 00093 pCover->pMask = NULL; 00094 pCover->pLits = NULL; 00095 return pCover; 00096 }
Mvc_Cover_t* Mvc_CoverCofactor | ( | Mvc_Cover_t * | p, | |
int | iValue, | |||
int | iValueOther | |||
) |
Function*************************************************************
Synopsis [Returns the cofactor w.r.t. to a binary var.]
Description []
SideEffects []
SeeAlso []
Definition at line 515 of file mvcUtils.c.
00516 { 00517 Mvc_Cover_t * pCover; 00518 Mvc_Cube_t * pCube, * pCubeCopy; 00519 // clone the cover 00520 pCover = Mvc_CoverClone( p ); 00521 // copy the cube list 00522 Mvc_CoverForEachCube( p, pCube ) 00523 if ( Mvc_CubeBitValue( pCube, iValue ) ) 00524 { 00525 pCubeCopy = Mvc_CubeDup( pCover, pCube ); 00526 Mvc_CoverAddCubeTail( pCover, pCubeCopy ); 00527 Mvc_CubeBitInsert( pCubeCopy, iValueOther ); 00528 } 00529 return pCover; 00530 }
Mvc_Cover_t** Mvc_CoverCofactors | ( | Mvc_Data_t * | pData, | |
Mvc_Cover_t * | pCover, | |||
int | iVar | |||
) |
void Mvc_CoverCommonCube | ( | Mvc_Cover_t * | pCover, | |
Mvc_Cube_t * | pComCube | |||
) |
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 152 of file mvcUtils.c.
00153 { 00154 Mvc_Cube_t * pCube; 00155 // clean the support 00156 Mvc_CubeBitFill( pComCube ); 00157 // collect the support 00158 Mvc_CoverForEachCube( pCover, pCube ) 00159 Mvc_CubeBitAnd( pComCube, pComCube, pCube ); 00160 }
Mvc_Cover_t* Mvc_CoverCommonCubeCover | ( | Mvc_Cover_t * | pCover | ) |
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 217 of file mvcUtils.c.
00218 { 00219 Mvc_Cover_t * pRes; 00220 Mvc_Cube_t * pCube; 00221 // create the new cover 00222 pRes = Mvc_CoverClone( pCover ); 00223 // get the new cube 00224 pCube = Mvc_CubeAlloc( pRes ); 00225 // get the common cube 00226 Mvc_CoverCommonCube( pCover, pCube ); 00227 // add the cube to the cover 00228 Mvc_CoverAddCubeTail( pRes, pCube ); 00229 return pRes; 00230 }
Mvc_Cover_t* Mvc_CoverComplement | ( | Mvc_Data_t * | p, | |
Mvc_Cover_t * | pCover | |||
) |
int Mvc_CoverContain | ( | Mvc_Cover_t * | pCover | ) |
FUNCTION DEFINITIONS ///Function*************************************************************
Synopsis [Removes the contained cubes.]
Description [Returns 1 if the cover has been changed.]
SideEffects []
SeeAlso []
Definition at line 44 of file mvcContain.c.
00045 { 00046 int nCubes; 00047 nCubes = Mvc_CoverReadCubeNum( pCover ); 00048 if ( nCubes < 2 ) 00049 return 0; 00050 Mvc_CoverSetCubeSizes(pCover); 00051 Mvc_CoverSort( pCover, NULL, Mvc_CubeCompareSizeAndInt ); 00052 Mvc_CoverRemoveDuplicates( pCover ); 00053 if ( nCubes > 1 ) 00054 Mvc_CoverRemoveContained( pCover ); 00055 return (nCubes != Mvc_CoverReadCubeNum(pCover)); 00056 }
void Mvc_CoverCopyAndAppendCubes | ( | Mvc_Cover_t * | pC1, | |
Mvc_Cover_t * | pC2 | |||
) |
int Mvc_CoverCountCubePairDiffs | ( | Mvc_Cover_t * | pCover, | |
unsigned char | pDiffs[] | |||
) |
Function*************************************************************
Synopsis [Counts the differences in each cube pair in the cover.]
Description [Takes the cover (pCover) and the array where the diff counters go (pDiffs). The array pDiffs should have as many entries as there are different pairs of cubes in the cover: n(n-1)/2. Fills out the array pDiffs with the following info: For each cube pair, included in the array is the number of literals in both cubes after they are made cube free.]
SideEffects []
SeeAlso []
Definition at line 339 of file mvcUtils.c.
00340 { 00341 Mvc_Cube_t * pCube1; 00342 Mvc_Cube_t * pCube2; 00343 Mvc_Cube_t * pMask; 00344 unsigned char * pByte, * pByteStart, * pByteStop; 00345 int nBytes, nOnes; 00346 int nCubePairs; 00347 00348 // allocate a temporary mask 00349 pMask = Mvc_CubeAlloc( pCover ); 00350 // get the number of unsigned chars in the cube's bit strings 00351 nBytes = pCover->nBits / (8 * sizeof(unsigned char)) + (int)(pCover->nBits % (8 * sizeof(unsigned char)) > 0); 00352 // iterate through the cubes 00353 nCubePairs = 0; 00354 Mvc_CoverForEachCube( pCover, pCube1 ) 00355 { 00356 Mvc_CoverForEachCubeStart( Mvc_CubeReadNext(pCube1), pCube2 ) 00357 { 00358 // find the bit-wise exor of cubes 00359 Mvc_CubeBitExor( pMask, pCube1, pCube2 ); 00360 // set the starting and stopping positions 00361 pByteStart = (unsigned char *)pMask->pData; 00362 pByteStop = pByteStart + nBytes; 00363 // clean the counter of ones 00364 nOnes = 0; 00365 // iterate through the positions 00366 for ( pByte = pByteStart; pByte < pByteStop; pByte++ ) 00367 nOnes += bit_count[*pByte]; 00368 // set the nOnes 00369 pDiffs[nCubePairs++] = nOnes; 00370 } 00371 } 00372 // deallocate the mask 00373 Mvc_CubeFree( pCover, pMask ); 00374 return 1; 00375 }
int Mvc_CoverCountLiterals | ( | Mvc_Cover_t * | pCover | ) |
Function*************************************************************
Synopsis [Returns the number of literals in the cover.]
Description [Allocates storage for literal counters and fills it up using the current information.]
SideEffects []
SeeAlso []
Definition at line 284 of file mvcLits.c.
00285 { 00286 Mvc_Cube_t * pCube; 00287 int nWord, nBit; 00288 int i, CounterTot, CounterCur; 00289 00290 // allocate/clean the storage for literals 00291 // Mvc_CoverAllocateArrayLits( pCover ); 00292 // memset( pCover->pLits, 0, pCover->nBits * sizeof(int) ); 00293 // go through each literal 00294 CounterTot = 0; 00295 for ( i = 0; i < pCover->nBits; i++ ) 00296 { 00297 // get the word and bit of this literal 00298 nWord = Mvc_CubeWhichWord(i); 00299 nBit = Mvc_CubeWhichBit(i); 00300 // go through all the cubes 00301 CounterCur = 0; 00302 Mvc_CoverForEachCube( pCover, pCube ) 00303 if ( pCube->pData[nWord] & (1<<nBit) ) 00304 CounterCur++; 00305 CounterTot += CounterCur; 00306 } 00307 return CounterTot; 00308 }
Mvc_Cover_t* Mvc_CoverCreateConst | ( | Mvc_Manager_t * | pMem, | |
int | nBits, | |||
int | Phase | |||
) |
Mvc_Cover_t* Mvc_CoverCreateEmpty | ( | Mvc_Cover_t * | pCover | ) |
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 199 of file mvcApi.c.
00200 { 00201 Mvc_Cover_t * pCoverNew; 00202 pCoverNew = Mvc_CoverAlloc( pCover->pMem, pCover->nBits ); 00203 return pCoverNew; 00204 }
Mvc_Cover_t* Mvc_CoverCreateTautology | ( | Mvc_Cover_t * | pCover | ) |
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 217 of file mvcApi.c.
00218 { 00219 Mvc_Cube_t * pCubeNew; 00220 Mvc_Cover_t * pCoverNew; 00221 pCoverNew = Mvc_CoverAlloc( pCover->pMem, pCover->nBits ); 00222 pCubeNew = Mvc_CubeAlloc( pCoverNew ); 00223 Mvc_CubeBitFill( pCubeNew ); 00224 Mvc_CoverAddCubeTail( pCoverNew, pCubeNew ); 00225 return pCoverNew; 00226 }
void Mvc_CoverDeallocateArrayLits | ( | Mvc_Cover_t * | pCover | ) |
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 238 of file mvcCover.c.
void Mvc_CoverDeallocateMask | ( | Mvc_Cover_t * | pCover | ) |
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 221 of file mvcCover.c.
00222 { 00223 Mvc_CubeFree( pCover, pCover->pMask ); 00224 pCover->pMask = NULL; 00225 }
void Mvc_CoverDeleteCube_ | ( | Mvc_Cover_t * | pCover, | |
Mvc_Cube_t * | pPrev, | |||
Mvc_Cube_t * | pCube | |||
) |
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 170 of file mvcList.c.
00171 { 00172 Mvc_List_t * pList = &pCover->lCubes; 00173 00174 if ( pPrev == NULL ) // deleting the head cube 00175 pList->pHead = Mvc_CubeReadNext(pCube); 00176 else 00177 pPrev->pNext = pCube->pNext; 00178 if ( pList->pTail == pCube ) // deleting the tail cube 00179 { 00180 assert( Mvc_CubeReadNext(pCube) == NULL ); 00181 pList->pTail = pPrev; 00182 } 00183 pList->nItems--; 00184 }
void Mvc_CoverDeleteLiteralsOfCube | ( | Mvc_Cover_t * | pCover, | |
Mvc_Cube_t * | pCube | |||
) |
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
int Mvc_CoverDist0Cubes | ( | Mvc_Data_t * | pData, | |
Mvc_Cube_t * | pA, | |||
Mvc_Cube_t * | pB | |||
) |
void Mvc_CoverDist1Merge | ( | Mvc_Data_t * | p, | |
Mvc_Cover_t * | pCover | |||
) |
void Mvc_CoverDivide | ( | Mvc_Cover_t * | pCover, | |
Mvc_Cover_t * | pDiv, | |||
Mvc_Cover_t ** | ppQuo, | |||
Mvc_Cover_t ** | ppRem | |||
) |
FUNCTION DEFINITIONS ///Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 44 of file mvcDivide.c.
00045 { 00046 // check the number of cubes 00047 if ( Mvc_CoverReadCubeNum( pCover ) < Mvc_CoverReadCubeNum( pDiv ) ) 00048 { 00049 *ppQuo = NULL; 00050 *ppRem = NULL; 00051 return; 00052 } 00053 00054 // make sure that support of pCover contains that of pDiv 00055 if ( !Mvc_CoverCheckSuppContainment( pCover, pDiv ) ) 00056 { 00057 *ppQuo = NULL; 00058 *ppRem = NULL; 00059 return; 00060 } 00061 00062 // perform the general division 00063 Mvc_CoverDivideInternal( pCover, pDiv, ppQuo, ppRem ); 00064 }
void Mvc_CoverDivideByCube | ( | Mvc_Cover_t * | pCover, | |
Mvc_Cover_t * | pDiv, | |||
Mvc_Cover_t ** | ppQuo, | |||
Mvc_Cover_t ** | ppRem | |||
) |
Function*************************************************************
Synopsis [Divides the cover by a cube.]
Description []
SideEffects []
SeeAlso []
Definition at line 265 of file mvcDivide.c.
00266 { 00267 Mvc_Cover_t * pQuo, * pRem; 00268 Mvc_Cube_t * pCubeC, * pCubeD, * pCubeCopy; 00269 int CompResult; 00270 00271 // get the only cube of D 00272 assert( Mvc_CoverReadCubeNum(pDiv) == 1 ); 00273 00274 // start the quotient and the remainder 00275 pQuo = Mvc_CoverAlloc( pCover->pMem, pCover->nBits ); 00276 pRem = Mvc_CoverAlloc( pCover->pMem, pCover->nBits ); 00277 00278 // get the first and only cube of the divisor 00279 pCubeD = Mvc_CoverReadCubeHead( pDiv ); 00280 00281 // iterate through the cubes in the cover 00282 Mvc_CoverForEachCube( pCover, pCubeC ) 00283 { 00284 // check the containment of literals from pCubeD in pCube 00285 Mvc_Cube2BitNotImpl( CompResult, pCubeD, pCubeC ); 00286 if ( !CompResult ) 00287 { // this cube belongs to the quotient 00288 // alloc the cube 00289 pCubeCopy = Mvc_CubeAlloc( pQuo ); 00290 // clean the support of D 00291 Mvc_CubeBitSharp( pCubeCopy, pCubeC, pCubeD ); 00292 // add the cube to the quotient 00293 Mvc_CoverAddCubeTail( pQuo, pCubeCopy ); 00294 } 00295 else 00296 { 00297 // copy the cube 00298 pCubeCopy = Mvc_CubeDup( pRem, pCubeC ); 00299 // add the cube to the remainder 00300 Mvc_CoverAddCubeTail( pRem, pCubeCopy ); 00301 } 00302 } 00303 // return the results 00304 *ppRem = pRem; 00305 *ppQuo = pQuo; 00306 }
void Mvc_CoverDivideByLiteral | ( | Mvc_Cover_t * | pCover, | |
Mvc_Cover_t * | pDiv, | |||
Mvc_Cover_t ** | ppQuo, | |||
Mvc_Cover_t ** | ppRem | |||
) |
Function*************************************************************
Synopsis [Divides the cover by a literal.]
Description []
SideEffects []
SeeAlso []
Definition at line 319 of file mvcDivide.c.
00320 { 00321 Mvc_Cover_t * pQuo, * pRem; 00322 Mvc_Cube_t * pCubeC, * pCubeCopy; 00323 int iLit; 00324 00325 // get the only cube of D 00326 assert( Mvc_CoverReadCubeNum(pDiv) == 1 ); 00327 00328 // start the quotient and the remainder 00329 pQuo = Mvc_CoverAlloc( pCover->pMem, pCover->nBits ); 00330 pRem = Mvc_CoverAlloc( pCover->pMem, pCover->nBits ); 00331 00332 // get the first and only literal in the divisor cube 00333 iLit = Mvc_CoverFirstCubeFirstLit( pDiv ); 00334 00335 // iterate through the cubes in the cover 00336 Mvc_CoverForEachCube( pCover, pCubeC ) 00337 { 00338 // copy the cube 00339 pCubeCopy = Mvc_CubeDup( pCover, pCubeC ); 00340 // add the cube to the quotient or to the remainder depending on the literal 00341 if ( Mvc_CubeBitValue( pCubeCopy, iLit ) ) 00342 { // remove the literal 00343 Mvc_CubeBitRemove( pCubeCopy, iLit ); 00344 // add the cube ot the quotient 00345 Mvc_CoverAddCubeTail( pQuo, pCubeCopy ); 00346 } 00347 else 00348 { // add the cube ot the remainder 00349 Mvc_CoverAddCubeTail( pRem, pCubeCopy ); 00350 } 00351 } 00352 // return the results 00353 *ppRem = pRem; 00354 *ppQuo = pQuo; 00355 }
void Mvc_CoverDivideByLiteralQuo | ( | Mvc_Cover_t * | pCover, | |
int | iLit | |||
) |
Function*************************************************************
Synopsis [Derives the quotient of division by literal.]
Description [Reduces the cover to be the equal to the result of division of the given cover by the literal.]
SideEffects []
SeeAlso []
Definition at line 370 of file mvcDivide.c.
00371 { 00372 Mvc_Cube_t * pCube, * pCube2, * pPrev; 00373 // delete those cubes that do not have this literal 00374 // remove this literal from other cubes 00375 pPrev = NULL; 00376 Mvc_CoverForEachCubeSafe( pCover, pCube, pCube2 ) 00377 { 00378 if ( Mvc_CubeBitValue( pCube, iLit ) == 0 ) 00379 { // delete the cube from the cover 00380 Mvc_CoverDeleteCube( pCover, pPrev, pCube ); 00381 Mvc_CubeFree( pCover, pCube ); 00382 // don't update the previous cube 00383 } 00384 else 00385 { // delete this literal from the cube 00386 Mvc_CubeBitRemove( pCube, iLit ); 00387 // update the previous cube 00388 pPrev = pCube; 00389 } 00390 } 00391 }
void Mvc_CoverDivideInternal | ( | Mvc_Cover_t * | pCover, | |
Mvc_Cover_t * | pDiv, | |||
Mvc_Cover_t ** | ppQuo, | |||
Mvc_Cover_t ** | ppRem | |||
) |
Function*************************************************************
Synopsis [Merge the cubes inside the groups.]
Description []
SideEffects []
SeeAlso []
Definition at line 78 of file mvcDivide.c.
00079 { 00080 Mvc_Cover_t * pQuo, * pRem; 00081 Mvc_Cube_t * pCubeC, * pCubeD, * pCubeCopy; 00082 Mvc_Cube_t * pCube1, * pCube2; 00083 int * pGroups, nGroups; // the cube groups 00084 int nCubesC, nCubesD, nMerges, iCubeC, iCubeD, iMerge; 00085 int fSkipG, GroupSize, g, c, RetValue; 00086 int nCubes; 00087 00088 // get cover sizes 00089 nCubesD = Mvc_CoverReadCubeNum( pDiv ); 00090 nCubesC = Mvc_CoverReadCubeNum( pCover ); 00091 00092 // check trivial cases 00093 if ( nCubesD == 1 ) 00094 { 00095 if ( Mvc_CoverIsOneLiteral( pDiv ) ) 00096 Mvc_CoverDivideByLiteral( pCover, pDiv, ppQuo, ppRem ); 00097 else 00098 Mvc_CoverDivideByCube( pCover, pDiv, ppQuo, ppRem ); 00099 return; 00100 } 00101 00102 // create the divisor and the remainder 00103 pQuo = Mvc_CoverAlloc( pCover->pMem, pCover->nBits ); 00104 pRem = Mvc_CoverAlloc( pCover->pMem, pCover->nBits ); 00105 00106 // get the support of the divisor 00107 Mvc_CoverAllocateMask( pDiv ); 00108 Mvc_CoverSupport( pDiv, pDiv->pMask ); 00109 00110 // sort the cubes of the divisor 00111 Mvc_CoverSort( pDiv, NULL, Mvc_CubeCompareInt ); 00112 // sort the cubes of the cover 00113 Mvc_CoverSort( pCover, pDiv->pMask, Mvc_CubeCompareIntOutsideAndUnderMask ); 00114 00115 // allocate storage for cube groups 00116 pGroups = MEM_ALLOC( pCover->pMem, int, nCubesC + 1 ); 00117 00118 // mask contains variables in the support of Div 00119 // split the cubes into groups using the mask 00120 Mvc_CoverList2Array( pCover ); 00121 Mvc_CoverList2Array( pDiv ); 00122 pGroups[0] = 0; 00123 nGroups = 1; 00124 for ( c = 1; c < nCubesC; c++ ) 00125 { 00126 // get the cubes 00127 pCube1 = pCover->pCubes[c-1]; 00128 pCube2 = pCover->pCubes[c ]; 00129 // compare the cubes 00130 Mvc_CubeBitEqualOutsideMask( RetValue, pCube1, pCube2, pDiv->pMask ); 00131 if ( !RetValue ) 00132 pGroups[nGroups++] = c; 00133 } 00134 // finish off the last group 00135 pGroups[nGroups] = nCubesC; 00136 00137 // consider each group separately and decide 00138 // whether it can produce a quotient cube 00139 nCubes = 0; 00140 for ( g = 0; g < nGroups; g++ ) 00141 { 00142 // if the group has less than nCubesD cubes, 00143 // there is no way it can produce the quotient cube 00144 // copy the cubes to the remainder 00145 GroupSize = pGroups[g+1] - pGroups[g]; 00146 if ( GroupSize < nCubesD ) 00147 { 00148 for ( c = pGroups[g]; c < pGroups[g+1]; c++ ) 00149 { 00150 pCubeCopy = Mvc_CubeDup( pRem, pCover->pCubes[c] ); 00151 Mvc_CoverAddCubeTail( pRem, pCubeCopy ); 00152 nCubes++; 00153 } 00154 continue; 00155 } 00156 00157 // mark the cubes as those that should be added to the remainder 00158 for ( c = pGroups[g]; c < pGroups[g+1]; c++ ) 00159 Mvc_CubeSetSize( pCover->pCubes[c], 1 ); 00160 00161 // go through the cubes in the group and at the same time 00162 // go through the cubes in the divisor 00163 iCubeD = 0; 00164 iCubeC = 0; 00165 pCubeD = pDiv->pCubes[iCubeD++]; 00166 pCubeC = pCover->pCubes[pGroups[g]+iCubeC++]; 00167 fSkipG = 0; 00168 nMerges = 0; 00169 00170 while ( 1 ) 00171 { 00172 // compare the topmost cubes in F and in D 00173 RetValue = Mvc_CubeCompareIntUnderMask( pCubeC, pCubeD, pDiv->pMask ); 00174 // cube are ordered in increasing order of their int value 00175 if ( RetValue == -1 ) // pCubeC is above pCubeD 00176 { // cube in C should be added to the remainder 00177 // check that there is enough cubes in the group 00178 if ( GroupSize - iCubeC < nCubesD - nMerges ) 00179 { 00180 fSkipG = 1; 00181 break; 00182 } 00183 // get the next cube in the cover 00184 pCubeC = pCover->pCubes[pGroups[g]+iCubeC++]; 00185 continue; 00186 } 00187 if ( RetValue == 1 ) // pCubeD is above pCubeC 00188 { // given cube in D does not have a corresponding cube in the cover 00189 fSkipG = 1; 00190 break; 00191 } 00192 // mark the cube as the one that should NOT be added to the remainder 00193 Mvc_CubeSetSize( pCubeC, 0 ); 00194 // remember this merged cube 00195 iMerge = iCubeC-1; 00196 nMerges++; 00197 00198 // stop if we considered the last cube of the group 00199 if ( iCubeD == nCubesD ) 00200 break; 00201 00202 // advance the cube of the divisor 00203 assert( iCubeD < nCubesD ); 00204 pCubeD = pDiv->pCubes[iCubeD++]; 00205 00206 // advance the cube of the group 00207 assert( pGroups[g]+iCubeC < nCubesC ); 00208 pCubeC = pCover->pCubes[pGroups[g]+iCubeC++]; 00209 } 00210 00211 if ( fSkipG ) 00212 { 00213 // the group has failed, add all the cubes to the remainder 00214 for ( c = pGroups[g]; c < pGroups[g+1]; c++ ) 00215 { 00216 pCubeCopy = Mvc_CubeDup( pRem, pCover->pCubes[c] ); 00217 Mvc_CoverAddCubeTail( pRem, pCubeCopy ); 00218 nCubes++; 00219 } 00220 continue; 00221 } 00222 00223 // the group has worked, add left-over cubes to the remainder 00224 for ( c = pGroups[g]; c < pGroups[g+1]; c++ ) 00225 { 00226 pCubeC = pCover->pCubes[c]; 00227 if ( Mvc_CubeReadSize(pCubeC) ) 00228 { 00229 pCubeCopy = Mvc_CubeDup( pRem, pCubeC ); 00230 Mvc_CoverAddCubeTail( pRem, pCubeCopy ); 00231 nCubes++; 00232 } 00233 } 00234 00235 // create the quotient cube 00236 pCube1 = Mvc_CubeAlloc( pQuo ); 00237 Mvc_CubeBitSharp( pCube1, pCover->pCubes[pGroups[g]+iMerge], pDiv->pMask ); 00238 // add the cube to the quotient 00239 Mvc_CoverAddCubeTail( pQuo, pCube1 ); 00240 nCubes += nCubesD; 00241 } 00242 assert( nCubes == nCubesC ); 00243 00244 // deallocate the memory 00245 MEM_FREE( pCover->pMem, int, nCubesC + 1, pGroups ); 00246 00247 // return the results 00248 *ppRem = pRem; 00249 *ppQuo = pQuo; 00250 // Mvc_CoverVerifyDivision( pCover, pDiv, pQuo, pRem ); 00251 }
Mvc_Cover_t* Mvc_CoverDivisor | ( | Mvc_Cover_t * | pCover | ) |
FUNCTION DEFINITIONS ///Function*************************************************************
Synopsis [Returns the quick divisor of the cover.]
Description [Returns NULL, if there is not divisor other than trivial.]
SideEffects []
SeeAlso []
Definition at line 43 of file mvcDivisor.c.
00044 { 00045 Mvc_Cover_t * pKernel; 00046 if ( Mvc_CoverReadCubeNum(pCover) <= 1 ) 00047 return NULL; 00048 // allocate the literal array and count literals 00049 if ( Mvc_CoverAnyLiteral( pCover, NULL ) == -1 ) 00050 return NULL; 00051 // duplicate the cover 00052 pKernel = Mvc_CoverDup(pCover); 00053 // perform the kerneling 00054 Mvc_CoverDivisorZeroKernel( pKernel ); 00055 assert( Mvc_CoverReadCubeNum(pKernel) ); 00056 return pKernel; 00057 }
Mvc_Cover_t* Mvc_CoverDup | ( | Mvc_Cover_t * | p | ) |
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 109 of file mvcCover.c.
00110 { 00111 Mvc_Cover_t * pCover; 00112 Mvc_Cube_t * pCube, * pCubeCopy; 00113 // clone the cover 00114 pCover = Mvc_CoverClone( p ); 00115 // copy the cube list 00116 Mvc_CoverForEachCube( p, pCube ) 00117 { 00118 pCubeCopy = Mvc_CubeDup( p, pCube ); 00119 Mvc_CoverAddCubeTail( pCover, pCubeCopy ); 00120 } 00121 return pCover; 00122 }
int Mvc_CoverFirstCubeFirstLit | ( | Mvc_Cover_t * | pCover | ) |
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 258 of file mvcLits.c.
00259 { 00260 Mvc_Cube_t * pCube; 00261 int iBit, Value; 00262 00263 // get the first cube 00264 pCube = Mvc_CoverReadCubeHead( pCover ); 00265 // get the first literal 00266 Mvc_CubeForEachBit( pCover, pCube, iBit, Value ) 00267 if ( Value ) 00268 return iBit; 00269 return -1; 00270 }
Mvc_Cover_t* Mvc_CoverFlipVar | ( | Mvc_Cover_t * | p, | |
int | iValue0, | |||
int | iValue1 | |||
) |
Function*************************************************************
Synopsis [Returns the cover, in which the binary var is complemented.]
Description []
SideEffects []
SeeAlso []
Definition at line 543 of file mvcUtils.c.
00544 { 00545 Mvc_Cover_t * pCover; 00546 Mvc_Cube_t * pCube, * pCubeCopy; 00547 int Value0, Value1, Temp; 00548 00549 assert( iValue0 + 1 == iValue1 ); // should be adjacent 00550 00551 // clone the cover 00552 pCover = Mvc_CoverClone( p ); 00553 // copy the cube list 00554 Mvc_CoverForEachCube( p, pCube ) 00555 { 00556 pCubeCopy = Mvc_CubeDup( pCover, pCube ); 00557 Mvc_CoverAddCubeTail( pCover, pCubeCopy ); 00558 00559 // get the bits 00560 Value0 = Mvc_CubeBitValue( pCubeCopy, iValue0 ); 00561 Value1 = Mvc_CubeBitValue( pCubeCopy, iValue1 ); 00562 00563 // if both bits are one, nothing to swap 00564 if ( Value0 && Value1 ) 00565 continue; 00566 // cannot be both zero because they belong to the same var 00567 assert( Value0 || Value1 ); 00568 00569 // swap the bits 00570 Temp = Value0; 00571 Value0 = Value1; 00572 Value1 = Temp; 00573 00574 // set the bits after the swap 00575 if ( Value0 ) 00576 Mvc_CubeBitInsert( pCubeCopy, iValue0 ); 00577 else 00578 Mvc_CubeBitRemove( pCubeCopy, iValue0 ); 00579 00580 if ( Value1 ) 00581 Mvc_CubeBitInsert( pCubeCopy, iValue1 ); 00582 else 00583 Mvc_CubeBitRemove( pCubeCopy, iValue1 ); 00584 } 00585 return pCover; 00586 }
void Mvc_CoverFree | ( | Mvc_Cover_t * | p | ) |
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 135 of file mvcCover.c.
00136 { 00137 Mvc_Cube_t * pCube, * pCube2; 00138 // recycle cube list 00139 Mvc_CoverForEachCubeSafe( p, pCube, pCube2 ) 00140 Mvc_CubeFree( p, pCube ); 00141 // recycle other pointers 00142 Mvc_CubeFree( p, p->pMask ); 00143 MEM_FREE( p->pMem, Mvc_Cube_t *, p->nCubesAlloc, p->pCubes ); 00144 MEM_FREE( p->pMem, int, p->nBits, p->pLits ); 00145 00146 #ifdef USE_SYSTEM_MEMORY_MANAGEMENT 00147 free( p ); 00148 #else 00149 Extra_MmFixedEntryRecycle( p->pMem->pManC, (char *)p ); 00150 #endif 00151 }
int Mvc_CoverGetCubeSize | ( | Mvc_Cube_t * | pCube | ) |
Function*************************************************************
Synopsis [Counts the cube sizes.]
Description []
SideEffects []
SeeAlso []
Definition at line 305 of file mvcUtils.c.
00306 { 00307 unsigned char * pByte, * pByteStart, * pByteStop; 00308 int nOnes, nBytes, nBits; 00309 // get the number of unsigned chars in the cube's bit strings 00310 nBits = (pCube->iLast + 1) * sizeof(Mvc_CubeWord_t) * 8 - pCube->nUnused; 00311 nBytes = nBits / (8 * sizeof(unsigned char)) + (int)(nBits % (8 * sizeof(unsigned char)) > 0); 00312 // clean the counter of ones 00313 nOnes = 0; 00314 // set the starting and stopping positions 00315 pByteStart = (unsigned char *)pCube->pData; 00316 pByteStop = pByteStart + nBytes; 00317 // iterate through the positions 00318 for ( pByte = pByteStart; pByte < pByteStop; pByte++ ) 00319 nOnes += bit_count[*pByte]; 00320 return nOnes; 00321 }
void Mvc_CoverIntersectCubes | ( | Mvc_Data_t * | pData, | |
Mvc_Cover_t * | pC1, | |||
Mvc_Cover_t * | pC2 | |||
) |
void Mvc_CoverInverse | ( | Mvc_Cover_t * | pCover | ) |
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 474 of file mvcUtils.c.
00475 { 00476 Mvc_Cube_t * pCube; 00477 // complement the cubes 00478 Mvc_CoverForEachCube( pCover, pCube ) 00479 Mvc_CubeBitNot( pCube ); 00480 }
int Mvc_CoverIsBinaryBuffer | ( | Mvc_Cover_t * | pCover | ) |
Function*************************************************************
Synopsis [Returns 1 if the cover is a binary buffer.]
Description []
SideEffects []
SeeAlso []
Definition at line 132 of file mvcApi.c.
00133 { 00134 Mvc_Cube_t * pCube; 00135 if ( pCover->nBits != 2 ) 00136 return 0; 00137 if ( Mvc_CoverReadCubeNum(pCover) != 1 ) 00138 return 0; 00139 pCube = pCover->lCubes.pHead; 00140 if ( Mvc_CubeBitValue(pCube, 0) == 0 && Mvc_CubeBitValue(pCube, 1) == 1 ) 00141 return 1; 00142 return 0; 00143 }
int Mvc_CoverIsCubeFree | ( | Mvc_Cover_t * | pCover | ) |
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 173 of file mvcUtils.c.
00174 { 00175 int Result; 00176 // get the common cube 00177 Mvc_CoverAllocateMask( pCover ); 00178 Mvc_CoverCommonCube( pCover, pCover->pMask ); 00179 // check whether the common cube is empty 00180 Mvc_CubeBitEmpty( Result, pCover->pMask ); 00181 return Result; 00182 }
int Mvc_CoverIsEmpty | ( | Mvc_Cover_t * | pCover | ) |
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 90 of file mvcApi.c.
00091 { 00092 return Mvc_CoverReadCubeNum(pCover) == 0; 00093 }
int Mvc_CoverIsIntersecting | ( | Mvc_Data_t * | pData, | |
Mvc_Cover_t * | pC1, | |||
Mvc_Cover_t * | pC2 | |||
) |
int Mvc_CoverIsOneLiteral | ( | Mvc_Cover_t * | pCover | ) |
Function*************************************************************
Synopsis [Returns the number of literals in the cover.]
Description []
SideEffects []
SeeAlso []
Definition at line 321 of file mvcLits.c.
00322 { 00323 Mvc_Cube_t * pCube; 00324 int iBit, Counter, Value; 00325 if ( Mvc_CoverReadCubeNum(pCover) != 1 ) 00326 return 0; 00327 pCube = Mvc_CoverReadCubeHead(pCover); 00328 // count literals 00329 Counter = 0; 00330 Mvc_CubeForEachBit( pCover, pCube, iBit, Value ) 00331 { 00332 if ( Value ) 00333 { 00334 if ( Counter++ ) 00335 return 0; 00336 } 00337 } 00338 return 1; 00339 }
int Mvc_CoverIsTautology | ( | Mvc_Cover_t * | pCover | ) |
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 106 of file mvcApi.c.
00107 { 00108 Mvc_Cube_t * pCube; 00109 int iBit, Value; 00110 00111 if ( Mvc_CoverReadCubeNum(pCover) != 1 ) 00112 return 0; 00113 00114 pCube = Mvc_CoverReadCubeHead( pCover ); 00115 Mvc_CubeForEachBit( pCover, pCube, iBit, Value ) 00116 if ( Value == 0 ) 00117 return 0; 00118 return 1; 00119 }
void Mvc_CoverList2Array | ( | Mvc_Cover_t * | pCover | ) |
Function*************************************************************
Synopsis [Transfers the cubes from the list into the array.]
Description []
SideEffects []
SeeAlso []
Definition at line 283 of file mvcList.c.
00284 { 00285 Mvc_Cube_t * pCube; 00286 int Counter; 00287 // resize storage if necessary 00288 Mvc_CoverAllocateArrayCubes( pCover ); 00289 // iterate through the cubes 00290 Counter = 0; 00291 Mvc_CoverForEachCube( pCover, pCube ) 00292 pCover->pCubes[ Counter++ ] = pCube; 00293 assert( Counter == Mvc_CoverReadCubeNum(pCover) ); 00294 }
void Mvc_CoverMakeCubeFree | ( | Mvc_Cover_t * | pCover | ) |
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 195 of file mvcUtils.c.
00196 { 00197 Mvc_Cube_t * pCube; 00198 // get the common cube 00199 Mvc_CoverAllocateMask( pCover ); 00200 Mvc_CoverCommonCube( pCover, pCover->pMask ); 00201 // remove this cube from the cubes in the cover 00202 Mvc_CoverForEachCube( pCover, pCube ) 00203 Mvc_CubeBitSharp( pCube, pCube, pCover->pMask ); 00204 }
void Mvc_CoverMakeEmpty | ( | Mvc_Cover_t * | pCover | ) |
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 157 of file mvcApi.c.
00158 { 00159 Mvc_Cube_t * pCube, * pCube2; 00160 Mvc_CoverForEachCubeSafe( pCover, pCube, pCube2 ) 00161 Mvc_CubeFree( pCover, pCube ); 00162 pCover->lCubes.nItems = 0; 00163 pCover->lCubes.pHead = NULL; 00164 pCover->lCubes.pTail = NULL; 00165 }
void Mvc_CoverMakeTautology | ( | Mvc_Cover_t * | pCover | ) |
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 178 of file mvcApi.c.
00179 { 00180 Mvc_Cube_t * pCubeNew; 00181 Mvc_CoverMakeEmpty( pCover ); 00182 pCubeNew = Mvc_CubeAlloc( pCover ); 00183 Mvc_CubeBitFill( pCubeNew ); 00184 Mvc_CoverAddCubeTail( pCover, pCubeNew ); 00185 }
void Mvc_CoverMinimizeByReshape | ( | Mvc_Data_t * | pData, | |
Mvc_Cover_t * | pCover | |||
) |
void Mvc_CoverPrint | ( | Mvc_Cover_t * | pCover | ) |
FUNCTION DEFINITIONS ///Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 44 of file mvcPrint.c.
00045 { 00046 Mvc_Cube_t * pCube; 00047 int i; 00048 // print general statistics 00049 printf( "The cover contains %d cubes (%d bits and %d words)\n", 00050 pCover->lCubes.nItems, pCover->nBits, pCover->nWords ); 00051 // iterate through the cubes 00052 Mvc_CoverForEachCube( pCover, pCube ) 00053 Mvc_CubePrint( pCover, pCube ); 00054 00055 if ( pCover->pLits ) 00056 { 00057 for ( i = 0; i < pCover->nBits; i++ ) 00058 printf( " %d", pCover->pLits[i] ); 00059 printf( "\n" ); 00060 } 00061 printf( "End of cover printout\n" ); 00062 }
void Mvc_CoverPrintMv | ( | Mvc_Data_t * | pData, | |
Mvc_Cover_t * | pCover | |||
) |
int Mvc_CoverReadBitNum | ( | Mvc_Cover_t * | pCover | ) |
Mvc_Cube_t* Mvc_CoverReadCubeHead | ( | Mvc_Cover_t * | pCover | ) |
Mvc_List_t* Mvc_CoverReadCubeList | ( | Mvc_Cover_t * | pCover | ) |
int Mvc_CoverReadCubeNum | ( | Mvc_Cover_t * | pCover | ) |
Mvc_Cube_t* Mvc_CoverReadCubeTail | ( | Mvc_Cover_t * | pCover | ) |
int Mvc_CoverReadWordNum | ( | Mvc_Cover_t * | pCover | ) |
FUNCTION DEFINITIONS ///
CFile****************************************************************
FileName [mvcApi.c]
PackageName [MVSIS 2.0: Multi-valued logic synthesis system.]
Synopsis []
Author [MVSIS Group]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - February 1, 2003.]
Revision [
] DECLARATIONS /// FUNCTION DEFINITIONS ///Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 40 of file mvcApi.c.
00040 { return pCover->nWords; }
Mvc_Cover_t* Mvc_CoverRemap | ( | Mvc_Cover_t * | p, | |
int * | pVarsRem, | |||
int | nVarsRem | |||
) |
Function*************************************************************
Synopsis [Creates a new cover containing some literals of the old cover.]
Description [Creates the new cover containing the given number (nVarsRem) literals of the old cover. All the bits of the new cover are initialized to "1". The selected bits from the old cover are copied on top. The numbers of the selected bits to copy are given in the array pVarsRem. The i-set entry in this array is the index of the bit in the old cover which goes to the i-th place in the new cover. If the i-th entry in pVarsRem is -1, it means that the i-th bit does not change (remains composed of all 1's). This is a useful feature to speed up remapping covers, which are known to depend only on a subset of input variables.]
SideEffects []
SeeAlso []
Definition at line 397 of file mvcUtils.c.
00398 { 00399 Mvc_Cover_t * pCover; 00400 Mvc_Cube_t * pCube, * pCubeCopy; 00401 int i; 00402 // clone the cover 00403 pCover = Mvc_CoverAlloc( p->pMem, nVarsRem ); 00404 // copy the cube list 00405 Mvc_CoverForEachCube( p, pCube ) 00406 { 00407 pCubeCopy = Mvc_CubeAlloc( pCover ); 00408 //Mvc_CubeBitClean( pCubeCopy ); //changed by wjiang 00409 Mvc_CubeBitFill( pCubeCopy ); //changed by wjiang 00410 Mvc_CoverAddCubeTail( pCover, pCubeCopy ); 00411 } 00412 // copy the corresponding columns 00413 for ( i = 0; i < nVarsRem; i++ ) 00414 { 00415 if (pVarsRem[i] < 0) 00416 continue; //added by wjiang 00417 assert( pVarsRem[i] >= 0 && pVarsRem[i] < p->nBits ); 00418 Mvc_CoverCopyColumn( p, pCover, pVarsRem[i], i ); 00419 } 00420 return pCover; 00421 }
void Mvc_CoverRemoveCubes | ( | Mvc_Cover_t * | pC | ) |
Mvc_Cover_t* Mvc_CoverRemoveDontCareLits | ( | Mvc_Cover_t * | pCover | ) |
Function*************************************************************
Synopsis [This function dups the cover and removes DC literals from cubes.]
Description []
SideEffects []
SeeAlso []
Definition at line 493 of file mvcUtils.c.
00494 { 00495 Mvc_Cover_t * pCoverNew; 00496 Mvc_Cube_t * pCube; 00497 00498 pCoverNew = Mvc_CoverDup( pCover ); 00499 Mvc_CoverForEachCube( pCoverNew, pCube ) 00500 Mvc_CubeBitRemoveDcs( pCube ); 00501 return pCoverNew; 00502 }
void Mvc_CoverSetCubeHead | ( | Mvc_Cover_t * | pCover, | |
Mvc_Cube_t * | pCube | |||
) |
void Mvc_CoverSetCubeList | ( | Mvc_Cover_t * | pCover, | |
Mvc_List_t * | pList | |||
) |
void Mvc_CoverSetCubeNum | ( | Mvc_Cover_t * | pCover, | |
int | nItems | |||
) |
int Mvc_CoverSetCubeSizes | ( | Mvc_Cover_t * | pCover | ) |
Function*************************************************************
Synopsis [Counts the cube sizes.]
Description []
SideEffects []
SeeAlso []
Definition at line 269 of file mvcUtils.c.
00270 { 00271 Mvc_Cube_t * pCube; 00272 unsigned char * pByte, * pByteStart, * pByteStop; 00273 int nBytes, nOnes; 00274 00275 // get the number of unsigned chars in the cube's bit strings 00276 nBytes = pCover->nBits / (8 * sizeof(unsigned char)) + (int)(pCover->nBits % (8 * sizeof(unsigned char)) > 0); 00277 // iterate through the cubes 00278 Mvc_CoverForEachCube( pCover, pCube ) 00279 { 00280 // clean the counter of ones 00281 nOnes = 0; 00282 // set the starting and stopping positions 00283 pByteStart = (unsigned char *)pCube->pData; 00284 pByteStop = pByteStart + nBytes; 00285 // iterate through the positions 00286 for ( pByte = pByteStart; pByte < pByteStop; pByte++ ) 00287 nOnes += bit_count[*pByte]; 00288 // set the nOnes 00289 Mvc_CubeSetSize( pCube, nOnes ); 00290 } 00291 return 1; 00292 }
void Mvc_CoverSetCubeTail | ( | Mvc_Cover_t * | pCover, | |
Mvc_Cube_t * | pCube | |||
) |
Mvc_Cover_t* Mvc_CoverSharp | ( | Mvc_Data_t * | p, | |
Mvc_Cover_t * | pA, | |||
Mvc_Cover_t * | pB | |||
) |
void Mvc_CoverSort | ( | Mvc_Cover_t * | pCover, | |
Mvc_Cube_t * | pMask, | |||
int(*)(Mvc_Cube_t *, Mvc_Cube_t *, Mvc_Cube_t *) | pCompareFunc | |||
) |
FuNCTION DEFINITIONS ///Function*************************************************************
Synopsis [Sorts cubes using the given cost function.]
Description []
SideEffects []
SeeAlso []
Definition at line 44 of file mvcSort.c.
00045 { 00046 Mvc_Cube_t * pHead; 00047 int nCubes; 00048 // one cube does not need sorting 00049 nCubes = Mvc_CoverReadCubeNum(pCover); 00050 if ( nCubes <= 1 ) 00051 return; 00052 // sort the cubes 00053 pHead = Mvc_CoverSort_rec( Mvc_CoverReadCubeHead(pCover), nCubes, pMask, pCompareFunc ); 00054 // insert the sorted list into the cover 00055 Mvc_CoverSetCubeHead( pCover, pHead ); 00056 Mvc_CoverSetCubeTail( pCover, Mvc_ListGetTailFromHead(pHead) ); 00057 // make sure that the list is sorted in the increasing order 00058 assert( pCompareFunc( Mvc_CoverReadCubeHead(pCover), Mvc_CoverReadCubeTail(pCover), pMask ) <= 0 ); 00059 }
void Mvc_CoverSupport | ( | Mvc_Cover_t * | pCover, | |
Mvc_Cube_t * | pSupp | |||
) |
FUNCTION DEFINITIONS ///Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 55 of file mvcUtils.c.
00056 { 00057 Mvc_Cube_t * pCube; 00058 // clean the support 00059 Mvc_CubeBitClean( pSupp ); 00060 // collect the support 00061 Mvc_CoverForEachCube( pCover, pCube ) 00062 Mvc_CubeBitOr( pSupp, pSupp, pCube ); 00063 }
int Mvc_CoverSupportSizeBinary | ( | Mvc_Cover_t * | pCover | ) |
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 97 of file mvcUtils.c.
00098 { 00099 Mvc_Cube_t * pSupp; 00100 int Counter, i, v0, v1; 00101 // compute the support 00102 pSupp = Mvc_CubeAlloc( pCover ); 00103 Mvc_CoverSupportAnd( pCover, pSupp ); 00104 Counter = pCover->nBits/2; 00105 for ( i = 0; i < pCover->nBits/2; i++ ) 00106 { 00107 v0 = Mvc_CubeBitValue( pSupp, 2*i ); 00108 v1 = Mvc_CubeBitValue( pSupp, 2*i+1 ); 00109 if ( v0 && v1 ) 00110 Counter--; 00111 } 00112 Mvc_CubeFree( pCover, pSupp ); 00113 return Counter; 00114 }
int Mvc_CoverSupportVarBelongs | ( | Mvc_Cover_t * | pCover, | |
int | iVar | |||
) |
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 127 of file mvcUtils.c.
00128 { 00129 Mvc_Cube_t * pSupp; 00130 int RetValue, v0, v1; 00131 // compute the support 00132 pSupp = Mvc_CubeAlloc( pCover ); 00133 Mvc_CoverSupportAnd( pCover, pSupp ); 00134 v0 = Mvc_CubeBitValue( pSupp, 2*iVar ); 00135 v1 = Mvc_CubeBitValue( pSupp, 2*iVar+1 ); 00136 RetValue = (int)( !v0 || !v1 ); 00137 Mvc_CubeFree( pCover, pSupp ); 00138 return RetValue; 00139 }
int Mvc_CoverTautology | ( | Mvc_Data_t * | p, | |
Mvc_Cover_t * | pCover | |||
) |
Mvc_Cover_t* Mvc_CoverTranspose | ( | Mvc_Cover_t * | pCover | ) |
Function*************************************************************
Synopsis [Transposes the cube cover.]
Description [Returns the cube cover that looks like a transposed matrix, compared to the matrix derived from the original cover.]
SideEffects []
SeeAlso []
Definition at line 801 of file mvcUtils.c.
00802 { 00803 Mvc_Cover_t * pRes; 00804 Mvc_Cube_t * pCubeRes, * pCube; 00805 int nWord, nBit, i, iCube; 00806 00807 pRes = Mvc_CoverAlloc( pCover->pMem, Mvc_CoverReadCubeNum(pCover) ); 00808 for ( i = 0; i < pCover->nBits; i++ ) 00809 { 00810 // get the word and bit of this literal 00811 nWord = Mvc_CubeWhichWord(i); 00812 nBit = Mvc_CubeWhichBit(i); 00813 // get the transposed cube 00814 pCubeRes = Mvc_CubeAlloc( pRes ); 00815 Mvc_CubeBitClean( pCubeRes ); 00816 iCube = 0; 00817 Mvc_CoverForEachCube( pCover, pCube ) 00818 { 00819 if ( pCube->pData[nWord] & (1<<nBit) ) 00820 Mvc_CubeBitInsert( pCubeRes, iCube ); 00821 iCube++; 00822 } 00823 Mvc_CoverAddCubeTail( pRes, pCubeRes ); 00824 } 00825 return pRes; 00826 }
Mvc_Cover_t* Mvc_CoverUnivQuantify | ( | Mvc_Cover_t * | p, | |
int | iValueA0, | |||
int | iValueA1, | |||
int | iValueB0, | |||
int | iValueB1 | |||
) |
Function*************************************************************
Synopsis [Returns the cover derived by universal quantification.]
Description [Returns the cover computed by universal quantification as follows: CoverNew = Univ(B) [Cover & (A==B)]. Removes the second binary var from the support (given by values iValueB0 and iValueB1). Leaves the first binary variable (given by values iValueA0 and iValueA1) in the support.]
SideEffects []
SeeAlso []
Definition at line 603 of file mvcUtils.c.
00605 { 00606 Mvc_Cover_t * pCover; 00607 Mvc_Cube_t * pCube, * pCubeCopy; 00608 int ValueA0, ValueA1, ValueB0, ValueB1; 00609 00610 // clone the cover 00611 pCover = Mvc_CoverClone( p ); 00612 // copy the cube list 00613 Mvc_CoverForEachCube( p, pCube ) 00614 { 00615 // get the bits 00616 ValueA0 = Mvc_CubeBitValue( pCube, iValueA0 ); 00617 ValueA1 = Mvc_CubeBitValue( pCube, iValueA1 ); 00618 ValueB0 = Mvc_CubeBitValue( pCube, iValueB0 ); 00619 ValueB1 = Mvc_CubeBitValue( pCube, iValueB1 ); 00620 00621 // cannot be both zero because they belong to the same var 00622 assert( ValueA0 || ValueA1 ); 00623 assert( ValueB0 || ValueB1 ); 00624 00625 // if the values of this var are different, do not add the cube 00626 if ( ValueA0 != ValueB0 && ValueA1 != ValueB1 ) 00627 continue; 00628 00629 // create the cube 00630 pCubeCopy = Mvc_CubeDup( pCover, pCube ); 00631 Mvc_CoverAddCubeTail( pCover, pCubeCopy ); 00632 00633 // insert 1's into for the first var, if both have this value 00634 if ( ValueA0 && ValueB0 ) 00635 Mvc_CubeBitInsert( pCubeCopy, iValueA0 ); 00636 else 00637 Mvc_CubeBitRemove( pCubeCopy, iValueA0 ); 00638 00639 if ( ValueA1 && ValueB1 ) 00640 Mvc_CubeBitInsert( pCubeCopy, iValueA1 ); 00641 else 00642 Mvc_CubeBitRemove( pCubeCopy, iValueA1 ); 00643 00644 // insert 1's into for the second var (the cover does not depend on it) 00645 Mvc_CubeBitInsert( pCubeCopy, iValueB0 ); 00646 Mvc_CubeBitInsert( pCubeCopy, iValueB1 ); 00647 } 00648 return pCover; 00649 }
int Mvc_CoverWorstLiteral | ( | Mvc_Cover_t * | pCover, | |
Mvc_Cube_t * | pMask | |||
) |
Function*************************************************************
Synopsis [Find the most often occurring literal.]
Description [Find the most often occurring literal among those that occur more than once.]
SideEffects []
SeeAlso []
Definition at line 159 of file mvcLits.c.
00160 { 00161 Mvc_Cube_t * pCube; 00162 int nWord, nBit; 00163 int i, iMin, nLitsMin, nLitsCur; 00164 int fUseFirst = 1; 00165 00166 // go through each literal 00167 iMin = -1; 00168 nLitsMin = 1000000; 00169 for ( i = 0; i < pCover->nBits; i++ ) 00170 if ( !pMask || Mvc_CubeBitValue(pMask,i) ) 00171 { 00172 // get the word and bit of this literal 00173 nWord = Mvc_CubeWhichWord(i); 00174 nBit = Mvc_CubeWhichBit(i); 00175 // go through all the cubes 00176 nLitsCur = 0; 00177 Mvc_CoverForEachCube( pCover, pCube ) 00178 if ( pCube->pData[nWord] & (1<<nBit) ) 00179 nLitsCur++; 00180 00181 // skip the literal that does not occur or occurs once 00182 if ( nLitsCur < 2 ) 00183 continue; 00184 00185 // check if this is the best literal 00186 if ( fUseFirst ) 00187 { 00188 if ( nLitsMin > nLitsCur ) 00189 { 00190 nLitsMin = nLitsCur; 00191 iMin = i; 00192 } 00193 } 00194 else 00195 { 00196 if ( nLitsMin >= nLitsCur ) 00197 { 00198 nLitsMin = nLitsCur; 00199 iMin = i; 00200 } 00201 } 00202 } 00203 00204 if ( nLitsMin < 1000000 ) 00205 return iMin; 00206 return -1; 00207 }
Mvc_Cube_t* Mvc_CubeAlloc | ( | Mvc_Cover_t * | pCover | ) |
CFile****************************************************************
FileName [mvcCube.c]
PackageName [MVSIS 2.0: Multi-valued logic synthesis system.]
Synopsis [Manipulating unate cubes.]
Author [MVSIS Group]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - February 1, 2003.]
Revision [
] DECLARATIONS /// FUNCTION DEFINITIONS ///Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 40 of file mvcCube.c.
00041 { 00042 Mvc_Cube_t * pCube; 00043 00044 assert( pCover->nWords >= 0 ); 00045 // allocate the cube 00046 #ifdef USE_SYSTEM_MEMORY_MANAGEMENT 00047 if ( pCover->nWords == 0 ) 00048 pCube = (Mvc_Cube_t *)malloc( sizeof(Mvc_Cube_t) ); 00049 else 00050 pCube = (Mvc_Cube_t *)malloc( sizeof(Mvc_Cube_t) + sizeof(Mvc_CubeWord_t) * (pCover->nWords - 1) ); 00051 #else 00052 switch( pCover->nWords ) 00053 { 00054 case 0: 00055 case 1: 00056 pCube = (Mvc_Cube_t *)Extra_MmFixedEntryFetch( pCover->pMem->pMan1 ); 00057 break; 00058 case 2: 00059 pCube = (Mvc_Cube_t *)Extra_MmFixedEntryFetch( pCover->pMem->pMan2 ); 00060 break; 00061 case 3: 00062 case 4: 00063 pCube = (Mvc_Cube_t *)Extra_MmFixedEntryFetch( pCover->pMem->pMan4 ); 00064 break; 00065 default: 00066 pCube = (Mvc_Cube_t *)malloc( sizeof(Mvc_Cube_t) + sizeof(Mvc_CubeWord_t) * (pCover->nWords - 1) ); 00067 break; 00068 } 00069 #endif 00070 // set the parameters charactering this cube 00071 if ( pCover->nWords == 0 ) 00072 pCube->iLast = pCover->nWords; 00073 else 00074 pCube->iLast = pCover->nWords - 1; 00075 pCube->nUnused = pCover->nUnused; 00076 return pCube; 00077 }
void Mvc_CubeBitRemoveDcs | ( | Mvc_Cube_t * | pCube | ) |
Function*************************************************************
Synopsis [Removes the don't-care variable from the cube.]
Description []
SideEffects []
SeeAlso []
Definition at line 156 of file mvcCube.c.
00157 { 00158 unsigned Mask; 00159 int i; 00160 for ( i = Mvc_CubeReadLast(pCube); i >= 0; i-- ) 00161 { 00162 // detect those variables that are different (not DCs) 00163 Mask = (pCube->pData[i] ^ (pCube->pData[i] >> 1)) & BITS_DISJOINT; 00164 // create the mask of all that are different 00165 Mask |= (Mask << 1); 00166 // remove other bits from the set 00167 pCube->pData[i] &= Mask; 00168 } 00169 }
int Mvc_CubeCompareInt | ( | Mvc_Cube_t * | pC1, | |
Mvc_Cube_t * | pC2, | |||
Mvc_Cube_t * | pMask | |||
) |
CFile****************************************************************
FileName [mvcCompare.c]
PackageName [MVSIS 2.0: Multi-valued logic synthesis system.]
Synopsis [Various cube comparison functions.]
Author [MVSIS Group]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - February 1, 2003.]
Revision [
] DECLARATIONS /// FUNCTION DEFINITIONS ///Function*************************************************************
Synopsis [Compares two cubes according to their integer value.]
Description []
SideEffects []
SeeAlso []
Definition at line 40 of file mvcCompare.c.
00041 { 00042 if ( Mvc_Cube1Words(pC1) ) 00043 { 00044 if ( pC1->pData[0] < pC2->pData[0] ) 00045 return -1; 00046 if ( pC1->pData[0] > pC2->pData[0] ) 00047 return 1; 00048 return 0; 00049 } 00050 else if ( Mvc_Cube2Words(pC1) ) 00051 { 00052 if ( pC1->pData[1] < pC2->pData[1] ) 00053 return -1; 00054 if ( pC1->pData[1] > pC2->pData[1] ) 00055 return 1; 00056 if ( pC1->pData[0] < pC2->pData[0] ) 00057 return -1; 00058 if ( pC1->pData[0] > pC2->pData[0] ) 00059 return 1; 00060 return 0; 00061 } 00062 else 00063 { 00064 int i = Mvc_CubeReadLast(pC1); 00065 for(; i >= 0; i--) 00066 { 00067 if ( pC1->pData[i] < pC2->pData[i] ) 00068 return -1; 00069 if ( pC1->pData[i] > pC2->pData[i] ) 00070 return 1; 00071 } 00072 return 0; 00073 } 00074 }
int Mvc_CubeCompareIntOutsideAndUnderMask | ( | Mvc_Cube_t * | pC1, | |
Mvc_Cube_t * | pC2, | |||
Mvc_Cube_t * | pMask | |||
) |
Function*************************************************************
Synopsis [Compares the cubes (1) outside the mask, (2) under the mask.]
Description []
SideEffects []
SeeAlso []
Definition at line 262 of file mvcCompare.c.
00263 { 00264 unsigned uBits1, uBits2; 00265 00266 if ( Mvc_Cube1Words(pC1) ) 00267 { 00268 // compare the cubes outside the mask 00269 uBits1 = pC1->pData[0] & ~(pMask->pData[0]); 00270 uBits2 = pC2->pData[0] & ~(pMask->pData[0]); 00271 if ( uBits1 < uBits2 ) 00272 return -1; 00273 if ( uBits1 > uBits2 ) 00274 return 1; 00275 00276 // compare the cubes under the mask 00277 uBits1 = pC1->pData[0] & pMask->pData[0]; 00278 uBits2 = pC2->pData[0] & pMask->pData[0]; 00279 if ( uBits1 < uBits2 ) 00280 return -1; 00281 if ( uBits1 > uBits2 ) 00282 return 1; 00283 // cubes are equal 00284 // should never happen 00285 assert( 0 ); 00286 return 0; 00287 } 00288 else if ( Mvc_Cube2Words(pC1) ) 00289 { 00290 // compare the cubes outside the mask 00291 uBits1 = pC1->pData[1] & ~(pMask->pData[1]); 00292 uBits2 = pC2->pData[1] & ~(pMask->pData[1]); 00293 if ( uBits1 < uBits2 ) 00294 return -1; 00295 if ( uBits1 > uBits2 ) 00296 return 1; 00297 00298 uBits1 = pC1->pData[0] & ~(pMask->pData[0]); 00299 uBits2 = pC2->pData[0] & ~(pMask->pData[0]); 00300 if ( uBits1 < uBits2 ) 00301 return -1; 00302 if ( uBits1 > uBits2 ) 00303 return 1; 00304 00305 // compare the cubes under the mask 00306 uBits1 = pC1->pData[1] & pMask->pData[1]; 00307 uBits2 = pC2->pData[1] & pMask->pData[1]; 00308 if ( uBits1 < uBits2 ) 00309 return -1; 00310 if ( uBits1 > uBits2 ) 00311 return 1; 00312 00313 uBits1 = pC1->pData[0] & pMask->pData[0]; 00314 uBits2 = pC2->pData[0] & pMask->pData[0]; 00315 if ( uBits1 < uBits2 ) 00316 return -1; 00317 if ( uBits1 > uBits2 ) 00318 return 1; 00319 00320 // cubes are equal 00321 // should never happen 00322 assert( 0 ); 00323 return 0; 00324 } 00325 else 00326 { 00327 int i; 00328 00329 // compare the cubes outside the mask 00330 for( i = Mvc_CubeReadLast(pC1); i >= 0; i-- ) 00331 { 00332 uBits1 = pC1->pData[i] & ~(pMask->pData[i]); 00333 uBits2 = pC2->pData[i] & ~(pMask->pData[i]); 00334 if ( uBits1 < uBits2 ) 00335 return -1; 00336 if ( uBits1 > uBits2 ) 00337 return 1; 00338 } 00339 // compare the cubes under the mask 00340 for( i = Mvc_CubeReadLast(pC1); i >= 0; i-- ) 00341 { 00342 uBits1 = pC1->pData[i] & pMask->pData[i]; 00343 uBits2 = pC2->pData[i] & pMask->pData[i]; 00344 if ( uBits1 < uBits2 ) 00345 return -1; 00346 if ( uBits1 > uBits2 ) 00347 return 1; 00348 } 00349 /* 00350 { 00351 Mvc_Cover_t * pCover; 00352 pCover = Mvc_CoverAlloc( NULL, 96 ); 00353 Mvc_CubePrint( pCover, pC1 ); 00354 Mvc_CubePrint( pCover, pC2 ); 00355 Mvc_CubePrint( pCover, pMask ); 00356 } 00357 */ 00358 // cubes are equal 00359 // should never happen 00360 assert( 0 ); 00361 return 0; 00362 } 00363 }
int Mvc_CubeCompareIntOutsideMask | ( | Mvc_Cube_t * | pC1, | |
Mvc_Cube_t * | pC2, | |||
Mvc_Cube_t * | pMask | |||
) |
Function*************************************************************
Synopsis [Compares two cubes under the mask.]
Description []
SideEffects []
SeeAlso []
Definition at line 202 of file mvcCompare.c.
00203 { 00204 unsigned uBits1, uBits2; 00205 00206 // compare the cubes under the mask 00207 if ( Mvc_Cube1Words(pC1) ) 00208 { 00209 uBits1 = pC1->pData[0] | pMask->pData[0]; 00210 uBits2 = pC2->pData[0] | pMask->pData[0]; 00211 if ( uBits1 < uBits2 ) 00212 return -1; 00213 if ( uBits1 > uBits2 ) 00214 return 1; 00215 // cubes are equal 00216 return 0; 00217 } 00218 else if ( Mvc_Cube2Words(pC1) ) 00219 { 00220 uBits1 = pC1->pData[1] | pMask->pData[1]; 00221 uBits2 = pC2->pData[1] | pMask->pData[1]; 00222 if ( uBits1 < uBits2 ) 00223 return -1; 00224 if ( uBits1 > uBits2 ) 00225 return 1; 00226 uBits1 = pC1->pData[0] | pMask->pData[0]; 00227 uBits2 = pC2->pData[0] | pMask->pData[0]; 00228 if ( uBits1 < uBits2 ) 00229 return -1; 00230 if ( uBits1 > uBits2 ) 00231 return 1; 00232 return 0; 00233 } 00234 else 00235 { 00236 int i = Mvc_CubeReadLast(pC1); 00237 for(; i >= 0; i--) 00238 { 00239 uBits1 = pC1->pData[i] | pMask->pData[i]; 00240 uBits2 = pC2->pData[i] | pMask->pData[i]; 00241 if ( uBits1 < uBits2 ) 00242 return -1; 00243 if ( uBits1 > uBits2 ) 00244 return 1; 00245 } 00246 return 0; 00247 } 00248 }
int Mvc_CubeCompareIntUnderMask | ( | Mvc_Cube_t * | pC1, | |
Mvc_Cube_t * | pC2, | |||
Mvc_Cube_t * | pMask | |||
) |
Function*************************************************************
Synopsis [Compares two cubes under the mask.]
Description []
SideEffects []
SeeAlso []
Definition at line 143 of file mvcCompare.c.
00144 { 00145 unsigned uBits1, uBits2; 00146 00147 // compare the cubes under the mask 00148 if ( Mvc_Cube1Words(pC1) ) 00149 { 00150 uBits1 = pC1->pData[0] & pMask->pData[0]; 00151 uBits2 = pC2->pData[0] & pMask->pData[0]; 00152 if ( uBits1 < uBits2 ) 00153 return -1; 00154 if ( uBits1 > uBits2 ) 00155 return 1; 00156 // cubes are equal 00157 return 0; 00158 } 00159 else if ( Mvc_Cube2Words(pC1) ) 00160 { 00161 uBits1 = pC1->pData[1] & pMask->pData[1]; 00162 uBits2 = pC2->pData[1] & pMask->pData[1]; 00163 if ( uBits1 < uBits2 ) 00164 return -1; 00165 if ( uBits1 > uBits2 ) 00166 return 1; 00167 uBits1 = pC1->pData[0] & pMask->pData[0]; 00168 uBits2 = pC2->pData[0] & pMask->pData[0]; 00169 if ( uBits1 < uBits2 ) 00170 return -1; 00171 if ( uBits1 > uBits2 ) 00172 return 1; 00173 return 0; 00174 } 00175 else 00176 { 00177 int i = Mvc_CubeReadLast(pC1); 00178 for(; i >= 0; i--) 00179 { 00180 uBits1 = pC1->pData[i] & pMask->pData[i]; 00181 uBits2 = pC2->pData[i] & pMask->pData[i]; 00182 if ( uBits1 < uBits2 ) 00183 return -1; 00184 if ( uBits1 > uBits2 ) 00185 return 1; 00186 } 00187 return 0; 00188 } 00189 }
int Mvc_CubeCompareSizeAndInt | ( | Mvc_Cube_t * | pC1, | |
Mvc_Cube_t * | pC2, | |||
Mvc_Cube_t * | pMask | |||
) |
Function*************************************************************
Synopsis [Compares the cubes (1) by size, (2) by integer value.]
Description []
SideEffects []
SeeAlso []
Definition at line 88 of file mvcCompare.c.
00089 { 00090 // compare the cubes by size 00091 if ( Mvc_CubeReadSize( pC1 ) < Mvc_CubeReadSize( pC2 ) ) 00092 return 1; 00093 if ( Mvc_CubeReadSize( pC1 ) > Mvc_CubeReadSize( pC2 ) ) 00094 return -1; 00095 // the cubes have the same size 00096 00097 // compare the cubes as integers 00098 if ( Mvc_Cube1Words( pC1 ) ) 00099 { 00100 if ( pC1->pData[0] < pC2->pData[0] ) 00101 return -1; 00102 if ( pC1->pData[0] > pC2->pData[0] ) 00103 return 1; 00104 return 0; 00105 } 00106 else if ( Mvc_Cube2Words( pC1 ) ) 00107 { 00108 if ( pC1->pData[1] < pC2->pData[1] ) 00109 return -1; 00110 if ( pC1->pData[1] > pC2->pData[1] ) 00111 return 1; 00112 if ( pC1->pData[0] < pC2->pData[0] ) 00113 return -1; 00114 if ( pC1->pData[0] > pC2->pData[0] ) 00115 return 1; 00116 return 0; 00117 } 00118 else 00119 { 00120 int i = Mvc_CubeReadLast( pC1 ); 00121 for(; i >= 0; i--) 00122 { 00123 if ( pC1->pData[i] < pC2->pData[i] ) 00124 return -1; 00125 if ( pC1->pData[i] > pC2->pData[i] ) 00126 return 1; 00127 } 00128 return 0; 00129 } 00130 }
Mvc_Cube_t* Mvc_CubeDup | ( | Mvc_Cover_t * | pCover, | |
Mvc_Cube_t * | pCube | |||
) |
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 91 of file mvcCube.c.
00092 { 00093 Mvc_Cube_t * pCubeCopy; 00094 pCubeCopy = Mvc_CubeAlloc( pCover ); 00095 Mvc_CubeBitCopy( pCubeCopy, pCube ); 00096 return pCubeCopy; 00097 }
void Mvc_CubeFree | ( | Mvc_Cover_t * | pCover, | |
Mvc_Cube_t * | pCube | |||
) |
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 111 of file mvcCube.c.
00112 { 00113 if ( pCube == NULL ) 00114 return; 00115 00116 // verify the parameters charactering this cube 00117 assert( pCube->iLast == 0 || ((int)pCube->iLast) == pCover->nWords - 1 ); 00118 assert( ((int)pCube->nUnused) == pCover->nUnused ); 00119 00120 // deallocate the cube 00121 #ifdef USE_SYSTEM_MEMORY_MANAGEMENT 00122 free( pCube ); 00123 #else 00124 switch( pCover->nWords ) 00125 { 00126 case 0: 00127 case 1: 00128 Extra_MmFixedEntryRecycle( pCover->pMem->pMan1, (char *)pCube ); 00129 break; 00130 case 2: 00131 Extra_MmFixedEntryRecycle( pCover->pMem->pMan2, (char *)pCube ); 00132 break; 00133 case 3: 00134 case 4: 00135 Extra_MmFixedEntryRecycle( pCover->pMem->pMan4, (char *)pCube ); 00136 break; 00137 default: 00138 free( pCube ); 00139 break; 00140 } 00141 #endif 00142 }
void Mvc_CubePrint | ( | Mvc_Cover_t * | pCover, | |
Mvc_Cube_t * | pCube | |||
) |
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 76 of file mvcPrint.c.
00077 { 00078 int iBit, Value; 00079 // iterate through the literals 00080 // printf( "Size = %2d ", Mvc_CubeReadSize(pCube) ); 00081 Mvc_CubeForEachBit( pCover, pCube, iBit, Value ) 00082 printf( "%c", '0' + Value ); 00083 printf( "\n" ); 00084 }
void Mvc_CubePrintMv | ( | Mvc_Data_t * | pData, | |
Mvc_Cover_t * | pCover, | |||
Mvc_Cube_t * | pCube | |||
) |
void Mvc_ListAddCubeHead_ | ( | Mvc_List_t * | pList, | |
Mvc_Cube_t * | pCube | |||
) |
CFile****************************************************************
FileName [mvcList.c]
PackageName [MVSIS 2.0: Multi-valued logic synthesis system.]
Synopsis [Manipulating list of cubes in the cover.]
Author [MVSIS Group]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - February 1, 2003.]
Revision [
] DECLARATIONS /// FUNCTION DEFINITIONS ///Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 40 of file mvcList.c.
00041 { 00042 if ( pList->pHead == NULL ) 00043 { 00044 Mvc_CubeSetNext( pCube, NULL ); 00045 pList->pHead = pCube; 00046 pList->pTail = pCube; 00047 } 00048 else 00049 { 00050 Mvc_CubeSetNext( pCube, pList->pHead ); 00051 pList->pHead = pCube; 00052 } 00053 pList->nItems++; 00054 }
void Mvc_ListAddCubeTail_ | ( | Mvc_List_t * | pList, | |
Mvc_Cube_t * | pCube | |||
) |
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 68 of file mvcList.c.
00069 { 00070 if ( pList->pHead == NULL ) 00071 pList->pHead = pCube; 00072 else 00073 Mvc_CubeSetNext( pList->pTail, pCube ); 00074 pList->pTail = pCube; 00075 Mvc_CubeSetNext( pCube, NULL ); 00076 pList->nItems++; 00077 }
void Mvc_ListDeleteCube_ | ( | Mvc_List_t * | pList, | |
Mvc_Cube_t * | pPrev, | |||
Mvc_Cube_t * | pCube | |||
) |
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 91 of file mvcList.c.
00092 { 00093 if ( pPrev == NULL ) // deleting the head cube 00094 pList->pHead = Mvc_CubeReadNext(pCube); 00095 else 00096 pPrev->pNext = pCube->pNext; 00097 if ( pList->pTail == pCube ) // deleting the tail cube 00098 { 00099 assert( Mvc_CubeReadNext(pCube) == NULL ); 00100 pList->pTail = pPrev; 00101 } 00102 pList->nItems--; 00103 }
Mvc_Cube_t* Mvc_ListGetTailFromHead | ( | Mvc_Cube_t * | pHead | ) |
Function*************************************************************
Synopsis [Returns the tail of the linked list given by the head.]
Description []
SideEffects []
SeeAlso []
Definition at line 348 of file mvcList.c.
00349 { 00350 Mvc_Cube_t * pCube, * pTail; 00351 for ( pTail = pCube = pHead; 00352 pCube; 00353 pTail = pCube, pCube = Mvc_CubeReadNext(pCube) ); 00354 return pTail; 00355 }
Mvc_Cube_t* Mvc_ListReadCubeHead | ( | Mvc_List_t * | pList | ) |
int Mvc_ListReadCubeNum | ( | Mvc_List_t * | pList | ) |
Mvc_Cube_t* Mvc_ListReadCubeTail | ( | Mvc_List_t * | pList | ) |
Mvc_Manager_t* Mvc_ManagerAllocCover | ( | ) |
Mvc_Manager_t* Mvc_ManagerAllocCube | ( | int | nWords | ) |
void Mvc_ManagerFree | ( | Mvc_Manager_t * | p | ) |
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 64 of file mvcMan.c.
00065 { 00066 Extra_MmFixedStop( p->pMan1 ); 00067 Extra_MmFixedStop( p->pMan2 ); 00068 Extra_MmFixedStop( p->pMan4 ); 00069 Extra_MmFixedStop( p->pManC ); 00070 free( p ); 00071 }
Mvc_Manager_t* Mvc_ManagerFreeCover | ( | Mvc_Cover_t * | pCover | ) |
Mvc_Manager_t* Mvc_ManagerFreeCube | ( | Mvc_Cover_t * | pCube, | |
int | nWords | |||
) |
Mvc_Manager_t* Mvc_ManagerStart | ( | ) |
CFile****************************************************************
FileName [mvcMan.c]
PackageName [MVSIS 2.0: Multi-valued logic synthesis system.]
Synopsis [Procedures working with the MVC memory manager.]
Author [MVSIS Group]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - February 1, 2003.]
Revision [
] DECLARATIONS /// FUNCTION DEFINITIONS ///Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 41 of file mvcMan.c.
00042 { 00043 Mvc_Manager_t * p; 00044 p = ALLOC( Mvc_Manager_t, 1 ); 00045 memset( p, 0, sizeof(Mvc_Manager_t) ); 00046 p->pMan1 = Extra_MmFixedStart( sizeof(Mvc_Cube_t) ); 00047 p->pMan2 = Extra_MmFixedStart( sizeof(Mvc_Cube_t) + sizeof(Mvc_CubeWord_t) ); 00048 p->pMan4 = Extra_MmFixedStart( sizeof(Mvc_Cube_t) + 3 * sizeof(Mvc_CubeWord_t) ); 00049 p->pManC = Extra_MmFixedStart( sizeof(Mvc_Cover_t) ); 00050 return p; 00051 }
int Mvc_UtilsCheckUnusedZeros | ( | Mvc_Cover_t * | pCover | ) |
Function*************************************************************
Synopsis [Checks that the cubes of the cover have 0's in unused bits.]
Description []
SideEffects []
SeeAlso []
Definition at line 839 of file mvcUtils.c.
00840 { 00841 unsigned Unsigned; 00842 Mvc_Cube_t * pCube; 00843 int nCubes; 00844 00845 nCubes = 0; 00846 Mvc_CoverForEachCube( pCover, pCube ) 00847 { 00848 if ( pCube->nUnused == 0 ) 00849 continue; 00850 00851 Unsigned = ( pCube->pData[pCube->iLast] & 00852 (BITS_FULL << (32-pCube->nUnused)) ); 00853 if( Unsigned ) 00854 { 00855 printf( "Cube %2d out of %2d contains dirty bits.\n", nCubes, 00856 Mvc_CoverReadCubeNum(pCover) ); 00857 } 00858 nCubes++; 00859 } 00860 return 1; 00861 }
int Mvr_CoverCountLitsWithValue | ( | Mvc_Data_t * | pData, | |
Mvc_Cover_t * | pCover, | |||
int | iVar, | |||
int | iValue | |||
) |