コード例 #1
0
ファイル: controller.cpp プロジェクト: maperr/inf3610_tp4
//////////////////////////////////////////////////////////////////////////////
///
///	Delegate the operation
///
//////////////////////////////////////////////////////////////////////////////
long controller::delegateOperation(Operation operation, long operand1, long operand2)
{
 long result;
    switch (operation)
    {
        case ADD:
        {
         sendAdditionOperand(operand1);
         sendAdditionOperand(operand2);
         result = readAdditionResult();

    SpacePrint("%d + %d = %d\n", operand1, operand2, result);

         break;
        }
        case SUBTRACTION:
        {
         sendSubtractionOperand(operand1);
         sendSubtractionOperand(operand2);
         result = readSubtractionResult();

    SpacePrint("%d - %d = %d\n", operand1, operand2, result);

         break;
        }
        case MULTIPLY:
        {
         sendMultiplicationOperand(operand1);
         sendMultiplicationOperand(operand2);
         result = readMultiplicationResult();

    SpacePrint("%d * %d = %d\n", operand1, operand2, result);

         break;
        }
        case DIVIDE:
        {
         sendDivisionOperand(operand1);
         sendDivisionOperand(operand2);
         result = readDivisionResult();

    SpacePrint("%d / %d = %d\n", operand1, operand2, result);

         break;
        }
        case MULTIPLY_MAT:
        {
         sendMultiplicationMatOperand(operand1);
   sendMultiplicationMatOperand(operand2);
   unsigned int *result = new unsigned int[200 * 200];
   readMultiplicationMatResult(result);
   sc_stop();
   break;
        }

    }

    return result;
}
コード例 #2
0
ファイル: controller.cpp プロジェクト: Marvens/inf3610lab4
//////////////////////////////////////////////////////////////////////////////
///
///	Delegate the operation
///
//////////////////////////////////////////////////////////////////////////////
long controller::delegateOperation(Operation operation, long operand1,
  long operand2) {

 // SpacePrint("+++delegateOperation\n");

 long result;
 unsigned int *resultMatrix = new unsigned int [300 * 300]; // no new here cause error
 switch (operation) {
 case ADD: {
  sendAdditionOperand(operand1);
  sendAdditionOperand(operand2);
  result = readAdditionResult();



  break;
 }
 case SUBTRACTION: {
  sendSubtractionOperand(operand1);
  sendSubtractionOperand(operand2);
  result = readSubtractionResult();



  break;
 }
 case MULTIPLY: {
  sendMultiplicationOperand(operand1);
  sendMultiplicationOperand(operand2);
  result = readMultiplicationResult();



  break;
 }
 case DIVIDE: {
  sendDivisionOperand(operand1);
  sendDivisionOperand(operand2);
  result = readDivisionResult();



  break;
 }
 case MATRIXMUL: {
  sendMatrixMulOperand(matrix_data[operand1]);
  sendMatrixMulOperand(matrix_data[operand2]);
  readMatrixMulRes(resultMatrix);

  //printing the values
  break;
 }

 }

 //SpacePrint("---delegateOperation\n");
 sc_stop();
 return result;
}
コード例 #3
0
ファイル: controller.cpp プロジェクト: Marvens/inf3610lab4
//////////////////////////////////////////////////////////////////////////////
///
///	Delegate the operation
///
//////////////////////////////////////////////////////////////////////////////
long controller::delegateOperation(Operation operation, long operand1,
  long operand2) {

 SpacePrint("+++delegateOperation\n");

 long result;
 unsigned int *resultMatrix = new unsigned int [200 * 200];
 switch (operation) {
 case ADD: {
  sendAdditionOperand(operand1);
  sendAdditionOperand(operand2);
  result = readAdditionResult();

  SpacePrint("%d + %d = %d\n", operand1, operand2, result);

  break;
 }
 case SUBTRACTION: {
  sendSubtractionOperand(operand1);
  sendSubtractionOperand(operand2);
  result = readSubtractionResult();

  SpacePrint("%d - %d = %d\n", operand1, operand2, result);

  break;
 }
 case MULTIPLY: {
  sendMultiplicationOperand(operand1);
  sendMultiplicationOperand(operand2);
  result = readMultiplicationResult();

  SpacePrint("%d * %d = %d\n", operand1, operand2, result);

  break;
 }
 case DIVIDE: {
  sendDivisionOperand(operand1);
  sendDivisionOperand(operand2);
  result = readDivisionResult();

  SpacePrint("%d / %d = %d\n", operand1, operand2, result);

  break;
 }
 case MATRIXMUL: {
  sendMatrixMulOperand(matrix_data[operand1]);
  sendMatrixMulOperand(matrix_data[operand2]);
  readMatrixMulRes(resultMatrix);

  //printing the values

  for (int i = 0; i < 200; i++) {
   for (int j = 0; j < 200; j++) {
    SpacePrint("%u ", resultMatrix[i * 200 + j]);
   }
   SpacePrint("\n");
  }

  break;
 }

 }

 SpacePrint("---delegateOperation\n");
 sc_stop();
 return result;
}
コード例 #4
0
ファイル: controller.cpp プロジェクト: maperr/inf3610_tp4
//////////////////////////////////////////////////////////////////////////////
///
///	Delegate the operation
///
//////////////////////////////////////////////////////////////////////////////
long controller::delegateOperation(Operation operation, long operand1, long operand2)
{
 long result;
    switch (operation)
    {
        case ADD:
        {
         sendAdditionOperand(operand1);
         sendAdditionOperand(operand2);
         result = readAdditionResult();

    SpacePrint("%d + %d = %d\n", operand1, operand2, result);

         break;
        }
        case SUBTRACTION:
        {
         sendSubtractionOperand(operand1);
         sendSubtractionOperand(operand2);
         result = readSubtractionResult();

    SpacePrint("%d - %d = %d\n", operand1, operand2, result);

         break;
        }
        case MULTIPLY:
        {
         sendMultiplicationOperand(operand1);
         sendMultiplicationOperand(operand2);
         result = readMultiplicationResult();

    SpacePrint("%d * %d = %d\n", operand1, operand2, result);

         break;
        }
        case DIVIDE:
        {
         sendDivisionOperand(operand1);
         sendDivisionOperand(operand2);
         result = readDivisionResult();

    SpacePrint("%d / %d = %d\n", operand1, operand2, result);

         break;
        }
        case MULTIPLY_MAT:
        {
         sendMultiplicationMatOperand(operand1);
   sendMultiplicationMatOperand(operand2);
   long result [30 * 30];
   readMultiplicationMatResult(result);

    SpacePrint("%d z %d = \n", operand1, operand2);
    for(unsigned int i = 0; i < 30 * 30; i++)
    {
     SpacePrint("%d\n", result[i]);
    }

   break;
        }

    }

    return result;
}