コード例 #1
0
ファイル: LogicProcessor.cpp プロジェクト: girishetty/mytools
/***********************************************************************
 Truth Table Generating function
 It takes the type of Family Type and number of inputs as input
 ***********************************************************************/
void LogicProcessor::ShowTruthTable(LogicType aLogicType, int aNumInputs){
    Logic* pLogic = CreateLogic(aLogicType, aNumInputs);
    bool** inputTable = GenerateInputTable(aNumInputs);
    int rowSize = int(pow(2, aNumInputs));

    int i=0;
    //For each combination of input
    for (;i<rowSize;i++) {
        //Display all input in this combination
        for (int j=0; j<aNumInputs; j++) {
            DisplayValue(inputTable[i][j]);
        }
        //Process these inputs for this Logic
        bool output = pLogic->Process(inputTable[i]);
        cout<<"--> ";
        //Display output
        DisplayValue(output);
        cout<<endl;
    }

    delete pLogic;

    //Destruct the Input Table
    for (i=0;i<rowSize;i++){
        delete []inputTable[i];
    }
}