Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Altera_Forum
Honored Contributor I
952 Views

Change compiler option flags for double precision floating point custom instruction

Hi, 

I am trying to impliment a double precision floating point in hardware (custom instruction) 

but I don't know how to change the compiler option flags to tell NIOS II to use the custom instruction 

instead of software implimentation. 

 

I'm using Nios II 13.0 in Windows 7 and this are the flags I want to change : 

-mcustom-fwrx=0 

-mcustom-fwry=1 

-mcustom-frdxlo=2 

-mcustom-frdxhi=3 

-mcustom-frdy=4 

-mcustom-fadd=5 

-mcustom-fsubd=6 

-mcustom-fmuld=7 

-mcustom-fdivd=8 

-mcustom-floatid=9 

-mcustom-fixdi=10 

-mcustom-fcmpltd=11 

-mcustom-fcmpled=12 

-mcustom-fcmpgtd=13 

-mcustom-fcmpged=14 

-mcustom-fcmpeqd=15 

-mcustom-fcmpned=16 

 

Thank You
0 Kudos
5 Replies
Altera_Forum
Honored Contributor I
44 Views

The compiler only has support for 'float' custom instrutions for FP (not double). 

 

Using custom instructions for 'double' would be more compilcated because the custom instruction interface only allows two 32bit arguments and one 32bit result from custom instructions. 

 

You could modify gcc to add patterns for your 'double' instructions, but it is probably easier to add gcc asm statements for them. 

You'll probably need to write them - I'm not sure how you get double values into a register pair though (rtfm ...). 

 

You might also want to read a recent thread about doing 1024bit integer arithmetic - you have the same problem.
Altera_Forum
Honored Contributor I
44 Views

Thank You very much for the reply 

 

I'm using several steps to get the double values into the custom instruction. 

for instance the operation A+B (dataa and datab are input operand to custom instruction) : 

1. set the 64 bits value of A to dataa and datab. the custom instruction concatenate the data back to 64 bit and save it to an internal register. 

2. set the 64 bits value of B to dataa and datab and process with the addition. 

3. when the additon is done, read the upper 32 bit of the result. 

4. read the lower 32 bits of the result. 

 

I'm not very good in coding assembler language, do you have any links or documents that can help me ? 

 

By the way in NIOSII IDE Version 10.1 an option was given in the GUI to change the Compier flags (please see attachement). 

 

Thank you in advance.
Altera_Forum
Honored Contributor I
44 Views

You'd need to rebuild gcc with extra instruction definitions in order to get it to use your custom instructions. 

 

Below is an example of the asm wrapper for a custom instruction. 

I'm not sure how to get a double value into two registers, try 

using a local variable that is a union of a double and two ints. 

 

/* There are 'int __builtin_custom_inii(int op, int a, int b)' * (and similar) wrappers for custom instructions defined by gcc itself. * But none for the 'c' variants that do not use the main register file. * The one below is useful when the 'b' field is used as a sub-opcode.*/ __attribute__((always_inline)) static __inline__ uint32_t custom_inic(const uint32_t op, uint32_t a, const uint32_t b) { uint32_t result; __asm__ ( "custom\t%1, %0, %2, c%3" : "=r" (result) : "n" (op), "r" (a), "n" (b)); return result; }
Altera_Forum
Honored Contributor I
44 Views

Thanks again for the reply. 

I'll give it a try.
Altera_Forum
Honored Contributor I
44 Views

Hi, 

 

I also would like to accelerate double precision floating point processing by use of custom instructions. Different to 

 

 

--- Quote Start ---  

You'd need to rebuild gcc with extra instruction definitions in order to get it to use your custom instructions. 

 

--- Quote End ---  

 

 

my understanding from this alterawiki (http://www.alterawiki.com/wiki/custom_instructions) article is that there should be no need to rebuild the gcc. However, although I have set all of the necessary flags, the gcc that comes along with quartus 13.0 does not make use of my double precision floating point custom instructions.  

 

Has anybody been successful in this? Any help is appreciated!
Reply