Jump to content

sc_fifo size


gurunath.kadam

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

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

Link to comment
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().

Link to comment
Share on other sites

  • 11 months later...

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

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