int N_col=128;
int i,j;
- float r[] = new float[N_sim];
+ /*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/*, H, F*/){tosamp};
+ FilterBankAtom fba = new FilterBankAtom(j,
+ N_ch,
+ N_col,
+ N_sim,
+ N_samp/*,
+ r*/){tosamp};
}
- FilterBank fb = new FilterBank(N_sim, N_ch){!finish};
+ FilterBank fb = new FilterBank(N_sim, N_ch){!finish, !print};
taskexit(s{!initialstate});
}
task t2(FilterBankAtom fba{tosamp}) {
//System.printString("task t2\n");
- fba.init();
+ //fba.init();
fba.FBCore();
taskexit(fba{!tosamp, tomerge});
}
public boolean merge(float[] result) {
- for(int i = 0; i < this.N_sim; i++) {
- this.y[i] += result[i];
- }
- this.counter--;
+ float[] ty = this.y;
+ int Nsim = this.N_sim;
+ for(int i = 0; i < Nsim; i++) {
+ ty[i] += result[i];
+ }
+ this.counter--;
- return this.counter == 0;
+ return this.counter == 0;
}
public void print() {
- /*for(int i = 0; i < this.N_sim; i++) {
- //System.printI((int)this.y[i]);
- }*/
+ for(int i = 0; i < this.N_sim; i++) {
+ System.printI((int)(this.y[i] * 10000));
+ }
}
}
int N_col;
int N_sim;
int N_samp;
- float[] r;
- float[] H;
+ //float[] r;
+ /*float[] H;
float[] F;
float[] vH;
float[] vDn;
- float[] vUp;
+ float[] vUp;*/
public float[] vF;
- public FilterBankAtom(int cindex, int N_ch, int N_col, int N_sim, int N_samp, float[] r/*, float[] H, float[] F*/) {
+ public FilterBankAtom(int cindex,
+ int N_ch,
+ int N_col,
+ int N_sim,
+ int N_samp/*,
+ float[] r*/) {
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.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.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];
}*/
}
- public void init() {
+ /*public void init() {
int j = this.ch_index;
this.H = new float[this.N_col];
this.F = new float[this.N_col];
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 j,k;
+ int i,j,k;
+ int chindex = this.ch_index;
+ int Ncol = this.N_col;
+ int Nsim = this.N_sim;
+ int Nch = this.N_ch;
+ int Nsamp = this.N_samp;
+ float[] tvF = this.vF;
+
+ float r[] = new float[Nsim];
+ for (i=0;i<Nsim;i++) {
+ r[i]=i+1;
+ }
+
+ float[] H = new float[Ncol];
+ float[] F = new float[Ncol];
+ for(i = 0; i < Ncol; i++) {
+ H[i]=i*Ncol+chindex*Nch+chindex+i+chindex+1;
+ F[i]=i*chindex+chindex*chindex+chindex+i;
+ }
+ float[] vH = new float[Nsim];
+ float[] vDn = new float[(int)(Nsim/Nsamp)];
+ float[] vUp = new float[Nsim];
//convolving H
- for (j=0; j< N_sim; j++) {
- this.vH[j]=0;
- for (k=0; ((k<this.N_col) && ((j-k)>=0)); k++) {
- this.vH[j]+=this.H[k]*this.r[j-k];
+ for (j=0; j< Nsim; j++) {
+ for (k=0; ((k<Ncol) && ((j-k)>=0)); k++) {
+ vH[j]+=H[k]*r[j-k];
}
}
//Down Samplin
- for (j=0; j < this.N_sim/this.N_samp; j++) {
- this.vDn[j]=this.vH[j*this.N_samp];
+ for (j=0; j < Nsim/Nsamp; j++) {
+ vDn[j]=vH[j*Nsamp];
}
//Up Sampling
- for (j=0; j < this.N_sim; j++) {
- this.vUp[j]=0;
- }
- for (j=0; j < this.N_sim/this.N_samp; j++) {
- this.vUp[j*this.N_samp]=this.vDn[j];
+ for (j=0; j < Nsim/Nsamp; j++) {
+ vUp[j*Nsamp]=vDn[j];
}
//convolving F
- for (j=0; j< this.N_sim; j++) {
- this.vF[j]=0;
- for (k=0; ((k<this.N_col) && ((j-k)>=0)); k++) {
- this.vF[j]+=this.F[k]*this.vUp[j-k];
+ for (j=0; j< Nsim; j++) {
+ for (k=0; ((k<Ncol) && ((j-k)>=0)); k++) {
+ tvF[j]+=F[k]*vUp[j-k];
}
}
}
--- /dev/null
+#include <math.h>
+#ifdef RAW
+#include <raw.h>
+#else
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#endif
+
+//const int N_sim=2*1024;
+const int N_sim=1200;//2048;
+const int N_samp=8;
+//const int N_ch=N_samp;
+const int N_ch=16;//8;
+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]);
+
+static int numiters = 1;
+
+#ifndef RAW
+int main(int argc, char **argv)
+{
+ int option;
+
+ while ((option = getopt(argc, argv, "i:")) != -1)
+ {
+ switch(option)
+ {
+ case 'i':
+ numiters = atoi(optarg);
+ }
+ }
+
+ begin();
+ return 0;
+}
+#endif
+
+void begin(void){
+
+ float r[N_sim];
+ float y[N_sim];
+ float H[N_ch][N_col];
+ float F[N_ch][N_col];
+
+
+ int i,j;
+
+ for (i=0;i<N_sim;i++)
+ r[i]=i+1;
+
+
+ for (i=0;i<N_col;i++) {
+
+ for (j=0;j<N_ch;j++){
+ H[j][i]=i*N_col+j*N_ch+j+i+j+1;
+
+ F[j][i]=i*j+j*j+j+i;
+
+ }
+ }
+
+ while (numiters == -1 || numiters-- > 0) {
+ FBCore(N_samp,N_ch,N_col,r,y,H,F);
+ for (i=0;i<N_sim;i++) {
+#ifdef RAW
+ //print_float(y[i]);
+#else
+ //printf("%f\n", y[i]);
+#endif
+ }
+ }
+
+#ifdef RAW
+ raw_test_pass(raw_get_cycle());
+ raw_test_done(1);
+#endif
+}
+
+
+// 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])
+{
+ 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
+#ifdef RAW
+ raw_test_pass(raw_get_cycle());
+#endif
+
+ //convolving H
+ for (j=0; j< N_sim; j++)
+ {
+ Vect_H[j]=0;
+ for (k=0; ((k<N_col) & ((j-k)>=0)); k++)
+ Vect_H[j]+=H[i][k]*r[j-k];
+ }
+
+ //Down Sampling
+ for (j=0; j < N_sim/N_samp; j++)
+ Vect_Dn[j]=Vect_H[j*N_samp];
+
+ //Up Sampling
+ /*for (j=0; j < N_sim;j++)
+ Vect_Up[j]=0;
+ for (j=0; j < N_sim/N_samp;j++)
+ Vect_Up[j*N_samp]=Vect_Dn[j];*/
+
+ //convolving F
+ for (j=0; j< N_sim; j++)
+ {
+ Vect_F[j]=0;
+ /*for (k=0; ((k<N_col) & ((j-k)>=0)); k++)
+ Vect_F[j]+=F[i][k]*Vect_Up[j-k];*/
+ }
+
+ //adding the results to the y matrix
+
+ for (j=0; j < N_sim; j++)
+ y[j]+=Vect_F[j];
+#ifdef RAW
+ raw_test_pass(raw_get_cycle());
+#endif
+ }
+}