Jump to content

fifo waveform tracing


veeresh k

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

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

 

    

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