简体   繁体   English

SystemC数据类型转换

[英]SystemC data type conversions

I am newbie to system c and i am trying to work on system c data type's conversions. 我是系统c的新手,我正在尝试处理系统c数据类型的转换。

I have a inport which a system c ufixed type and i need to change it to a bool type on the outport. 我有一个系统固定的类型的入口,我需要在出口上将其更改为布尔型。

i tried the following code. 我尝试了以下代码。

SC_MODULE(convert)
{
sc_in<sc_ufixed < 1, 1, SC_TRN, SC_SAT > > din;
sc_out<bool> dout;

bool i;

void conversion1() {

i = din.to_bool();
dout.write(i);

}
SC_CTOR(convert)
{
SC_METHOD(conversion);
sensitive<< din;
}
};

Is the above code correct? 上面的代码正确吗? do i need to use the process method to convert the inport type to a another datatype on the outport? 我是否需要使用处理方法将输入类型转换为输出上的其他数据类型?

And Could you please refer me some good reference for system c data type conversions. 能否请您为我提供一些有关系统c数据类型转换的参考。

Thank you very much 非常感谢你

This code not correct. 此代码不正确。 Your behavioral function name not the same with name of function which reg. 您的行为功能名称与reg的功能名称不同。 like a SC_METHOD in constructor. 就像构造函数中的SC_METHOD一样。 Change the name of your function "convecrsion1" to "conversion". 将函数“ convecrsion1”的名称更改为“ conversion”。

Good tutorials: web page www.asic-world.com 好的教程: 网页 www.asic-world.com

Also I recommend for you good book which could give to you deep information about library: SystemC From the ground up 我也为您推荐一本好书,它可以为您提供有关库的深入信息:SystemC从头开始

Your code is incorrect: 您的代码不正确:

  • as mentioned by Ivanov, the member function conversion1 should be conversion as you defined as SC_METHOD. 如Ivanov所述,成员函数conversion1应该是您定义为SC_METHOD的转换。
  • the sc_in<...> has no method called to_bool(). sc_in <...>没有名为to_bool()的方法。 You should use din.read() to get the sc_ufixed value first and then convert the value to the bool implictly. 您应该使用din.read()首先获取sc_ufixed的值,然后将其隐式转换为bool。
 SC_MODULE(convert) { sc_in<sc_ufixed < 1, 1, SC_TRN, SC_SAT > > din; sc_out<bool> dout; void conversion() { dout.write(din.read()); } SC_CTOR(convert) { SC_METHOD(conversion); sensitive<< din; } }; 

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

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