Jump to content

Alaba

Members
  • Content Count

    7
  • Joined

  • Last visited

Posts posted by Alaba

  1. sca_eln::sca_de_rswitch sw0;
    
    SC_CTOR(mod): sw0("sw0",R_on,R_off ,off_state0) 
    	sw0.p(p);
    	sw0.n(n);
    	sw0.off_state =off_state1;
    	sw0.ctrl(ctrl);

     

    From documentation :

    if we assume  off_state1 = true

    sw0.off_state  sets the boolean state that correspond to the switch off_state.  in this case off_state is set to true, which means when the value of "ctrl"  is true it will switch to R_off 
    My question is,  how to set the default state of the sw0 ?  The argument  "off_state0" , also sets the off_state boolean value,  but it does not set the default state of the switch at initialization. Is it always set to Ron by default? 

    I could not find it in the documentation. 

    Thanks

  2. Hello 

    I 'm trying  to create an nxn array (nested vectors) of an rc component,  with each having different r,c values 

    ex: rc[0][0] (r=10,c=5), rc[1][1] (r=3,c=4).....

    I've  created the rc sub module that take the values of R and C as  arguments,

    As follows:

    SC_MODULE (rc){
    
        sca_eln::sca_terminal n;    
        sca_eln::sca_terminal p;
        sca_eln::sca_r r1;
        sca_eln::sca_c c1;
        sca_eln::sca_node  n1;  
       
        rc( sc_core::sc_module_name nm , double r0_,double c0_) :p("p"),n("n"), r1("r1"),c1("c1"), r0(r0_),c0(c0_) 
         
        {
            r1.p(p);
            r1.n(n1);
            r1.value=r0;    
            c1.p(n1);
            c1.n(n);
            c1.value=c0;
             
        }
    
       private:
        double r0; 
        double c0; 
    };

     

     I have found the following  post that shows how to initialize 1D vector so I customized my module accordingly ,which a follows    

    #include <systemc>
    #include <systemc-ams>
    using namespace  sc_core;
    
    SC_MODULE (rc){
    
        sca_eln::sca_terminal n;    
        sca_eln::sca_terminal p;
        sca_eln::sca_r r1;
        sca_eln::sca_c c1;
        sca_eln::sca_node  n1;  
       
        rc( sc_core::sc_module_name nm , double r0_,double c0_) :p("p"),n("n"), r1("r1"),c1("c1"), r0(r0_),c0(c0_) 
         
        {
            r1.p(p);
            r1.n(n1);
            r1.value=r0;    
            c1.p(n1);
            c1.n(n);
            c1.value=c0;
             
        }
    
       private:
        double r0; 
        double c0; 
    };
    
    
    struct create_mod
    {
         double m_arg1;
         double m_arg2;
         create_mod(double arg1, double arg2) : m_arg1(arg1), m_arg2(arg2) {}
         rc* operator()(const char* name, size_t)
         {
              return new rc(name, m_arg1, m_arg2);
         }
    };
    
    
    
    SC_MODULE (rc_tb){
        rc rc0;
        rc_tb( sc_core::sc_module_name nm ):rc0("rc0",1.0,1.0)  {
            unsigned int num_of_rcs = 4;
            unsigned int r_value = 5, c_value = 4;
            sc_vector<rc> vec_rc("mods");
            vec_rc.init(num_of_rcs, create_mod( r_value,  c_value));
            //... connect nodes
        }
     
    };

     

    Now the code works But it is only for 1D array 

    This method also forces me to set same argument values for all the initialized submodules  (  vec_rc.init(num_of_rcs, create_mod( r_value,  c_value));  ).

    So my 2 questions are

    1- How to make it a 2D vectors ?

    2-  How to initialize each component with specific RC values?  

     I also have tried the code  suggested in to make a 2D nested vectors but I failed 

     

    I don't mind using either methods  as long as it does the job. It will be nice if I use lambda function also

    Thanks in advance 

    RF

     

  3. 12 hours ago, karsten said:

    There is no real limitation except the available memory. Each resistor is a SystemC module which allocates some memory due the sc_module members.

    I guess SystemC and SystemC AMS does not check always, that memory could be allocated - thus you get the segfault.

    You can try a computer with more memory or try to setup the equation manually- for a resistive network this should be some lines of c code only - if you have inductors or capacitors you can use the state space or Ltf objects.

    I get same problem for same value of N with system of 32GB RAM and 8GB Ram 

  4. Hello there,

    I'm building a system that includes a large number of resistors.  I used  sc_vector  of elements and nodes, as I increase the number of resistors I get segmentation error.

    The below example is a simpler form  of my code that also gives the same error  

     

    In the code below if I use small value of N:

    ( N=10000):  I get the right result 

    but for N=1048576:  //(large N)

    I get: Segmentation fault (core dumped) 

     

    ------------------------------------------------------resistors in series module----------------

    //            p-    r0-r1-r2-r3...rN   -n

     static const int N=1048576;
      
        sca_eln::sca_terminal n;
        sca_eln::sca_terminal p;
       
        sc_vector< sca_eln::sca_node > c_vec{"c_vec", N };  //nodes beteen resistors  
        sc_vector<sca_eln::sca_r>     rs_vec{"rs_vec",   N  };  

    SC_CTOR(rmatnn):  
                                
           p("p"),n("n") // 
                    
          {

        rs_vec[0].p(p); //connect  p  port of first resistor to main p port 
        rs_vec[0].n(c_vec[0]); //connect n port of first resistor to nod 0
        rs_vec[0 ].value=10;
        
        for (int i = 1; i < N-1;  i++) {
          rs_vec[i ].p(c_vec[i-1]);
          rs_vec[i ].n(c_vec[i]);
          rs_vec[i ].value=10;
              }
         rs_vec[N-1 ].p(c_vec[N-2]);
         rs_vec[N-1 ].n(n);
             rs_vec[N-1 ].value=10;
            } 
          };

    Is there any limitations on the number of modules we use  for the simulation??

    Thanks in advance 

     

×
×
  • Create New...