Jump to content

How to use sc_fifo vector


Ganesan R

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.

 

 

 

Link to comment
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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...