KMLM List
View email archives for the history of this mailing list.
|
|
|
|
systemc-forum - Re: [systemc-forum] deriving module from multiple module
|
Message Thread:
Previous |
Next
|
- To: Gagandeep Khanna <gagandeep@xxxxxxxxxxxxxxxx>
- From: "Philipp A. Hartmann" <philipp.hartmann@xxxxxxxx>
- Date: Fri, 29 Oct 2010 13:53:59 +0200
- Cc: systemc-forum@xxxxxxxxxxxxxxxxx
- Send Email to systemc-forum@lists.systemc.org:
- Send new message
- Reply to this message
|
Gagan,
On 29/10/10 11:37, Gagandeep Khanna wrote:
> I am a new to systemC and facing a problem of deriving a module from
> multiple module.
No surprise. ;-) Your problem below is one of the more obvious ones,
when doing stuff like that.
> I would like to ask that " How to Derive a module from multiple module?"
The short answer is: Don't do that.
Especially, when your new to SystemC and even more so, if you are not a
skilled C++ developer.
> Though I tried to solve my problem in following way but I got few errors
> mentioned below the given program
The errors you get ("pointer to member conversion via virtual base")
come from your static process declarations inside your modules,
virtually inheriting from sc_module.
In C++, the "pointer-to-member" conversion in downwards the
inheritance chain is not allowed. SystemC uses a base-class
pointer-to-member (function) to refer to the process function body
(somewhere inside SC_THREAD). In the light of virtual inheritance, this
downcast is not possible.
The only way to add processes to such modules is via dynamic process
spawning. (sc_spawn and friends). I still do not recommend virtually
inherit from sc_module, unless you really know what you are doing (as I
said just recently in another thread).
Greetings from Oldenburg,
Philipp
> #include<systemc.h>
>
> class base_module: virtual public sc_module
> {
> public:
> sc_core::sc_event ev1;
>
> void process(void)
> {
> }
>
> SC_HAS_PROCESS(base_module);
> base_module(sc_module_name nm):sc_module(nm)
> {
> SC_METHOD(process);
> sensitive<<ev1;
> }
>
> };
>
> class base_module2: virtual public sc_module
>
> {
> public:
> sc_core::sc_event ev2;
> void process2(void)
> {
> }
> SC_HAS_PROCESS(base_module2);
> base_module2(sc_module_name nm):sc_module(nm)
> {
> SC_METHOD(process2);
> sensitive<<ev2;
> }
> };
> class derived_module : public base_module, public base_module2
> {
> public:
> SC_HAS_PROCESS(derived_module)
> ;
> derived_module ( sc_module_name nm
> ):sc_module(nm),base_module(nm),base_module2(nm)
> {
> SC_THREAD(proc);
> }
> void proc()
> {
> ev1.notify();
> ev2.notify();
> }
> };
>
>
> ----------------------------------error------------------------------
>
> test.cpp: In constructor
> ‘base_module::base_module(sc_core::sc_module_name)’:
> test.cpp:15: error: pointer to member conversion via virtual base
> ‘sc_core::sc_module’
> test.cpp: In constructor
> ‘base_module2::base_module2(sc_core::sc_module_name)’:
> test.cpp:32: error: pointer to member conversion via virtual base
> ‘sc_core::sc_module’
> test.cpp: In constructor
> ‘derived_module::derived_module(sc_core::sc_module_name)’:
> test.cpp:42: error: pointer to member conversion via virtual base
> ‘sc_core::sc_module’
>
> Gagan
>
> Circuitsutra Pvt Ltd.
>
--
Philipp A. Hartmann
Hardware/Software Design Methodology Group
OFFIS Institute for Information Technology
R&D Division Transportation · FuE-Bereich Verkehr
Escherweg 2 · 26121 Oldenburg · Germany
Phone/Fax: +49-441-9722-420/282 · PGP: 0x9161A5C0 · http://www.offis.de/
Attachment:
signature.asc
Description: OpenPGP digital signature
|
|