carter Posted April 5, 2014 Report Share Posted April 5, 2014 Hi. i made simple inverter by clock. I trying to trace "popo_in", "popo_out". popo_in have normally transition and i checked from vcd. But popo_out is not work(it's not having transition). what is wrong ? Here's problems. #include <systemc.h> class popo_clk_gen : public sc_module { public: sc_out<bool> popo_out; sc_in<bool> popo_in; SC_HAS_PROCESS(popo_clk_gen); void test() { int i=0; { popo_out = ~popo_in; } } popo_clk_gen(sc_module_name name) : sc_module(name) { SC_METHOD(test); sensitive(popo_out); } }; int sc_main (int, char *[]) { sc_signal<bool> popo_out; sc_signal<bool> popo_in; sc_clock clk1("clk1",10,SC_NS); popo_clk_gen pcg("pcg"); pcg.popo_out(popo_out); pcg.popo_in(clk1); sc_trace_file *tf = sc_create_vcd_trace_file("wave"); sc_trace(tf,clk1, "clock"); sc_trace(tf,pcg.popo_in, "in_clk"); sc_trace(tf,pcg.popo_out, "out_clk"); sc_start(50,SC_NS); sc_close_vcd_trace_file(tf); return 0; } Quote Link to comment Share on other sites More sharing options...
dakupoto Posted April 6, 2014 Report Share Posted April 6, 2014 Hi. i made simple inverter by clock. I trying to trace "popo_in", "popo_out". popo_in have normally transition and i checked from vcd. But popo_out is not work(it's not having transition). what is wrong ? Here's problems. #include <systemc.h> class popo_clk_gen : public sc_module { public: sc_out<bool> popo_out; sc_in<bool> popo_in; SC_HAS_PROCESS(popo_clk_gen); void test() { int i=0; { popo_out = ~popo_in; } } popo_clk_gen(sc_module_name name) : sc_module(name) { SC_METHOD(test); sensitive(popo_out); } }; int sc_main (int, char *[]) { sc_signal<bool> popo_out; sc_signal<bool> popo_in; sc_clock clk1("clk1",10,SC_NS); popo_clk_gen pcg("pcg"); pcg.popo_out(popo_out); pcg.popo_in(clk1); sc_trace_file *tf = sc_create_vcd_trace_file("wave"); sc_trace(tf,clk1, "clock"); sc_trace(tf,pcg.popo_in, "in_clk"); sc_trace(tf,pcg.popo_out, "out_clk"); sc_start(50,SC_NS); sc_close_vcd_trace_file(tf); return 0; } Hello Sir, It is highly recommended that you read up good references on C++ and SystemC. To sensitize a thread to a clock use: SC_CTHREAD(<thread_name>); sensitive << clk.pos(); /* sensitive to positive clock edge */ OR sensitive << clk.neg(); /* sensitive to negative clock edge */ To make a thread sensitive to ANY changes in a signal, use SC_THREAD(<thread_name>); sensitive << sig; /* Thread responds to ANY changes in sig */ Once again, read up the background material. Quote Link to comment Share on other sites More sharing options...
carter Posted April 6, 2014 Author Report Share Posted April 6, 2014 Hello Sir, It is highly recommended that you read up good references on C++ and SystemC. To sensitize a thread to a clock use: SC_CTHREAD(<thread_name>); sensitive << clk.pos(); /* sensitive to positive clock edge */ OR sensitive << clk.neg(); /* sensitive to negative clock edge */ To make a thread sensitive to ANY changes in a signal, use SC_THREAD(<thread_name>); sensitive << sig; /* Thread responds to ANY changes in sig */ Once again, read up the background material. Thanks your advice. I recently modified code like following #include <systemc.h> class popo_clk_gen : public sc_module { public: sc_out<bool> popo_out; sc_in<bool> popo_in; void test() { while(1) { int i=0; { //popo_out = ~popo_in; wait(); popo_out = ~popo_in; //wait(); } } } SC_HAS_PROCESS(popo_clk_gen); popo_clk_gen(sc_module_name name) : sc_module(name) { //SC_METHOD(test); SC_THREAD(test); //sensitive( popo_in); //sensitive( popo_out); sensitive << popo_in; sensitive << popo_out; } }; int sc_main (int argc, char **argv) { sc_signal<bool> popo_out; sc_signal<bool> popo_in; sc_clock clk1("clk1",10,SC_NS); popo_clk_gen pcg("pcg"); pcg.popo_out(popo_out); pcg.popo_in(clk1); sc_trace_file *tf = sc_create_vcd_trace_file("wave"); sc_trace(tf,clk1, "clock"); sc_trace(tf,pcg.popo_in, "in_clk"); sc_trace(tf,pcg.popo_out, "out_clk"); sc_start(500,SC_NS); sc_close_vcd_trace_file(tf); return 0; } i solved it. thanks. 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.