hakimelectronics Posted December 11, 2013 Report Share Posted December 11, 2013 Hi,I am getting errors like below:Trace ERROR:No traces can be added once simulation has started.To add traces, create a new vcd trace file.Code of memory.cpp corresponding to error: Memory::Memory(sc_core::sc_module_name name, unsigned int size) : sc_module(name), m_size(size) { tf = sc_core::sc_create_vcd_trace_file("trace_data1"); // tracing, trace file creation tf->set_time_unit(10, sc_core::SC_US); storage = new ensitlm::data_t[size/sizeof(ensitlm::data_t)]; } // Destructor Memory::~Memory() { // close trace file sc_close_vcd_trace_file(tf); delete [] storage; } // Read transactions tlm::tlm_response_status Memory::read(ensitlm::addr_t a, ensitlm::data_t& d) { // Check if the address is within memory bounds if (a >= m_size) { sleep(5); return tlm::TLM_ADDRESS_ERROR_RESPONSE; } else { d = storage[a/sizeof(ensitlm::data_t)]; sc_trace(tf, d ,"d"); return tlm::TLM_OK_RESPONSE; } } // Write transactions tlm::tlm_response_status Memory::write(ensitlm::addr_t a, ensitlm::data_t d) { // Check if the address is within memory bounds if (a >= m_size) { sleep(5); return tlm::TLM_ADDRESS_ERROR_RESPONSE; } else { storage[a/sizeof(ensitlm::data_t)] = d; return tlm::TLM_OK_RESPONSE; } } code of memory.h : SC_MODULE(Memory) { ensitlm::target_socket<Memory> target; sc_core::sc_trace_file *tf; Memory(sc_core::sc_module_name name, unsigned int size); ~Memory(); tlm::tlm_response_status read(ensitlm::addr_t a, ensitlm::data_t& d); tlm::tlm_response_status write(ensitlm::addr_t a, ensitlm::data_t d); private: unsigned int m_size; public: /* The loader must have access to the storage */ ensitlm::data_t* storage; }; #endif Please tell me the reasons behind these errors Regards Hakimelectronics CliffordPersechino 1 Quote Link to comment Share on other sites More sharing options...
Philipp A Hartmann Posted December 11, 2013 Report Share Posted December 11, 2013 Hakim, Trace ERROR:No traces can be added once simulation has started.To add traces, create a new vcd trace file. Well, the reason for this error is the call to "sc_trace" inside your function, i.e. during the simulation. In order to trace the data values, you should add a member variable to your memory and add it to the trace file within the constructor. Something like: SC_MODULE(Memory) { // ... private: ensitlm::data_t data_trace; }; In the constructor, you then register the variable for tracing: Memory::Memory( ... ) : ... { // ... sc_trace(tf, data_trace ,"d"); } And in the "read" function, you update the "data_trace" variable: tlm::tlm_response_status Memory::read(ensitlm::addr_t a, ensitlm::data_t& d) { // instead of "sc_trace(...)" data_trace = d; } Hope that helps, Philipp Quote Link to comment Share on other sites More sharing options...
hakimelectronics Posted December 12, 2013 Author Report Share Posted December 12, 2013 It works fine! thanks Philipp Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.