Jump to content

Search the Community

Showing results for tags 'sc_vector'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Accellera Systems Initiative
    • Information
    • Announcements
    • In the News
  • SystemC
    • SystemC Language
    • SystemC AMS (Analog/Mixed-Signal)
    • SystemC TLM (Transaction-level Modeling)
    • SystemC Synthesizable Subset v1.4 Public Review
    • SystemC Verification (UVM-SystemC, SCV)
  • UVM (Universal Verification Methodology)
    • UVM 1.2 Public Review
    • Methodology and BCL Forum
    • UVM SystemVerilog Discussions
    • Simulator Specific Issues
    • UVM Commercial Announcements
  • Portable Stimulus
    • Portable Stimulus Discussion
  • IP-XACT
    • IP-XACT Discussion
  • IEEE 1735/IP Encryption
    • IEEE 1735/IP Encryption Discussion
  • OCP (Open Core Protocol)
  • UCIS (Unified Coverage Interoperability Standard)
  • Commercial Announcements
    • Announcements

Categories

  • SystemC
  • UVM
  • UCIS
  • IEEE 1735/IP Encryption

Calendars

  • Community Calendar

Found 9 results

  1. Vector of modules errors

    Hi, I am pretty new to systemc, and I am trying for days to instantiate an array of modules; but I am not being successfull using sc_vector. Here is the code: submodule.h #ifndef __SUBMODULE_h #define __SUBMODULE_h #include <systemc.h> //------------ DEFINITIONS --------------------------------- #define BYTE 8 typedef sc_uint<2*BYTE> uint_16b; typedef sc_uint<BYTE> uint_8b; //------------ PARAMETERS ---------------------------------- #define MAX_COUNT1 6 #define MAX_COUNT2 4 #define RESET_VALUE false //------------ MODULE -------------------------------------- template <int N> class SUBMODULE : public sc_module { public: //------------ Ports ----------------------------------- sc_in_clk i_clk; sc_in<bool> i_rst; sc_in<bool> i_en; sc_vector< sc_out<uint_16b> > o_data; sc_out<bool> o_finish; //------------ Variables ------------------------------- uint_8b v_state; uint_8b v_count1; uint_8b v_count2; //------------ Process --------------------------------- void p_main(void) { if (i_rst.read()){ v_state = 0; v_count1 = 0; v_count2 = 0; for(int i = 0; i < N; i++) o_data[i] = 0; } else{ if(i_en.read()){ switch(v_state){ case 0: for(int i = 0; i < N; i++) o_data[i] = 0; if (MAX_COUNT1 > 0) v_state = 1; else v_state = 2; break; case 1: v_count1++; if(!(v_count1 < MAX_COUNT1)) v_state = 2; break; case 2: if(v_count2 < MAX_COUNT2) for(int i = 0; i < N; i++) o_data[i] = (uint_16b)(100/MAX_COUNT2*(v_count2+1)); v_count2++; if(!(v_count2 < MAX_COUNT2)){ for(int i = 0; i < N; i++) o_data[i] = 100; v_state = 3; } break; case 3: if (!RESET_VALUE) for(int i = 0; i < N; i++) o_data[i] = 0; o_finish = 1; break; default: break; } } else{ v_state = 0; v_count1 = 0; v_count2 = 0; } } } //------------ Constructor ----------------------------- SC_HAS_PROCESS(SUBMODULE); SUBMODULE(sc_module_name name_) : sc_module(name_), o_data("o_data", N){ SC_METHOD(p_main); for (int j = 0; j < N; j++) sensitive << i_clk.pos() << i_rst; } }; #endif topmodule.h #ifndef __TOPMODULE_h #define __TOPMODULE_h #include <systemc.h> #include "SUBMODULE.h" #define MAX_N 8 template <int N> class TOPMODULE : public sc_module { public: //------------ General Data ---------------------------- //------------ Ports ----------------------------------- sc_in_clk i_clk; sc_in<bool> i_rst; sc_in<uint_8b> i_type; sc_vector< sc_out<uint_16b> > o_data; //------------ Signals --------------------------------- sc_signal<bool> s_en; sc_signal<bool> s_finish[N]; //------------ Variables ------------------------------- //------------ Components ------------------------------ sc_vector<SUBMODULE<N> > SM; //------------ Methods --------------------------------- //------------ Process --------------------------------- void p_main(void) { if (i_rst.read()){ } else{ } } //------------ Constructor ----------------------------- SC_HAS_PROCESS(TOPMODULE); TOPMODULE(sc_module_name name_) : sc_module(name_), SM("SM",N){ for (int i = 0; i < N; i++){ SM[i].i_clk(i_clk); SM[i].i_rst(i_rst); SM[i].i_en(s_en); SM[i].o_finish(s_finish[i]); SM[i].o_data(o_data[i]); } SC_METHOD(p_main); sensitive << i_clk.pos() << i_rst; } }; #endif TOPMODULE_tbm.cpp #include <systemc.h> #include "TOPMODULE.h" #define MIN_PERIOD 5 void debug(sc_trace_file* tf, TOPMODULE<MAX_N> *dut){ sc_trace(tf, dut->i_clk, "i_clk"); sc_trace(tf, dut->i_rst, "i_rst"); sc_trace(tf, dut->i_type, "i_en"); for (int i = 0; i < MAX_N; i++){ char str[16]; sprintf(str, "%d", i); sc_trace(tf, dut->o_data[i], "o_data_" + std::string(str)); } } int sc_main (int argc, char* argv[]) { sc_clock clk ("my_clock",MIN_PERIOD,0.5); sc_signal<bool> rst; sc_signal<uint_16b> data[MAX_N]; sc_signal<uint_8b> type; // Connect the DUT TOPMODULE<MAX_N> dut("dut"); dut.i_clk(clk); dut.i_rst(rst); dut.i_type(type); for (int i = 0; i < MAX_N; i++) dut.o_data[i](data[i]); // Open VCD file sc_trace_file *wf = sc_create_vcd_trace_file("SM_waveform"); debug(wf, &dut); //TODO // Test // End Test sc_close_vcd_trace_file(wf); return 0;// Terminate simulation } The error code I get is: Any help? I tried also with sc_assemble_vector( SM, &SUBMODULE::o_data).bind( o_data ) but this also does not work.
  2. I created vector of fifos: sc_vector<sc_fifo> fifos; and in my constructor: template <unsigned S> class my_chnl : public my_chnl_if, public sc_channel { sc_vector<sc_fifo> fifos; //vectors of fifos //----------------------------------------------------------- public: //----------------------------------------------------------- //constructor //----------------------------------------------------------- explicit my_chnl(sc_module_name nm, unsigned _size = 4) : sc_channel(nm), fifos("FIFO") { fifos.init(S, _size); } ..... I am getting compile error saying that include/sysc/utils/sc_vector.h:634: error: \u2018c\u2019 cannot be used as a function If I do fifos.init(S), it works, but I get default size of 16. How do I set custom size? Any help? Thanks
  3. sc_vector and TLM

    I need to create a TLM module (that here we will call top_level) containing an array of TLM target modules (defined by class reg). As a consequence, the top_level module should implement the tlm_bw interface, and contain an array of initiator sockets, each bound to a target socket of the reg modules. Is it possible to implement this hierarchy by using the sc_vector construct? Here is a snapshot of the code that I am trying to implement, to give a clearer idea: Top level #include "reg.h" class top_level : public sc_module , public virtual tlm::tlm_bw_transport_if<> { private: sc_time time; sc_vector<reg*> register_file; tlm::tlm_generic_payload reg_trans; public: sc_vector <tlm::tlm_initiator_socket<>*> initiator_socket; ... }; Target module: class reg : public sc_module , public virtual tlm::tlm_fw_transport_if<> { public: tlm::tlm_target_socket<> target_socket; virtual void b_transport(tlm::tlm_generic_payload& trans, sc_time& t); reg(sc_module_name name_); ... }; When trying to compile, the compiler returns this error: error: ISO C++ forbids declaration of ‘sc_vector’ with no type error: expected ‘;’ before ‘<’ token referring to both the instances of sc_vector, as if neither my class nor the initiator_socket class were recognized as datatypes... Best regards, S.
  4. 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
  5. I am trying to get an interface binded with a vector of port declared as sc_vector<sc_in<bool> > : std::vector<sc_object*> children = get_child_objects(); sc_signal<bool> *s = NULL; const char *tmp = "sc_vector"; for (unsigned i = 0; i < children.size(); i++) { if (strcmp(nm, children->basename()) == 0) { if (strcmp(children->kind(), tmp) == 0) { sc_vector<sc_in<bool> > *v = dynamic_cast<sc_vector<sc_in<bool> > * > (children); if (v != 0) { s = dynamic_cast<sc_signal<bool> *> (&v->at(0)); } } } } In the above code, I got the value of s as NULL. I have binded a port with signal, but still it's unexpected behavior. Am I doing something wrong here ??
  6. Hello, I've been trying to instantiate (if I'm not mistaken) an array of submodules that were created using sc_vector. So far, I've followed the recommendations for using custom creator functions, but I'm kind of lost at how to actually make it work. Especially with sc_bind, which keeps returning me errors. The module master houses an array of ports that will be connected to a corresponding number of slaves. Order of connection does not matter. I'm using MSVC++ 10. The code is as follows: class top : public sc_module { //Submodule declarations master master_i; sc_vector<slave> slave_i; public: // Constructor top( sc_module_name module_name , int k ) : sc_module( module_name ) , master_i("master"), slave_i("slave") { slave_i.init(N_SLAVE, sc_bind(&top::create_slave, this, sc_unnamed::_1, sc_unnamed::_2)("slave",k)); sc_assemble_vector(slave_i, &slave::target_port).bind(master_i.initiator_port); } The creator function, which is a member of the class top, is as follows: static slave* top::create_slave(const char* name, size_t idx) { slave* s = new slave(name,1); // Hardcoding not intended; it's just to get it to // compile return s; } slave class constructor prototype: slave( sc_module_name module_name , int k ); Errors that I have so far: 1>c:\systemc\systemc-2.3.1\src\sysc\packages\boost\bind.hpp(63): error C2825: 'F': must be a class or namespace when followed by '::' 1> c:\systemc\systemc-2.3.1\src\sysc\packages\boost\bind\bind_template.hpp(15) : see reference to class template instantiation 'sc_boost::_bi::result_traits<R,F>' being compiled 1> with 1> [ 1> R=sc_boost::_bi::unspecified, 1> F=slave *(__cdecl *)(const char *,size_t) 1> ] 1> c:\users\khairul\dropbox\cours\systemc\examples\source\11\master_slave\top.h(32) : see reference to class template instantiation 'sc_boost::_bi::bind_t<R,F,L>' being compiled 1> with 1> [ 1> R=sc_boost::_bi::unspecified, 1> F=slave *(__cdecl *)(const char *,size_t), 1> L=sc_boost::_bi::list3<sc_boost::_bi::value<top *>,sc_boost::arg<1>,sc_boost::arg<2>> 1> ] Any ideas? Thanks,
  7. I am trying to use an sc_vector of modules with a custom creator to pass constructor arguments. It seems to work and run through the entire program, but at exit causes a segfault. GDB shows that this is due to to sc_vector calling the destructor of the module. I have no dynamically-allocated memory or pointers in the module. Here's the overview: outside of sc_main (global -- but I also tried inside of sc_main): -------------------------- struct create_mod { unsigned int m_arg1; unsigned int m_arg2; create_mod(unsigned int arg1, unsigned int arg2) : m_arg1(arg1), m_arg2(arg2) {} mod* operator()(const char* name, size_t) { return new mod(name, m_arg1, m_arg2); } }; Inside sc_main: --------------------------- unsigned int num_of_mods = 8; unsigned int args1 = 5, args2 = 4; sc_vector<mod> vec_mod("mods"); vec_mod.init(num_of_mods, create_mod(args1, args2)); // ... use vec_mod, bind ports, etc ... return 0; So the program runs, then segfaults at the end with "core dumped". GDB results: Backtracing shows: Note the bit in red. Also note that line 334 is the closing brace of sc_main. Also: As I said, I have no dynamically-allocated memory in the class. I have tried an empty destructor (as well as = default since I'm using C++11) but got the same result. Any ideas? Thanks in advance.
  8. Hi, So I have a submodule having an array of boolean input ports. Now in the top module, I define an sc_vector of the submodule type. Also, I define an array of sc_vector signals to be bound to. Questions: Can I use an array of sc_vectors? Any conventions on using them? eg: can I write sc_vector < sc_signal <bool> > operand_vec[max_operands]; If no, then is there any work around for this? Also, I now need to assemble and bind these ports: The code below doesn't seem to work. Both the stack_cnt_vec and operand_vec are initialized properly. for(int i=0;i<max_operands;i++){ operand_vec[i].init(10); } for(int i=0; i<10; i++) { sc_assemble_vector( stack_cnt_vec, &StackController::operands[i]).bind( operand_vec[i] ); } Thanks a lot for your time.
  9. Greetings everyone, I have a process that is sensitive to an sc_vector (specifically a vector of input ports) and was curious about how to handle the fact that values are maintained on each port in that vector on subsequent iterations of the process. This makes it very difficult to determine which values are actually new when the process is executed. I was hoping there would be a way to clear the value on a port once it had been read, but I could not find anything like this. The closest thing to a solution is to "latch" the value each time the process gets triggered and then compare the latch value with the port value to determine if anything new has arrived. Is there a better way to do this? Thanks a bunch in advance.
×