cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Visitor
Visitor
573 Views
Registered: ‎04-25-2020

Problems with HLS Vivado Run C simulation

Hello I am an engineer student and currently I am doing my final studies project , but i encounter some problems using vivado HLS , I hope that you can help me and thanks ,

I am going to show you my algorithm by the end of the message,

First my first problem is after i add file in Top Function (my main C file), the next step is Test bench files , I don't know what to put ??? I only have one algorithm, And this makes the Run C simulation not going in fact i got this message "cannot build design unless a test bunch with function main() is defined"

I tried to put my algorithm in both (top function same in test bench files) but i encounter some problems . My final goal is do verification synthesis and finally optimisation . I thank you for your help.

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
#include <string.h>




 





int main()
{
	
	
int n1,n2,n3,i,j,k;
    float nu,a,b;
   
    a=0.25;
    b=0.5;
    nu=0.6; //donnée
       

    scanf("%i",&n1);
        scanf("%i",&n2);

    scanf("%i",&n3);
    
     float X[n1],W[n1][n2],W1[n2][n3],E[n2],Y[n2],E1[n3],Y1[n3],Deltaj[n2],Deltak[n3],Sd[n3],es[n3],Wa[n1][n2],Wa1[n2][n3];
     
    
for (i=0;i<n1;i++){

    scanf("%f",&X[i]);
}

for (i=0;i<n3;i++){

    scanf("%f",&Sd[i]);

}
// ici j'ai pas su comment calculer es[k] qui est egale es[k] = Sd[k]-Sc[k]; Sc[k] commont la calculer ??
for (i=0;i<n3;i++){

    scanf("%f",&es[i]);

}


for (i=0;i<n1;i++){
    for (j=0;j<n2;j++){
            W[i][j]= (rand()) / (RAND_MAX + 1.0);
    }
}

for (i=0;i<n2;i++){
    for (j=0;j<n3;j++){
            W1[i][j]= (rand()) / (RAND_MAX + 1.0);
    }
};




 float Somme1 (int n1,int i,int j,float X[n1],float W[n1][n2])
{
int h;
float Somme=0;
for (h=i;h<n1;h++)
{
Somme += (X[h]*W[h][j]);
}
return (Somme);
};

float Somme2 (int n3,int j , float es[n3] , float W1[n2][n3])
{
int h;
float Somme=0;
for (h=0 ; h<n3;h++)
{
Somme += es[h]*W1[j][h];
}
return(Somme);
};





//Fonction globale(1)
for (j=0;j<n2;j++)
{
for (i=0;i<n1;i++)
{
E[j]=Somme1(n1,i,j,X,W);
Y[j]=b+a*E[j];
Deltaj[j]=Y[j]*(1-Y[j])*Somme2(n3,j,es,W1);
Wa[i][j]=W[i][j]+nu*Deltaj[j]*X[i];
}
}
// Fonction 2
for (k=0;k<n3;k++)
{
for (j=0;j<n2;j++)
{
E1[k]=Somme1(n2,j,k,Y,W1);
Y1[k]=b+a*E1[k];
Deltak[k]=Y1[k]*(1-Y1[k])*(Sd[k]-Y1[k]);
Wa1[j][k]=W1[j][k]+nu*Deltaj[j]*Y1[k];
}
}
return 0;
}

 

0 Kudos
6 Replies
Highlighted
Advisor
Advisor
563 Views
Registered: ‎02-12-2013

I think you want to separate your so-called testbench program and your function to synthesize into two different files. Your testbench contains a "main" function that calls your HLS function.  If main returns 0 then the C simulation will be judged to pass.

I usually end up with a main.c under the testbench section and functionname.c in my source folder.  That will make HLS happy for your purposes.  Eventually, you should put some meaningful tests in main.c.

----------------------------------------
DSP in hardware and software
-----------------------------------------
0 Kudos
Highlighted
Visitor
Visitor
556 Views
Registered: ‎04-25-2020

Thank you a lot,

So what I did now is make an empty file in Top Function , and put my main function in Test bunch files ,

So it works and I didn't encounter the normal error , but this time i got error i think in the script . Do you have an idea about it ?and thanks a lot

Tags (1)
0 Kudos
Highlighted
Moderator
Moderator
393 Views
Registered: ‎11-21-2018

Hi @bdiouiska 

Can you please provide the new error you are getting so the community can help you? 

Aoife
Product Application Engineer - Xilinx Technical Support EMEA
**~ Don't forget to reply, give kudos, and accept as solution.~**
0 Kudos
Highlighted
Scholar
Scholar
352 Views
Registered: ‎03-28-2016

@bdiouiska ,

If you haven't done so already, you might want to take a look at UG871.  It is an HLS Tutorial that should take you through all of the steps to create, simulate and synthesize an IP.

https://www.xilinx.com/support/documentation/sw_manuals/xilinx2019_2/ug871-vivado-high-level-synthesis-tutorial.pdf

Ted Booth | Tech. Lead FPGA Design Engineer | DesignLinx Solutions
https://www.designlinxhs.com
Highlighted
Visitor
Visitor
338 Views
Registered: ‎04-25-2020

Thank you all for responding , So what i did now is I put the same algroithm in Source file as well in the test bunch i've made some changes to make it more clear ,and what i got is this message : "Generating csim.exe" the Run C Simulation keeps and keeps rolling with no stop .thanks for your help .

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
#include <string.h>




 int n1,n2,n3,i,j,k;


 float Somme1 (int n1,int i,int j,float X[n1],float W[n1][n2])
{
int h;
float Somme=0;
for (h=i;h<n1;h++)
{
Somme += (X[h]*W[h][j]);
}
return (Somme);
};


float Somme2 (int n3,int j , float es[n3] , float W1[n2][n3])
{
int h;
float Somme=0;
for (h=0 ; h<n3;h++)
{
Somme += es[h]*W1[j][h];
}
return(Somme);
};

int main()
{
	
	

    float nu,a,b;
   
    a=0.25;
    b=0.5;
    nu=0.6; //donnée
       

    scanf("%i",&n1);
        scanf("%i",&n2);

    scanf("%i",&n3);
    
     float X[n1],W[n1][n2],W1[n2][n3],E[n2],Y[n2],E1[n3],Y1[n3],Deltaj[n2],Deltak[n3],Sd[n3],es[n3],Wa[n1][n2],Wa1[n2][n3];
     
    
for (i=0;i<n1;i++){

    scanf("%f",&X[i]);
};

for (i=0;i<n3;i++){

    scanf("%f",&Sd[i]);

};
// ici j'ai pas su comment calculer es[k] qui est egale es[k] = Sd[k]-Sc[k]; Sc[k] commont la calculer ??
for (i=0;i<n3;i++){

    scanf("%f",&es[i]);

};


for (i=0;i<n1;i++){
    for (j=0;j<n2;j++){
            W[i][j]= (rand()) / (RAND_MAX + 1.0);
    }
};

for (i=0;i<n2;i++){
    for (j=0;j<n3;j++){
            W1[i][j]= (rand()) / (RAND_MAX + 1.0);
    }
};

 printf("%f",W[1,1]);








//Fonction globale(1)
for (j=0;j<n2;j++)
{
for (i=0;i<n1;i++)
{
E[j]=Somme1(n1,i,j,X,W);
Y[j]=b+a*E[j];
Deltaj[j]=Y[j]*(1-Y[j])*Somme2(n3,j,es,W1);
Wa[i][j]=W[i][j]+nu*Deltaj[j]*X[i];
}
}
// Fonction 2
for (k=0;k<n3;k++)
{
for (j=0;j<n2;j++)
{
E1[k]=Somme1(n2,j,k,Y,W1);
Y1[k]=b+a*E1[k];
Deltak[k]=Y1[k]*(1-Y1[k])*(Sd[k]-Y1[k]);
Wa1[j][k]=W1[j][k]+nu*Deltaj[j]*Y1[k];
}
}
return 0;
}
0 Kudos
Highlighted
Participant
Participant
156 Views
Registered: ‎07-03-2009

You also get this error when you do not match the parenthesis {} in your test bench main() function.

0 Kudos