Jump to content

Limit the sc_biguint & sc_bigint simulation size


MING1116

Recommended Posts

Hi,

Recently in my design, I used the datatype "sc_biguint",since the simulation speed is slower than before.

So, I found that I can modify the SC_MAX_NBTIS for faster speed.

./systemc-2.3.3/include/sysc/kernel/sc_constants.h

// Maximum number of bits for arbitrary precision arithmetic. If
// defined, the arithmetic becomes faster. If not defined, the
// arithmetic becomes slower and the precision becomes infinite.  It
// is a good idea to define this constant as a multiple of
// BITS_PER_DIGIT, which is defined in numeric_bit/sc_nbdefs.h.
//#define SC_MAX_NBITS    510    // 17 * BITS_PER_DIGIT

#define SC_MAX_NBITS    510    // 17 * BITS_PER_DIGIT

But, after I define the SC_MAX_NBITS, compilation has some error showed up as follow.

In file included from /usr/cad/systemc/systemc-2.3.3/include/sysc/datatypes/int/sc_signed.h:103:0,
                 from /usr/cad/systemc/systemc-2.3.3/include/sysc/datatypes/bit/sc_proxy.h:66,
                 from /usr/cad/systemc/systemc-2.3.3/include/sysc/datatypes/bit/sc_bit_proxies.h:34,
                 from /usr/cad/systemc/systemc-2.3.3/include/sysc/datatypes/bit/sc_bv_base.h:58,
                 from /usr/cad/systemc/systemc-2.3.3/include/sysc/datatypes/bit/sc_lv_base.h:69,
                 from /usr/cad/systemc/systemc-2.3.3/include/sysc/datatypes/bit/sc_lv.h:51,
                 from /usr/cad/systemc/systemc-2.3.3/include/sysc/communication/sc_signal_rv.h:33,
                 from /usr/cad/systemc/systemc-2.3.3/include/systemc:93,
                 from /usr/cad/systemc/systemc-2.3.3/include/systemc.h:219,
/usr/cad/systemc/systemc-2.3.3/include/sysc/datatypes/int/sc_unsigned.h: In member function ‘sc_dt::sc_digit* sc_dt::sc_unsigned::get_raw() const’:
/usr/cad/systemc/systemc-2.3.3/include/sysc/datatypes/int/sc_unsigned.h:1081:37: error: invalid conversion from ‘const sc_digit* {aka const unsigned int*}’ to ‘sc_dt::sc_digit* {aka unsigned int*}’ [-fpermissive]
  sc_digit* get_raw() const { return digit; }
                                     ^~~~~
In file included from /usr/cad/systemc/systemc-2.3.3/include/sysc/datatypes/bit/sc_proxy.h:66:0,
                 from /usr/cad/systemc/systemc-2.3.3/include/sysc/datatypes/bit/sc_bit_proxies.h:34,
                 from /usr/cad/systemc/systemc-2.3.3/include/sysc/datatypes/bit/sc_bv_base.h:58,
                 from /usr/cad/systemc/systemc-2.3.3/include/sysc/datatypes/bit/sc_lv_base.h:69,
                 from /usr/cad/systemc/systemc-2.3.3/include/sysc/datatypes/bit/sc_lv.h:51,
                 from /usr/cad/systemc/systemc-2.3.3/include/sysc/communication/sc_signal_rv.h:33,
                 from /usr/cad/systemc/systemc-2.3.3/include/systemc:93,
                 from /usr/cad/systemc/systemc-2.3.3/include/systemc.h:219,
/usr/cad/systemc/systemc-2.3.3/include/sysc/datatypes/int/sc_signed.h: In member function ‘sc_dt::sc_digit* sc_dt::sc_signed::get_raw() const’:
/usr/cad/systemc/systemc-2.3.3/include/sysc/datatypes/int/sc_signed.h:1177:11: error: invalid conversion from ‘const sc_digit* {aka const unsigned int*}’ to ‘sc_dt::sc_digit* {aka unsigned int*}’ [-fpermissive]
  { return digit; }
           ^~~~~
In file included from /usr/cad/systemc/systemc-2.3.3/include/systemc:106:0,
                 from /usr/cad/systemc/systemc-2.3.3/include/systemc.h:219,
/usr/cad/systemc/systemc-2.3.3/include/sysc/datatypes/misc/sc_concatref.h: In member function ‘const sc_dt::sc_unsigned& sc_dt::sc_concatref::value() const’:
/usr/cad/systemc/systemc-2.3.3/include/sysc/datatypes/misc/sc_concatref.h:258:52: error: incompatible types in assignment of ‘sc_dt::sc_digit* {aka unsigned int*}’ to ‘sc_dt::sc_digit [35] {aka unsigned int [35]}’
                 sizeof(sc_digit)*result_p->ndigits );

Is there any other setting I should modify, or any solution for this problem?

Thank you.

Note:
GCC version = 7.3.1
Systemc version = 2.3.3

 

Link to comment
Share on other sites

Defining SC_MAX_NBITS has not been used for many years, it dates to early in SystemC's development, so I am not surprised it fails. The performance issue you are encountering is caused by the fact that malloc is done for each sc_signed or sc_unsigned value created. This issue is addressed in the next release of SystemC. In the mean time, if it is practical, use statically created variables where possible, e.g., static variables in functions/methods, or variables in structures that are allocated once. This should improve your speed for some cases, but does  not solve the problem of dynamic intermediate results, e.g., the results of arithmetic and logical operations. Again, this will be addressed in the next release of SystemC.

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...