cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Highlighted
Visitor
Visitor
245 Views
Registered: ‎10-27-2017

Bug in Compiler (gcc) for 64-bit Microblaze Double Precision Floating Point??

Hi,

For a recent project, I have a Kintex 7 where I have instantiated one 32-bit Microblaze and two 64-bit Microblaze processors. All of these have extended floating point support, no cache, 128kB of combined data / instruction LMB. I am running Vivado / Xilixn SDK 2019.1 (I am aware that this is not the latest, but I have not seen a similar bug reported).

The issue is when using double precision code on the 64-bit processor - it doesn't work (pretty much at all). I boiled it down to a simple test set of code (actual results observed using the debugger recorded in comments) as shown below. I can only conclude that the issue is with the compiler. Any thoughts?

Edited to add: At the moment, I see no sensible way forward other than reverting to single precision and having to be very careful with loss of precision in my application (which is the whole reason that we went for the 64-bit processor in the first place).

Regards, Robert

 

int main () {
	float fA, fB, fC;
	double dA, dB, dC;

	while(1) {
		fA = -10.0f;		// -10.0
		fB = 10.0f;		// 10.0
		fC = 20.0f;		// 20.0

		dA = -10.0;		// -NaN
		dB = 10.0;		// 5.316645948E-315
		dC = 20.0;		// 5.321826602E-315

		dA = (double) fA;	// -10.0
		dB = (double) fB;	// 10.0
		dC = (double) fC;	// 20.0

		dA /= dC;		// -0.5
		dA = pow(dB, dA);	// 1.021082904419538E-285
		dC = dA * dB;		// 1.021082904419538E-284
		dC = sqrt(dB);		// 3.162277660168379

		fA /= fC;		// -0.5
		fA = powf(fB, fA);	// 0.3162278
		fC = fA * fB;		// 3.162278
		fC = sqrtf(fB);		// 3.162278
	}

	return 0;
}

 

 

0 Kudos
2 Replies
Highlighted
Visitor
Visitor
218 Views
Registered: ‎10-27-2017

One of my colleagues has just pointed out that for the constant assignment errors, the problem seems to be that the upper and lower 32-bit chunks are swapped:

0x4034000000000000 = 20.0
0x0000000040340000 = 5.321826602E-315

This sounds to me like there is some error in the endian-ness understanding of the compiler (and possibly also the standard library... but then again, this may just be a compiler issue).

0 Kudos
Highlighted
Newbie
Newbie
70 Views
Registered: ‎11-20-2020

Hi,

This is an old issue due to compiler bug.

Either upgrade to the latest version of the tools or turn on the barrel shifter

 

0 Kudos