Jump to content
veeresh k

beginner problems on fifo waveform

Recommended Posts

Hi ,

I am trying to trace out the wave for the input and the output.

I have tried for different ways,but not getting the desired results.

One of the way was,i created 2 same signals with diff. name in testbench file and tried to trace ,but i was not successful in doing so.

Any suggestions to do? 

Thank you. 🙂

Ps:- I have attached the code through which m trying to trace.Plz,help me out with this.I have modified the code according to the errors,So thats the reason for using namespace sc::core while declaring fifo tracing input.I am posting full code along with the errors.

 

/////////ERRORS/////////////////////////////////////

testbench.cpp: In function 'int sc_main(int, char**)':
testbench.cpp:16:18: error: no match for call to '(sc_core::sc_fifo<sc_dt::sc_int<32> >) (sc_core::sc_fifo_in<int>&)'
testbench.cpp:17:19: error: no match for call to '(sc_core::sc_fifo<sc_dt::sc_int<32> >) (sc_core::sc_fifo_out<int>&)'
testbench.cpp:21:29: error: no matching function for call to 'sc_trace(sc_core::sc_trace_file*&, sc_core::sc_fifo_in<int>&, const char [6])'

 

 

////////////////////CODE/////////////////////////////

 

#ifndef EXAMPLE_H
  #define EXAMPLE_H
using namespace sc_dt;

typedef sc_int<32> sc_int32;

  SC_MODULE(example) 
    
    sc_fifo<sc_int32> fifo;
    
    //producer thread
    void producer_thread();
    
    //consumer thread
    void consumer_thread();
    
    SC_CTOR(example) : fifo(2) {
      SC_THREAD(producer_thread);
      SC_THREAD(consumer_thread);
    };
  
  };

#endif

/////////////////////////////////////////

#include <systemc.h>
#include "example.h"
using namespace sc_dt;

void example::producer_thread()
{
        int unsigned number_of_accesses = 4;

        for (int i = 0; i < number_of_accesses; i++) {

            sc_int32 value(i);

            cout << "[" << sc_time_stamp() << "] writing to FIFO value: " << value << ", free: " << fifo.num_free() << endl;

            fifo.write(value);


            cout << "[" << sc_time_stamp() << "] wrote to FIFO value: " << value << endl;

            


            wait(1, SC_NS);
        }
    }

    //consumer thread
    void example::consumer_thread()
    {
        sc_int<32> value(0);


        for (;;) {
            wait(4, SC_NS);

            fifo.read(value);


            cout << "[" << sc_time_stamp() << "] read from FIFO value: " << value << endl;


        }
    }

////////////////////////////////////////////////MAIN.CPP////////////////////

#include "systemc.h"
#include "example.h"

using namespace sc_dt;

int sc_main(int, char* []) {
  
  sc_core::sc_fifo_out<int> output1; 
  sc_core::sc_fifo_in<int> input1; 
  
   //create the instance of the example
  example eg1("example_inst");
  eg1.fifo(input1);
  eg1.fifo(output1);
  
  
  sc_trace_file*tf=sc_create_vcd_trace_file("fi");
  sc_trace(tf,input1,"input");
  sc_trace(tf,output1,"output");
    
  sc_start();
  
  if(not sc_end_of_simulation_invoked()) {
      sc_stop;  
  }
  sc_close_vcd_trace_file(tf);
  
  return 0;
}

 

Share this post


Link to post
Share on other sites

Hi,

you cannot bind interface to e.g. a class implementing those interface. What you can bind are sc_port and sc_export. So you would need to change your declaration to

 sc_core::sc_port< sc_core::sc_fifo_out<int> > output1; 
 sc_core::sc_port< sc_core::sc_fifo_in<int> >  input1; 

But this is not going to solve your problem as you cannot trace an sc_core::sc_fifo_out interface. Tracing is only possible for elements having a value semantic which are variables of various types (primitive ones like int or composed ones coming with the SystemC library like sc_int or sc_bv) and signals (since they have also a value semantic).

interfaces (like are sc_core::sc_fifo_in) are essentially description how to manipulate things and therefore not trace with a tracefile. Using SCV it would be possible to do so but requires implementing some glue code.

BR

Share this post


Link to post
Share on other sites

Hi eyck,

Thanx fo d rply. 🙂

Is it possible to copy the read and write values in temporary variables and trace that signal.?

I had tried this way but it was not possible,so needed suggestions for alternatives. 

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

×