Jump to content

Fernando M

Members
  • Posts

    2
  • Joined

  • Last visited

Fernando M's Achievements

Member

Member (1/2)

0

Reputation

  1. Thank you both. You are right, I had to move the init instructions inside the constructor, now I feel really silly. About the arrays, I have been using them for years. Are they really not a good option?
  2. I am trying to code a very generic module that takes the number of elements of a sc_vector of sc_in from an argument. This module looks like: transformation_arbiter.h using namespace sc_core; using namespace sc_dt; class transformation_arbiter : public sc_module { public: sc_in<bool> clk; sc_vector< sc_in<bool> > enable_in; . . . private: unsigned pre_rep; public: SC_HAS_PROCESS( transformation_arbiter ); transformation_arbiter( sc_module_name trans_arbiter, unsigned ext_pre_rep ): sc_module( trans_arbiter ), pre_rep( ext_pre_rep ), enable_in( "enable_in" ) { SC_THREAD( arbitrate ); sensitive << clk; } void arbitrate() { enable_in.init( pre_rep ); . . . } Then I am instantiating this module, along with a sc_vector of another module (request_generator.cpp) in a top module (top.cpp): request_generator.h . . . using namespace sc_core; using namespace sc_dt; class req_generator : public sc_module { public: //ports: sc_in_clk clk; sc_out<bool> enable_out; . . . top.h #include "trans_arbiter.h" #include "request_generator.h" . . . sc_signal<bool> signal[4]; sc_vector<req_generator> req_gen; transformation_arbiter trans_1_arb; . . . and top.cpp #include top.h top::top(sc_module_name sys_m): sc_module(top_m), trans_1_arb ( "trans_1_arb", 4 ), req_gen( "req_gen", 4) { . . . for ( auto i = 0; i < REQ_MODULES; ++i ) { trans_1_arb.enable_in[i].bind ( signal[i] ); } . . . } The problem is that this causes a segmentation fault in the bind instruction: Program received signal SIGSEGV, Segmentation fault. 0x0000000000412501 in sc_core::sc_vector<sc_core::sc_in<bool> >::operator[] (this=0x7fffffffcec0, i=0) at ./systemc-2.3.1/include/sysc/utils/sc_vector.h:384 384 { return *static_cast<element_type*>( base_type::at(i) ); } If I don't use de delayed initialization of the sc_vector like this: public: SC_HAS_PROCESS( transformation_arbiter ); transformation_arbiter( sc_module_name trans_arbiter ): sc_module( trans_arbiter ), enable_in( "enable_in", 4) { SC_THREAD( arbitrate ); sensitive << clk; } void arbitrate() { . . . } The code works, but then it is not generic anymore, since several instances of the module could have different number of ports, and not always 4. I'd really appreciate any help on this issue. Thanks, Fernando
×
×
  • Create New...