ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
Ttopt::TruthTableCare Class Reference
Inheritance diagram for Ttopt::TruthTableCare:
Collaboration diagram for Ttopt::TruthTableCare:

Public Member Functions

 TruthTableCare (int nInputs, int nOutputs)
 
void Save (unsigned i)
 
void Load (unsigned i)
 
void SaveIndices (unsigned i)
 
void LoadIndices (unsigned i)
 
void Swap (int lev)
 
void RestoreCare ()
 
word GetCare (int index_lev, int lev)
 
void CopyFuncMasked (int index1, int index2, int lev, bool fCompl)
 
bool IsDC (int index, int lev)
 
int Include (int index1, int index2, int lev, bool fCompl)
 
int Intersect (int index1, int index2, int lev, bool fCompl, bool fEq=true)
 
void MergeCare (int index1, int index2, int lev)
 
void Merge (int index1, int index2, int lev, bool fCompl)
 
int BDDBuildOne (int index, int lev)
 
void CompleteMerge ()
 
void BDDBuildStartup ()
 
virtual void BDDRebuildByMerge (int lev)
 
int BDDRebuild (int lev)
 
int BDDSwap (int lev)
 
void OptimizationStartup ()
 
virtual void Optimize ()
 
- Public Member Functions inherited from Ttopt::TruthTableRewrite
 TruthTableRewrite (int nInputs, int nOutputs)
 
void SetValue (int index_lev, int lev, word value)
 
void CopyFunc (int index1, int index2, int lev, bool fCompl)
 
void ShiftToMajority (int index, int lev)
 
- Public Member Functions inherited from Ttopt::TruthTable
 TruthTable (int nInputs, int nOutputs)
 
word GetValue (int index_lev, int lev)
 
int IsEq (int index1, int index2, int lev, bool fCompl=false)
 
bool Imply (int index1, int index2, int lev)
 
int BDDNodeCountLevel (int lev)
 
int BDDNodeCount ()
 
int BDDFind (int index, int lev)
 
virtual void BDDBuildLevel (int lev)
 
virtual int BDDBuild ()
 
void SwapIndex (int &index, int d)
 
int SiftReo ()
 
void Reo (std::vector< int > vLevelsNew)
 
int RandomSiftReo (int nRound)
 
int BDDGenerateAigRec (Gia_Man_t *pNew, std::vector< int > const &vInputs, std::vector< std::vector< int > > &vvNodes, int index, int lev)
 
virtual void BDDGenerateAig (Gia_Man_t *pNew, Vec_Int_t *vSupp)
 

Public Attributes

std::vector< wordoriginalt
 
std::vector< wordcaret
 
std::vector< wordcare
 
std::vector< std::vector< std::pair< int, int > > > vvMergedIndices
 
std::vector< std::vector< word > > savedcare
 
std::vector< std::vector< std::vector< std::pair< int, int > > > > vvMergedIndicesSaved
 
- Public Attributes inherited from Ttopt::TruthTable
int nInputs
 
int nSize
 
int nTotalSize
 
int nOutputs
 
std::vector< wordt
 
std::vector< std::vector< int > > vvIndices
 
std::vector< std::vector< int > > vvRedundantIndices
 
std::vector< int > vLevels
 
std::vector< std::vector< word > > savedt
 
std::vector< std::vector< std::vector< int > > > vvIndicesSaved
 
std::vector< std::vector< std::vector< int > > > vvRedundantIndicesSaved
 
std::vector< std::vector< int > > vLevelsSaved
 

Additional Inherited Members

- Public Types inherited from Ttopt::TruthTable
typedef std::bitset< 64 > bsw
 
- Static Public Attributes inherited from Ttopt::TruthTable
static const int ww = 64
 
static const int lww = 6
 
static const word ones []
 
static const word swapmask []
 

Detailed Description

Definition at line 697 of file giaTtopt.cpp.

Constructor & Destructor Documentation

◆ TruthTableCare()

Ttopt::TruthTableCare::TruthTableCare ( int nInputs,
int nOutputs )
inline

Definition at line 708 of file giaTtopt.cpp.

709 if(nSize) {
710 care.resize(nSize);
711 } else {
712 care.resize(1);
713 }
714 }
std::vector< word > care
Definition giaTtopt.cpp:701
TruthTableRewrite(int nInputs, int nOutputs)
Definition giaTtopt.cpp:630
Here is the call graph for this function:
Here is the caller graph for this function:

Member Function Documentation

◆ BDDBuildOne()

int Ttopt::TruthTableCare::BDDBuildOne ( int index,
int lev )
inlinevirtual

Reimplemented from Ttopt::TruthTable.

Reimplemented in Ttopt::TruthTableLevelTSM.

Definition at line 906 of file giaTtopt.cpp.

906 {
907 int r = BDDFind(index, lev);
908 if(r >= -2) {
909 if(r >= 0) {
910 Merge(vvIndices[lev][r >> 1], index, lev, r & 1);
911 }
912 return r;
913 }
914 vvIndices[lev].push_back(index);
915 return (vvIndices[lev].size() - 1) << 1;
916 }
void Merge(int index1, int index2, int lev, bool fCompl)
Definition giaTtopt.cpp:901
std::vector< std::vector< int > > vvIndices
Definition giaTtopt.cpp:51
int BDDFind(int index, int lev)
Definition giaTtopt.cpp:165
unsigned long long size
Definition giaNewBdd.h:39
Here is the call graph for this function:
Here is the caller graph for this function:

◆ BDDBuildStartup()

void Ttopt::TruthTableCare::BDDBuildStartup ( )
inlinevirtual

Reimplemented from Ttopt::TruthTable.

Definition at line 926 of file giaTtopt.cpp.

926 {
927 RestoreCare();
928 vvIndices.clear();
929 vvIndices.resize(nInputs);
930 vvRedundantIndices.clear();
932 vvMergedIndices.clear();
933 vvMergedIndices.resize(nInputs);
934 for(int i = 0; i < nOutputs; i++) {
935 if(!IsDC(i, 0)) {
936 BDDBuildOne(i, 0);
937 }
938 }
939 }
bool IsDC(int index, int lev)
Definition giaTtopt.cpp:821
std::vector< std::vector< std::pair< int, int > > > vvMergedIndices
Definition giaTtopt.cpp:703
int BDDBuildOne(int index, int lev)
Definition giaTtopt.cpp:906
std::vector< std::vector< int > > vvRedundantIndices
Definition giaTtopt.cpp:52
Here is the call graph for this function:

◆ BDDRebuild()

int Ttopt::TruthTableCare::BDDRebuild ( int lev)
inlinevirtual

Reimplemented from Ttopt::TruthTable.

Reimplemented in Ttopt::TruthTableLevelTSM.

Definition at line 948 of file giaTtopt.cpp.

948 {
949 RestoreCare();
950 int i;
951 for(i = lev; i < nInputs; i++) {
952 vvIndices[i].clear();
953 vvMergedIndices[i].clear();
954 if(i) {
955 vvRedundantIndices[i-1].clear();
956 }
957 }
958 for(i = 0; i < lev; i++) {
960 }
961 for(i = lev; i < nInputs; i++) {
962 if(!i) {
963 for(int j = 0; j < nOutputs; j++) {
964 if(!IsDC(j, 0)) {
965 BDDBuildOne(j, 0);
966 }
967 }
968 } else {
969 BDDBuildLevel(i);
970 }
971 }
972 return BDDNodeCount();
973 }
virtual void BDDRebuildByMerge(int lev)
Definition giaTtopt.cpp:941
virtual void BDDBuildLevel(int lev)
Definition giaTtopt.cpp:232
Here is the call graph for this function:
Here is the caller graph for this function:

◆ BDDRebuildByMerge()

virtual void Ttopt::TruthTableCare::BDDRebuildByMerge ( int lev)
inlinevirtual

Reimplemented in Ttopt::TruthTableLevelTSM.

Definition at line 941 of file giaTtopt.cpp.

941 {
942 for(unsigned i = 0; i < vvMergedIndices[lev].size(); i++) {
943 std::pair<int, int> &p = vvMergedIndices[lev][i];
944 MergeCare(p.first >> 1, p.second, lev);
945 }
946 }
void MergeCare(int index1, int index2, int lev)
Definition giaTtopt.cpp:884
Cube * p
Definition exorList.c:222
Here is the call graph for this function:
Here is the caller graph for this function:

◆ BDDSwap()

int Ttopt::TruthTableCare::BDDSwap ( int lev)
inlinevirtual

Reimplemented from Ttopt::TruthTable.

Definition at line 975 of file giaTtopt.cpp.

975 {
976 Swap(lev);
977 return BDDRebuild(lev);
978 }
void Swap(int lev)
Definition giaTtopt.cpp:742
int BDDRebuild(int lev)
Definition giaTtopt.cpp:948
Here is the call graph for this function:

◆ CompleteMerge()

void Ttopt::TruthTableCare::CompleteMerge ( )
inline

Definition at line 918 of file giaTtopt.cpp.

918 {
919 for(int i = nInputs - 1; i >= 0; i--) {
920 for(std::vector<std::pair<int, int> >::reverse_iterator it = vvMergedIndices[i].rbegin(); it != vvMergedIndices[i].rend(); it++) {
921 CopyFunc((*it).second, (*it).first >> 1, i, (*it).first & 1);
922 }
923 }
924 }
void CopyFunc(int index1, int index2, int lev, bool fCompl)
Definition giaTtopt.cpp:642
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CopyFuncMasked()

void Ttopt::TruthTableCare::CopyFuncMasked ( int index1,
int index2,
int lev,
bool fCompl )
inline

Definition at line 792 of file giaTtopt.cpp.

792 {
793 assert(index1 >= 0);
794 assert(index2 >= 0);
795 int logwidth = nInputs - lev;
796 if(logwidth > lww) {
797 int nScopeSize = 1 << (logwidth - lww);
798 for(int i = 0; i < nScopeSize; i++) {
799 word value = t[nScopeSize * index2 + i];
800 if(fCompl) {
801 value = ~value;
802 }
803 word cvalue = caret[nScopeSize * index2 + i];
804 t[nScopeSize * index1 + i] &= ~cvalue;
805 t[nScopeSize * index1 + i] |= cvalue & value;
806 }
807 } else {
808 word one = ones[logwidth];
809 word value1 = GetValue(index1, lev);
810 word value2 = GetValue(index2, lev);
811 if(fCompl) {
812 value2 ^= one;
813 }
814 word cvalue = GetCare(index2, lev);
815 value1 &= cvalue ^ one;
816 value1 |= cvalue & value2;
817 SetValue(index1, lev, value1);
818 }
819 }
ABC_NAMESPACE_IMPL_START typedef signed char value
word GetCare(int index_lev, int lev)
Definition giaTtopt.cpp:783
std::vector< word > caret
Definition giaTtopt.cpp:700
void SetValue(int index_lev, int lev, word value)
Definition giaTtopt.cpp:632
word GetValue(int index_lev, int lev)
Definition giaTtopt.cpp:109
std::vector< word > t
Definition giaTtopt.cpp:49
static const int lww
Definition giaTtopt.cpp:42
static const word ones[]
Definition giaTtopt.cpp:60
unsigned __int64 word
DECLARATIONS ///.
Definition kitPerm.c:36
#define assert(ex)
Definition util_old.h:213
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetCare()

word Ttopt::TruthTableCare::GetCare ( int index_lev,
int lev )
inline

Definition at line 783 of file giaTtopt.cpp.

783 {
784 assert(index_lev >= 0);
785 assert(nInputs - lev <= lww);
786 int logwidth = nInputs - lev;
787 int index = index_lev >> (lww - logwidth);
788 int pos = (index_lev % (1 << (lww - logwidth))) << logwidth;
789 return (caret[index] >> pos) & ones[logwidth];
790 }
bool pos
Definition globals.c:30
Here is the caller graph for this function:

◆ Include()

int Ttopt::TruthTableCare::Include ( int index1,
int index2,
int lev,
bool fCompl )
inline

Definition at line 835 of file giaTtopt.cpp.

835 {
836 assert(index1 >= 0);
837 assert(index2 >= 0);
838 int logwidth = nInputs - lev;
839 bool fEq = true;
840 if(logwidth > lww) {
841 int nScopeSize = 1 << (logwidth - lww);
842 for(int i = 0; i < nScopeSize && (fEq || fCompl); i++) {
843 word cvalue = caret[nScopeSize * index2 + i];
844 if(~caret[nScopeSize * index1 + i] & cvalue) {
845 return 0;
846 }
847 word value = t[nScopeSize * index1 + i] ^ t[nScopeSize * index2 + i];
848 fEq &= !(value & cvalue);
849 fCompl &= !(~value & cvalue);
850 }
851 } else {
852 word cvalue = GetCare(index2, lev);
853 if((GetCare(index1, lev) ^ ones[logwidth]) & cvalue) {
854 return 0;
855 }
856 word value = GetValue(index1, lev) ^ GetValue(index2, lev);
857 fEq &= !(value & cvalue);
858 fCompl &= !((value ^ ones[logwidth]) & cvalue);
859 }
860 return 2 * fCompl + fEq;
861 }
Here is the call graph for this function:

◆ Intersect()

int Ttopt::TruthTableCare::Intersect ( int index1,
int index2,
int lev,
bool fCompl,
bool fEq = true )
inline

Definition at line 863 of file giaTtopt.cpp.

863 {
864 assert(index1 >= 0);
865 assert(index2 >= 0);
866 int logwidth = nInputs - lev;
867 if(logwidth > lww) {
868 int nScopeSize = 1 << (logwidth - lww);
869 for(int i = 0; i < nScopeSize && (fEq || fCompl); i++) {
870 word value = t[nScopeSize * index1 + i] ^ t[nScopeSize * index2 + i];
871 word cvalue = caret[nScopeSize * index1 + i] & caret[nScopeSize * index2 + i];
872 fEq &= !(value & cvalue);
873 fCompl &= !(~value & cvalue);
874 }
875 } else {
876 word value = GetValue(index1, lev) ^ GetValue(index2, lev);
877 word cvalue = GetCare(index1, lev) & GetCare(index2, lev);
878 fEq &= !(value & cvalue);
879 fCompl &= !((value ^ ones[logwidth]) & cvalue);
880 }
881 return 2 * fCompl + fEq;
882 }
Here is the call graph for this function:

◆ IsDC()

bool Ttopt::TruthTableCare::IsDC ( int index,
int lev )
inline

Definition at line 821 of file giaTtopt.cpp.

821 {
822 if(nInputs - lev > lww) {
823 int nScopeSize = 1 << (nInputs - lev - lww);
824 for(int i = 0; i < nScopeSize; i++) {
825 if(caret[nScopeSize * index + i]) {
826 return false;
827 }
828 }
829 } else if(GetCare(index, lev)) {
830 return false;
831 }
832 return true;
833 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Load()

void Ttopt::TruthTableCare::Load ( unsigned i)
inlinevirtual

Reimplemented from Ttopt::TruthTable.

Definition at line 724 of file giaTtopt.cpp.

724 {
726 care = savedcare[i];
727 }
std::vector< std::vector< word > > savedcare
Definition giaTtopt.cpp:705
virtual void Load(unsigned i)
Definition giaTtopt.cpp:89
Here is the call graph for this function:

◆ LoadIndices()

void Ttopt::TruthTableCare::LoadIndices ( unsigned i)
inlinevirtual

Reimplemented from Ttopt::TruthTable.

Definition at line 737 of file giaTtopt.cpp.

737 {
740 }
std::vector< std::vector< std::vector< std::pair< int, int > > > > vvMergedIndicesSaved
Definition giaTtopt.cpp:706
virtual void LoadIndices(unsigned i)
Definition giaTtopt.cpp:104
Here is the call graph for this function:

◆ Merge()

void Ttopt::TruthTableCare::Merge ( int index1,
int index2,
int lev,
bool fCompl )
inline

Definition at line 901 of file giaTtopt.cpp.

901 {
902 MergeCare(index1, index2, lev);
903 vvMergedIndices[lev].push_back(std::make_pair((index1 << 1) ^ (int)fCompl, index2));
904 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ MergeCare()

void Ttopt::TruthTableCare::MergeCare ( int index1,
int index2,
int lev )
inline

Definition at line 884 of file giaTtopt.cpp.

884 {
885 assert(index1 >= 0);
886 assert(index2 >= 0);
887 int logwidth = nInputs - lev;
888 if(logwidth > lww) {
889 int nScopeSize = 1 << (logwidth - lww);
890 for(int i = 0; i < nScopeSize; i++) {
891 caret[nScopeSize * index1 + i] |= caret[nScopeSize * index2 + i];
892 }
893 } else {
894 word value = GetCare(index2, lev);
895 int index = index1 >> (lww - logwidth);
896 int pos = (index1 % (1 << (lww - logwidth))) << logwidth;
897 caret[index] |= value << pos;
898 }
899 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ OptimizationStartup()

void Ttopt::TruthTableCare::OptimizationStartup ( )
inline

Definition at line 980 of file giaTtopt.cpp.

980 {
981 originalt = t;
982 RestoreCare();
983 vvIndices.clear();
984 vvIndices.resize(nInputs);
985 vvMergedIndices.clear();
986 vvMergedIndices.resize(nInputs);
987 for(int i = 0; i < nOutputs; i++) {
988 if(!IsDC(i, 0)) {
989 BDDBuildOne(i, 0);
990 } else {
991 ShiftToMajority(i, 0);
992 }
993 }
994 }
std::vector< word > originalt
Definition giaTtopt.cpp:699
void ShiftToMajority(int index, int lev)
Definition giaTtopt.cpp:680
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Optimize()

virtual void Ttopt::TruthTableCare::Optimize ( )
inlinevirtual

Definition at line 996 of file giaTtopt.cpp.

996 {
998 for(int i = 1; i < nInputs; i++) {
999 for(unsigned j = 0; j < vvIndices[i-1].size(); j++) {
1000 int index = vvIndices[i-1][j];
1001 BDDBuildOne(index << 1, i);
1002 BDDBuildOne((index << 1) ^ 1, i);
1003 }
1004 }
1005 CompleteMerge();
1006 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ RestoreCare()

void Ttopt::TruthTableCare::RestoreCare ( )
inline

Definition at line 768 of file giaTtopt.cpp.

768 {
769 caret.clear();
770 if(nSize) {
771 for(int i = 0; i < nOutputs; i++) {
772 caret.insert(caret.end(), care.begin(), care.end());
773 }
774 } else {
775 caret.resize(nTotalSize);
776 for(int i = 0; i < nOutputs; i++) {
777 int padding = i * (1 << nInputs);
778 caret[padding / ww] |= care[0] << (padding % ww);
779 }
780 }
781 }
static const int ww
Definition giaTtopt.cpp:41
Here is the caller graph for this function:

◆ Save()

void Ttopt::TruthTableCare::Save ( unsigned i)
inlinevirtual

Reimplemented from Ttopt::TruthTable.

Definition at line 716 of file giaTtopt.cpp.

716 {
718 if(savedcare.size() < i + 1) {
719 savedcare.resize(i + 1);
720 }
721 savedcare[i] = care;
722 }
virtual void Save(unsigned i)
Definition giaTtopt.cpp:80
Here is the call graph for this function:

◆ SaveIndices()

void Ttopt::TruthTableCare::SaveIndices ( unsigned i)
inlinevirtual

Reimplemented from Ttopt::TruthTable.

Definition at line 729 of file giaTtopt.cpp.

729 {
731 if(vvMergedIndicesSaved.size() < i + 1) {
732 vvMergedIndicesSaved.resize(i + 1);
733 }
735 }
virtual void SaveIndices(unsigned i)
Definition giaTtopt.cpp:95
Here is the call graph for this function:

◆ Swap()

void Ttopt::TruthTableCare::Swap ( int lev)
inlinevirtual

Reimplemented from Ttopt::TruthTable.

Definition at line 742 of file giaTtopt.cpp.

742 {
743 TruthTable::Swap(lev);
744 if(nInputs - lev - 1 > lww) {
745 int nScopeSize = 1 << (nInputs - lev - 2 - lww);
746 for(int i = nScopeSize; i < nSize; i += (nScopeSize << 2)) {
747 for(int j = 0; j < nScopeSize; j++) {
748 std::swap(care[i + j], care[i + nScopeSize + j]);
749 }
750 }
751 } else if(nInputs - lev - 1 == lww) {
752 for(int i = 0; i < nSize; i += 2) {
753 care[i+1] ^= care[i] >> (ww / 2);
754 care[i] ^= care[i+1] << (ww / 2);
755 care[i+1] ^= care[i] >> (ww / 2);
756 }
757 } else {
758 for(int i = 0; i < nSize || (i == 0 && !nSize); i++) {
759 int d = nInputs - lev - 2;
760 int shamt = 1 << d;
761 care[i] ^= (care[i] >> shamt) & swapmask[d];
762 care[i] ^= (care[i] & swapmask[d]) << shamt;
763 care[i] ^= (care[i] >> shamt) & swapmask[d];
764 }
765 }
766 }
virtual void Swap(int lev)
Definition giaTtopt.cpp:276
static const word swapmask[]
Definition giaTtopt.cpp:61
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ care

std::vector<word> Ttopt::TruthTableCare::care

Definition at line 701 of file giaTtopt.cpp.

◆ caret

std::vector<word> Ttopt::TruthTableCare::caret

Definition at line 700 of file giaTtopt.cpp.

◆ originalt

std::vector<word> Ttopt::TruthTableCare::originalt

Definition at line 699 of file giaTtopt.cpp.

◆ savedcare

std::vector<std::vector<word> > Ttopt::TruthTableCare::savedcare

Definition at line 705 of file giaTtopt.cpp.

◆ vvMergedIndices

std::vector<std::vector<std::pair<int, int> > > Ttopt::TruthTableCare::vvMergedIndices

Definition at line 703 of file giaTtopt.cpp.

◆ vvMergedIndicesSaved

std::vector<std::vector<std::vector<std::pair<int, int> > > > Ttopt::TruthTableCare::vvMergedIndicesSaved

Definition at line 706 of file giaTtopt.cpp.


The documentation for this class was generated from the following file: