UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Visitor migr
Visitor
5,591 Views
Registered: ‎10-02-2016

How to initialize class private data member to avoid power-on initialization?

Jump to solution

Hello everybody

 

In my project, I want to generate RTL code with Vivado HLS (Version 2016.1). To do this, I want to use class members that represent internal states of my program. To simplify the analysis, I wrote a short code (shown below) to illustrate my problem with one class data member number: I wrote a Counter that adds with each call adds 1 to number, starting from 1.125 (I chose a float, as my class members are typically floats).  

C-Simulation results are:

2.125

3.125

 

Now upon C-synthesis I get the following warning:

WARNING: [RTGEN 206-101] Register 'iCounter_number' is power-on initialization.

 

This is not what I want, because this means that number would be set to 0 at the beginning. I want that it to be set to 1.125.

How can I fix this ?

Note: I do not want to return the current value of number to the test bench file (as this would actually work, but result in other complications).

 

My example header files are:

// Counter.h
#ifndef COUNTER_H_
#define COUNTER_H_
class Counter
{
private:
float number;
public:
Counter();
~Counter();
float Counterfun(int);

};
#endif /* COUNTER_H_ */

 

// CounterTop.h
#ifndef COUNTERTOP_H_
#define COUNTERTOP_H_
float CounterTop(int);
#endif /* COUNTERTOP_H_ */

 

My example source files are:

 

// Counter.cpp
#include<iostream>
#include "Counter.h"
using namespace std;
Counter::Counter()
{
number = 1.125;
}
Counter::~Counter()
{
}
float Counter::Counterfun(int integer)
{
number = number + integer;
return number;
}

 

// CounterTop.cpp
#include "CounterTop.h"
#include "Counter.h"
float CounterTop(int integer)
{
static Counter iCounter;
return iCounter.Counterfun(integer);
}

 

My example test bench file is:

// CounterApp.cpp
#include<iostream>
#include "Counter.h"
#include "CounterTop.h"

using namespace std;
int main()
{
float d;
int integer = 1;
for(int i = 0; i < 2; i++)
{
Counter i1Counter;
d = CounterTop(integer);
cout << d << endl;
}
}

 

Any help is appreciated.

Thank you!

0 Kudos
1 Solution

Accepted Solutions
Visitor migr
Visitor
10,078 Views
Registered: ‎10-02-2016

Re: How to initialize class private data member to avoid power-on initialization?

Jump to solution

Ok, thank you Jim.

I thought the warning is somehow related to the warning I get in C/RTL-Simulation: OPMODE 0110X0X with CARRYINSEL to DSP48 (not exact phrasing of the warning). But after adding config_rtl with reset all in Solution > Solution Settings > General the power-on initialization warning is gone, whereas the C/RTL-Simulation warning still persists, so probably this 2 problems are not related to each other.

Cheers,

Michael

0 Kudos
4 Replies
Visitor woude3t
Visitor
5,546 Views
Registered: ‎04-18-2016

Re: How to initialize class private data member to avoid power-on initialization?

Jump to solution

Hi!

 

Did you try member initialization?

 

Counter::Counter() : 
  number(1.125)
{
}

With kind regards,

Jacob

0 Kudos
Visitor migr
Visitor
5,536 Views
Registered: ‎10-02-2016

Re: How to initialize class private data member to avoid power-on initialization?

Jump to solution

Hi Jacob

 

Thank you very much for your suggestion and your effort.

 

I tried member initialization now, but unfortunately I still get the same warning in Synthesis:

WARNING: [RTGEN 206-101] Register 'iCounter_number' is power-on initialization.

 

Further suggestions are highly appreciated.

 

Kind regards,

Michael

0 Kudos
Xilinx Employee
Xilinx Employee
5,533 Views
Registered: ‎11-28-2007

Re: How to initialize class private data member to avoid power-on initialization?

Jump to solution

"power-on initialization" doesn't mean that the register is initialized to 0 during power on. It means the register is only reset during power-on. The reset value comes from your C source code. You will not be able to reset by asserting the reset signal to the block.

 


@migr wrote:

Hi Jacob

 

Thank you very much for your suggestion and your effort.

 

I tried member initialization now, but unfortunately I still get the same warning in Synthesis:

WARNING: [RTGEN 206-101] Register 'iCounter_number' is power-on initialization.

 

Further suggestions are highly appreciated.

 

Kind regards,

Michael


 

Cheers,
Jim
Visitor migr
Visitor
10,079 Views
Registered: ‎10-02-2016

Re: How to initialize class private data member to avoid power-on initialization?

Jump to solution

Ok, thank you Jim.

I thought the warning is somehow related to the warning I get in C/RTL-Simulation: OPMODE 0110X0X with CARRYINSEL to DSP48 (not exact phrasing of the warning). But after adding config_rtl with reset all in Solution > Solution Settings > General the power-on initialization warning is gone, whereas the C/RTL-Simulation warning still persists, so probably this 2 problems are not related to each other.

Cheers,

Michael

0 Kudos