4 Replies Latest reply on Apr 27, 2020 7:55 AM by bdiouiska

    Problems with HLS Vivado Run C simulation

    bdiouiska

      I hope this is in the right Topic.

      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.

      Here my algorithm in C.

      #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;
      }
      
        • Re: Problems with HLS Vivado Run C simulation
          bartokon

          I don't remember but there are like 2 places where you can put files -Test Bench and the other one

           

          Make those files:

           

          Main_tb.cpp with:

          #include "myFunction.h"

          int main()

          {

          //Call function make some operations and typical dynamic programming

          //compare results with accelerated function

               int a, b, c;

               a = 1;

               b = 2;

               myDoSomethingInHardwareOne(a, b, c);

               if(c)

               {

                    myDoSomethingInHardwareTwo(a,  b, c);

               };

           

          };

           

          in the other one (synthesis function location this is one row above TestBench):

          myFunction.h:

          void myDoSomethingInHardwareOne(int a, int b, int c);

          void myDoSomethingInHardwareTwo(int a, int b, int c);

           

          and myFunction.cpp:

          #include "myFunction.h"

          void myDoSomethingInHardwareOne(int a, int b, int c){c = a*b;};

          void myDoSomethingInHardwareTwo(int a, int b, int c){c = a-b;};

           

          If you are making cosim also include myFunction.h and myFunction.cpp to Main_tb.cpp catalog/row because without it cosim wouldn't work for me.

          1 of 1 people found this helpful