int N_ch=16;
int N_col=128;
int i,j;
-
- /*float r[] = new float[N_sim];
- for (i=0;i<N_sim;i++) {
- r[i]=i+1;
- }*/
for(j = 0; j < N_ch; j++) {
FilterBankAtom fba = new FilterBankAtom(j,
N_ch,
N_col,
N_sim,
- N_samp/*,
- r*/){tosamp};
+ N_samp){tosamp};
}
FilterBank fb = new FilterBank(N_sim, N_ch){!finish, !print};
task t2(FilterBankAtom fba{tosamp}) {
//System.printString("task t2\n");
- //fba.init();
fba.FBCore();
taskexit(fba{!tosamp, tomerge});
int N_col;
int N_sim;
int N_samp;
- //float[] r;
- /*float[] H;
- float[] F;
- float[] vH;
- float[] vDn;
- float[] vUp;*/
public float[] vF;
public FilterBankAtom(int cindex,
int N_ch,
int N_col,
int N_sim,
- int N_samp/*,
- float[] r*/) {
+ int N_samp) {
this.ch_index = cindex;
this.N_ch = N_ch;
this.N_col = N_col;
this.N_sim = N_sim;
this.N_samp = N_samp;
- /*this.r = r;
- //this.H = null;
- //this.F = null;
- this.vH = new float[this.N_sim];
- this.vDn = new float[(int) this.N_sim/this.N_samp];
- this.vUp = new float[this.N_sim];*/
this.vF = new float[this.N_sim];
- /*this.H[] = new float[N_col];
- this.F[] = new float[N_col];
- for(int i = 0; i < N_col; i++) {
- H[i]=i*N_col+j*N_ch+j+i+j+1;
- F[i]=i*j+j*j+j+i;
- }*/
}
-
- /*public void init() {
- int j = this.ch_index;
- this.H = new float[this.N_col];
- this.F = new float[this.N_col];
- for(int i = 0; i < this.N_col; i++) {
- this.H[i]=i*this.N_col+j*this.N_ch+j+i+j+1;
- this.F[i]=i*j+j*j+j+i;
- }
- }*/
public void FBCore() {
int i,j,k;
//convolving H
for (j=0; j< Nsim; j++) {
- /*for (k=0; ((k<Ncol) & ((j-k)>=0)); k++) {
- vH[j]+=H[k]*r[j-k];
- }*/
k = 0;
boolean stat = false;
int diff = j;
//convolving F
for (j=0; j< Nsim; j++) {
- /*for (k=0; ((k<Ncol) & ((j-k)>=0)); k++) {
- tvF[j]+=F[k]*vUp[j-k];
- }*/
k = 0;
boolean stat = false;
int diff = j;
const int N_col=128;//32;
void begin(void);
-void FBCore(int N_samp,int N_ch, int N_col,float r[N_sim],float y[N_sim], float H[N_ch][N_col],float F[N_ch][N_col]);
+void FBCore(int N_samp,
+ int N_ch,
+ int N_col,
+ float* r,
+ float* y,
+ float** H,
+ float** F);
static int numiters = 1;
void begin(void){
- float r[N_sim];
- float y[N_sim];
- float H[N_ch][N_col];
- float F[N_ch][N_col];
-
+ float* r = (float*)malloc(sizeof(float) * N_sim);
+ float* y = (float*)malloc(sizeof(float) * N_sim);
+ float** H = (float**)malloc(sizeof(float) * N_ch);
+ float** F = (float**)malloc(sizeof(float) * N_ch);
int i,j;
+
+ for(i = 0; i < N_ch; i++) {
+ H[i] = (float*)malloc(sizeof(float) * N_col);
+ F[i] = (float*)malloc(sizeof(float) * N_col);
+ }
for (i=0;i<N_sim;i++)
r[i]=i+1;
#endif
}
}
+
+ free(r);
+ free(y);
+ for(i = 0; i < N_ch; i++) {
+ free(H[i]);
+ free(F[i]);
+ }
+ free(H);
+ free(F);
#ifdef RAW
raw_test_pass(raw_get_cycle());
// the FB core gets the input vector (r) , the filter responses H and F and generates the output vector(y)
-void FBCore(int N_samp,int N_ch, int N_col,float r[N_sim],float y[N_sim], float H[N_ch][N_col],float F[N_ch][N_col])
-{
+void FBCore(int N_samp,
+ int N_ch,
+ int N_col,
+ float* r,
+ float* y,
+ float** H,
+ float** F) {
int i,j,k;
for (i=0; i < N_sim;i++)
y[i]=0;
- for (i=0; i< N_ch; i++)
- {
- float Vect_H[N_sim]; //(output of the H)
- float Vect_Dn[(int) N_sim/N_samp]; //output of the down sampler;
- float Vect_Up[N_sim]; // output of the up sampler;
- float Vect_F[N_sim];// this is the output of the
+ for (i=0; i< N_ch; i++) {
+ float* Vect_H = (float *)malloc(sizeof(float) * N_sim); //(output of the H)
+ float* Vect_Dn = (float *)malloc(sizeof(float) * (int)(N_sim/N_samp)); //output of the down sampler;
+ float* Vect_Up = (float *)malloc(sizeof(float) * N_sim); // output of the up sampler;
+ float* Vect_F = (float *)malloc(sizeof(float) * N_sim);// this is the output of the
+
#ifdef RAW
//raw_test_pass(raw_get_cycle());
#endif
for (j=0; j < N_sim; j++)
y[j]+=Vect_F[j];
+
+ free(Vect_H);
+ free(Vect_Dn);
+ free(Vect_Up);
+ free(Vect_F);
#ifdef RAW
//raw_test_pass(raw_get_cycle());
#endif