[英]Understanding types in SystemC
I am a beginner in SystemC programming and there is one thing I noticed (looking in the SystemC official documentation): all types that I used to deal with in VHDL simulations have not been "ported" to SystemC. 我是SystemC编程的初学者,我注意到了一件事(请参阅SystemC官方文档):我以前在VHDL模拟中处理的所有类型都没有“移植”到SystemC。
I mean: 我的意思是:
std_logic
in the VHDL standard library, there is not an equivalent in SystemC, however, in the SystemC documentation, I see many examples using bool
. std_logic
,在SystemC中没有等效项,但是,在SystemC文档中,我看到了许多使用bool
示例。 std_logic_vector
, I see no equivalent in SystemC. std_logic_vector
,我发现SystemC中没有等效的东西。 Instead I can see, in many examples, usage of sc_int
. sc_int
用法。 So I'm thinking that SystemC does not provide types in order to manage single bits or electric signals, but it provides a higher abstraction like in every common C/C++ applications. 因此,我认为SystemC不提供用于管理单个位或电信号的类型,而是像在每个常见的C / C ++应用程序中一样提供更高的抽象度。
Is it so or am I missing something? 是这样还是我缺少什么?
它确实有一些类型: sc_int
, sc_bv
(位向量)等。
- Consider
std_logic
in the vhdl standard library, there is not an equivalent in SystemC, however, in the sysc documentation, I see many examples usingbool
.考虑vhdl标准库中的
std_logic
,在SystemC中没有等效项,但是在sysc文档中,我看到了许多使用bool
示例。- Consider
std_logic_vector
, I see no equivalent in sysc.考虑
std_logic_vector
,我在sysc中看不到任何等效的东西。 Instead I can see, in many examples, usage ofsc_int
.相反,在许多示例中,我可以看到
sc_int
用法。
It's not all that correct. 这还不是全部正确。
In SystemC you can use sc_logic
and sc_lv< T >
as std_logic
and std_logic_vector
respectively. 在SystemC中,可以将
sc_logic
和sc_lv< T >
分别用作std_logic
和std_logic_vector
。
You can assign to SC_LOGIC_0
or SC_LOGIC_1
literals to sc_logic
. 您可以将
SC_LOGIC_0
或SC_LOGIC_1
文字分配给sc_logic
。
While you can use integer, hex or even 'bit-specific' literal to assign sc_lv< T >
a value. 虽然您可以使用整数,十六进制甚至是“特定于位”的文字来为
sc_lv< T >
分配一个值。
For example: 例如:
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);
}
}
Hope that helps. 希望能有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.