Jump to content

rayzekus

Members
  • Content Count

    8
  • Joined

  • Last visited

Posts posted by rayzekus


  1. Hi Ameya,

    Thanks, your reply sounds like what is happening ... I am just a novice at this so here is what I know about my build environment ... I am running on a Window7 laptop, I compiled the SystemC library with Cygwin g++ (note: I am now compiling my code with g++ -std=c++11 not just g++) ... I write and compile my code in Eclipse(Neon) ...

    Q: I didn't quite understand your statement ...

    9 hours ago, AmeyaVS said:

    I also tried your code locally on my system, and even I am getting the random number generated.

    Are you saying you are getting random numbers generated with my code (unmodified)?

    Thx


  2. Hi,

    I am getting the same sequence of random numbers every time I run my SystemC code ... there is too much code to post here, so I will attempt to describe what I am doing ...

    I have written a DUT (SC_MODULE) with 9 input ports and I have written a Driver (SC_MODULE) to drive one of those ports, I have instantiated 9 Drivers and 1 DUT in sc_main ... the Driver uses rand() ...

    Each Driver produces the exact same sequence of random numbers ...

    I didn't some looking on the C++ forums and tried the following ...

    1. Adding srand(time(NULL)) to the Driver ... but it won't compile

    2. Adding srand(time(NULL)) to just sc_main ... compiled ok but made no difference

    3. Adding srand(time(NULL)) to the constructor, I added it to the Driver SC_CTOR ... compiled ok but again made no difference

    Those were the only possible solutions I found on the C++ forums ... I didn't see anything related on here ...

    As always any and all help would be greatly appreciated :-)


  3. 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?


  4. 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

×