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 tmrnvrcome
Visitor
11,294 Views
Registered: ‎10-17-2013

Vivado HLS Compilation Error

Jump to solution

Hi

 

I am working with Vivado HLS 2012.4. I have encountered an error during compilation.

 

@E [HLS-70] llvm-ld: error: Cannot link file '/home/ga54doh/AES_Evaluation/solution1/.autopilot/db/aes.bc': Linking globals named 'Rcon0': symbol multiply defined!
Error in linking the design.
    while executing
"csynth_design"

 

Can anyone suggest how I may resolve this problem?

 

Thanks.

0 Kudos
1 Solution

Accepted Solutions
Teacher muzaffer
Teacher
14,515 Views
Registered: ‎03-31-2012

Re: Vivado HLS Compilation Error

Jump to solution

Actually my initial conclusion was right. You do have multiple copies of the same symbol. The reason is aes.c includes aes_key.c and you include both .c files in your project. So you get one copy through aes.c and one copy through aes_key.c.

If you remove all .c files except aes.c and change the top function name to aes_main, the project compiles. I am not sure if the result is something useful but there are no errors and rtl is generated. The return is exactly what the aes_main return ie a constant '0' of integer size.

If you need any useful results from this code, I think you would want to make an aes_enc and aes_dec top level functions which take and return parameters. This has nothing to do with HLS but with regular programming. Look at the c code and ask yourself how a client of these interfaces would use them. How does one pass something to aes_enc/dec to process and how does one get the result? When you answer those questions how you need to modify the code will become apparent.

- Please mark the Answer as "Accept as solution" if information provided is helpful.
Give Kudos to a post which you think is helpful and reply oriented.
16 Replies
Teacher muzaffer
Teacher
11,276 Views
Registered: ‎03-31-2012

Re: Vivado HLS Compilation Error

Jump to solution
>> globals named 'Rcon0': symbol multiply defined

pay attention to the tool is telling you. Do you have the Rcon0 symbol defined in both files outside any functions? You can have only one declaration of a global symbol; others should be "extern"
- Please mark the Answer as "Accept as solution" if information provided is helpful.
Give Kudos to a post which you think is helpful and reply oriented.
Highlighted
Visitor tmrnvrcome
Visitor
11,274 Views
Registered: ‎10-17-2013

Re: Vivado HLS Compilation Error

Jump to solution

the Rcon0 is defined in the same file. but used in different function. it is like this, in this file aes_key.c, i  have declared and defined this: 

 

const char Rcon0[30] = {
0x01, 0x02, 0x04, 0x08,
0x10, 0x20, 0x40, 0x80,

...

...

...};

 

then in the same file aes_key.c, i have written a function that uses the Rcon0

 

int KeySchedule (int type, int key[32])
{

...

...

...

if ((j % nk) == 0)
{
temp[0] = SubByte (word[1][j - 1]) ^ Rcon0[(j / nk) - 1];
temp[1] = SubByte (word[2][j - 1]);
temp[2] = SubByte (word[3][j - 1]);
temp[3] = SubByte (word[0][j - 1]);
}

...

..

...

}

 

I did not use Rcon0 in other files. 

 

So any suggestions?

 

0 Kudos
Teacher muzaffer
Teacher
11,272 Views
Registered: ‎03-31-2012

Re: Vivado HLS Compilation Error

Jump to solution
You have a straight link problem. Saying everything is perfect points to a compiler or linker bug. Although it is possible, it is a very low likelihood and it is more likely that there is something wrong with your code. Maybe post your project so that it can be observed in totality ?
- Please mark the Answer as "Accept as solution" if information provided is helpful.
Give Kudos to a post which you think is helpful and reply oriented.
0 Kudos
Visitor tmrnvrcome
Visitor
11,267 Views
Registered: ‎10-17-2013

Re: Vivado HLS Compilation Error

Jump to solution

ok.

 

/*
+--------------------------------------------------------------------------+
| CHStone : a suite of benchmark programs for C-based High-Level Synthesis |
| ======================================================================== |
*/


#include "aes.h"

//int main_result;

/* **************key generate & key display *******************/
const char Rcon0[30] = {
0x01, 0x02, 0x04, 0x08,
0x10, 0x20, 0x40, 0x80,
0x1b, 0x36, 0x6c, 0xd8,
0xab, 0x4d, 0x9a, 0x2f,
0x5e, 0xbc, 0x63, 0xc6,
0x97, 0x35, 0x6a, 0xd4,
0xb3, 0x7d, 0xfa, 0xef,
0xc5, 0x91};

/* **************** key expand ************************ */
int
KeySchedule (int type, int key[32])
{
int nk, nb, round_ing;
int i, j, temp[4];

switch (type)
{
case 128128:
nk = 4;
nb = 4;
round_ing = 10;
break;
case 128192:
nk = 4;
nb = 6;
round_ing = 12;
break;
case 128256:
nk = 4;
nb = 8;
round_ing = 14;
break;
case 192128:
nk = 6;
nb = 4;
round_ing = 12;
break;
case 192192:
nk = 6;
nb = 6;
round_ing = 12;
break;
case 192256:
nk = 6;
nb = 8;
round_ing = 14;
break;
case 256128:
nk = 8;
nb = 4;
round_ing = 14;
break;
case 256192:
nk = 8;
nb = 6;
round_ing = 14;
break;
case 256256:
nk = 8;
nb = 8;
round_ing = 14;
break;
default:
return -1;
} //end of switch..case
for (j = 0; j < nk; ++j)
for (i = 0; i < 4; ++i)
/* 0 word */
word[i][j] = key[i + j * 4];

/* expanded key is generated */
for (j = nk; j < nb * (round_ing + 1); ++j)
{

/* RotByte */
if ((j % nk) == 0)
{
temp[0] = SubByte (word[1][j - 1]) ^ Rcon0[(j / nk) - 1];
temp[1] = SubByte (word[2][j - 1]);
temp[2] = SubByte (word[3][j - 1]);
temp[3] = SubByte (word[0][j - 1]);
}
if ((j % nk) != 0)
{
temp[0] = word[0][j - 1];
temp[1] = word[1][j - 1];
temp[2] = word[2][j - 1];
temp[3] = word[3][j - 1];
}
if (nk > 6 && j % nk == 4)
for (i = 0; i < 4; ++i)
temp[i] = SubByte (temp[i]);
for (i = 0; i < 4; ++i)
word[i][j] = word[i][j - nk] ^ temp[i];
}
return 0;
}

0 Kudos
Teacher muzaffer
Teacher
11,263 Views
Registered: ‎03-31-2012

Re: Vivado HLS Compilation Error

Jump to solution
What is the source of the aes.bc bit code file? That's where the complaint is coming from.
- Please mark the Answer as "Accept as solution" if information provided is helpful.
Give Kudos to a post which you think is helpful and reply oriented.
0 Kudos
Visitor tmrnvrcome
Visitor
11,262 Views
Registered: ‎10-17-2013

Re: Vivado HLS Compilation Error

Jump to solution

Here it is. As attached. 

0 Kudos
Visitor tmrnvrcome
Visitor
11,252 Views
Registered: ‎10-17-2013

Re: Vivado HLS Compilation Error

Jump to solution

Sorry, but i am new to using Vivado HLS. How do I open the .bc file in Vivado HLS? Or is there any way that I can open it? I am using Windows 7 OS. 

0 Kudos
Teacher muzaffer
Teacher
11,249 Views
Registered: ‎03-31-2012

Re: Vivado HLS Compilation Error

Jump to solution

I downloaded and looked at the CHStone\aes project. This project doesn't seem to be structured for HLS as far as I can tell. aes.c seems to be a something like a testbench but it includes all the other C files and aes_enc writes its output to a global variable. As far as I understand HLS, these files need some work to be useful for it.

I think aes_enc and aes_dec should be work on so that they can get inputs and outputs as parameters and return results.

- Please mark the Answer as "Accept as solution" if information provided is helpful.
Give Kudos to a post which you think is helpful and reply oriented.
Xilinx Employee
Xilinx Employee
11,245 Views
Registered: ‎11-28-2007

Re: Vivado HLS Compilation Error

Jump to solution

Could you attach the entire project with all source files?

 

 

Cheers,
Jim
0 Kudos
Visitor tmrnvrcome
Visitor
9,017 Views
Registered: ‎10-17-2013

Re: Vivado HLS Compilation Error

Jump to solution

ok. I have attached the enitre project. Please give me some advice and help me out, I am not sure how to move on from this error. 

0 Kudos
Visitor tmrnvrcome
Visitor
9,018 Views
Registered: ‎10-17-2013

Re: Vivado HLS Compilation Error

Jump to solution
so it means i have to modify the codes?

Sorry, I am new to HLS.
0 Kudos
Teacher muzaffer
Teacher
14,516 Views
Registered: ‎03-31-2012

Re: Vivado HLS Compilation Error

Jump to solution

Actually my initial conclusion was right. You do have multiple copies of the same symbol. The reason is aes.c includes aes_key.c and you include both .c files in your project. So you get one copy through aes.c and one copy through aes_key.c.

If you remove all .c files except aes.c and change the top function name to aes_main, the project compiles. I am not sure if the result is something useful but there are no errors and rtl is generated. The return is exactly what the aes_main return ie a constant '0' of integer size.

If you need any useful results from this code, I think you would want to make an aes_enc and aes_dec top level functions which take and return parameters. This has nothing to do with HLS but with regular programming. Look at the c code and ask yourself how a client of these interfaces would use them. How does one pass something to aes_enc/dec to process and how does one get the result? When you answer those questions how you need to modify the code will become apparent.

- Please mark the Answer as "Accept as solution" if information provided is helpful.
Give Kudos to a post which you think is helpful and reply oriented.
Visitor tmrnvrcome
Visitor
8,997 Views
Registered: ‎10-17-2013

Re: Vivado HLS Compilation Error

Jump to solution

And how do I make aes_enc and aes_dec as top level functions?

0 Kudos
Visitor tmrnvrcome
Visitor
8,987 Views
Registered: ‎10-17-2013

Re: Vivado HLS Compilation Error

Jump to solution
When you say remove all .c files, do you mean removing from the 'Sources' tab, or do you mean to exclude the lines in the aes.c:
#include "aes_enc.c"
//#include "aes_dec.c"
//#include "aes_key.c"
//include "aes_func.c"
0 Kudos
Xilinx Employee
Xilinx Employee
8,964 Views
Registered: ‎03-24-2010

Re: Vivado HLS Compilation Error

Jump to solution

Only one function can be set as top function for RTL synthsis.

To do it,  open Project->Project Settings->Synthesis, and then set "aes_enc" for top function.

Regards,
brucey
----------------------------------------------------------------------------------------------
Kindly note- Please mark the Answer as "Accept as solution" if information provided is helpful.

Give Kudos to a post which you think is helpful and reply oriented.
----------------------------------------------------------------------------------------------
0 Kudos
Xilinx Employee
Xilinx Employee
8,963 Views
Registered: ‎03-24-2010

Re: Vivado HLS Compilation Error

Jump to solution

Some guidelines for c coding:

1. Do not include source file(*.c) in another source file.

2. Add macro check for head file(*.h). For example,

add following two line to the start of your "aes.h"

    #ifndef __AES_H__

    #define __AES_H__

 add following line to the end of your "aes.h"

    #endif

Regards,
brucey
----------------------------------------------------------------------------------------------
Kindly note- Please mark the Answer as "Accept as solution" if information provided is helpful.

Give Kudos to a post which you think is helpful and reply oriented.
----------------------------------------------------------------------------------------------