Jump to content

elibre

Members
  • Content Count

    1
  • Joined

  • Last visited

  1. Hello, I would like to create an arbitrary (random) number of processes, of the same module. So I tried with sc_vector. I can instantiate sc_module but not when there is a SC_THREAD in the module. I have the following code in my header "nodes.h" struct CNodes : sc_core::sc_module { CNodes(sc_core::sc_module_name instance); ~CNodes(void) = default; void CNodes::Init_node(int, float, float); SC_HAS_PROCESS(CNodes); private: int id = 0; // Processes and overrides void Thread_node(void); }; And the cpp files is : #include "Nodes.h" CNodes::CNodes(sc_core::sc_module_name instance) { id = 0; std::cout << "Constructing CNodes " << std::endl; SC_THREAD(Thread_node); // PROBLEMATIC LINE dont_initialize(); } void CNodes::Init_node(int pid, float bias, float rate) { } void CNodes::Thread_node(void) { while(true) { std::cout << "Hi there" << std::endl; wait(10,sc_core::SC_NS); } } When I put the "SC_THREAD" macro in my code, I got an error during elaboration Error: (E549) uncaught exception: Access violation - n In file: C:\SystemC\src\sysc\kernel\sc_except.cpp:98 The top module is this one. It instantiates 20 objects of class CNodes : #include <string> #include <time.h> #include "Network.h" #include "Nodes.h" using namespace std; CNetwork::CNetwork (sc_core::sc_module_name name, unsigned _size = 4): sc_core::sc_module(name), nodes("node") { float bias, rate; /* initialize random seed: */ srand((unsigned int)time(NULL)); nodes.init(20); for (unsigned int i = 0; i < nodes.size(); i++) { // generate random numbers for nodes bias = (float)rand() / RAND_MAX; rate = (float)rand() / RAND_MAX; nodes[i].Init_node(i, bias, rate); } } The modules "nodes" will have also ports, etc. But for the moment, I'm stuck with the instantiation. When I remove the problematic line, "SC_THREAD(Thread_node);", it works fine for the moment. But in that case I don't have the processes I need for my model. Is ther a way to instantiate a arbitrary number of processes, arbitrary meaning that the number is not known during coding phase because it will be random. Thanks ! Arnaud
×
×
  • Create New...