Jump to content

apfitch

Members
  • Posts

    613
  • Joined

  • Last visited

  • Days Won

    121

apfitch last won the day on January 10

apfitch had the most liked content!

7 Followers

Profile Information

  • Gender
    Not Telling

Recent Profile Visitors

2,275 profile views

apfitch's Achievements

Advanced Member

Advanced Member (2/2)

214

Reputation

  1. There's also a video library supplied with Xilinx HLS http://www.wiki.xilinx.com/HLS+Video+Library HLS supports SystemC as well as C++. regards Alan
  2. Hi Yosri, I don't understand why you want to do this in SystemC, the algorithm you've written just reads from a file and writes to a file, which is well suited to a plain C or C++ program. Some specific comments - you have declared "sig" and haven't used it. In sc_main you've called the SC_METHOD using master.MotionDetector. You don't need to do that, the SC_METHOD is a parallel thread and will run automatically at time 0. However as I said above, my main comment is why are you using SystemC? Why not just write a plain C/C++ program? regards Alan
  3. There's a complete example here: https://www.doulos.com/knowhow/systemc/faq/#q1 regards Alan P.S. Note it uses inline friends, which is perhaps a bit quirky.
  4. Hi Mr SystemCInDepth, I think it's important to realise that SC_CTHREAD is special, in that the specified sensitivity is a clock (the rising or falling edge event of a bool or sc_logic). There's no such thing as a "clock" for SC_METHOD and SC_THREAD - just events on channels such as sc_signal, sc_fifo, or any other channel that implements an event. So I would not say because an SC_METHOD or an SC_THREAD does not have a clock. That's what Philipp meant when he said Does that make it clearer? regards Alan
  5. Is your sc_fifo a class member? Don't forget you must initialise class members on the constructor initialiser list (at least before c++ 11) regards Alan
  6. If your goal is to synthesize the design, then your first step should be to check what is synthesisable - are you using a particular high level synthesis tool? Have you checked this it will support sc_fifo and sc_semaphore? If your tool supported std::map, couldn't you use use that? regards Alan
  7. Hi, in UVM people tend to talk about agents as being passive, active, or reactive instead of "master" or "slave". Each agent contains a driver, a monitor, and a sequencer. An active agent has all three. A passive agent monitors, but does not drive. A reactive agent drives, but depends on the DUT more closely (i.e. the agent drives data to the DUT, but reacts in some way with the DUT. So I guess you could be using "master" to mean active, and "slave" to mean reactive *or* passive. regards Alan
  8. You should be able to view the Call Stack in Visual C++ - that may give you an idea of exactly where the exception is being thrown, regards Alan
  9. There's lots wrong with your code - did you look at the tutorial on www.doulos.com as someone suggested in the earlier thread? Any way, I've tried to add some comments in your code #include "systemc.h" #include "stdio.h" #include "string.h" #include "stdio.h" #include"stdlib.h" #define _CRT_SECURE_NO_WARNINGS sc_out<bool> in; // DON'T DECLARE A PORT OUTSIDE A MODULE SC_MODULE(synchronous) { bool synchronization() { sc_out<bool> in; // DON'T DECLARE A PORT INSIDE A FUNCTION 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); // YOU CAN'T RETURN A PORT CLASS LIKE THIS } }; SC_MODULE(imageProcess) // WHY USE A MODULE HERE? I can't see what SystemC features you're using? { sc_in<bool> in; // WHAT'S THIS FOR? 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_main is not a class so you can't declare a constructor here. { SC_METHOD(synchronization); } SC_CTOR(imageProcess) // sc_main is not a class so you can't declare a constructor here. { SC_METHOD(MotionDetector); sensitive << in; } sc_start(); return(0); } Your code shows a lot of confusion between ports, modules, sc_main, and processes. I highly recommend going back to that tutorial and getting a very simple example running (perhaps an AND gate) and checking you understand that first, kind regards Alan
  10. Hi Zdenek, the template parameter to the various sockets represents the width of the bus, so you could change that to 12 from the default of 32. However the existing code does generally assume that 1 byte = 8 bits (e.g. the byte enables work with words split into 8 bit bytes). So you'd probably have to write some custom code, Alan
  11. You can use sc_vector and its various helpers and assemble and dis-assemble vectors. regards Alan
  12. Hi, the reason for the error is that you're not binding all your ports. You bind the ports in this loop: for(int i=0;i<n;i++) { for (int j=0;j<=i;j++) { std::cout << i << " " << j << " " << std::endl; test_CHOL0->chol_in_data[i][j](chol_in_data[i][j]); test_CHOL0->chol_out_data[i][j](chol_out_data[i][j]); } } but in the second loop you have j <= i. I've added printing and you can see that you only bind 6 of the 9 ports SystemC 2.3.1-Accellera --- Sep 3 2016 13:00:03 Copyright (c) 1996-2014 by all Contributors, ALL RIGHTS RESERVED 0 0 1 0 1 1 2 0 2 1 2 2 I think you need j < n regards Alan
  13. I guess first you'd need to add an attribute (extension) to the generic payload to represent the priority. Then you could write a variant of the PEQ which takes into account that priority. regards Alan
  14. For that kind of modelling you probably need resolved types, e.g. sc_signal_resolved, sc_in/out resolved. These types model signal strength resolution, i.e. if you drive two values such as '1' and 'Z', '1' will be the resulting value because '1' is stronger than 'Z'. Have a look at the SystemC standard 1666-2011, especially section 6.13.5 where there's a little example that might help, regards Alan
  15. Could you post your code? regards Alan
×
×
  • Create New...