Jump to content

All Activity

This stream auto-updates     

  1. Today
  2. Yes, but you need to use a real string (not empty). Usually, the instance name matches the name of the instance itself. For example: #include "top_module.cpp" //< Real code goes in here #include <systemc> // Minimal sc_main function int sc_main(int argc, const char* argv[]) { Top_module top_instance{ "top_instance" }; sc_core::sc_start(); return 0; }
  3. David Black

    Fsm

    Depends on what the problem statement is. Likely as not, the test will rely on some type of SystemC ports for the inputs.
  4. Bes

    Fsm

    I’m kinda confused with the syntax for systemc, I don’t know if the states or the keys are input ports or just signals not with the fsm logic
  5. Bes

    Compile error

    Isn’t this required for the constructor?
  6. You really should not use an empty string for the instance name.
  7. David Black

    Fsm

    This looks like homework and a trivial FSM. Most of the coding would be simple C++. Good luck!
  8. Bes

    Compile error

    I’m using sc_has_process constructor in the header file. i have an output port and 2 signals( my inputs that i want to read from csv file but I can’t) , so in the header file i only initialize my output port, 2 signals and my method in the .cpp file, i do convolution between the two input signals which are used as 2D arrays using nested sc_vector. then in the main method i write convLayer c(“ “); // convLayer is my module name. c.in1(array) ; //in1 is the signal in the header file, array is a new signal with same size in main.cpp file
  9. Bes

    Fsm

    Can someone help how could do something like this using systemc
  10. Yesterday
  11. Hello , i have a compile error that I don’t seem to understand, can someone help
  12. Thank you so much, this helped
  13. You can access elements using array index operator like this: in2[0][1]=42.0; But you write you want to put values onto the array. You cannot write onto ports as these are only proxys and do not hold values. You need to create a similar sc_signal array and connect it to the ports. sc_signals hold values so you can put values on them using write(). A side node: you should declare your vectors as: sc_vector<sc_vector<sc_in<float>>> in2{"in2", 4, [](char const* name, size_t idx) -> sc_vector<sc_in<float>>*{ return new sc_vector<sc_in<float>>(name, 4); }}; This names your ports (very helpful when tracing values) and you don't need to call init() separately.
  14. Last week
  15. hello, i'm new to systemc i want to have a code that initialize 2 2D arrays and perform convolution, what i've done in the header file is sc_vector < sc_vector <sc_in < float >>> in2 sc_vector < sc_vector <sc_in < float >>> w2 in2.init(4); in2[0].init(4) ; in2[1].init(4) ; in2[2].init(4) ; in2[3].init(4) ; w2.init(2); w2[0].init(2); w2[1].init(2) ; my problem is that i want to put values for in2 and w2 2D arrays to test my mehod however i don't know the syntax for this in main.cpp file i get compile errors . Thanks in advance
  16. From the code itself, it's not obvious to me, where the unexpected overload of sc_core::wait(int) is called. Can you try attaching a debugger and break on the exception (catch throw in gdb) and check from the backtrace, where from the exception is thrown?
  17. Ok find the issue. I needed to compile all the .cpp dependencies as well with g++ -I/usr/local/systemc-2.3.3/include -L/usr/local/systemc-2.3.3/lib-linux64/ -lsystemc -lm -o out counter.cpp shifter.cpp testbench.cpp main.cpp
  18. So, I'm trying to compile my main.cpp that includes three modules. For instance I got a module counter with this .h file #include <systemc.h> SC_MODULE(counter) { sc_in<bool> clk; //porta ingresso clock sc_in<bool> load; //porta ingresso load sc_in<bool> clear; //porta ingresso clear sc_in<sc_uint<8> > din; //porta ingresso dato (intero 8 bit) sc_out<sc_uint<8> > dout; //porta uscita dato (intero 8 bit) unsigned int countval; //valore del contatore (intero senza segno) void counting(); //funzione conteggio (il mio processo) SC_CTOR(counter) { //costruttore di counting() SC_METHOD(counting); //costruttore del mio processo attraverso metodo (meglio del thread) sensitive << clk.pos(); //sensibile al fronte del clock, positivo } }; now, when I run the compiler with g++ -I/usr/local/systemc-2.3.3/include -L/usr/local/systemc-2.3.3/lib-linux64/ -lsystemc -lm -o out main.cpp but I got this error /tmp/ccz92lN5.o: In function `counter::counter(sc_core::sc_module_name)': main.cpp:(.text._ZN7counterC2EN7sc_core14sc_module_nameE[_ZN7counterC5EN7sc_core14sc_module_nameE]+0xba): undefined reference to `counter::counting()' How do I fix it?
  19. what you saw in first post is called pure virtual class. It's inherited by derived class where sensitivity list is supplied.
  20. I'm forced to use whatever systemC version that comes with latest VCS version(vcs_vP-2019.06-SP2). Here is healer file: #include "systemc.h" #include "tkn.h" #include "cmod_utils.h" #include <cmod_module.h> // from Dierke model #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <math.h> //#include "global.h" //#include "ISP_Utils.h" #include "ltm.h" #include "ltm.HW_MOD_BA.h" #define CTRL LTM_Ctrl<sc_uint<14>, sc_uint<13>, sc_uint<20>, sc_uint<20> > #define TKN MDA3_tkn<sc_int<2>,unsigned int > class ltm_func: public cmod_module<TKN, unsigned int > { public: sc_fifo_in< CTRL> params_in_fifo; CTRL params; hdr_param hdr; unsigned int pxl_out; virtual bool hasBufferSpace(); virtual bool canSendTkn(); virtual void processRcvdTkn(TKN& tkn); virtual void processTknToSend(unsigned int& tkn); virtual void processParams(); SC_CTOR(ltm_func) { numTknsRcvd=0; numTknsSent=0; SC_THREAD(ingress); dont_initialize(); sensitive << tkn_in_fifo.data_written(); SC_THREAD(egress); sensitive << tkn_in_fifo.data_written() << tkn_out_fifo.data_read(); dont_initialize(); //SC_THREAD(params); //sensitive << params_in_fifo.data_written(); } }; ltm_func.cpp #include "ltm_func.h" bool ltm_func::hasBufferSpace() { return true; } bool ltm_func::canSendTkn() { return this->numTknsRcvd > this->numTknsSent; } void ltm_func::processRcvdTkn(TKN& tkn) { unsigned int Y1; ltm_debug debug; cout << "result before is::: " << pxl_out << endl; LTM_HW_func_BA(tkn.data, &hdr, &Y1, &pxl_out, &debug); cout << "result after is::: " << pxl_out << endl; } void ltm_func::processTknToSend(unsigned int& tkn) { tkn = pxl_out; } void ltm_func::processParams() { while(true){ while (! canSendTkn()) { wait(params_in_fifo.data_written_event()); } params_in_fifo.read(params); wait(); } }
  21. I suggest to move to SystemC 2.3.3, if possible. (The error message indicates, that you seem to be using SystemC 2.3.1). Secondly, can you show the derived class of the fifo as well (including its constructor)?
  22. So you say that rather than stalling in SystemC, I need to wait for a SystemC event generated by the GUI? then the SystemC thread can emit a signal, and the two guys can ping-pong with the signals? It sounds good, thank you. That is, as @David Blacksuggested, I shall use the async_request_update() method from the thread, running SystemC? Is some sample around? in the book and the examples I do not find a call like this.
  23. My case is less complex. I am aware of that this process is not that process, and this scheduler is not that scheduler. My intention is exactly just to stall SystemC at some point of execution, and just to read some variables for displaying it in the GUI. I am interested in sc_time only from the aspect to display it in the GUI. I do not want any other communication, than emitting a message that SystemC stalled, then -- after finishing the GUI update -- to resume it. A kind of breakpoint. In the same way as used in a debugger. To resume, I can ask the thread to send a message. I wonder if I can stall SystemC safely, without interfering with anything. Maybe SC_ZERO_TIME solves the problem; however the simulation itself also uses SC_ZERO_TIME in some cases; so they may interfere; I need to check. I do not want to use non-zero time as it falsifies the simulation time, which is also important.
  24. When implementing some simulation control I usually have the logic as part of a SC_THREAD. Once the thread is active it is save to access all the other data structures as -like @David Black mentioned- SystemC is cooperative multi tasking. Based on the GUI thread you can then decide to run for a certain time, until a certain event, or stop simulation entirely using sc_stop()
  25. The syntax wait(), which calls void sc_core::wait(void), assumes a static sensitivity list, but you have not setup a static sensitivity list that I can see. Also, you are sending and immediate notification, which I somehow doubt you really grasp the implication thereof. You need to learn about the fundamentals of the SystemC scheduler to get this working correctly.
  26. Keep in mind that SystemC's kernel is not threadsafe. SC_THREAD and SC_METHOD processes are completely different animals than OS threads as well. You can use the async_request_update() method to interface into SystemC from the outside. From the inside you can of course stall everything in the SystemC side because it is cooperative multitasking system. In either case, you will need to use appropriately setup mutex to protect shared resources. Due to differences in the concept of time (simulated vs real), you will also likely need to use mailboxes for communication. You might also what to consider scheduling events to happen at the end of a delta cycle (ie. event.notify(SC_ZERO_TIME) or perhaps even a non-zero time in the future.
  27. As I mentioned in a previous post, I want to display the state of the simulated object in a GUI thread, while the simulation thread is suspended. Can I do that in an elegant way? I mean, that if I am after receiving my event, the event queue is empty, so the simulation stops immediately. If I suspend it before triggering the event, then the event queue is empty again; so my waiting terminates again. If I trigger the event first, then I stop at a wait(resume-event), the simulation goes to serve the event first, I wanted to stop at; and comes back to my wait(resume-event), and since the event queue is empty, stops again. I guess I need to forcefully prevent taking out the event before the GUI thread returned a resume_event. How can I do that?
  28. I'm new to systemC. My code needs to process some data after reading it from fifo. So I created sc_event tkn_in_fifo_data_written. However compiler produces this error message: Can someone please tell me what's wrong? Also perhaps error message should say something else? template <class T, class M> class cmod_module: public sc_module { public: sc_fifo_in< T > tkn_in_fifo; sc_fifo_out< M > tkn_out_fifo; sc_event tkn_in_fifo_data_written; int numTknsRcvd; int numTknsSent; BAYER_TYPE *bayer_444; //virtual void ingress(); //get tkn in void ingress() { T tkn; while(true) { while(! hasBufferSpace() ) { // do something } tkn_in_fifo.read(tkn); processRcvdTkn(tkn); numTknsRcvd++; cout << name() << " " << numTknsRcvd << " tkns receivedd!" << endl; tkn_in_fifo_data_written.notify(); wait(); } } void egress() { M tkn; cout << name() << " " << numTknsSent << " tkns sent!" << endl; while(true){ while (! canSendTkn()) { cout << "waiting!" <<endl; //wait(tkn_in_fifo.data_written_event()); wait(tkn_in_fifo_data_written); } processTknToSend(tkn); tkn_out_fifo.write(tkn); numTknsSent++; cout << name() << " " << numTknsSent << " tkns sent!" << endl; wait(); } } virtual bool hasBufferSpace() = 0; virtual bool canSendTkn() = 0; virtual void processRcvdTkn(T& tkn) = 0; virtual void processTknToSend(M& tkn) = 0; };
  1. Load more activity
×
×
  • Create New...