English 中文(简体)
Is it possible to use System C data types in C++ without the entire System C kernel?
原标题:
  • 时间:2010-10-06 20:02:58
  •  标签:
  • c++
  • systemc

System C provides arbitrary length integer types that can be manipulated either as numbers (i.e. with support for artihmetic) or as bit-vectors (i.e. with support for logic operations and working with sub-vectors).

System C also provides support for all sorts of other things I don t want, such as clocks, flip flops and such, as well as its own runtime. I m picky - I want the datatypes without the overhead.

Can these data types be used independently of the rest of the system C kernel? If so, how?

最佳回答

I m not familiar with SystemC, but I do always like to point out that in open source projects, you can get the answer from the horse s mouth.

Browsing the CPP files which implement the integer type, it seems to depend on things in datatypes/, utils/, and kernel/:

http://github.com/systemc/systemc-2.2.0/tree/master/src/sysc/datatypes/int/

If the static linking that Jerry suggests doesn t pare it down enough to what seems reasonable (due to some kind of unnecessary global or subsystem inits), you could fork it off GitHub for your minimalist version if it s important to do so...but there s always a cost to maintaining your own branch.

(Or you could contribute a meta-system for paring down bits of system-C people don t need which might get incorporated into the main distribution!)

问题回答

At least TTBOMK, no. There are quite a few libraries that support arbitrary-length integers in C++ without the hardware-design "stuff" in SystemC though (e.g., NTL, GMP, MIRACL). Some of them do add more than just plain arbitrary-precision arithmetic (e.g., various functions used heavily on number theory).

OTOH, given the typical implementations, at least if you use them as static libraries, only what you actually use will be linked into your executable.

I had this same need: I wanted the flexible length integers and bit-vectors in C++. I did not want the rest of SystemC, particularly the runtime.

I investigated GMP and similar and found them overly large and complex for my needs.

I found a very similar set of datatypes that may provide exactly what you want are available as AC Datatypes at https://hlslibs.org They are available under Apache 2.0 license. The integer datatypes are very similar to SystemC integer/bit-vector datatypes.

However, they are very lightweight: just include the appropriate header file. No runtime component like SystemC.





相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?

热门标签