Esempio n. 1
0
        public static string GetGroupString(SCarnoGroup group, char[] letters)
        {
            ArrayList groupChars = new ArrayList();

            int[] mintermIndexes    = GetMintermsIndexes(GetMintermsInsideGroup(group));
            int   firstMintermIndex = mintermIndexes[0];
            int   indexesCount      = mintermIndexes.GetLength(0);
            int   equalityResult    = firstMintermIndex;
            byte  lettersCount      = (byte)letters.GetLength(0);
            bool  flag;

            // Group string for group RectGroup_16
            if ((group.Type == EGroupTypes.RectGroup_16 && lettersCount == 4) || (group.Type == EGroupTypes.RectGroup_8_Hor && lettersCount == 3))
            {
                return("1 (True)");
            }
            // Find bits in minterms that are equal (bits with same height)
            for (byte i = 0; i < lettersCount; i++)
            {
                flag = true;
                for (int j = 1; j < indexesCount; j++)
                {
                    if (BinaryManip.GetBitValue(firstMintermIndex, i)
                        != BinaryManip.GetBitValue(mintermIndexes[j], i))
                    {
                        flag = false;
                        break;
                    }
                }
                BinaryManip.SetBitValue(ref equalityResult, i, flag);
            }
            // - - -

            // Produce group string
            for (byte i = 0; i < lettersCount; i++)
            {
                if (BinaryManip.GetBitValue(equalityResult, i))
                {
                    string tmpStr;
                    if (BinaryManip.GetBitValue(firstMintermIndex, i))
                    {
                        tmpStr = letters[lettersCount - i - 1].ToString();
                    }
                    else
                    {
                        tmpStr = letters[lettersCount - i - 1].ToString() + "\'";
                    }

                    groupChars.Add(tmpStr);
                }
            }
            groupChars.Reverse();
            // - - -

            // Return all strings
            string[] str = (string[])groupChars.ToArray(typeof(string));
            return(string.Concat(str));
        }
Esempio n. 2
0
        public string GetBinaryIndex(EKarnaughTableType tableType)
        {
            int digitsCount;

            if (tableType == EKarnaughTableType.Karnaugh3Var)
            {
                digitsCount = 3;
            }
            else
            {
                digitsCount = 4;
            }

            return(BinaryManip.GetBinaryValue(m_mintermIndex, digitsCount));
        }
Esempio n. 3
0
 public bool GetBitValue(byte bitIndex)
 {
     return(BinaryManip.GetBitValue(m_mintermIndex, bitIndex));
 }
Esempio n. 4
0
 public void SetBitValue(byte bitIndex, bool newBitValue)
 {
     BinaryManip.SetBitValue(ref m_mintermIndex, bitIndex, newBitValue);
 }