Question

I am newbie to system c and i am trying to work on system c data type's conversions.

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.

Thank you very much

Was it helpful?

Solution

Your code is incorrect:

  • as mentioned by Ivanov, the member function conversion1 should be conversion as you defined as SC_METHOD.
  • the sc_in<...> has no method called to_bool(). You should use din.read() to get the sc_ufixed value first and then convert the value to the bool implictly.
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;
  }
};

OTHER TIPS

This code not correct. Your behavioral function name not the same with name of function which reg. like a SC_METHOD in constructor. Change the name of your function "convecrsion1" to "conversion".

Good tutorials: web page 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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top