Jump to content

Ganesan R

  • Content count

  • Joined

  • Last visited

About Ganesan R

  • Rank

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Ganesan R

    System C quite different from c++

    Thank you Sir. I finally got array of fifo objects after lot of efforts using SC_vector I apologize for the title of the post, but I meant only what worked for c++ was not working for system c in that particular line. Again sorry. The problem with beginners like me is that if something is not working we don't know what would have gone wrong. A lot of book reading is of little assistance in tracing out the error in debugging the error. This is where expert help is of timely assistance like Eyck comment yesterday. Again lot of thanks for all of you as I am getting past my major hurdle. Will keep posting any further problems I face in my design. R. Ganesan
  2. I have sc_module class fifog. What I want is an array of fifog in the fashion fifog[0],fifog[1] etc. fifog fifogarray[2]={fifog("fifog231"),fifog("fifog232")} declare in sc_main will surely work in c++, but in system c it throws up an error 1> error C2248: 'sc_core::sc_module::sc_module' : cannot access private member declared in class 'sc_core::sc_module' even though I have all member functions and elements declared as public in fifog. If that line is commented the program quite compiles and runs. Why so? You can check this in attached file. Trying how to access data members of fifog[0], fifog[1] etc. in sc_main. Any help will be deeply appreciated. accelerra.txt
  3. Ganesan R

    How to create an array of sc_module objects

    Thanks Eyck that helped Suppose sc_vector<fifog>fifog32("fifog32",4) is declared in SC_main fifog constructor is called four times But fifog32[0].FIFO_pointer is not working even in SC_main How to get fifog32[0].FIFO_pointer? Eager n thanking you
  4. Ganesan R

    How to create an array of sc_module objects

    Somehow I was able to get this work. But I have only one difficulty right now: How to access the member of individual class object in the attached file It is sc_vector of fifog elements of four. fifo_pointer should be accessible in c++ like this. What is the problem with me? fifog32[0].fifo_pointer Any help will be deeply appreciated as I am heavily struck up. R. Ganesan (Pl. ignore earlier post I was able to get new sc_vector(fifog,4) with constant size) fifog_15May_end_mod.txt
  5. Ganesan R

    How to create an array of sc_module objects

    Thanks Ameya Singh. I am attaching relevant code herewith. If I can get your contact details, I can get in touch with you as I need a lot of help. R. Ganesan fifog_13May2015_error.txt
  6. I understand that an array of sc_module objects cannot be created even in a vector as sc_ctor requires a char* argument. For example suppose that fifog is defined as sc_module object. Then sc_vector<fifog>fifog("fifogarray",4) will not create an array four of fifog object as fifogarray is not a unique name. My VS2012 throws a warning that object fifogarray already exists on subsequent loops and instead names the instances as fifogarray[0], fifogarray[1] etc. Moreover if fifog contains sc_processe sc_method functions, how they can be invoked on each unique instances of object? Even if I ignore that VS2012 warning, will the sc_method operate on each object instance individually? Pl. help. Eager to go through your replies. Simple example will help as I am newbie both to C++ and SystemC.
  7. Ganesan R

    How to initialize sc_fifo

    Thank you very much Sir. Yes, I am trying to get on with c++. Won't this line initialize: sc_vector<sc_vector<sc_fifo_e> >q[4][4] as that has been called inside sc_fifo_array constructor? Pl. help.
  8. Ganesan R

    How to initialize sc_fifo

    In running the following program I am getting error: Debug assertion failed, vector subscript out of range. I gather that the problem lies in initializing sc_fifo. As I am newbie to system C, any help in initializing sc_fifo will be deeply appreciated. sc_fifo.h #ifndef SC_FIFO_E_H_ #define SC_FIFO_E_H_ #include <iostream> #include "systemc.h" class sc_fifo_e { sc_fifo_e() { sc_fifo<int>a(10); } public: sc_fifo<int>a; }; #endif sc_fifo_array.h SC_FIFO_ARRAY_H_ #define SC_FIFO_ARRAY_H_ #include <iostream> #include "systemc.h" #include <sc_fifo_e.h> SC_MODULE(sc_fifo_array) { public: SC_HAS_PROCESS(sc_fifo_array); void drain_packets(void); void p_source(void); sc_fifo_array(sc_module_name name_):sc_module(name_) { sc_vector<sc_vector<sc_fifo_e> >q[4][4]; SC_METHOD(drain_packets); SC_THREAD(p_source); } public: sc_vector<sc_vector < sc_fifo_e> > q; int i,j,k; }; void sc_fifo_array::drain_packets(void) { int val; if (q[0][0].a.nb_read(val)) cout<<"packets received\n"; else cout<<"Fifo empty\n"; next_trigger(4,SC_NS); } void sc_fifo_array::p_source(void) { int val=1000; for (; ;) { wait(3, SC_NS); val++; q[0][0].a.write(val); std::cout<<sc_time_stamp()<<"p_thread wrote:"<<val<<std::endl; } } #endif Main program: #include <iostream> #include <systemc> #include <sc_fifo_e.h> #include<sc_fifo_array.h> int sc_main(int argc, char *argv[]) { sc_fifo_array e1("e1"); sc_start(10,SC_NS); cout<<"Hare Ram\n"; return EXIT_SUCCESS; } Thanks.
  9. Dear Sir, I am getting the following errors in running this program: error C2466: cannot allocate an array of constant size 0 error C2133: 'matrix' : unknown size Assume I am getting m and n through functions already written and declared in constructor. SC_MODULE(sc_fifo_array) { public: SC_HAS_PROCESS(sc_fifo_array); sc_fifo_array(sc_module_name name_):sc_module(name_) { int m,n; int *matrix[m]; for (int i=0; i<m; i++) matrix=new int[n]; matrix[0][0]=20; cout<<"\nmatrix="<<matrix[0][0]<<"\n"; } public: int m,n; }; Does system C does not support variable size matrix?
  10. Ganesan R

    How to define constructor in cpp file?

    Thanks a lot Ameya Singh. It helped really. Very timely help, but could not work on due to my illness. R. Ganesan
  11. Ganesan R

    How to define constructor in cpp file?

    Hi Ameya Singh, How to add destructor for NAME in this example? Thanks.
  12. Ganesan R

    Initialization of nested sc_vector< sc_vector< > >

    Can you suggest any good book on C++ library where I can begin? I want to know how to use modern C++ library and lambda functions.
  13. Ganesan R

    How to use sc_fifo vector

    Apropos to my earlier post I tried to define sc_fifo as array. But I am still unable to populate individual sc_fifo array member. Advise from senior members like Phillipp A Hartmann is eagerly awaited. Thanks. / scfifo_ex1.cpp : Defines the entry point for the console application. // #include "systemc.h" #include <stdio.h> SC_MODULE(exfifo) { SC_CTOR(exfifo) { //SC_METHOD(fifo_pop); sc_fifo <int> (packet_fifo[1])(5); } /*void fifo_pop(void) { int val; if (ex1.packet_fifo.nb_read(val)) cout << "\n hi \n"; else cout << "\n no \n"; WAIT(2, SC_NS); }*/ sc_fifo<int> packet_fifo[5]; }; int sc_main(int argc, char* argv[]) { cout << "Maha Ganapatim Veera Nangai Gnanananda\n"; exfifo example_fifo("ex1"); sc_start(10, SC_NS); return 0; } Severity Code Description Project File Line Suppression State Error (active) E0144 a value of type "int" cannot be used to initialize an entity of type "sc_core::sc_fifo<int> [1]" scfifo_ex1 c:\Users\acer\Documents\Visual Studio 2017\Projects\scfifo_ex1\scfifo_ex1\scfifo_ex1.cpp 13 Severity Code Description Project File Line Suppression State Error C3074 an array cannot be initialized with a parenthesized initializer scfifo_ex1 c:\users\acer\documents\visual studio 2017\projects\scfifo_ex1\scfifo_ex1\scfifo_ex1.cpp 13 R. Ganesan accelera.rtf
  14. Ganesan R

    How to use sc_fifo vector

    Dear Sir, I am new to SystemC. Pl. advise how to access ex1[0] etc. in the following program: #include "systemc.h" #include <stdio.h> SC_MODULE(exfifo) { SC_CTOR(exfifo) { SC_METHOD(fifo_pop); sc_fifo<int> packet_fifo(5); } void fifo_pop(void) { int val; if ((ex1[0].packet_fifo).nbread(val)) cout << "\n hi \n"; WAIT(2, SC_NS); }   };     int sc_main(int argc, char* argv[]) { cout << "Maha Ganapatim Veera Nangai Gnanananda\n"; sc_vector<exfifo>("ex1", 4); sc_start(10, SC_NS); return 0; } Throwing ex1 undeclared identifier. Left side of packet_fifo must have class/struct/union Appreciate your help. If things are to be done differently, pl. indicate complete steps as I am a newbie. Thanks.
  15. Dear Sir, I am new to System C. The problem is number of forums offering support to system c problems are few. As such I want help in understanding why this elementary program is not compiling. It returns error C2039: 'con_arrayfifo' : is not a member of 'arrayfifo'. Now the program: #include <systemc.h> SC_MODULE(arrayfifo) { SC_CTOR(arrayfifo) { SC_METHOD(con_arrayfifo); } }; void arrayfifo::con_arrayfifo (void) { //delcare the fifo //sc_fifo<int> rowfifo[n]; } int sc_main(int , char*[] ) { int m,n; cout << "Sadguru Jai Jai \n"; cout << "Enter the value of m: \t"; cin >> m; cout << "Enter the value of n: \t"; cin >> n; cout << m <<"\t" << n <<"\n"; arrayfifo arrayfifo1("arr_fifo"); //con_arrayfifo(m,n); //sc_fifo<int> rowfifo[n]; return 0; } The commented lines are intentional to find out why this program is not compiling. Thanks in advance for your patience and reply back. R. Ganesan