Karthik Rao Posted April 12, 2018 Report Share Posted April 12, 2018 (edited) Hello Everyone, In the existing code, the width of the WdwType is defined as shown below. Here WDW_SIZE is a macro. typedef sc_bv<WDW_SIZE> WdwType; But I want the width to be configurable. So I have declared a structure variable of datatype unsigned int and want to do the same. Can anybody please let me know how this can be done? Thank you. Regards Karthik. Edited April 12, 2018 by Karthik Rao Added Regards message. Quote Link to comment Share on other sites More sharing options...
Eyck Posted April 12, 2018 Report Share Posted April 12, 2018 Hi Karthik, you need to provide a constant expression as template argument so that it can be evaluated at compilation time. See http://en.cppreference.com/w/cpp/language/constant_expression. and http://en.cppreference.com/w/cpp/language/template_parameters#Template_non-type_arguments. So it would need to be written as: const int WDW_SIZE = 2; Best regards -Eyck Karthik Rao 1 Quote Link to comment Share on other sites More sharing options...
DS1701 Posted April 13, 2018 Report Share Posted April 13, 2018 In many cases , I cant use "const" I often use : #define or enum{}; you can try : #define WDW_SIZE 2 or enum {WDW_SIZE=2}; Best regards Karthik Rao 1 Quote Link to comment Share on other sites More sharing options...
David Black Posted April 13, 2018 Report Share Posted April 13, 2018 These questions have little to do with SystemC per se, and are really about C++. Templates are all about compile-time elaboration and template arguments must be compile-time computable. If you use C++11 or later, then various forms of constexpr functions may be available, but they are still compile-time issues. You could of course use sc_bv_base and its constructors, but keep in mind that modules, ports, and other "hardware" constructs are not allowed to be modified after end_of_elaboration. KEY POINT: To be an effective SystemC designer, you MUST be proficient at C++. Minimal C++ is NOT enough. Knowledge of C (even expert knowledge) is totally inadequate and in some cases downright harmful. Furthermore, really good SystemC often requires excellent C++ skills. Therefore, before you even consider learning much in SystemC, you really should invest in a solid C++ course. Expert SystemC practitioners take time to continually update their C++ skills. If this does not sound like fun to you, then I would advise choosing a different discipline. Karthik Rao and maehne 2 Quote Link to comment Share on other sites More sharing options...
Karthik Rao Posted May 4, 2018 Author Report Share Posted May 4, 2018 Hello Everyone, Thank you for your insights. I looked up at the LRM later and found that it has to be a constant and also cannot be modified after end_of_elaboration. To achieve my task I later found another method which does not involve making the width configurable. Best Regards Karthik Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.