Jump to content

feron_jb

Members
  • Content Count

    14
  • Joined

  • Last visited

  1. Hi everyone, For a processor model, I need to be able to reset or kill a transaction sent across an interface and stored in a Payload Event Queue. How can I do that? If I initiate a transaction like this : tlm::tlm_generic_payload* trans = new tlm::tlm_generic_payload; tlm::tlm_phase* trans_phase = new tlm::tlm_phase; sc_time* delay = new sc_time; tlm::tlm_sync_enum* transStatus = new tlm::tlm_sync_enum; *trans_phase = tlm::BEGIN_REQ; *delay = SC_ZERO_TIME; // Or any delay trans->set_command(tlm::TLM_WRITE_COMMAND); trans->set_dmi_allowed(false); trans->set_response_status(tlm::TLM_INCOMPLETE_RESPONSE); *transStatus = InitSocket.nb_transport_fw(*trans, *trans_phase, *delay); How could I, afterwards and before the specified delay has elapsed, kill this transaction or remove it from the target Payload Event Queue? Can I keep a copy of the 'trans' pointer to reset the transaction content if needed? Thank you for your help! Regards, J-B
  2. Hello, I have a SystemC program encapsulated into a C++ class allowing to interact with a SystemC model. In order to easily call that program from a scripting language, I would like to generate a shared-library containing all my SystemC program and the SystemC library. Is it different from generating a classical C/C++ shared-library? How can you deal with the sc_main required by the SystemC? Can you point me to some documentation about that topic, I didn't find anything about it for SystemC on the internet... Thank you! Regards! J-B
  3. Hi, I have some problems with exceptions thrown inside systemC modules and catched in a classical C++ class, parent of the systemC one. The codes shown here only illustrate the structure of my program and are not intended to be compiled. I defined my own exception class, extending the standard exception class : #include "systemc.h" class customException : public std::exception{ // Constructor customException{ // Instance variables with information about the error std::string message; std::string fileInfo; sc_time time; }; // Get information about the error std::string getMessage(); std::string getFileInfo(); sc_time getTime(); }; In a systemC module, one of my customException is thrown. If it is catched inside the modules, it is correctely interpreted. #include "systemc.h" #include "customException.h" SC_MODULE (funcModule){ // Constructor SC_HAS_PROCESS(funcModule); funcModule(sc_module_name instanceName) : sc_module(instanceName){ SC_THREAD(funcThread); } // SystemC thread, throwing an exception void funcThread(){ while(true){ ... // Throw one of my custom exception customException e("Error message", __FILE__, sc_time_stamp()); throw e; ... } // If 'while block' in try-catch block, exception is caught normally, // as a custom exception } }; A classical C++ class instanciates this systemC module and defines a function running it, able to catch its exception: #include "systemc.h" #include "customException.h" #include "funcModule.h" class testFunc{ funcModule myFunc; // Consructor testFunc : myFunc("myFunc"){ }; // Run the SystemC module void funcRun(){ try{ sc_start(20, SC_NS); } catch (customException& e){ // Not catched } catch (const std::exception &exc){ // Catched } catch (...){ // Catched } } }; In a testbench, if I call the funcRun function testFunc myTestFunc; myTestFunc.funcRun(); The exception will be catched, but as a standard exception, not as one of my custom exception. Do you have any idea about why this happens? Do you have a solution? Thank you, Regards, J-B
  4. feron_jb

    Segmentation fault after pointer content copy

    I finally found a bug caused by an uninitialized pointer. I had to extensively use the command line GDB and discovered a really powerful debug tool, more reliable than the graphical GDB integrated to Eclipse CDT. Thank you also for your useful advices about GDB use, pointer initialization, etc.
  5. feron_jb

    Segmentation fault after pointer content copy

    Hi, Thank you for your answers. @dakupoto : I noticed your advices about Eclipse. I am using it for its dynamic error detection which is really useful and makes me gain a lot of time. If you have lighter solution, please share. Regarding my example, I am indeed using a lot of pointers which make it difficult to understand and debug. However, as I said in my initial post, I initialize my table of pointers itemArray correctly as I can read the content, I just do not show the initialization code in the example. The error is not in my pointer use, I think, but instead in my use of some systemC function (see GDB results hereunder). I need more an external point of view on my methodology of examining the array content because I think the error is there. I however note that some improvement in the pointer content copy could be made. @apfitch : Indeed, GDB seems really easy. Here is the GDB output : Program received signal SIGSEGV, Segmentation fault. 0x00007ffff7b22313 in sc_core::vcd_trace_file::initialize() () from /usr/local/systemc-2.3.0/lib-linux64/libsystemc-2.3.0.so (gdb) backtrace #0 0x00007ffff7b22313 in sc_core::vcd_trace_file::initialize() () from /usr/local/systemc-2.3.0/lib-linux64/libsystemc-2.3.0.so #1 0x00007ffff7b22950 in sc_core::vcd_trace_file::cycle(bool) () from /usr/local/systemc-2.3.0/lib-linux64/libsystemc-2.3.0.so #2 0x00007ffff7afc543 in sc_core::sc_simcontext::trace_cycle(bool) () from /usr/local/systemc-2.3.0/lib-linux64/libsystemc-2.3.0.so #3 0x00007ffff7aff92a in sc_core::sc_simcontext::simulate(sc_core::sc_time const&) () from /usr/local/systemc-2.3.0/lib-linux64/libsystemc-2.3.0.so #4 0x00007ffff7afffb1 in sc_core::sc_start(sc_core::sc_time const&, sc_core::sc_starvation_policy) () from /usr/local/systemc-2.3.0/lib-linux64/libsystemc-2.3.0.so #5 0x000000000042bb9e in sc_core::sc_start (duration=70, unit=sc_core::SC_NS, p=sc_core::SC_RUN_TO_TIME) at /usr/local/systemc-2.3.0/include/sysc/kernel/sc_simcontext.h:112 #6 0x000000000042b204 in sc_main (argc=1, argv=0x6748f0) at Testbenches/TB_CLP_top.cpp:151 #7 0x00007ffff7aed7e3 in sc_elab_and_sim () from /usr/local/systemc-2.3.0/lib-linux64/libsystemc-2.3.0.so #8 0x00007ffff71c876d in __libc_start_main () from /lib/x86_64-linux-gnu/libc.so.6 #9 0x0000000000405019 in _start () It seem to come from the SystemC library. Any idea about what happens? Thank you & have a nice WE! J-B
  6. Hello, I have a strange beahavior of a systemC program caused by a debug function. This function (called memItemExamine) allows to read a memory cell in a sub-module (memDev in the example) from the top level class (Model_top in the example). The particularity of that error lies in the fact that I can read the memory cell (content is correctly displayed in terminal), but when later a process comes to read the memory cell again, the program fails with a segmentation fault. Please find a simplified example of my codes hereunder, they illustrate the hierarchy of my program and the methodology I use to implement the memItemExamine function. Any comment or feedback is welcome. Do not hesitate to give me SystemC debug advices, I almost found nothing on internet about it (another topic could arrive on that subject regarding Eclipse CDT debug environment). memDev.h : One of the systemC thread implements an array of pointers which represent the memory cells. Initialisation of the pointers is not shown in the code but it is done. SC_MODULE (memDev){ public : memItem** itemArray; void readmemItem(int address, memItem** ppReadItem); SC_HAS_PROCESS(memDev); memDev(sc_module_name instname) : sc_module(instname) { SC_THREAD(execute); itemArray = new memItem*[100]; // Memory initialization performed } }; memDev.cpp void memDev::execute(){ while(true){ ... wait(20, SC_NS); }; void memDev::readmemItem(int address, memItem** ppReadItem){ *ppReadItem = itemArray[address]->content; }; Model_top.h : memItemExamine function copy the memory cell content in the provided pointer readItem. #include "memDev.h" #include "otherDev.h" // Not important here class Model_top { memDev my_memDev; // SystemC thread otherDev my_otherDev; //SystemC thread Model_top(); void memItemExamine(int address, memItem* readItem); } Model_top.cpp Model_top::Model_top(): my_memDev("my_memDev"), my_otherDev("my_otherDev"){ } void Model_top::memItemExamine(int address, memItem* readItem){ memItem** tempVal = new memItem*; my_memDev.readmemItem(address, tempVal); readItem->content = (*tempVal)->content; delete tempVal; } main.cpp : If the memItemExamine function is not executed, no segmentation fault occurs. int sc_main(int argc, char* argv[]) { Model_top my_modelTop; // sc_start(30, SC_NS); // Possibility to start simulation before examine // Memory item examine (debug purpose) memItem* pmemItem = new memItem; modelTop.memItemExamine(1, pmemItem); cout << pmemItem->content << endl; // Content is displayed // Segmentation fault occurs here : sc_start(70, SC_NS); return 0; }; Thank you for your time! Regards, J-B
  7. You are right, declaring my two threads in my class definition and then instanciating it in the constructor fixed my problem. A stupid basic C++ error... Thank you for your solution!
  8. Hello everyone, I have a runtime error when trying to simulate the top level of a system containing 2 sc_threads. An example of my code architecture is presented hereunder, do you see any problem? Here is my error : Error: (E519) wait() is only allowed in SC_THREADs and SC_CTHREADs: in SC_METHODs use next_trigger() instead In file: ../../../../src/sysc/kernel/sc_wait.cpp:166 In process: Test_top.th1.Thread_test @ 0 s TB_test_top.cpp: #include "Test_top.h" int sc_main(int argc, char* argv[]) { Test_top topLevel("topLevel"); sc_start(70, SC_NS); }; Test_top.h: #include <systemc> #include "Thread.h" class Test_top { Test_top(); }; Test_top.cpp: #include "Test_top.h" Test_top::Test_top(){ Thread th1("th1"); Thread th2("th2"); }; Thread.h: #include <systemc> SC_MODULE (Thread){ void Thread_test(); SC_HAS_PROCESS(Thread); Thread(sc_module_name instanceName) : sc_module(instanceName){ SC_THREAD(Thread_test); } }; Thread.cpp #include "Thread.h" void Thread::Thread_test(){ ... wait(...); ... }; Thank you for your comments!
  9. feron_jb

    SystemC object instanciation in C++ class

    I am now effectively initializing my SystemC object in the user classe constructor. My question about dynamic allocation, pointer and array of systemC objects is more for syntaxic interest and to be able to implement it. Who knows, one day, it might be necessary.
  10. feron_jb

    SystemC object instanciation in C++ class

    Hi Philipp, Thank you for your quick answer and interesting remarks. I think my main problem is my misunderstanding of the SystemC constructor. I though the string passed as argument was used as instance name in simulation, I'm now doubting. Or maybe it is not necessary in a pointer to a SystemC object declaration. By this misunderstanding, I can't declare a pointer to the SystemC object MySC_obj (what I was trying to do, not to initialize the oblect in the class :-D ) Could you, please, explain (or point me to the documentation about) : the role of the string in the systemC constructor how to declare a pointer to a systemC object (and how to instanciate its content using 'new' dynamic constructor). An example is sufficient. Thank you! J-B EDIT : It seems that I should declare and instanciate pointers and their content like it : File sc_user.h #include "MySC_obj.h" class sc_user{ public : // Service class constructor sc_user(); // SC model instanciation MySC_obj* test; } File sc_user.cpp #include "sc_user.h" // Service class constructor sc_user::sc_user(){ test = new MySC_obj("test"); } } What if I want to initialize an array of MySC_obj? test = new MySC_obj("test")[2]; The previous command doesn't work... I didn't find answer to the string role in the constructor.
  11. Hello, I am trying to develop a service class allowing a user to interact with a SystemC model. I am in trouble during my SystemC object instanciation in the service class. Do you see any errors in my example codes hereunder? File sc_user.h #include "MySC_obj.h" class sc_user{ public : // Service class constructor sc_user(); // SC model instanciation MySC_obj* test("test"); } File MySC_obj.h #include <systemc.h> SC_MODULE(MySC_obj){ ... SC_HAS_PROCESS(MySC_obj); MySC_obj(sc_module_name instName) : sc_module(instName), ...{ SC_THREAD(...); ... } } The complier complains about an expected ';' at end of member declaration in the line (MySC_obj* test("test"); ). If I declare the same MySC_obj outside of the sc_user class, in a main function for instance, it is ok. Any idea about my error? Thank you!
  12. Hi, I had the same problems as you and I could solve it with some documentation. I provide links in an answer of my own question here. Have a nice day, Regards, J-B
  13. I could finally make it using TLM docmentation (the IEEE 1666 standard might be useful). I had to implement a TLM transaction extension to fit the particular needs of some transactions between the pipeline and the file register. Useful examples for TLM transaction extensions are provided in a document from the university of Munich. Finally, the Doulos examples are also interesting (but less interesting than the last one). Hope this helped! J-B
  14. Hello, I'm developping a processor behavioural model using SystemC/TLM standard. I try to make the result cycle-accurate. I have some troubles for modelling the pipeline-file register communication with TLM. I want to to be able to write in a register but the new data must be available for a read only one clock cycle later (or 20ns later). I could do this by implementing sockets in my pipeline and my file register modules, using the available generic payload, as my file register is addressed. However, some of my registers are defined as structure containing boolean in order to read or write easily configuration or status flags. If I want to read or write the complete register, I have functions concatenating boolean flags into or extracting boolean flags from short integers. Using TLM, how could I easily write a particular flag in a register with a delay? Is it possible to add a mask to the generic payload or to delay the write in the boolean structure? If someone has a solution, can he illustrate it with an example? If necessary, I can try to illustrate my problem with an example, do not hesitate to ask! Thank you!
×