#include "IFFT4096DataTurn.h"


void IFFT4096DataTurn(int ConfigBaseAddr,int Nsymbol,int Nport,int InputAddr0,int InputAddr1,int OutputAddr0,int OutputAddr1){

	//KI2
    const unsigned int addr_move_base = ConfigBaseAddr;
	volatile unsigned int *addr_move = (volatile unsigned int *)addr_move_base;
	int a=Nsymbol;//+1;
	int KSize;
	int FFTSize=4096;
        addr_move[0] = a;//>>1;
        if (FFTSize==2048)
	{
		addr_move[2] = 128;
		addr_move[3] = 128;
		KSize=3;
	}
	else
	{
		addr_move[2] = 256;
		addr_move[3] = 256;
		KSize=4;
	}
        //prog 1-6 BIU
    const unsigned int addr_biu_base1 = ConfigBaseAddr+0x40;
	volatile unsigned int *addr_biu1 = (volatile unsigned int *)addr_biu_base1;
        //BIU0.T0
        addr_biu1[0] = InputAddr0;
        addr_biu1[1] = InputAddr0;
        addr_biu1[2] = InputAddr0;
        addr_biu1[3] = InputAddr0;

        //BIU1.T0
        addr_biu1[0+16*1] = InputAddr1;
        addr_biu1[1+16*1] = InputAddr1;
        addr_biu1[2+16*1] = InputAddr1;
        addr_biu1[3+16*1] = InputAddr1;


        //BIU2.T2
        addr_biu1[0+16*2] = OutputAddr0;
        addr_biu1[1+16*2] = OutputAddr0;
        addr_biu1[2+16*2] = OutputAddr0;
        addr_biu1[3+16*2] = OutputAddr0;
        addr_biu1[14+16*2] = KSize;

        //BIU2.T3
        addr_biu1[0+16*3] = OutputAddr1;
        addr_biu1[1+16*3] = OutputAddr1;
        addr_biu1[2+16*3] = OutputAddr1;
        addr_biu1[3+16*3] = OutputAddr1;
        addr_biu1[14+16*3] = KSize;

        addr_biu1[0+16*3] = OutputAddr1;
        addr_biu1[1+16*3] = OutputAddr1;
        addr_biu1[2+16*3] = OutputAddr1;
        addr_biu1[3+16*3] = OutputAddr1;
        addr_biu1[14+16*3] = KSize;

        int FRF;
        if (Nport==1){
        	FRF=5792;//11585;
        }
        else{
        	FRF=8192;//16384;
        }

        addr_biu1[0+16*4] = FRF;
        addr_biu1[1+16*4] = FRF;
        addr_biu1[2+16*4] = FRF;
        addr_biu1[3+16*4] = FRF;
        addr_biu1[4+16*4] = FRF;
        addr_biu1[5+16*4] = FRF;
        addr_biu1[6+16*4] = FRF;
        addr_biu1[7+16*4] = FRF;
        addr_biu1[8+16*4] = FRF;
        addr_biu1[9+16*4] = FRF;
        addr_biu1[10+16*4] = FRF;
        addr_biu1[11+16*4] = FRF;
        addr_biu1[12+16*4] = FRF;
        addr_biu1[13+16*4] = FRF;
        addr_biu1[14+16*4] = FRF;
        addr_biu1[15+16*4] = FRF;
}
