re1418ma Posted October 13, 2018 Report Posted October 13, 2018 hi i installed systemc in microsoft visual studio and i wrote some code now i want to see output wave in gtkwave how should i export my code to see waves in gtkwave? Quote
Eyck Posted October 13, 2018 Report Posted October 13, 2018 Actually SystemC provided sc_trace(...) functions where you register your signals and variables for tracing. Running the simulation yields a .vcd file which you can open in gtkwave. You may have a look into https://github.com/Minres/SystemC-Components-Test/blob/master/examples/transaction_recording/scv_tr_recording_example.cpp In sc_main() you will find sc_trace_file *tf = sc_create_vcd_trace_file("my_db"); sc_trace_file *tf = sc_create_vcd_trace_file("my_db"); This opens the waveform database. At the end you have to call sc_close_vcd_trace_file(tf); to properly close the database. 'tf' is a handle to the database, if you follow the code you will see how to trace signals (or variables), Best re1418ma 1 Quote
re1418ma Posted October 14, 2018 Author Report Posted October 14, 2018 thanks for the reply i wrote this code #include "systemc.h" SC_MODULE(and_gate){ sc_in<bool> a, b; sc_out<bool> c; void and_gate_p(){ next_trigger(5, SC_NS); c.write(a.read() & b.read()); } SC_CTOR(and_gate){ SC_METHOD(and_gate_p); sensitive << a << b; } }; int sc_main(int argc, char* argv[]){ sc_signal<bool> a, b, c; and_gate and1("and_gate_and1"); and1.a(a); and1.b(b); and1.c(c); sc_trace_file *tf = sc_create_vcd_trace_file("and_gate"); tf->set_time_unit(1, SC_NS); sc_trace(tf, a, "a"); sc_trace(tf, b, "b"); sc_trace(tf, c, "c"); a = 0; b = 0; sc_start(1.0, SC_NS); a = 0; b = 1; sc_start(1.0, SC_NS); a = 1; b = 0; sc_start(1.0, SC_NS); a = 1; b = 1; sc_start(1.0, SC_NS); sc_stop(); sc_close_vcd_trace_file(tf); cout << "Finished at time " << sc_time_stamp() << endl; return 0; } and still getting error and i have no idea how to solve the problem Quote
Roman Popov Posted October 14, 2018 Report Posted October 14, 2018 2 hours ago, re1418ma said: thanks for the reply i wrote this code .. Your code is not correct. Why did you put next_trigger(5, SC_NS) inside a method? Remove it, and you will get correct waveform for and gate. re1418ma 1 Quote
re1418ma Posted October 14, 2018 Author Report Posted October 14, 2018 the gate must have delay of 5ns removing that statement and still getting error Quote
Roman Popov Posted October 14, 2018 Report Posted October 14, 2018 Quote removing that statement and still getting error I've removed next_trigger and simulated your code. Check attached waveform. Quote the gate must have delay of 5ns Check how to model delay line here: re1418ma 1 Quote
re1418ma Posted October 14, 2018 Author Report Posted October 14, 2018 thanks for reply i removed next_trigger and code build succeeded this seems stupid question where vcd trace file located? Quote
Roman Popov Posted October 14, 2018 Report Posted October 14, 2018 Just now, re1418ma said: thanks for reply i removed next_trigger and code build succeeded this seems stupid question where vcd trace file located? In the working directory (active directory when you launch the executable). Search for "and_gate.vcd" re1418ma 1 Quote
re1418ma Posted October 14, 2018 Author Report Posted October 14, 2018 i've searched whole my computer and only found object and source code Quote
Roman Popov Posted October 14, 2018 Report Posted October 14, 2018 3 minutes ago, re1418ma said: i've searched whole my computer and only found object and source code I don't work on Windows. But as far as I remember executable should be somewhere in project sub-directory called "Release" or "Debug". Sorry, can't help you more here. re1418ma 1 Quote
re1418ma Posted October 14, 2018 Author Report Posted October 14, 2018 you helped a lot sir and for final question i read the post about delay and make some changes #include "systemc.h" SC_MODULE(and_gate){ sc_in<bool> a, b; sc_out<bool> c; void and_gate_p(){ while(true){ wait(5,SC_NS); c.write(a.read() & b.read()); } } SC_CTOR(and_gate){ SC_THREAD(and_gate_p); sensitive << a << b; } }; int sc_main(int argc, char* argv[]){ sc_signal<bool> a, b, c; and_gate and1("and_gate_and1"); and1.a(a); and1.b(b); and1.c(c); sc_trace_file *tf = sc_create_vcd_trace_file("and_gate"); tf->set_time_unit(1, SC_NS); sc_trace(tf, a, "a"); sc_trace(tf, b, "b"); sc_trace(tf, c, "c"); a = 0; b = 0; sc_start(1.0, SC_NS); a = 0; b = 1; sc_start(1.0, SC_NS); a = 1; b = 0; sc_start(1.0, SC_NS); a = 1; b = 1; sc_start(1.0, SC_NS); sc_stop(); sc_close_vcd_trace_file(tf); cout << "Finished at time " << sc_time_stamp() << endl; return 0; } is it correct? Quote
Roman Popov Posted October 14, 2018 Report Posted October 14, 2018 3 minutes ago, re1418ma said: SC_MODULE(and_gate){ sc_in<bool> a, b; sc_out<bool> c; void and_gate_p(){ while(true){ wait(5,SC_NS); c.write(a.read() & b.read()); } } SC_CTOR(and_gate){ SC_THREAD(and_gate_p); sensitive << a << b; } }; is it correct? No. If you want to model a gate with a delay to output you will need to attach a delay line (check AmeyaVS code on a thread I've referenced before) to output signal. But first I suggest you to learn what each line in your code does, and understand why it does not work. Quote
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.