carter Posted April 4, 2014 Report Share Posted April 4, 2014 Deal all, i just make systemc modeling. i just want to make module what have just sc_in, sc_out. So when i trying to connect to sc_in by sc_clock's clock and i just want to see that reversed output. this is code. #include <systemc.h> int i=0; int sc_main (int, char *[]) { sc_signal<bool> popo_out; pcg(popo_out); sc_clock clk1("clock1",10,0.5,5,true); pcg(popo_in); //??????????i'm not sure this line.. return 0; } So What am i do to correct above code? Quote Link to comment Share on other sites More sharing options...
apfitch Posted April 4, 2014 Report Share Posted April 4, 2014 I'm not sure exactly what you want to do - but I assume you want to connect the clock clk1 to the port popo_in. So in sc_main you need int sc_main (int argc, char *[] argv) { sc_signal<bool> popo_out; sc_clock clk1("clock1",10,0.5,5,true); popo_clk_gen pcg("pcg"); pcg.popo_out(popo_out); pcg.popo_in(clk1); sc_start(50,SC_NS); return 0; } You also need to trigger your SC_METHOD by making it sensitive to the port popo_in, For ease of understanding, I would rename the module "popo_clk_gen" to "popo_inverter" since it's just an inverter. regards Alan Quote Link to comment Share on other sites More sharing options...
apfitch Posted April 4, 2014 Report Share Posted April 4, 2014 I've just realised your clock declaration looks wrong. It should be (I think) sc_clock clk1("clk1", 10, SC_NS); regards Alan P.S. I highly recommend that the label should be identical to the instance name, it makes debugging easier. Quote Link to comment Share on other sites More sharing options...
dakupoto Posted April 5, 2014 Report Share Posted April 5, 2014 I've just realised your clock declaration looks wrong. It should be (I think) sc_clock clk1("clk1", 10, SC_NS); regards Alan P.S. I highly recommend that the label should be identical to the instance name, it makes debugging easier. Hello Sir, The sc_core::sc_clock class has a set of constructors. For example, the following compiles and runs fine : sc_core::sc_clock clk_jk("clk_jk", 20.0, sc_core::SC_NS, 0.5); There are some other options. Quote Link to comment Share on other sites More sharing options...
carter Posted April 5, 2014 Author Report Share Posted April 5, 2014 I'm not sure exactly what you want to do - but I assume you want to connect the clock clk1 to the port popo_in. So in sc_main you need int sc_main (int argc, char *[] argv) { sc_signal<bool> popo_out; sc_clock clk1("clock1",10,0.5,5,true); popo_clk_gen pcg("pcg"); pcg.popo_out(popo_out); pcg.popo_in(clk1); sc_start(50,SC_NS); return 0; } You also need to trigger your SC_METHOD by making it sensitive to the port popo_in, For ease of understanding, I would rename the module "popo_clk_gen" to "popo_inverter" since it's just an inverter. regards Alan Yes, you are right. Actually i want make "invert block" like following figure. so i think that i make input port but i'm not sure output. so i need your advice. i'm really thank you Quote Link to comment Share on other sites More sharing options...
carter Posted April 5, 2014 Author Report Share Posted April 5, 2014 (edited) I'm not sure exactly what you want to do - but I assume you want to connect the clock clk1 to the port popo_in. So in sc_main you need int sc_main (int argc, char *[] argv) { sc_signal<bool> popo_out; sc_clock clk1("clock1",10,0.5,5,true); popo_clk_gen pcg("pcg"); pcg.popo_out(popo_out); pcg.popo_in(clk1); sc_start(50,SC_NS); return 0; } You also need to trigger your SC_METHOD by making it sensitive to the port popo_in, For ease of understanding, I would rename the module "popo_clk_gen" to "popo_inverter" since it's just an inverter. regards Alan Dear Alan, When i have modified code as your advice, it's seem passed. thank you. here's modified code. #include <systemc.h> public: sc_out<bool> popo_out; } void test() { int i=0; { popo_out = ~popo_in; } } }; int sc_main (int, char *[]) { sc_start(50,SC_NS); return 0; } Edited April 6, 2014 by carter Quote Link to comment Share on other sites More sharing options...
carter Posted April 5, 2014 Author Report Share Posted April 5, 2014 I'm not sure exactly what you want to do - but I assume you want to connect the clock clk1 to the port popo_in. So in sc_main you need int sc_main (int argc, char *[] argv) { sc_signal<bool> popo_out; sc_clock clk1("clock1",10,0.5,5,true); popo_clk_gen pcg("pcg"); pcg.popo_out(popo_out); pcg.popo_in(clk1); sc_start(50,SC_NS); return 0; } You also need to trigger your SC_METHOD by making it sensitive to the port popo_in, For ease of understanding, I would rename the module "popo_clk_gen" to "popo_inverter" since it's just an inverter. regards Alan Dear Alan, If you can would you please let me know example about as your advice "You also need to trigger your SC_METHOD by making it sensitive to the port popo_in,"? Actually, i don't know exactly how can i make trigger for sensitive. One more thing, When i captured VCD trace, popo_out, but i failed. I used tarce like this. I can trace "clk1" and "popo_in" But pcg.popo_out is not have transition. Why pcg.popo_out has not transition in wave? Quote Link to comment Share on other sites More sharing options...
apfitch Posted April 5, 2014 Report Share Posted April 5, 2014 Hi Carter, your two problems are connected - when you declare an SC_METHOD you need something to trigger it otherwise it will only run once at time zero. That's what I meant by "you need to make your SC_METHOD sensitive to popo_in". If you do that, when it runs it will then assign a new value to popo_out, and you will see the change on the waveforms. There are examples of sensitivity here: www.doulos.com/knowhow/systemc/tutorial Look at the section "Modules and Processes". Also I recommend you read section 5.2.9 of the IEEE 1666-2011 standard, which you can download free via the accellera website, regards Alan Quote Link to comment Share on other sites More sharing options...
carter Posted April 5, 2014 Author Report Share Posted April 5, 2014 Hi Carter, your two problems are connected - when you declare an SC_METHOD you need something to trigger it otherwise it will only run once at time zero. That's what I meant by "you need to make your SC_METHOD sensitive to popo_in". If you do that, when it runs it will then assign a new value to popo_out, and you will see the change on the waveforms. There are examples of sensitivity here: www.doulos.com/knowhow/systemc/tutorial Look at the section "Modules and Processes". Also I recommend you read section 5.2.9 of the IEEE 1666-2011 standard, which you can download free via the accellera website, regards Alan Quote Link to comment Share on other sites More sharing options...
carter Posted April 5, 2014 Author Report Share Posted April 5, 2014 Dear Alan, i have modified public: sc_out<bool> popo_out; (popo_clk_gen); popo_clk_gen(sc_module_name name) : sc_module(name) { SC_METHOD(test); sensitive(popo_in); } }; int (int, char *[]) { sc_clock ("clk1",10,SC_NS); return 0; } [/font][/color] Quote Link to comment Share on other sites More sharing options...
apfitch Posted April 5, 2014 Report Share Posted April 5, 2014 All I meant was to change your sc_method to SC_METHOD(test); sensitive << popo_in; That makes it run every time popo_In changes. If you want to use an SC_THREAD, you'd need SC_THREAD(test); sensitive << popo_in; void test () while (1) { wait(); popo_out = ~popo_in; } } regards Alan Quote Link to comment Share on other sites More sharing options...
carter Posted April 6, 2014 Author Report Share Posted April 6, 2014 above popo_out is always high. why? Quote Link to comment Share on other sites More sharing options...
apfitch Posted April 6, 2014 Report Share Posted April 6, 2014 It looks OK to me, perhaps someone else can see what's wrong? Alan Quote Link to comment Share on other sites More sharing options...
carter Posted April 6, 2014 Author Report Share Posted April 6, 2014 It looks OK to me, perhaps someone else can see what's wrong? Alan It looks OK to me, perhaps someone else can see what's wrong?Alan Dear Alan,Sir, Would you have checked I will make inverter example. But you can find popo_out is always high not transition. Would you Please check? Quote Link to comment Share on other sites More sharing options...
apfitch Posted April 6, 2014 Report Share Posted April 6, 2014 OK, I spotted it - you should use ! instead of ~ regards Alan Quote Link to comment Share on other sites More sharing options...
carter Posted April 7, 2014 Author Report Share Posted April 7, 2014 OK, I spotted it - you should use ! instead of ~ regards Alan Are they same things, aren't you? Quote Link to comment Share on other sites More sharing options...
apfitch Posted April 7, 2014 Report Share Posted April 7, 2014 No, they're not the same. Alan Quote Link to comment Share on other sites More sharing options...
carter Posted April 8, 2014 Author Report Share Posted April 8, 2014 No, they're not the same. Alan Thanks you Alan it's solved. 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.