Jump to content

some question about generate the vcd file


Rick Chen

Recommended Posts

I'm new for SystemC, and here is my question:

 

I put this code in my main.cpp

 

sc_trace_file *tf = sc_create_vcd_trace_file("RESULT.vcd");

but it didn't generate the vcd file.

 

Here is the whole code:

 

// main.cpp
#include "systemc.h"
#include "timer.h"


int sc_main(int argc, char* argv[])


{
   // stimuli 
   sc_signal<bool> START, TIMEOUT;
   
   sc_time clkPrd(10, SC_NS);// period
   sc_clock CLOCK("clock", clkPrd); // timer
   // Binding
   timer tm("timer");
   tm.clock(CLOCK);
   tm.start(START);
   tm.timeout(TIMEOUT);

    // tracing
   
    sc_trace_file *tf = sc_create_vcd_trace_file("RESULT.vcd");
    tm.trace(tf);


    // 3 cycles delay ---> first time
    START.write(1);

    sc_start(3*clkPrd);

    // start counting ---> first time
    START.write(0);

    sc_start(3*clkPrd);

    // reset before count reaches 0; 3 cycles delay  ---> first time
    START.write(1);

    sc_start(3*clkPrd);

    // start counting again until count = 0
    START.write(0);

    sc_start(5*clkPrd);

    // reset after count = 0; 3 cycles delay
    START.write(1);

    sc_start(3*clkPrd);

    // start counting ---> second time
    START.write(0);

    sc_start(3*clkPrd);

    // reset before count reaches 0 ---> second time
    START.write(1);

    sc_start(1*clkPrd);

    // start counting again until count = 0 ---> second time
    START.write(0);

    sc_start(6*clkPrd);

    // reset after count = 0; 3 cycles delay  ---> second time
    START.write(1);

    sc_start(3*clkPrd);
    sc_close_vcd_trace_file(tf);

  return(0);
  }
// timer.cpp
#include "timer.h"

void timer::runtimer()
{
    while(1)
  {
        if (start.read())
    {
            cout << "Timer: timer start detected "<< endl;
            count = 5;
            timeout.write(0);
        }
    else
    {
            if (count == 0) timeout.write(1);
        else
          {
                count--;
                timeout.write(0);
              }
        }
        wait();
    }
}
//timer.h

#include <systemc.h>

SC_MODULE(timer)
{
    sc_in<bool> start;      // ports
    sc_out<bool> timeout;
    sc_in<bool> clock;

    int count;          // data and function members
    void runtimer();

    SC_CTOR(timer)
  {     // constructor
	SC_CTHREAD(runtimer, clock.pos());
	reset_signal_is(start, true);
    }
}; 

and this is my makefile:

 

SYSTEMC_DIR = /usr/local/systemc-2.3.3

PROJECT     = timer

BUILDFLAGS  = -g3

CXX         = g++



INCFLAGS    = -I. -I /usr/local/systemc-2.3.2/include

LDFLAGS     = -L /usr/local/systemc-2.3.2/lib-linux64 -lsystemc -lm

SRC_CPPHEAD = timer

SRC_CPP     =

HEADERS     =

MAIN        = main.cpp

OBJECTS     = $(SRC_CPPHEAD:=.o) $(SRC_CPP:cpp=o)



EXE = $(PROJECT)



all: $(EXE)



$(EXE): $(MAIN) $(OBJECTS) $(HEADERS)

	@echo "$@ building..."

	$(CXX) $(INCFLAGS) $(MAIN) $(OBJECTS) $(LDFLAGS) -o $@

	@echo ""

	@echo "$@ build done successfully..."

	@echo ""



%.o:%.cpp %.h

	@echo "Compiling $< ..."

	$(CXX) -c $< $(INCFLAGS)



clean:

	rm -f $(EXE)

	rm -f *.o

 

 

thanks a lot for helping me!!!

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