cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
joao.s.ferreira
Adventurer
Adventurer
7,895 Views
Registered: ‎07-25-2014

Multidimensional array

Jump to solution

Hello

 

I'm trying to make in vivado HLS a program that it is always receiving data and storing the data in an array.

 

The intention is to receive 2048 samples and store in an array, and the next 2048 samples in another and so on, till 10 arrays.

 

Then the next data will be introduced in the first array and i discard the first 2048 samples, so like a circular buffer.

 

I tried to store the data in a variable like this:

 

ap_int <16> x_store [10][2048]

 

But then when i try to synthesize the vivado hls takes too much time so probably it is not eficient.

 

Now i'm trying to use the LineBuffer class but the memory consumption is very large.

 

LineBuffer< 2048,10,ap_int<16> > buff;

 

Am i following the right path? Or it is a more eficient way to do this?

 

I'm trying to implement the buffer with a structure but now i'm getting this error

 

 Port 'buff/y_V_dout' has no fanin or fanout and is left dangling.

 

This is the code that i implemented:

 

#include "ap_int.h"

#define BUFFER_SIZE 20480

struct no{
public:
	ap_int<16> Data;
	no *Proximo;
};

struct buffer{
public:
	no *Cabeca;

	void InsereItem(ap_int<16> Item){
		no *Novo,*Actual;

		Novo->Data=Item;
		Novo->Proximo=NULL;
		if(Cabeca==NULL){
			Cabeca=Novo;
		}else{
			Actual=Cabeca;
			while(Actual->Proximo!=NULL)
				Actual=Actual->Proximo;
			Actual->Proximo=Novo;
		}
	}

	int Contador(){
		no *Actual=Cabeca;
		int contador=0;
		if(Cabeca==NULL)
			return(0);
		else{
			while(Actual!=NULL){
				Actual=Actual->Proximo;
				contador++;
			}
			return(contador);
		}
	}

	ap_int<16> LeBuffer(){
		no *Actual=Cabeca;
		int contador=0;
		ap_int <30> intsum=0;
		ap_int <16> temp;

		if(Cabeca==NULL)
			return(0);
		else{
			intsum=Actual->Data;
			Cabeca=Actual->Proximo;
			while(Actual!=NULL){
				Actual=Actual->Proximo;
				contador++;
				if (0<(contador/2048)<10){
					intsum+=Actual->Data;
				}
			}
			temp = (ap_int <16>) intsum/(ap_int<16>)10;
			return(temp);
		}
	}

	buffer(){
		Cabeca=NULL;
	}

};

void buff(volatile ap_int<16> * x,volatile ap_int<16> * y)
{
#pragma HLS INTERFACE ap_fifo port=x
#pragma HLS INTERFACE ap_fifo port=y
	
	ap_int <16> y_out,input;

	int Full_Buffer=0;

	struct buffer bff;

	while(1){
#pragma HLS PIPELINE
			input=*(x++);
			bff.InsereItem(input);

			Full_Buffer=bff.Contador();

			if(Full_Buffer==BUFFER_SIZE)
			{
				y_out=bff.LeBuffer();
				*(y++) = y_out;
			}

        }
}
0 Kudos
1 Solution

Accepted Solutions
joao.s.ferreira
Adventurer
Adventurer
14,122 Views
Registered: ‎07-25-2014

I have been able to pass this problem. The code that i used was simpler than the one above.

 

#include "ap_int.h"

#define BURSTSIZE 2048

void buff(volatile ap_int<16> * x,volatile ap_int<16> * y)
{
#pragma HLS INTERFACE ap_fifo port=x
#pragma HLS INTERFACE ap_fifo port=y

	ap_int <16> x_store[BURSTSIZE];
#pragma HLS RESOURCE variable=x_store core=FIFO_BRAM
	ap_int <16> y_out,temp;

	int i;


	while(1){
#pragma HLS PIPELINE

		LOOP_UPDATE:for(i=0; i<BURSTSIZE-1; i++)
							{
								x_store[i+1]=x_store[i];
								//Actualização do buffer
							}
		temp=*(x++);
		x_store[0]=temp;
		*(y++)=x_store[0]+x_store[1024];
		

	}
}

This code is doing what i wanted but just for 2 arrays of 1024 samples.

View solution in original post

0 Kudos
2 Replies
joao.s.ferreira
Adventurer
Adventurer
14,123 Views
Registered: ‎07-25-2014

I have been able to pass this problem. The code that i used was simpler than the one above.

 

#include "ap_int.h"

#define BURSTSIZE 2048

void buff(volatile ap_int<16> * x,volatile ap_int<16> * y)
{
#pragma HLS INTERFACE ap_fifo port=x
#pragma HLS INTERFACE ap_fifo port=y

	ap_int <16> x_store[BURSTSIZE];
#pragma HLS RESOURCE variable=x_store core=FIFO_BRAM
	ap_int <16> y_out,temp;

	int i;


	while(1){
#pragma HLS PIPELINE

		LOOP_UPDATE:for(i=0; i<BURSTSIZE-1; i++)
							{
								x_store[i+1]=x_store[i];
								//Actualização do buffer
							}
		temp=*(x++);
		x_store[0]=temp;
		*(y++)=x_store[0]+x_store[1024];
		

	}
}

This code is doing what i wanted but just for 2 arrays of 1024 samples.

View solution in original post

0 Kudos
debrajr
Moderator
Moderator
7,823 Views
Registered: ‎04-17-2011
@joao.s.ferreira If the issue is resolved by your last reply, then please close this topic and mark the last post as an accepted solution.
Regards,
Debraj
----------------------------------------------------------------------------------------------
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