mohitnegi Posted December 27, 2013 Report Share Posted December 27, 2013 Hello , I have a confusion related to systemc data types particularly what is the difference between sc_int and int(c++) ....the difference i found out was that sc_int is 64bit and int is 2byte or 4 byte depends on compiler.... could anyone elaborate any difference in above and which is preferred ??? does it have any effect on scheduler ?? Quote Link to comment Share on other sites More sharing options...
manikanta.mashetti Posted December 27, 2013 Report Share Posted December 27, 2013 Hie, 1.sc_int<w> , here 'w' can vary from 1 to 64 bits any number you can take,based on your requirement.default is 32 bits 2.int ,it is a c++ data type it takes by default 32 bits. But simulation speed is fast when you use c++ data type compare to the systemC datatype.. so when you use 32 bits use C++ datatype(int) data type ...else use systemC datatype(sc_int)... Quote Link to comment Share on other sites More sharing options...
apfitch Posted December 27, 2013 Report Share Posted December 27, 2013 Also sc_int has lots features, for instance the ability to select a range of bits; concatenation operators; bit select; various type conversions; and so on. See the 1666-2011 Language Reference Manual for details, regards Alan Quote Link to comment Share on other sites More sharing options...
saraswathi.m Posted January 1, 2014 Report Share Posted January 1, 2014 Hi, Even sizeof int and sc_int<w> is different.in 32 bit machine sizeof sc_int<w> is around 20 bytes. could anyone tell why sc_int<w> is required so much space ? Quote Link to comment Share on other sites More sharing options...
dakupoto Posted January 3, 2014 Report Share Posted January 3, 2014 Hi, Even sizeof int and sc_int<w> is different.in 32 bit machine sizeof sc_int<w> is around 20 bytes. could anyone tell why sc_int<w> is required so much space ? Hello Sir, sc_int is a signed, 64 bit integer stored in 2's complement form, with the N - 1 th bit the sign bit. Quote Link to comment Share on other sites More sharing options...
apfitch Posted January 3, 2014 Report Share Posted January 3, 2014 sc_int is a (template) class, hence takes more space Alan Quote Link to comment Share on other sites More sharing options...
David Black Posted January 7, 2014 Report Share Posted January 7, 2014 If you want to guarantee the # of bits, but want speed then you should include <cstdint> or stdint.h (which has become part of the C++11 standard, but has been available for many years). You only have access to multiples of 8-bits, but at least least it's fast. Of course to grab bit ranges you will need to do the standard software masking rather than the convenience of sc_int. sc_int<W> should be used for situations where modeling the exact number of bits will make a difference in the results. For example, if the hardware implementation will have 13 bits and you do arithmetic (addition/subtraction), then sc_int<W> can catch overflow issues. Another example is synthesis of a register, where you need to control size of the hardware. The difference in performance is dramatic. Consider the following code and timing results: { using data_t = int32_t; //< replace this with sc_int<32>, sc_fixed<32,32>, float, etc... data_t result = 1; data_t A = 1103515245; data_t C = 12345; start_timer(); //< Calls a routine to get CPU time using C++11 constructs -- portable for (size_t loop=loop_count; loop!=0; --loop) { result = A * result + C; } cout << "result=" << result << endl; // Ensure compiler doesn't optimize loop out report_time(typeid(data_t).name); //< Calculates final time -- Be sure to filter with c++filt } I saw results for SystemC 2.3.0-ASI --- Jan 6 2014 07:20:27 (on 2.7GHz Intel i7) with no optimization using clang++ compiler: loop_count = 1e8 int took 0.343008s sc_dt::sc_int<32> took 2.01204s double took 0.755805s sc_dt::sc_fixed<32, 32> took 41.3482s With -O3 optimization: loop_count = 1e8 int took 0.125028s sc_dt::sc_int<32> took 0.199671s double took 0.364543s sc_dt::sc_fixed<32, 32> took 25.6714s So be careful what you select AND what compiler options you use. You can view the source code at https://github.com/dcblack/scdataperf Philipp A Hartmann 1 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.