2017-05-06 8 views
0

Ich schrieb in diesem Forum um Hilfe bitten, um dieses Problem zu lösen, das eine Menge Zeit nahm, iwrite mein erstes Programm mit SystemC, mein Programm debug aber Lauf Ausnahme Ich werde mein Ziel so viel wie ich kann , Ich speicherte 2 Matrix des Pixelwertes des Bildes in zwei verschiedenen Textdateien, ich schreibe einen SystemC Code, der zwei Matrix lädt und compapre sie, wenn Zahl von verschiedenen Vorgesetzten eines Schwellenwertes der Code Nachricht anzeigt (Bewegung).mein erstes Programm systemC

Mein Code besteht aus zwei Modulen, das erste Modul überprüft, ob eine Zahl in einer Textdatei vorhanden ist. Wenn ja, automatisiert dieses Modul das andere Modul, um die zwei Matrix zu laden und sie zu vergleichen. Ich brauche diesen Code wirklich für mein Projekt Abschluss jede Hilfe oder Anregung.

#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); 
} 

Antwort

0

Zwar gibt es keine Informationen über das, was Ausnahme, die Sie je gesehen habe, fand ich einige potenzielle Fehler im Code:

  1. Die sc_start() aufgerufen direkt vor der Rückkehr werden soll (0).
  2. Meiner Erfahrung nach sollte die Funktionalität eines SC_MODULE in einen SC_THREAD oder SC_METHOD eingefügt werden.