Jump to content


  • Content Count

  • Joined

  • Last visited

  • Days Won


Everything posted by AmeyaVS

  1. Hi @rayzekus, Can you post details about your build environment? (e.g: Which OS and Which Compiler and also the configuration used to Create SystemC library) As per the info available here. It looks like the data race condition is getting triggered. I would not trust the libraries when utilizing any C based API's from C++. I also tried your code locally on my system, and even I am getting the random number generated. Also you are missing the following headers in your files: // In File sc_main.cpp // For srand declaration. #include <cstdlib> // For time() #include <ctime> // In file foo_drvr.h // For rand() function. #include <cstdilb> I would suggest you look into another random number generator such as boost::random, or if you are on Linux System you can also look into /dev/random or /dev/urandom files which are used for these purposes. Best Regards, Ameya VIkram Singh
  2. Hello @R.Adiga, I have developed something similar you can have a look here: https://github.com/AmeyaVS/trace-ninja (Still under development but basic functionality implemented for getting traces). If you are developing on Linux I would suggest of having a look here: https://github.com/namhyung/uftrace , which offers much better tracing capabilities and lower latencies. Both the methodologies are dependent on using GCC toolchain for building the SystemC library. The only advantage you get on using my project is that it would work under Cygwin/Windows with GCC compiler (Not tested under MinGW). Regards, Ameya Vikram Singh
  3. Hi @darshanKM, This is a discussion forum, not your homework/assignment discussion platform. It would be better if you could show what you came up with and discuss anything that you are not able to understand. I would recommend exploring the SystemC documentation directory(i.e. docs directory when you would have installed the SystemC library or when you downloaded the SystemC library sources.). Regards, Ameya Vikram Singh
  4. Hello @yosri ben salah, As far as my experience is OpenCV image processing algorithms cannot be directly translated to synthesized design. It would involve manual translation of the algorithms in it's current form, but the work is progressing as mentioned here about utilizing the FPGA's. Regards, Ameya Vikram Singh
  5. Hi @Roman Popov, It is quite possible to have multiple installations of SystemC library. This is what I have in my development environment setup: # SystemC debug installation directory. $HOME/apps/systemc-2.3.1a_debug # SystemC release installation directory. $HOME/apps/systemc-2.3.1a_release I currently use a shell script to switch between the environments but it is quite easy to add the condition in CMakeLists.txt/FindSystemCLanguage.cmake script to support such behaviour. Regards, Ameya Vikram Singh
  6. Hello @katang, You need to declare the method as a friend method and the definition has to be moved to corresponding source file. For e.g.: // scMWE.h #ifndef scMWE_h #define scMWE_h #include <systemc> #include <iostream> struct Transfer_Type { int Select; int Content; friend std::ostream& operator << (std::ostream& os, const Transfer_Type& I); //< Declaration for the friend method. }; SC_MODULE(scMWE) { scMWE(sc_core::sc_module_name nm); sc_core::sc_fifo<Transfer_Type> from; }; #endif scMwe.cpp: // scMWE.cpp #include "scMWE.h" // Definition for the friend method. std::ostream& operator << (std::ostream& os, const Transfer_Type& I) { return os; } Hope it helps. Regards, Ameya Vikram Singh
  7. Hello @katang, Can you provide the minimal code which reproduces this behaviour? Regards, Ameya Vikram Singh
  8. @yosri ben salah, Unable to open the attachment. Kindly provide the necessary context for the attachment. What exactly is it providing for this discussion? Regards, Ameya Vikram Singh
  9. Hello @Roman Popov, You can have a look here: Hope it helps. Regards, Ameya Vikram Singh
  10. Hello @katang, In SystemC the parent and child relationship is intrinsically handled by the Kernel. Kindly refer the SystemC LRM Section for more details. Their should be no differences in stack and heap allocated objects. As for the last part it is not very clear what you are asking. Can you elaborate more on the last part? Regards, Ameya Vikram Singh
  11. Hello @katang, You can use: sc_core::sc_in<bool> clk; in your modules and bind them in the top module as a normal sc_in/out port binding operation. e.g: // In top module. // Clock is the system clock object. some_module_having.clk(Clock); some_other_module_having.clk(Clock); some_another_module_having.clk(Clock); Each of the modules will have public port interface mentioned above. Regards, Ameya Vikram Singh
  12. Hello @katang, The error spawns from not specifying the namespace resolution correctly. Following code compiles without errors: NAME.h: #ifndef NAME_H_ #define NAME_H_ #include <systemc> SC_MODULE(NAME) { SC_CTOR(NAME); }; #endif // NAME_H_ NAME.cpp: #include "NAME.h" SC_HAS_PROCESS(NAME); NAME::NAME(sc_core::sc_module_name nm) //< Added sc_core namespace resolution. : sc_core::sc_module(nm) //< Added sc_core namespace resolution. {} Regards, Ameya Vikram Singh
  13. Hello @katang, It seems the macro NAME has not been defined. From the book they have mentioned about the file "NAME.h". There recommendation on providing simpler and cleaner declarations. Regards, Ameya Vikram Singh
  14. Hello @yosri, This is mostly a discussion forum. In-case you need help while having issues in implementing your design, then do post your queries here. While assuming members to straight away help you in your homework is too much to ask. Kindly show us some research input about the project and some implementation that you have written, and facing issues with them. It would be unwise to comment since one can have multiple implementation of the said requirement as it is too vague, plus show us some due diligence in researching about the topic you are working on. Regards, Ameya
  15. Hello @katang, Here is a modified source for Bit_Adder.h which emulates the delay between component/modules: #ifndef BIT_ADDER_H_ #define BIT_ADDER_H_ #include <systemc> #include <queue> template<typename T = bool> SC_MODULE(BIT_ADDER) { public: sc_core::sc_in<T> a, b, cin; sc_core::sc_out<T> sum, cout; SC_CTOR(BIT_ADDER): a("a") , b("b") , ci("cin") , sum("sum") , cout("cout") , delay(sc_core::sc_time(2, sc_core::SC_NS)) , eqSum("eqSum") , eqCarry("eqCarry") { SC_METHOD(do_add); sensitive << a << b << cin; dont_initialize(); SC_METHOD(drive_sum); sensitive << eqSum; dont_initialize(); SC_METHOD(drive_carry); sensitive << eqCarry; dont_initialize(); } void do_add(void) { T valA = a.read(); T valB = b.read(); T valCi = cin.read(); T tmpCo = (valA & valB) | (valB & valCi) | (valA & valCi); T tmpSum = valA ^ valB ^ valCi; coq.push(tmpCo); sumq.push(tmpSum); eqSum.notify(delay); eqCarry.notify(delay); } void drive_sum(void) { T valSum = sumq.front(); sum.write(valSum); sumq.pop(); } void drive_carry(void) { T valCarry = coq.front(); cout.write(valCarry); coq.pop(); } private: sc_core::sc_time delay; sc_core::sc_event_queue eqSum; sc_core::sc_event_queue eqCarry; std::queue<T> sumq; std::queue<T> coq; }; // BIT_ADDER #endif // BIT_ADDER_H_ This should be drop-in replacement for your module. One thing you will have to change is the declaration where it would change something from: BIT_ADDER bitAdder to: BIT_ADDER<sc_logic> bitAdder Let us know if you need further clarification on how the module behavior is modeled. Regards, Ameya Vikram Singh
  16. Hello @katang, The way the SystemC library is configured by default it doesn't create system threads(OS threads). That is it uses "user-space library" for creating the notion of parallel execution of threads(in user-space). This depends on the platform and configuration option provided to SystemC kernel while building it. e.g: In Windows under Visual Studio it uses the fiber user space threading library for execution of SC_THREAD's/CTHREAD's. In UNIX/Linux you can use QuickThreads (User-space threading) which is selected by default while running the configuration option for SystemC library. As per the OS it only sees one thread of execution for the whole simulation. Note: In-case you have configured the SystemC library with pthreads in Linux/UNIX like environment then the debugger will show you multiple threads of execution. Even in that scenario you can look here for reference on gdb and multi-threaded debugging, by default on most Linux systems the GDB suspends other threads making it easier to narrow down thread racing condition(the OSCI SystemC kernel sceduler implementation is already synchronized with the main execution thread of the SystemC application). As per your question The answer is: Yes it is possible to run the SystemC simulation stepwise while is debugging mode. In-case you need more clarification let us know. Regards, Ameya Vikram Singh
  17. Hello @sumit_tuwien, If you can elaborate the use-case more, it would be better. It seems you are trying to implement your own channel interface, if my assumptions are right. If you are just looking for custom datatype which you need to push through the sc_in/out interface then this might not be required at all. Let us know. Regards, Ameya Vikram Singh
  18. Hello @sumit_tuwien, You can declare the sc_trace method as a friend function. Here is a small sample of what it might look like: # ifndef ALLESGUTE_H_ # define ALLESGUTE_H_ # include <cstdint> # include <systemc> template < typename T > class allesGute final : public sc_core::sc_object { private : T vData ; T someOtherVData ; public : explicit allesGute(const char* name_) : sc_core::sc_object { name_ } , vData { 0 } {} const char* kind() const override { return "allesGute" ; } // Helpers : T read() const { return vData ; } void write(const T& var_) { vData = var_ ; } ~allesGute() final = default ; allesGute(const allesGute& other) = delete ; allesGute& operator=(const allesGute& other) = delete ; allesGute(allesGute&& other) = delete ; allesGute&& operator=(allesGute&& other) = delete ; // Friend function declaration. // Don't inline the definition since you might face issues later due to aggressive compiler optimizations. friend void sc_trace(sc_core::sc_trace_file *tf, const allesGute<T>& tObj, const std::string& name); }; // Friend function definition. template<typename T> void sc_trace(sc_core::sc_trace_file *tf, const allesGute<T>& tObj, const std::string& name) { // Assuming the type T is traceable type. // If not then you'll have to implement the sc_trace friend function for type T. sc_trace(tf, tObj.vData, name + "_vData"); sc_trace(tf, tObj.someOtherVData, name + "_someOtherVData"); } # endif Let me know if this helps. Regards, Ameya Vikram Singh
  19. Hello @sumit_tuwien, Is the allesGute template class derived from sc_object? If yes, then it will be straightforward to find object using sc_find_object. While instantiating the allesGute object you would be providing the name (object name during construction), which will be registered with the SystemC kernel at the right hierarchical level. Hope this helps. Regards, Ameya Vikram Singh
  20. Hello @SRachuj, Please find the comment in-line: while (1) { sc_time t; std::cout << sc_get_curr_simcontext()->next_time(t) << ": " << t << std::endl; //< It hits the call to next_time(t) when the simulation has ended or did not even begin. sc_start(sc_time(1, SC_NS)); sleep(1); } You are calling the next_time(t): when the simulation has not even started so no events would be scheduled in the SystemC kernel. In the next pass once you have started the simulation for 1 ns. The simulation kernel will delete all the events which are scheduled after 1 ns. Try running putting the code in the module B. void t() { sc_time t; //< Added the sc_time state variable. while (1) { wait(in.value_changed_event()); std::cout << sc_get_curr_simcontext()->next_time(t) << ": " << t << std::endl; //< Added the next_time(t) in Module B. std::cout << "got: " << in.read() << std::endl; } } Regards, Ameya Vikram Singh
  21. Hello @makiso, The error message it-self is providing you hint about the port interface not bound. From chol.h (checkout the inline comments): ... SC_MODULE (chol) { public: // Inputs sc_in_clk clk; //< This probably is port_0 sc_in<bool> rst; //<This probably is port_1 sc_in<sc_fixed<16,10, SC_TRN, SC_WRAP> > chol_in_data[3][3] ; //< port_2 to port_11 // Output sc_out<sc_fixed<16,10, SC_TRN, SC_WRAP> > chol_out_data[3][3] ; //< port_12 to port_20 /* F */ void chol_main ( void ); //sc_fixed<32,16, SC_TRN, SC_WRAP> cholesky(sc_fixed<32,16, SC_TRN, SC_WRAP> *); // Constructor SC_CTOR (chol): // have initializer list here for your interfaces to help you in debugging the code. // e.g.: chol_out_data("chol_out_data") { SC_CTHREAD (chol_main, clk.pos() ); reset_signal_is(rst, false) ; sensitive << clk.pos(); } // Destructor ~chol() {} }; ... This following binding operation is incomplete(see commment inline): Note: Refer here for initialize list(checkout the example use-case): https://www.doulos.com/knowhow/systemc/tutorial/modules_and_processes/ Try out these changes and let us know if it helped you. Regards, Ameya Vikram Singh
  22. Hello @SysC_Lrnr, @ralph.goergen is right you need to use sc_vector's for SystemC objects. Also use C++ built-in datatype's (bool, char, short int, int, etc.) to have better performance and better compiler optimizations. For small designs you would not feel the need but as you would add complexity to your SystemC simulation models you'll start noticing the difference. Regards, Ameya Vikram Singh
  23. Thank you @ralph.goergen for providing the SystemC LRM reference. Regards, Ameya Vikram Singh
  24. Hello @katang, It would be better that you start here from this tutorial: https://www.doulos.com/knowhow/systemc/tutorial/modules_and_processes/ Then refer the earlier post for delay simulation: Checkout my reply to the post which references this: http://workspace.accellera.org/Discussion_Forums/helpforum/archive/msg/msg?list_name=help_forum&monthdir=200803&msg=msg00061.html Finally check my comment on how to do away with the SC_THREAD to improve performance of the simulation: in-case you have more questions or need more elaboration on the answer let me know. Regards, Ameya Vikram Singh
  • Create New...