rayzekus Posted October 27, 2017 Report Share Posted October 27, 2017 I am a novice at SystemC (some OOP background but not much) ... I am getting an error for the code below ... ../src/xor2.h:20:31: error: invalid initializer for array member 'nand<2> xor2::nand2 [4]' I have much more complicated but netted my problem down to this much simpler and smaller example ... #include "systemc.h" template <int width> SC_MODULE(nand) { sc_in<bool> A[width]; sc_out<bool> F; void nand_func() { F.write(!and_reduce(A)); } SC_CTOR(nand) { SC_METHOD(nand_func); sensitive << A; } }; #include "systemc.h" #include "nand.h" SC_MODULE(xor2) { sc_in<bool> A, B; sc_out<bool> F; nand<2> nand2[4]; sc_signal<bool> sig1, sig2, sig3; SC_CTOR(xor2) : nand2("NAND2") { nand2[0].A[0](A); nand2[0].A[1](B); nand2[0].F(sig1); nand2[1].A[0](A); nand2[1].A[1](sig1); nand2[1].F(sig2); nand2[2].A[0](sig1); nand2[2].A[1](B); nand2[2].F(sig3); nand2[3].A[0](sig2); nand2[3].A[1](sig3); nand2[3].F(F); } }; I would greatly appreciate any help and suggestions of ways to use multiple template'd modules in this way ... xor2.h nand.h Quote Link to comment Share on other sites More sharing options...
ralph.goergen Posted October 27, 2017 Report Share Posted October 27, 2017 Hi. You cannot do an array or a std::vector of SystemC modules. Both would require a default constructor which is not available for sc_modules. Use sc_vector instead. See Section 8.5 in the SystemC LRM (IEEE 1666:2011). Regards Ralph Quote Link to comment Share on other sites More sharing options...
rayzekus Posted October 27, 2017 Author Report Share Posted October 27, 2017 Thanks Ralph, I tried what you suggested and that should be the right answer but I get the following error ... ../src/xor2.h:17:38: warning: non-static data member initializers only available with -std=c++11 or -std=gnu++11 sc_vector<nand<2> > nand2{"NAND2", 4}; ^ As I said I am a novice at this ... and my next Q isn't SystemC but maybe you can help me ... I am using Eclipse and Cygwin gcc ... Can I add the c++11option to fix the error I got? Quote Link to comment Share on other sites More sharing options...
David Black Posted October 27, 2017 Report Share Posted October 27, 2017 Assumes you are using a version of c++ that supports c++11, just add -std=c++11 to fix this problem or move the constructor arguments to the initializer list of your constructor, which will require abandoning the SC_CTOR macro in favor of full C++ constructor syntax. Or you use the deferred vector construction. Gcc 4.8 or newer supports c++11 if I recall correctly. Quote Link to comment Share on other sites More sharing options...
rayzekus Posted October 27, 2017 Author Report Share Posted October 27, 2017 Thanks David, Looks like Cygwin gcc supports c++11 ... I used sc_vector compiles cleanly :-) 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.