简体   繁体   English

是否可以在 C++ 中使用系统 C 数据类型而不使用整个系统 C kernel?

[英]Is it possible to use System C data types in C++ without the entire System C kernel?

System C provides arbitrary length integer types that can be manipulated either as numbers (ie with support for artihmetic) or as bit-vectors (ie with support for logic operations and working with sub-vectors).系统 C 提供任意长度的 integer 类型,可以作为数字(即支持算术)或作为位向量(即支持逻辑运算和使用子向量)进行操作。

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.系统 C 还提供对我不想要的各种其他东西的支持,例如时钟、触发器等,以及它自己的运行时。 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?这些数据类型可以独立于系统C kernel的rest使用吗? If so, how?如果是这样,如何?

At least TTBOMK, no. 至少TTBOMK,不。 There are quite a few libraries that support arbitrary-length integers in C++ without the hardware-design "stuff" in SystemC though (eg, NTL , GMP , MIRACL ). 尽管有相当多的库在C ++中支持任意长度的整数,但在SystemC中却没有硬件设计的“东西”(例如NTLGMPMIRACL )。 Some of them do add more than just plain arbitrary-precision arithmetic (eg, 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. OTOH,考虑到典型的实现,至少如果将它们用作静态库,则仅将实际使用的内容链接到可执行文件中。

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. 我不熟悉SystemC,但我总是想指出,在开源项目中,您可以从中得到答案。

Browsing the CPP files which implement the integer type, it seems to depend on things in datatypes/ , utils/ , and kernel/ : 浏览实现整数类型的CPP文件,它似乎取决于datatypes/utils/kernel/

http://github.com/systemc/systemc-2.2.0/tree/master/src/sysc/datatypes/int/ 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. 如果Jerry建议的静态链接没有将其缩减到看起来合理的程度(由于某种不必要的全局或子系统init),那么您可以将它从GitHub的最低版本中剥离出来,如果这样做很重要的话...但是维护自己的分支机构总是有成本的。

(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!) (或者,您可以提供一个元系统来削减人们不需要的C系统代码,而这些C系统可能会合并到主发行版中!)

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.我有同样的需求:我想要 C++ 中的灵活长度整数和位向量。我不想要 SystemC 的 rest,尤其是运行时。

I investigated GMP and similar and found them overly large and complex for my needs.我调查了 GMP 和类似的东西,发现它们对于我的需要来说过于庞大和复杂。

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.我在https://hlslibs.org找到了一组非常相似的数据类型,可以提供您想要的数据类型,它们在 Apache 2.0 许可证下可用。 The integer datatypes are very similar to SystemC integer/bit-vector datatypes. integer 数据类型与 SystemC 整数/位向量数据类型非常相似。

However, they are very lightweight: just include the appropriate header file.然而,它们非常轻量级:只包含相应的 header 文件。 No runtime component like SystemC.没有像 SystemC 这样的运行时组件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM