Jump to content

All Activity

This stream auto-updates

  1. Today
  2. Last week
  3. Assuming your processes only write on the posedge clock, you could use an sc_buffer<bool> and make the last process sensitive to the buffer instead of the clock. Every time the queue is written, also write to the buffer (true). Since all the other processes will be enabled at the posedge clock, the buffer will not be processed until one delta-cycle after the clock has been processed. You would probably want to create a simple wrapper for the queue and processing. I suggest using an unbounded tlm_fifo<T> for the queue.
  4. This is not correct. since it is a sequence, it belongs to object class. So you should create it like an object class. reg_bitbash = reg_bit_bash_seq::type_id::create("reg_bitbash");
  5. Earlier
  6. Thanks a lot @AmeyaVS @Eyck. I will try to use SC in the same OS.
  7. Hi, As part of our development @AsFigo we developed a custom UVMLint for BCL and the results can be found at https://asfigo.blogspot.com/2024/03/customizing-uvmlint-for-ieee-18002-base.html Happy to share more details if anyone is interested. Ajeetha AsFigo
  8. Hi Eyck, thank you for the hint. Other processes may or may not write to the queue every cycle. Do you have in mind some mechanism which I could use to be sure that send_m is called when all of those who (potentially) write to the queue have written?
  9. There is no way to enforce an ordering on thread or method invokation. One way to achieve this is to make send_m sensitive on the queue (using sc_fifo or tlm_utils::peq*) and let the other processes write into this queue.
  10. They have been further developed and we moved them to github: https://github.com/Minres/TGC-VP https://github.com/Minres/HIFIVE1-VP
  11. Hello @Allen yang, As responded by @Eyck, it might work. But I would not recommend it. You might hit issues due to incompatibilities in OS, system libraries, compiler generated output, etc. You might get very hard to debug issues or random simulation crashes. It's better to recompile for the target platform if you can to have a chance of better compatibility. Regards, Ameya Vikram Singh
  12. Hi! I need a help with SystemC processes. If I have the design with several SC_THREADs/METHODs which are sensitive to the clk.posedge_event() (some of them are using non blocking transport), is there a way that we ensure one SC_METHOD to be scheduled "last" among them? All other threads should put some data to the queue, and then SEND thread should send it. Would this approach (with wait(SC_ZERO_TIME)) help? void send_m() { // should be called last wait(clk.posedge_event()); wait(SC_ZERO_TIME); // send things from the queue }
  13. Usually this does not work. There are quite a few dependenies to OS and compiler libraries which prevent this. If you build systemc as a shared library there is some chance to get it work.
  14. Hi, Everyone, I have download SC on github and compile install on el7 which runs well. I want to use formmer compile SC result and copy the sc.a and include to my new el8 OS. However, I get undefined error on new OS. ../include/systemc/sysc/datatypes/int/sc_uint_base.h:848: undefined referece to `sc_dt::sc_uint_base::to_string() const` Here's my quenction, can we reuse the compile result of other OS?
  15. Hi David Black, Thankyou for your response, I have good knowledge on basic UVM RAL and my requirement is about RAL implementation especially "accessing register from more than one master". From your response i got to know that is being covered as part of Doulos UVM Adopter course. Can you please share the course and Price details , i tried sending a enquiry form to doulous from link " https://www2.doulos.com/forms/enquiry " but it didn't work for some reason.
  16. #include <systemc.h> #include <pthread.h> #include <unistd.h> using namespace std; class ThreadSafeEventIf : public sc_interface { virtual void notify(sc_time delay = SC_ZERO_TIME) = 0; virtual const sc_event &default_event(void) const = 0; protected: virtual void update(void) = 0; }; class ThreadSafeEvent : public sc_prim_channel, public ThreadSafeEventIf { public: ThreadSafeEvent(const char *name = ""): event(name) {} void notify(sc_time delay = SC_ZERO_TIME) { this->delay = delay; async_request_update(); } const sc_event &default_event(void) const { return event; } protected: virtual void update(void) { event.notify(delay); } sc_event event; sc_time delay; }; sc_event GenScEvent; sc_event workingFinishEvent; // finish event int workingFlag = 0; // maybe dnot need a lock SC_MODULE(Foo) { public: SC_CTOR(Foo) { SC_THREAD(main); SC_METHOD(eventTriggered); sensitive << threadSafeEvent; dont_initialize(); } private: void main() { //extra forever thread to avoid simulation exit while (1) { usleep(1*1000*1000); // check if there is any instruction every one sec. wait(SC_ZERO_TIME); if(workingFlag){ // check working wait(workingFinishEvent); // wait the working finish } usleep(1*1000*1000); } } void eventTriggered() { // printf("Foo: Got event from pthread \n"); GenScEvent.notify(); } public: ThreadSafeEvent threadSafeEvent; }; void* PollingThread(void* arg) { int cnt = 0; while (1) { cnt++; printf("[POLL]: %d: Before generating event from PollingThread \n", cnt); usleep(3*1000*1000); Foo *foo = (Foo*)(arg); foo->threadSafeEvent.notify(); printf("[POLL]: %d: Event notified from PollingThread \n", cnt); } }; class sc_top : public sc_module { private: SC_HAS_PROCESS(sc_top); public: sc_top(sc_module_name name="SCTOP"): sc_module(name) { SC_THREAD(processing_thread); } void processing_thread(); }; void sc_top::processing_thread() { int cnt =0; while (1) { printf("[PROC]: processing_thread called \n"); cout << "[PROC]: Wait GenScEvent time: " << sc_time_stamp(); wait(GenScEvent); workingFlag = 1; cnt++; wait(10, SC_SEC); // advance simulation time cout << "[PROC]: Got and Finish "<<cnt << " GenScEvent time: " << sc_time_stamp(); workingFinishEvent.notify(); workingFlag = 0; } } int sc_main(int argc, char *argv[]) { Foo foo("foo"); sc_top u_sc_top("u_sc_top"); pthread_t thread; pthread_create(&thread, NULL, PollingThread, &foo); sc_start(); return 0; } this example is a better one. it won't destory simulation time.
  17. My use-case is in `SC_METHOD` or `SC_(C)THREAD` if exception caught I can see the ori stack trace with c++ not rethrow or caught by `sc_report`. The stack trace isn't my exception. I don't want to use `catch throw` to get stack trace which I really need.
  18. hi yaohe, I understand your question and I met same problem too. We want the simulation keep alive and wait asyn events, but the extra SC_THREAD "main"(as you said) destroy simulation time. Do you solve this problem now? Or I hope the example blew can solve it: #include <systemc.h> #include <pthread.h> #include <unistd.h> using namespace std; class ThreadSafeEventIf : public sc_interface { virtual void notify(sc_time delay = SC_ZERO_TIME) = 0; virtual const sc_event &default_event(void) const = 0; protected: virtual void update(void) = 0; }; class ThreadSafeEvent : public sc_prim_channel, public ThreadSafeEventIf { public: ThreadSafeEvent(const char *name = ""): event(name) {} void notify(sc_time delay = SC_ZERO_TIME) { this->delay = delay; async_request_update(); } const sc_event &default_event(void) const { return event; } protected: virtual void update(void) { event.notify(delay); } sc_event event; sc_time delay; }; sc_event GenScEvent; sc_event workingFinishEvent; // finish event int workingFlag = 0; // maybe dnot need a lock SC_MODULE(Foo) { public: SC_CTOR(Foo) { SC_THREAD(main); SC_METHOD(eventTriggered); sensitive << threadSafeEvent; dont_initialize(); } private: void main() { //extra forever thread to avoid simulation exit while (1) { usleep(1*1000*1000); // check if there is any instruction every one sec. wait(SC_ZERO_TIME); if(workingFlag){ // check working wait(workingFinishEvent); // wait the working finish } usleep(1*1000*1000); } } void eventTriggered() { // printf("Foo: Got event from pthread \n"); GenScEvent.notify(); } public: ThreadSafeEvent threadSafeEvent; }; void* PollingThread(void* arg) { int cnt = 0; while (1) { cnt++; printf("[POLL]: %d: Before generating event from PollingThread \n", cnt); usleep(3*1000*1000); Foo *foo = (Foo*)(arg); foo->threadSafeEvent.notify(); printf("[POLL]: %d: Event notified from PollingThread \n", cnt); } }; class sc_top : public sc_module { private: SC_HAS_PROCESS(sc_top); public: sc_top(sc_module_name name="SCTOP"): sc_module(name) { SC_THREAD(processing_thread); } void processing_thread(); }; void sc_top::processing_thread() { int cnt =0; while (1) { printf("[PROC]: processing_thread called \n"); cout << "[PROC]: Wait GenScEvent time: " << sc_time_stamp(); wait(GenScEvent); workingFlag = 1; cnt++; wait(10, SC_SEC); // advance simulation time cout << "[PROC]: Got and Finish "<<cnt << " GenScEvent time: " << sc_time_stamp(); workingFinishEvent.notify(); workingFlag = 0; } } int sc_main(int argc, char *argv[]) { Foo foo("foo"); sc_top u_sc_top("u_sc_top"); pthread_t thread; pthread_create(&thread, NULL, PollingThread, &foo); sc_start(); return 0; }
  19. Hi BR, I noticed that the two paths at minres are 404 errored now. Is the github path the replicate of that? https://github.com/vherdt/riscv-vp/tree/master Best Regards, User 128
  20. The difference between sc_buffer and sc_signal is that sc_buffer<T>::write issues an event on every write; whereas, sc_signal<T>::write only issues an event if the value changes (e.g., from 0 to 1 or 1 to 0). I would have to see all your code (preferably on EDA playground) to understand the issue.
  21. Something like the following might be a clue... uvm_reg regs[$]; regmodel.get_registers(regs); foreach( regs[i] ) begin `uvm_report_info("Register",regs[i].get_name()) end
  22. Hello @Allen yang, It is possible to get a stack trace, but then again what is your use-case? Regards, Ameya Vikram Singh
  23. Hi @AmeyaVS, When I try `vector::at` in `SC_METHOD` or `SC_(C)THREAD`, the stack can't be show. I try to rewrite `sc_except.cpp::sc_handle_exception`, it didn't work. Can you help me figure out this? Regards, Allen
  24. You could setup the masters to access through a common agent and use the lock/unlock methods in the sequence. This something I teach in Doulos UVM Adopter course.
  25. SystemC is not designed to allow more than one sc_main to run. If you want more than one kernel to run, you will need to launch a separate OS process and use IPC. You will probably also need to learn how to use the new sc_suspend_all method and its cousins from section 4.6.3 in IEEE-1666-2023. This also requires you to use SystemC 3.0 (released just over a week ago on March 29th, 2024) and C++17. async_request_update can then be used to resume. Please note this is an advanced topic and requires have a solid grasp of SystemC simulation semantics including the subtle differences between SystemC processes (SC_THREAD and SC_METHOD) and OS processes vs OS threads. [Hint: SystemC is mostly not OS thread-safe; hence, the need for async_request_update and the suspend mcchanisms.]. You will also need a strong understanding of software concurrency including thread_local variables, std::mutex, std::lock_guard, and std::atomic. In other words, you need to be a proficient Modern C++ programmer. Hacking, googling, and even AI won't do the job.
  26. Hello @Allen yang, You could try removing the catch all block itself, so that the exceptions is thrown from the sc_main method. Regards, Ameya Vikram Singh
  27. Hi @AmeyaVS, Thank you for your help. Do you mean that I should rewrite `sc_main_main.cpp` by myself fixing `catch(...) ...` code ? Can I just use code below? catch( ... ) { // don't translate other escaping exceptions }
  1. Load more activity
×
×
  • Create New...