Jump to content

Fifo slots


Thomas_M

Recommended Posts

Hi every one,

 

My question might be a bit dumb, i'm a bit new to all of this.

I have a module using an array of Fifos and I want to initialize em with custom depth (# of slots, not 16 as default).

 

When using only one sc_fifo you can give the number of slots in the constructor for instance SC_CTOR(....):......... fifo(#Slots){

But when using an array of, it I don't know how I am supposed to do. Everything I try won't work.

 

Can you help me with this ? Please :)

 

Thomas

Link to comment
Share on other sites

Dear Thomas,

 

Maybe using sc_vector instead of an array could solve your issue.

For details about sc_vector usage see Section 8.5 in the SystemC LRM (IEEE1666).

 

The following paper describes easy using, instantiating and binding or arbitrary numbers of signals and ports with sc_vector and C++11.

https://dvcon-europe.org/sites/dvcon-europe.org/files/archive/2015/proceedings/DVCon_Europe_2015_TA2_4_Paper.pdf

 

Greetings

Ralph

Link to comment
Share on other sites

Hey,

 

Thank you for your answer :) I didn't try it but it might work ! (I don't necesserly need vectors for my purpose :) )

 

Some guy working with me gave me another one which worked just fine. I share in case some one else is interested. Instead of static declaration, use dynamic in constructor.

 

 

 

 

sc_fifo<... >                  *Fifos [...];

 

 my_module(sc_module_name _name) : sc_module(_name)  {

  

for(i=0;i<...;i++)
          Fifos = new sc_fifo< ... > (nb_of_slots);
...

}

 

 

~my_module()
{
  for(i=0;i<...;i++)

    delete Fifos;
};

 

 

 

Here you go.

Link to comment
Share on other sites

This is the old and nasty way :) (before sc_vector was available).

 

sc_vector is not meant to be resizable. It is more to avoid error prone pointer handling and dynamic memory handling.

It hides memory handling from the user and gives you safe access to the elements.

 

One more benefit: Naming of objects.

You should give the fifos a name because it makes error messages (like 'unbound port', ...) much more readable and helpfull.

 

Doing this with your implementation (array of pointers/new) is possible but a lot of code writing.

sc_vector automatically names its elements by appending the element index to a prefix given by the user.

 

In addition to this, sc_vector provides some facilities for binding, ... of entire vectors instead of element by element. 

 

But for me most important is: No pointers and no dynamic memory required (and these are the root cause of so many errors in C and C++ programms).

 

So, my advice: have a look at sc_vector, and if you like it, tell the guys working with you about it :)

 

Greetings

Ralph

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...