Rick Chen Posted January 7, 2022 Report Share Posted January 7, 2022 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!!! Quote Link to comment Share on other sites More sharing options...
David Black Posted January 7, 2022 Report Share Posted January 7, 2022 You need to call sc_trace for every individual signal or variable you wish to trace. If you have custom data types, then you need to overload sc_trace with your own type. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.