yosri ben salah

Members
  • Content count

    15
  • Joined

  • Last visited

  1. dr ralph I do not have enough time yet for my project graduation i was stopped at this point posting a lot of topic in this forum, . if you can comment my code helping me to fix some issues and i will try to check some tutorials from doulos, the time i finish my project i will get a basic courses on systemC im really interrested by this language because it is necessaire for my future learning in embedded system field, thank you
  2. dr, this is my last attempt, the code is debugged but does not respect the condition( condition as i said iwant if the synchronous module find string in text file, it activates the second module) even i dont use port because i dont know how to use them, #include "systemC.h" #include "string.h" #include "stdio.h" #include"stdlib.h" #include <time.h> #include <fstream> #define _CRT_SECURE_NO_WARNINGS _CRT_SECURE_NO_WARNINGS double elapsed; int in = false; SC_MODULE(synchronous) { SC_CTOR(synchronous) { SC_METHOD(synchronization); } void synchronization() { FILE *workspace = fopen("F:/yosri.txt", "r"); char buff[12]; fgets(buff, 12, workspace); int ret = 0; while (ret = 0) { printf("Waiting for request...\n"); ret = strcmp(buff, "SWITCHCONTEXT"); printf("%d", ret); } //SWITCHCONTXT is a string written in a text file in = true; printf("Establishing communication"); } }; clock_t start = clock(); SC_MODULE(imageProcess) { sc_in<bool>sig; SC_CTOR(imageProcess) { SC_METHOD(MotionDetector) sensitive(sig); } void MotionDetector() { if (in = true) { printf("\n...Communication established"); char *mode1 = "r"; char *mode2 = "w"; int i, j, k; int C = 0; int rows1, cols1, rows2, cols2; bool fileFound = false; bool multiplcation = true; FILE *image1; FILE *image2; FILE *image3; int sum = 0; image3 = fopen("F:/image3.txt", mode2); do { char *mode1 = "r"; char *mode2 = "w"; image1 = fopen("F:/image1.txt", mode1); if (!image1) { printf("File Not Found!!\n"); fileFound = true; } else fileFound = false; } while (fileFound); do { image2 = fopen("F:/image2.txt", mode1); if (!image2) { printf("File Not Found!!\n"); fileFound = true; } else fileFound = false; } while (fileFound); //allocate Matrcies rows1 = rows2 = 384; cols1 = cols2 = 512; int **mat1 = (int **)malloc(rows1 * sizeof(int*)); for (i = 0; i < rows1; i++) mat1 = (int *)malloc(cols1 * sizeof(int)); i = 0; int **mat2 = (int **)malloc(rows2 * sizeof(int*)); for (i = 0; i < rows2; i++) mat2 = (int *)malloc(cols2 * sizeof(int)); i = 0; while (!feof(image1)) { for (i = 0; i < rows1; i++) { for (j = 0; j < cols1; j++) fscanf(image1, "%d%", &mat1[j]); } } i = 0; j = 0; while (!feof(image2)) { for (i = 0; i < rows2; i++) { for (j = 0; j < cols2; j++) fscanf(image2, "%d%", &mat2[j]); } } ///////////////////////// i = 0; j = 0; printf("\n\n"); //print matrix 1 //for (i = 0; i<rows1; i++) //{ //for (j = 0; j<cols1; j++) //printf("%d\t", mat1[j]); //printf("\n"); //} //////////////////////////// i = 0; k = 0; printf("\n\n"); //for (i = 0; i < rows2; i++) //{ //for (j = 0; j < cols2; j++) //printf("%d\t", mat2[j]); //printf("\n"); //} ///////////////////////// for (i = 0; i < rows1; i++) { for (j = 0; j < cols1; j++) { if (mat1[j] != mat2[j]) C++; } } i = j = 0; if (C > 20) { printf("MOTION...DETECTED\a \a"); for (i = 0; i < rows1; i++) { for (j = 0; j < cols1; j++) { fprintf(image3, "%d ", mat2[j]); } fprintf(image3, "\n"); } printf("\n Image Saved...."); } fclose(image1); fclose(image2); fclose(image3); clock_t end = clock(); elapsed = ((double)end - start) / CLOCKS_PER_SEC; printf("time is %f", elapsed); std::ofstream mon_fichier("F:/toto.txt"); mon_fichier << "Une chaine\n"; mon_fichier << elapsed << '\n'; } } }; int sc_main(int argc, char* argv[]) { //synchronization(); synchronous yosri("e"); yosri.synchronization(); imageProcess master("EE2"); master.MotionDetector(); sc_start(); return(0); }
  3. Hi, i wanna thank you dr , i try to use port with the aim of automatng the second module (ImageProcess) the time the condition in first module is validated (string found in a text file). i dont succeeded on it, i dont know how to do it, i use intanciate module in SC_main following a suggestion of a member in the forum
  4. hi, i debugged my systemC code, but it dispalys an error, pls which is the main cause of this message exception Microsoft C++ : sc_core::sc_report à l'emplacement de mémoire 0x0099F6A8.
  5. hi all, can someone explain for me why my code display error when i instanciate module in main function thanks ystemc modules should include systemc.h header file #include "systemc.h" #include "stdio.h" #include "string.h" #include "stdio.h" #include"stdlib.h" #define _CRT_SECURE_NO_WARNINGS sc_out<bool> in; SC_MODULE(synchronous) { bool synchronization() { sc_out<bool> in; FILE *workspace = fopen("F:/yosri.txt", "r"); char buff[13]; fgets(buff, 12, workspace); int ret = 0; while (ret == 0) { cout << "Waiting for request...\n"; ret = strcmp(buff, "SWITCHCONTEXT"); printf("%d", ret); } //SWITCHCONTXT is a string written in a text file in = true; cout << "Establishing communication"; return(in); } }; SC_MODULE(imageProcess) { sc_in<bool> in; void MotionDetector(bool signal) { printf("\nCommuncation established"); char *mode1 = "r"; char *mode2 = "w"; int i, j, k; int C = 0; int rows1, cols1, rows2, cols2; bool fileFound = false; bool multiplcation = true; FILE *image1; FILE *image2; FILE *image3; int sum = 0; image3 = fopen("F:/image3.txt", mode2); do { char *mode1 = "r"; char *mode2 = "w"; image1 = fopen("F:/image1.txt", mode1); if (!image1) { printf("File Not Found!!\n"); fileFound = true; } else fileFound = false; } while (fileFound); do { image2 = fopen("F:/image2.txt", mode1); if (!image2) { cout << "File Not Found!!\n"; fileFound = true; } else fileFound = false; } while (fileFound); //allocate Matrcies rows1 = rows2 = 384; cols1 = cols2 = 512; int **mat1 = (int **)malloc(rows1 * sizeof(int*)); for (i = 0; i < rows1; i++) mat1 = (int *)malloc(cols1 * sizeof(int)); i = 0; int **mat2 = (int **)malloc(rows2 * sizeof(int*)); for (i = 0; i < rows2; i++) mat2 = (int *)malloc(cols2 * sizeof(int)); i = 0; while (!feof(image1)) { for (i = 0; i < rows1; i++) { for (j = 0; j < cols1; j++) fscanf(image1, "%d%", &mat1[j]); } } i = 0; j = 0; while (!feof(image2)) { for (i = 0; i < rows2; i++) { for (j = 0; j < cols2; j++) fscanf(image2, "%d%", &mat2[j]); } } i = 0; j = 0; printf("\n\n"); i = 0; k = 0; cout << "\n\n"; for (i = 0; i < rows1; i++) { for (j = 0; j < cols1; j++) { if (mat1[j] != mat2[j]) C++; } } i = j = 0; if (C > 20) { printf("MOTION...DETECTED\a \a"); for (i = 0; i < rows1; i++) { for (j = 0; j < cols1; j++) { fprintf(image3, "%d ", mat2[j]); } fprintf(image3, "\n"); } cout << "\n Image Saved...."; } fclose(image1); fclose(image2); fclose(image3); } }; // sc_main in top level function like in C++ main int sc_main(int argc, char* argv[]) { SC_CTOR(synchronous) { SC_METHOD(synchronization); } SC_CTOR(imageProcess) { SC_METHOD(MotionDetector); sensitive << in; } sc_start(); return(0); }
  6. thank you dr Ralph for advices, the following is my attempt but it still displaying problems, // All systemc modules should include systemc.h header file #include "systemc.h" #include "stdio.h" #include "string.h" #include "stdio.h" #include"stdlib.h" #define _CRT_SECURE_NO_WARNINGS SC_MODULE(synchronous) { sc_out<bool> in; #define _CRT_SECURE_NO_WARNINGS _CRT_SECURE_NO_WARNINGS bool synchronization() { sc_out<bool> in; FILE *workspace = fopen("F:/yosri.txt", "r"); char buff[13]; fgets(buff, 12, workspace); int ret = 0; while (ret == 0) { cout<<"Waiting for request...\n"; ret = strcmp(buff, "SWITCHCONTEXT"); cout<<"%d", ret; } //SWITCHCONTXT is a string written in a text file in = true; cout<<"Establishing communication"); return(in); } SC_MODULE(imageProcess) { sc_in<bool> in; void MotionDetector(bool signal) { printf("\nCommuncation established"); char *mode1 = "r"; char *mode2 = "w"; int i, j, k; int C = 0; int rows1, cols1, rows2, cols2; bool fileFound = false; bool multiplcation = true; FILE *image1; FILE *image2; FILE *image3; int sum = 0; image3 = fopen("F:/image3.txt", mode2); do { char *mode1 = "r"; char *mode2 = "w"; image1 = fopen("F:/image1.txt", mode1); if (!image1) { printf("File Not Found!!\n"); fileFound = true; } else fileFound = false; } while (fileFound); do { image2 = fopen("F:/image2.txt", mode1); if (!image2) { cout<<"File Not Found!!\n"; fileFound = true; } else fileFound = false; } while (fileFound); //allocate Matrcies rows1 = rows2 = 384; cols1 = cols2 = 512; int **mat1 = (int **)malloc(rows1 * sizeof(int*)); for (i = 0; i < rows1; i++) mat1 = (int *)malloc(cols1 * sizeof(int)); i = 0; int **mat2 = (int **)malloc(rows2 * sizeof(int*)); for (i = 0; i < rows2; i++) mat2 = (int *)malloc(cols2 * sizeof(int)); i = 0; while (!feof(image1)) { for (i = 0; i < rows1; i++) { for (j = 0; j < cols1; j++) fscanf(image1, "%d%", &mat1[j]); } } i = 0; j = 0; while (!feof(image2)) { for (i = 0; i < rows2; i++) { for (j = 0; j < cols2; j++) fscanf(image2, "%d%", &mat2[j]); } } i = 0; j = 0; printf("\n\n"); i = 0; k = 0; cout<<"\n\n"; for (i = 0; i < rows1; i++) { for (j = 0; j < cols1; j++) { if (mat1[j] != mat2[j]) C++; } } i = j = 0; if (C > 20) { printf("MOTION...DETECTED\a \a"); for (i = 0; i < rows1; i++) { for (j = 0; j < cols1; j++) { fprintf(image3, "%d ", mat2[j]); } fprintf(image3, "\n"); } cout<<"\n Image Saved...."; } fclose(image1); fclose(image2); fclose(image3); } // sc_main in top level function like in C++ main int sc_main(int argc, char* argv[]) { SC_CTOR(synchronous) { SC_METHOD(synchronization) } SC_CTOR(imageProcess) { SC_METHOD(MotionDetector); sensitive << in; } sc_start(); return(0); }
  7. debuging result : Exception levée à 0x76C2A932 dans ConsoleApplication1.exe : exception Microsoft C++ : sc_core::sc_report à l'emplacement de mémoire 0x00E0EDB8. Le programme '[15048] ConsoleApplication1.exe' s'est arrêté avec le code 1 (0x1).
  8. as you see, i used CS_START() in main function, nt sc_main(int argc, char* argv[]) { sc_start(); synchronous yosri("A"); yosri.verify(); imageProcess go("B"); go.MotionDetection(); return(0); } you have my code how can i deal to solve this problem my friend,
  9. can you explain more, as i said im not familiar with coding systemC
  10. hi all, i write in this forum asking for help to solve this problem that tooks a lot of my time,iwrite my first program using systemC, my program debug but run exception i will expain my aim as much as i can , i stored 2 matrix of pixel value of image in two dfferent text file, i write a systemC code that load two matrix and comapre them, if number of different superior of a Threshold the code dispalays message (motion) my code composed of two modules, the first module check if there a number in a text file, if yes this Module will automates the other module to load the two matrix and compare them, i really need this code for my project graduation any help or sugesstion, sorry for my bad english. thank you // All systemc modules should include systemc.h header file #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 for request..."; } 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); } Quote Edit
  11. hi, i want to install systemC on visual studio 2015, i did all step in this tuto but when i compile this hello world example it displays problem "" not found stdafx.h and namespace std is not a member of gets , i want to ask there a difference between visaul studio version, and how can i solve this problem thanks
  12. i remove it but no things was changed, also i turn of precompiled stdafx.h in project properties but i does not resolve the problem, it displays std is not a member gets
  13. hi, i want to install systemC on visual studio 2015, i did all step in this tuto but when i compile this hello world example // All systemc modules should include systemc.h header file #include "systemc.h" // Hello_world is module name SC_MODULE (hello_world) { SC_CTOR (hello_world) { // Nothing in constructor } void say_hello() { //Print "Hello World" to the console. cout << "Hello World.\n"; } }; // sc_main in top level function like in C++ main int sc_main(int argc, char* argv[]) { hello_world hello("HELLO"); // Print the hello world hello.say_hello(); return(0); } it displays problem "" not found stdafx.h and namespace std is not a member of gets , i want to ask there a difference between visaul studio version, and how can i solve this problem thanks
  14. hi all, i want to integrate systemC and openCv in visual studio 2015 to process images for motion detector system. it is possible to do that ? thanks i ask for a snippet of code that compares successives images for motion detection with or without using openCv or other such library for images processing thank you
  15. hi friend, im not familiar with systemC, iwant to model system à processor that campares two sucessives frames, any help i would be grateful