Home / Language / [ SC Tutorial ] 3. SystemC Data types

[ SC Tutorial ] 3. SystemC Data types

SystemC has a number of predefined data types to support hardware designs spanning from the native C++ data types to specialized fractional fixed-point representations. Choosing a data type depends on the range of values to be represented, the required precision, and the required operations. The choice of a data type also affects the speed of simulation, synthesizability, and synthesis results. The data types used differ depending on the level of abstraction represented in your model

[1] Native Data Types

SystemC is a C++ class library, therefore, SystemC supports all the native C++ data types: bool, char, short, int, unsigned char, unsigned short int, unsigned int, long int, unsigned long int, double, float, …

Native C++ data types are the most efficient in terms of memory usage and execution speed of the simulator.

[2] Arithmetic Data Types

SystemC provides two sets of numeric data types.  One set models data with bit widths up to 64-bits; another set models data with bit widths larger than 64-bits. 

[2.1] sc_int and sc_uint

The built-in sc_int and sc_uint (unsigned) numeric data types provide an efficient way to model data with specific widths from 1- to 64-bits wide.

Any data type that is not native to both the C++ language and the processor width will simulate slower than the native types. Thus, built-in C++ data types (eg: int, unsigned int, …) are faster than sc_int and sc_uint.

NOTE: Do not use sc_int unless or until prudent. One necessary condition for using sc_int is when using synthesis tools that require hardware representation

[2.2] sc_bigint and sc_biguint

Some hardware may be larger than the numbers supported by native C++ data types. SystemC provides sc_bigint and sc_biguint for this purpose

NOTE : Do not use sc_bigint for 64 or fewer bits. Doing so causes performance to suffer compared to using sc_int

[3] Boolean Data Types

[3.1] sc_bit and sc_bv

For ones and zeroes, SystemC provides the sc_bit, and for long bit-vectors SystemC provides sc_bv<> (bit vector) data types. These types do not support arithmetic data like the sc_int types, and these data types don’t execute as fast as bool and  std::bitset types

[3.2] sc_logic and sc_lv

SystemC represents these with the sc_logic and sc_lv<> (logic vector) data types. These types are represented with SC_LOGIC_1, SC_LOGIC_0, SC_LOGIC_X, and SC_LOGIC_Z. For less typing, if using namespace sc_dt, then type Log_1, Log_0, Log_X, and Log_Z, or even type ‘1’, ‘0’, ‘X’ and ‘Z’

Because of the overhead, these data types are considerably slower than their sc_bit and sc_bv counterparts. For best performance, always use built-in types such as bool.

[4] Fixed-point Data Types

SystemC provides the following fixed-point data types: sc_fixed, sc_ufixed, sc_fix, sc_ufix, and the _fast variants of them

Integral data types do not satisfy all design types. In particular, DSP applications often need to represent numbers with fractional components. SystemC provides eight data types providing fixed-point numeric representation. While native float and double data types satisfy highlevel representations, realizable hardware has speed and area requirements. Also, integer-based DSP processors do not natively support floating point. Fixed-point numbers provide an efficient solution11 in both hardware and software.


About admin

Check Also

[ SC Tutorial ] 2. SystemC Components

[1] Modules and Hierarchy First, We need to understand two basic types of processes in …

Leave a Reply

Your email address will not be published. Required fields are marked *