Jump to content
Karthik Rao

Changing the width in sc_bv<W>

Recommended Posts

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 by Karthik Rao
Added Regards message.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×