Jump to content
Sign in to follow this  
gurunath.kadam

sc_fifo size

Recommended Posts

Hi all,

I am defining the sc_fifo as,

sc_fifo<sc_lv<FLIT_SIZE> > fifo_rx1 (BUFFER_SIZE);

and BUFFER_SIZE and FLIT_SIZE are defined in another header file as,

const unsigned int FLIT_SIZE = 39;

const int BUFFER_SIZE = 50;

The problem I encounter is, whenever I change the BUFFER_SIZE, I do not get any change in the performance of my system.

And I checked that sc_fifo is getting defined at default size of 16 (with num_free() ).

As I understand the size_ variable in sc_fifo class is of int type, so I am not sure what is the problem exactly,

Help is appreciated.

Thank you.

Sincerely,

Gurunath

Share this post


Link to post
Share on other sites

Since we do not see your source code, it is impossible to give you decent advice. Could you post the relevant source code?

My second question (probably answered when you post): Where are you declaring/defining the FIFO? In a module as module data? Inside the constructor (bad idea)? In sc_main (not recommended)?

Share this post


Link to post
Share on other sites

Hi guys,

I got the mistake i was making.

For future reference (check MISTAKE and CORRECTION comments):

Mistake:

SC_MODULE(fifo_rx){
sc_in<bool> clk;
//etc decl.
void fifo_rx_write();
void fifo_rx_read();
sc_fifo<sc_lv<FLIT_SIZE> > fifo_rx1; //Declare
SC_CTOR(fifo_rx){

 //------Initializations-------//
 fifo_rx_full.initialize(0);
 dout.initialize(0);
 data_step = 0;
 //----------METHODs--------------//
 SC_METHOD(fifo_rx_write);
 sensitive << clk.pos();
 SC_METHOD(fifo_rx_read);
 sensitive << clk.pos();
 sc_fifo<sc_lv<FLIT_SIZE> > fifo_rx1 (Wi_BUFFER_SIZE * 4); //Define // **MISTAKE**
}
};

Correct:

SC_MODULE(fifo_rx){
//etc. decl.
void fifo_rx_write();
void fifo_rx_read();
sc_fifo<sc_lv<FLIT_SIZE> > fifo_rx1; //Declare
SC_CTOR(fifo_rx): fifo_rx1 (Wi_BUFFER_SIZE * 4){ // **CORECTION**

 //------Initializations-------//
 fifo_rx_full.initialize(0);
 dout.initialize(0);
 data_step = 0;
 //----------METHODs--------------//
 SC_METHOD(fifo_rx_write);
 sensitive << clk.pos();
 SC_METHOD(fifo_rx_read);
 sensitive << clk.pos();
}
};

WHY:

Although I am not expert on C++, this is happening because (int) size_ is a constructor variable, so should be passed while constructor is being implemented. In 1st code it was passed after the constructor ran and therefore SC implemented fifo with default size. (Experts can correct or give more info about it.)

Thank you.

Gurunath

Share this post


Link to post
Share on other sites

Actually, what happened in your first attempt was:

1. At the class level you defined fifo_rx1

2. Because you did not initialize it, the default constructor was used which has a default depth of 16.

3. Inside your constructor, you created a second fifo with the same name and an explicit depth. Unfortunately because it was declared as data on the stack (how normal variables inside a function/method are created), this fifo immediately got deleted when the constructor function exited.

Consider:

void f(int a)
double b = sqrt(a);
}

int sc_main(int argc, char* argv[]) {
f(5);
std::cout << "b=" << b << std::endl;
}

The above won't work because 'b' is only defined inside the function f().

Share this post


Link to post
Share on other sites

Hello,

 

questions:

 

1) I have to create fifo of 18 locations(depth) and 16 bit size of each location, i had written like as:

    sc_fifo<sc_lv<18>>  fifo_1;       // default buffer size is of 16 bits, so no need to pass buffer size

    So is it right?

2 Now i have to write/read on location 1 of fifo_1.So how I can write?Please tell me.

 

Regards

cam

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
Sign in to follow this  

×