Jump to content
veeresh k

fifo waveform tracing

Recommended Posts

Hey everyone,

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.

 

 

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

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;
}

 

 

Edited by veeresh k

Share this post


Link to post
Share on other sites

You need to be more precise in your problem description! You did not post the exact error message you might have obtained nor is your code example complete and self-contained. Therefore, any answer by us is mostly based on wild guessing. Please note that you will only actually see traces in your VCD files if actually events happened during your simulation. If your sc_module example constitutes your Design Under Verification, you are missing at least in the posted code snippet some stimuli generator, which would trigger any events.

I suggest you that you get familiar with C++ and then start with a good introduction tutorial / book on SystemC before pursuing your own modeling attempts.

Share this post


Link to post
Share on other sites

Hey maehne,

Sorry for the incomplete post.Actually it was a follow up question which i had previously asked,so thats the reason for posting it up in this way.

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

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

×