c++ - 了解 SystemC 中的类型

标签 c++ c vhdl systemc

我是 SystemC 编程的初学者,我注意到一件事(查看 SystemC 官方文档):我用来在 VHDL 模拟中处理的所有类型都没有“移植”到 SystemC。

我的意思是:

  1. 考虑一下 VHDL 标准库中的 std_logic,SystemC 中没有等效项,但是,在 SystemC 文档中,我看到许多使用 bool 的示例。
  2. 考虑一下 std_logic_vector,我在 SystemC 中没有看到类似的东西。相反,我可以在许多示例中看​​到 sc_int 的用法。

所以我认为 SystemC 并不提供类型来管理单个位或电信号,但它提供了更高的抽象,就像每个常见的 C/C++ 应用程序一样。

是这样还是我错过了什么?

最佳答案

  1. Consider std_logic in the vhdl standard library, there is not an equivalent in SystemC, however, in the sysc documentation, I see many examples using bool.
  2. Consider std_logic_vector, I see no equivalent in sysc. Instead I can see, in many examples, usage of sc_int.

这并不完全正确。

在SystemC中你可以使用sc_logicsc_lv< T >std_logicstd_logic_vector分别。

您可以分配给SC_LOGIC_0SC_LOGIC_1文字为 sc_logic .

虽然您可以使用整数、十六进制甚至“特定于位”的文字来分配 sc_lv< T >一个值。

例如:

class some_device : sc_module
{
    sc_out< sc_lv<32> > address;
    sc_out< sc_logic > write_enable;

    SC_CTOR (some_device)
    {
        write_enable.initialize(SC_LOGIC_0);

        /* The following three lines do the same thing. 
         * Obviously you won't use all three at the same time... */
        address.initialize(0b00001111000011110000111100001111);
        address.initialize(0x0F0F0F0F);
        address.iniziatize(252645135);
    }
}

希望有帮助。

关于c++ - 了解 SystemC 中的类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5551071/

相关文章:

syntax - 如何在 VHDL 中对整数进行按位与运算?

c++ - 如何有选择地从序列中并行删除对象?

c++ - 将信号 (SIGINT) 传播到 C++11 线程

c - 循环不会运行多次

c - 通过调用共享 DLL 在两个线程之间进行信息交换

vhdl - 枚举中的字 rune 字别名的正确语法是什么?

vhdl - unsigned和std_logic_vector之间的区别

c++ - 如何在 openCV C++ 中读取 .xml 文件

c++ - 使用指针遍历检查字符串是否重复

c - 数组是存储为指针还是完整存储在 C 结构中? (是 : How to dump structs to disk when some fields are pointers? )