Jump to content
Ganesan R

How to use sc_fifo vector

Recommended Posts

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.

 

 

 

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Hello, SystemC is a C++ library. You should master C++ before learning SystemC, which is just a C++ library. It will be a wisely spent time, since C++ is used in many industries.

After you learn C++ you will be able to understand and fix errors in your code.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×