Jump to content

Philipp A Hartmann

  • Content Count

  • Joined

  • Last visited

  • Days Won


Everything posted by Philipp A Hartmann

  1. There is no builtin support for custom-sized floating point types in SystemC. An open-source C++ bfloat16 implementation can be found here: http://half.sourceforge.net. I would expect that this works more or less out of the box in SystemC (maybe you need to implement a custom sc_trace overload). Hope that helps, Philipp
  2. Hi Khushi, just adding to Eyck's answer, the "default" extensions in SystemC 2.3.3 are the following two implementation defined classes: tlm::tlm_endian_context tlm_utils::instance_specific_extension_carrier Greetings from Duisburg, Philipp
  3. Please be aware, that an sc_and_event_list does not imply that the events in the list are triggered at the same time. I would suggest to keep the only the clock sensitivity and act on the triggers in the body of the method instead: SC_METHOD(func2); sensitive << clk.pos(); dont_initialize(); // ... void func2() { if( nreset.posedge() ) { // nreset went high in this clock cycle // ... } } Alternatively, you can be sensitive to nreset.pos() and check for clk.posedge() (as a consistency check), if you don't have anything else to do in the body of the method. With this approach, you might be able to avoid unnecessary triggers of the method. Side note to Eyck: There's a small typo in the example above, which should should use "&=" to append to an sc_event_and_list. ev_list &= nreset;
  4. Port-to-port binding is not tracked by SystemC after elaboration is completed. You can try to restore (or at least approximate) the mapping yourself by checking "overlap" in the get_interface() results across ports and the hierarchical relationship between the ports' parent objects.
  5. Changing the default writer policy requires to be set consistently throughout the whole application, which might be difficult with third-party infeeds. Since SystemC 2.3.2, you can also set the environment variable SC_SIGNAL_WRITE_CHECK=CONFLICT, which effectively enables SC_MANY_WRITERS at runtime (for all signals, though). Quoting the release notes: - [2.3.2] Add support for SC_SIGNAL_WRITE_CHECK=CONFLICT Instead of disabling all runtime signal write checks via the environment setting SC_SIGNAL_WRITE_CHECK=DISABLE, setting the variable to SC_SIGNAL_WRITE_CHECK=CONFLICT allows detecting conflicting writes to a signal within a single evaluation phase (see INSTALL).
  6. Won't you have multiple drivers anyway as soon as you have a second initiator accessing your transactor? I would recommend to switch your pin interface to use sc_export<sc_signal_*_if<T> > instead of plain signal ports and bind signals with an SC_MANY_WRITERS policy internally. These signals also have constructors that allow initialization to a non-zero value without triggering an event at the start of simulation.
  7. If your company is an Accellera member already, I encourage you to join the SystemC language working group. Otherwise, you can find some documentation about the changes in the RELEASENOTES file of each release (although this particular feature seems to miss an entry :-/).
  8. The match will occur (almost) at the "correct" point in time during the simulation. However, if you sample the value from an unrelated process, there might be some process evaluation ordering dependency (i.e. whether the update_method had already been run). It depends on your requirements, whether this might be an issue. If you do the checks outside of the simulation, i.e. between sc_start calls, you would need to complete the deltas (as per the loop sketched above) before every check. You cannot call sc_start during end_of_simulation.
  9. I don't fully understand the question? My snippet above runs all remaining delta cycles at the current time without advancing the time any further. You can wrap your original sc_start call with the loop in a small helper function (e.g. sc_start_including_deltas(...) , if you find yourself copying the snippet too often.
  10. You can run the delta cycles at the current time until everything settles: while( sc_pending_activity_at_current_time() ) sc_start( SC_ZERO_TIME );
  11. sc_get_curr_process_kind´╗┐() is non-standard. You can use something like this: void stop_now() { // Assuming: sc_set_stop_mode( SC_STOP_IMMEDIATE ); to avoid running other processes? sc_core::sc_stop(); auto p = sc_get_current_process_handle(); bool is_thread_or_cthread = p.valid() && p.proc_kind() != SC_METHOD_PROC_; if( is_thread_or_cthread ) sc_core::wait(); }
  12. Generally speaking, it would be a bug if the whole SystemC simulation is hanging inside a timed wait. I suspect that you have in face a separate (set of) process(es) that are running indefinitely without advancing SystemC time (beyond these 4 ns). You can try to find the culprit by setting a breakpoint in a debugger on the affected line above, continue the simulation for a bit and then break, checking in which SystemC process you end up. Maybe you are missing a similar "wait" on the consumer side? Hope that helps, Philipp
  13. Unfortunately, there is currently no way to obtain the name of the affected signals/variables in this message. You can suppress the warning via: sc_core::sc_report_handler::set_actions(sc_core::SC_ID_TRACING_VCD_DUPLICATE_TIME_, sc_core::SC_DO_NOTHING);
  14. In SystemC 2.3.2 and later, you can use the sc_event::triggered() member function to query, if an event was triggered (and thus might have caused your method to run): if( event1.triggered() ) { std::cout << "event1 got triggered"; } if( event2.triggered() ) { std::cout << "event2 got triggered"; } Please note that if both events were triggered in/for the same evaluation phase, your method might well be run only once.
  15. I gave it a shot locally and noticed that there are indeed quite some compiler warnings due to differences between __declspec(...) and __attribute__((visibility(...))). Most of these warnings can be ignored for now, but are certainly annoying. Additionally, you need to explicitly mark the following with SC_API as well: // src/sysc/communication/sc_port.h template <class IF> class SC_API sc_port_b template <class IF> class SC_API sc_port // src/sysc/communication/sc_prim_channel.h class SC_API sc_prim_channel_registry // src/sysc/communication/sc_signal.h template< class T, sc_writer_policy POL > class SC_API sc_signal_t template< class T, sc_writer_policy POL > class SC_API sc_signal // src/sysc/datatypes/sc_proxy.h template <class X> class SC_API sc_proxy // src/sysc/datatypes/sc_proxy.h extern "C" SC_API int sc_main(int argc, char* argv[]) // src/sysc/utils/sc_temporary.h template<class T> class SC_API sc_vpool For compiling SystemC itself with -fvisibility=hidden, some further changes to the .cpp files are needed. And some of the above changes might break the Windows DLL support. But for me, the above changes work with the examples in the SystemC distribution (i.e. "gmake check CXXFLAGS='-fvisibility=hidden"). Long story short: The feature to SystemC build models with limited symbol visibility will require more changes and testing. I will forward this topic to the Language Working Group for further discussion.
  16. I'm not suggesting to export all of your classes, but the SystemC class (templates) used in your code. By reusing the macro annotations for Windows, you can try changing src/sysc/kernel/sc_cmnhdr.h and redefine SC_API for your platform # define SC_API __attribute__((visibility("default"))) (with this, you can even try building SystemC itself with -fvisibility=hidden).
  17. This is likely caused by the "hidden" RTTI information, messing with dynamic_cast and typeid usage in SystemC, see e.g. https://gcc.gnu.org/wiki/Visibility. You at least need to export all SystemC (template) classes from your shared library. Greetings from Duisburg, Philipp
  18. These classes are templates themselves. You need to pass the type of the values as parameter, for example tlm_fifo< std::array<int,4> > // a FIFO sending 4-element arrays of integers /Philipp
  19. Use an std::vector or std::array as value type in your FIFO instead of a C-style array.
  20. The INSTALL notes currently say the following about the SC_CPLUSPLUS preprocessor switch (emphasis mine): This means, that you can explicitly opt-out of some SystemC features, that would generally be supported by your compiler's C++ language support. Selecting a newer C++ standard version than supported by your compiler (setup) will typically not work - as you have experienced. That said, adding a preprocessor flag on the compiler command-line does not affect the language mode of the compiler. How to switch your compiler to C++17 mode is outside of the scope of SystemC. Your compiler (version) seems to require the -std=c++17 switch to enable this mode. The SC_CPLUSPLUS flag is then not needed as it will be set automatically to the selected version. Hope that helps, Philipp
  21. The issue is likely caused because you access a port (via -> or for example calling functions like .read()) already inside the module constructor. You should only access ports after binding has completed, this means from within a SystemC process or in end_of_elaboration() / start_of_simulation() callbacks. Hope that helps, Philipp
  22. From my understanding, the "before_end_of_elaboration" limitation got fixed in SystemC 2.3.1 (and a regression introduced by this was fixed in 2.3.2/2.3.3). /Philipp
  23. Yes, TLM sockets are dependent on SystemC and can only be used inside of a SystemC module. This is because they are implemented via SystemC ports/exports, which can itself only be instantiated in SystemC modules as per the SystemC standard. If you want to bridge into a pure C++ model, you can pass the corresponding interface pointers into your C++ model via your own code (via get_interface() after elaboration). This way, you only depend on sc_interface from SystemC (which is a base class of all SystemC/TLM interface classes) inside your C++ model. I'm not sure, what you are trying to achieve, though. Why can't you use SystemC (which is just C++ at the end anyway)? Greetings from Duisburg, Philipp
  24. SystemC 2.3.2 (and later) does support a query whether an event was triggered in the previous delta cycle (or immediately in the current evaluation cycle). This is similar to the sc_signal<>::event() function. With this, you can ask every element in your array, whether it was triggered and may have caused a wakeup of the process. Of course, multiple events can have triggered simultaneously and will only cause a single wakeup of the process. for( const auto ev& : e ) { if ( ev.triggered() ) { // ... } } Hope that helps, Philipp
  25. Thanks! I can reproduce the behavior and verified that removing the dynamic sensitivity in sc_thread_process::kill_process fixes the issue: void sc_thread_process::kill_process(sc_descendant_inclusion_info descendants ) { // ... if ( sc_is_running() && m_has_stack ) { m_throw_status = THROW_KILL; m_wait_cycle_n = 0; remove_dynamic_events(); // <-- add this line to avoid the exception simcontext()->preempt_with(this); } // ... } I'm not sure, if it is necessary to do the same for the static sensitivity. At least I haven't come up with a similar scenario, where the error is actually "incorrect".
  • Create New...