2017-05-06 5 views
0

이 포럼에서이 문제를 해결하는 데 많은 시간이 걸렸으므로 systemC를 사용하여 첫 번째 프로그램을 iwrite하고 프로그램 디버그를 실행하지만 예외를 실행할 수 있도록 최대한 많이 작성했습니다. , 나는 두 개의 다른 텍스트 파일에 이미지의 픽셀 값의 2 매트릭스를 저장, 나는 임계 값의 다른 상사의 수가 메시지 (모션)를 표시하는 경우 두 개의 매트릭스 및 comapre 그들을로드 systemC 코드를 작성하십시오.내 첫 번째 프로그램 systemC

내 코드는 두 개의 모듈로 구성됩니다. 첫 번째 모듈은 텍스트 파일에 숫자가 있는지 확인합니다. 그렇다면이 모듈은 다른 모듈을 자동화하여 두 개의 행렬을로드하고 비교합니다. 내 프로젝트에이 코드가 필요합니다. 어떤 도움이나 제안을 졸업. 당신이 발견 한 내용을 예외에 대한 어떤 정보도 없다지만

#include "systemc.h" 
    #include "stdio.h" 
#define _CRT_SECURE_NO_WARNINGS 

    SC_MODULE(synchronous) { 
sc_out<bool> in; 
SC_CTOR(synchronous) 
{} 
void verify() { 
    FILE *ifp, *ofp; 
    char *mode = "r"; 
    char outputFilename[] = "F:/yosri.txt"; 
    int val; 
    ifp = fopen(outputFilename, mode); 
    while (fscanf_s(ifp, "%d", &val) != 1) 
    { 
     cout << " waiting..."; 
} 
in = true; 
    } 

}; 

SC_MODULE(imageProcess) 
    { 
sc_in<bool> in; 


SC_CTOR(imageProcess) 
{ 
    SC_METHOD(MotionDetection); 
    sensitive<<in; 
    } 
    void MotionDetection() 
    { 
    int Threshold = 20; 
    bool fileFound; 
    char *mode1 = "r"; 
    char *mode2 = "w"; 
    FILE *ofp1 = fopen("F:/image1.txt", mode1); 
    FILE *ofp2 = fopen("F:/images2.txt", mode1); 
    FILE *Motion = fopen("F:/image3.txt", mode2); 
    int rowCounter, colCounter, isEqual = 0; 
    int firstMatrix[384][512], secondMatrix[384][512]; 

    // if (!(ofp1 || ofp2)) 
     //{ 
      //printf("2222222222222222222"); 

      //fileFound = false; 
     //} 
     //else fileFound = true; 
     //if (fileFound) { 

    while (!feof(ofp1) && !feof(ofp2)) 
    { 

     for (rowCounter = 0; rowCounter < 384; rowCounter++) { 
      for (colCounter = 0; colCounter < 512; colCounter++) { 
       scanf("%d", &firstMatrix[rowCounter][colCounter]); 
      } 
     } 

     for (rowCounter = 0; rowCounter < 384; rowCounter++) 
     { 
      for (colCounter = 0; colCounter < 512; colCounter++) 
      { 
       scanf("%d", &secondMatrix[rowCounter][colCounter]); 

       if (firstMatrix[rowCounter][colCounter] != 
       secondMatrix[rowCounter][colCounter]) 
       { 

        isEqual++; 

        break; 
       } 
      } 
     } 
       if (isEqual > Threshold) 
       { 
        fputc(secondMatrix[rowCounter][colCounter], Motion); 
       } 
       else cout<< "MOTION"; 

      } 

     cout << "%d", isEqual; 
    } 
    }; 


// sc_main in top level function like in C++ main 
int sc_main(int argc, char* argv[]) { 
sc_start(); 
synchronous yosri("A"); 
yosri.verify(); 

imageProcess go("B"); 
go.MotionDetection(); 
return(0); 
} 

답변

0

, 나는 코드에서 몇 가지 잠재적 인 오류를 발견 :

  1. sc_start()가 바로 반환하기 전에 호출되어야합니다 (0).
  2. 내 경험상 SC_MODULE의 기능은 SC_THREAD 또는 SC_METHOD 안에 있어야합니다.