Jump to content

bad63r

Members
  • Content Count

    3
  • Joined

  • Last visited

  1. Hello everyone, so I'm feeding lut module with data via generator module. When I'm done, I'm sending to last address(that is location where my start is stored) value 1, and then after 20 ns value 0. So basically, I want to set start "signal" to be length of one clock period. When I detect that start is 1, I'm starting my calculation in lut.cpp module. If i change wait to 10 ns on line 1575 in generator.cpp it is fine, but when I put it to 20, I get segmentation fault. I should mention that in both cases code is compiling without errors. If anyone can explain to me why this error is occurring it will help me a lot 🙂 Thank you in advance, Tom generator.cpp generator.hpp lut.cpp lut.hpp main.cpp mem_manager.cpp mem_manager.hpp stim.cpp stim.hpp
  2. Thanks @Eyck, that did the trick. For future reference, I will put here my whole solution for LT TLM2.0 for writing and reading floating values. Normal TLM2.0 transport - write : // Normal TLM transport interface. for (unsigned int i = 0; i != 24; ++i) { unsigned int data_length = 4; unsigned int addr = rand() % 200; tlm_command cmd = i < 20 ? TLM_WRITE_COMMAND : TLM_READ_COMMAND; std::string msg = cmd == TLM_WRITE_COMMAND ? "Write " : "Read "; //OK, so whene you you want to write with regular mode into array, you should know that float value is 4 byte //and unsigned char is 1 byte. To be able to write float to unsigned char array, you must cast unsigned char array //to char array. float* buf_fl = reinterpret_cast<float*>(buf); buf_fl[0]=555.23; pl.set_command ( TLM_WRITE_COMMAND ); pl.set_address ( 8 );//targeting ram[2] pl.set_data_ptr (buf ); pl.set_data_length ( 4 ); pl.set_response_status ( TLM_INCOMPLETE_RESPONSE ); isoc->b_transport(pl, offset); buf_fl[0]=777.23; pl.set_command ( TLM_WRITE_COMMAND ); pl.set_address ( 20 );//targeting ram[5] pl.set_data_ptr (buf ); pl.set_data_length ( 4 ); pl.set_response_status ( TLM_INCOMPLETE_RESPONSE ); isoc->b_transport(pl, offset); buf_fl[0]=654.321; pl.set_command ( TLM_WRITE_COMMAND ); pl.set_address ( 796 );//targeting ram[199] pl.set_data_ptr (buf ); pl.set_data_length ( 4 ); pl.set_response_status ( TLM_INCOMPLETE_RESPONSE ); isoc->b_transport(pl, offset); Normal TLM2.0 transport - read: isoc->transport_dbg(dbg_pl); msg = " RAM at time " + sc_time_stamp().to_string(); msg += "\n"; unsigned char *moj_p; moj_p = dbg_pl.get_data_ptr(); float* moj_p_fl = reinterpret_cast<float*>(moj_p); std::cout << "it was written: "<<std::endl; std::cout<<"teting location 2 and 199: "<<moj_p_fl[2]<<" "<<moj_p_fl[199]<<std::endl;
  3. Hello everyone, so I'm learning systemC and currently I'm researching tlm2.0. I know how to send int values with tlm2.0 but I really can't send any float value (e.g. 12.53) and read it back. I'm using generator module and memory module, where generator module is generating transactions and memory module is receiving them. I focused on just how to insert float values inside unsigned char array. As I tested my solution with simple test.cpp to insert float value inside unsigned char array and read it back, I tried to implement that without success inside systemc tlm2.0. I tried with direct memory access: // Init first 20 locations to FF with DMI access tlm_dmi dmi; dmi_valid = isoc->get_direct_mem_ptr(pl, dmi); if (dmi_valid) { dmi_mem = dmi.get_dmi_ptr(); //dmi_mem is pointer to ram[] array in memory.h for (int i = 0; i != 20; ++i) fl_ptr[i] = 12.7; //dmi_mem[i] = 0xFF; } but I couldn't read correct values back with: isoc->transport_dbg(dbg_pl); msg = " RAM at time " + sc_time_stamp().to_string(); msg += "\n"; unsigned char *moj_p; moj_p = dbg_pl.get_data_ptr(); float* moj_p_fl = reinterpret_cast<float*>(moj_p); std::cout << "it was written: "<<std::endl; for (int i = 0; i != 200; ++i) { msg += std::to_string(moj_p_fl[i]); msg += " "; } SC_REPORT_INFO("generator", msg.c_str()); Or should I say, there are values I inserted into array but not on the right places. Any help is much appreciated 🙂 Tom generator.cpp generator.hpp main.cpp memory.cpp memory.hpp test.cpp
×
×
  • Create New...