Jump to content

Ganesan R

Members
  • Content count

    9
  • Joined

  • Last visited

  1. 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.
  2. 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.
  3. 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?
  4. 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
  5. How to define constructor in cpp file?

    Hi Ameya Singh, How to add destructor for NAME in this example? Thanks.
  6. 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.
  7. 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
  8. 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.
  9. 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
×