Jump to content

ANKUR SAINI

Members
  • Content count

    8
  • Joined

  • Last visited

  1. @David Black: Hello David.. Nice solution.. just one comment.. as you mentioned the usage of callbacks -"before_end_of_elaboration" and "end_of_elaboration", I guess we can use the "start_of_simulation" and "end_of_simulation" also to do the same stuff you written in the code above. Correct me if I am wrong anywhere.
  2. before_end_of_elaboration callback

    If I am right, with SystemC 2.x onwards, it gave us a flexibility to still leave the ports unbound if they are defined with SC_ZERO_OR_MORE_BOUND binding policy. Correct me in-case I am wrong.
  3. before_end_of_elaboration callback

    @maehne: I got your point to some extent. So that means this callback is just provided to bind/create additional hierarchy which is not part of the actual design but rather helpful for debugging and understanding !! Apart from this is there any other use-case of this callback which you think is worth explaining its existence inside the standard (Just to get little insight)
  4. before_end_of_elaboration callback

    @Philipp A Hartmann: I really want to know the significance of "before_end_of_elaboration" callback in SystemC. On Doulos website (https://www.doulos.com/knowhow/systemc/new_standard/), it is mentioned that it can be used in the scenarios where we bind the module monitor ports to the top level singleton monitor channel. Referring to the attached example, why are we not binding the module monitor ports to the top level monitor channel in the top level constructor ? Why the binding of ports is done in the particular module callback function ? Also, what is the need of providing an additional callback function to instantiate module/ports when we can do the same thing in the constructor itself ?
  5. How exactly sc_main works !!

    @Philipp A Hartmann: Thanks for the short summary. It really gave me a good understanding from the top level.
  6. How exactly sc_main works !!

    How "sc_main" works in SystemC ? I mean what I understood from library is that - there is a main function defined in library which calls the sc_elab_and_sim which in turns calls the sc_main function. But my question is SystemC library is distributed as source which user builds at his end; and links to his application. And if SystemC has main inside it then it should have got compiled into exe! Am I right ? Can somebody help me in understanding this flow ?
  7. before_end_of_elaboration callback

    @Philipp A Hartmann: Thanks a lot Philipp for the clarification.. understood the point now..
  8. I created a simple example to see how the callbacks are being called by the systemc simulation kernel. But I am little surprised with the output. Can somebody explain or justify the output ? CODE: ============================= class analyzer : public sc_module { public: sc_out<bool> out_portA; sc_in<bool> in_portA; analyzer(sc_module_name nm) : out_portA("OUT_PORT_A"),in_portA("IN_PORT_A") { std::cout << "I am in analyzer constructor " << std::endl; } void before_end_of_elaboration(){ std::cout << "I am in before_end_of_elaboration of " << name() << std::endl; } }; class producer : public sc_module { public: sc_out<bool> out_portP; producer(sc_module_name nm) : out_portP("OUT_PORT_P") { std::cout << "I am in producer constructor " << std::endl; } void before_end_of_elaboration(){ std::cout << "I am in before_end_of_elaboration of " << name() << std::endl; } }; class consumer : public sc_module { public: sc_in<bool> in_portC; consumer(sc_module_name nm) : in_portC("IN_PORT_C") { std::cout << "I am in consumer constructor " << std::endl; } void before_end_of_elaboration(){ std::cout << "I am in before_end_of_elaboration of " << name() << std::endl; } }; class top_module : public sc_module { public: sc_signal<bool> sig1; producer p1; consumer c1; top_module(sc_module_name nm):sig1("SIG1"),p1("P1"),c1("C1") { std::cout << "I am in top constructor " << std::endl; p1.out_portP(sig1); c1.in_portC(sig1); } void before_end_of_elaboration(){ std::cout << "I am in before_end_of_elaboration of " << name() << std::endl; analyzer a1("A1"); //p1.out_portP(sig1);a1.in_portA(sig1); //sc_signal<bool> sig2; //a1.out_portA(sig2);c1.in_portC(sig2); } }; int sc_main(int argc, char *argv[]) { top_module top("TOP"); sc_start(1,SC_MS); sc_stop(); return 0; } OUTPUT: ============================= SystemC 2.3.0-ASI --- Feb 1 2014 18:12:06Copyright (c) 1996-2012 by all Contributors,ALL RIGHTS RESERVEDI am in producer constructor I am in consumer constructor I am in top constructor I am in before_end_of_elaboration of TOPI am in analyzer constructor I am in before_end_of_elaboration of TOP.P1I am in before_end_of_elaboration of TOP.C1Info: /OSCI/SystemC: Simulation stopped by user. Why it has not called the analyzer before_end_of_elaboration() callback ? Also, can I alter/modify/redefine the port bindings in the top level before_end_of_elaboration callback (see the commented lines in top level callback)?
×