
#ifndef REMOVE_MC_TEST
#include <stdio.h>
#include <string.h>

#include <tick.h>

#include "ucps2.h"
#include "LdpcDecBG1AllZc.h"

#define SHIFTBIT_EN
//#undef	SHIFTBIT_EN

#ifdef  SHIFTBIT_EN
	#define case_24Zc384_Iter8
	#define	Zc			(384)
	#define CodeRate	(0)
	__DM0 char zeros[384*2] = {0};
	__DM0 int in_ZnAddr[0x4000] =
	{
		#include "testdata/case_24Zc384_Iter8/iter1/Ue0_Cb3_ByteShift_out.dat"
	};
#else
	#include "testdata/in_Zn_LdpcDecBG1.dat"
#endif

__DM0 int tmp_AZnSaveAddr[0xa000] = {0};
__DM1 int tmp_BZnSaveAddr[0xa000] = {0};

__DM2 int DecOut[1024] = {0};

__DM0 int CheckMatrix0[48] =
{
	#include "GenLdpcBG1Para/BG1CheckMatrix0.dat"
};

__DM1 int CheckMatrix1[48] =
{
	#include "GenLdpcBG1Para/BG1CheckMatrix1.dat"
};

__DM1 int DecMatrixZcLatch[26*16] =
{
	#include "GenLdpcBG1Para/DecMatrixZcLatch.dat"
};

__DM2 int Lmn0[0x4000] =
{
#include <Lmn/Lmn.dat>
};

__DM3 int Lmn1[0x4000] =
{
#include <Lmn/Lmn.dat>
};

__DM4 int Lmn2[0x4000] =
{
#include <Lmn/Lmn.dat>
};

__DM5 int Lmn3[0x4000] =
{
#include <Lmn/Lmn.dat>
};

__DM3 int Config[32*16] =
{
#include <CfgLdpcDecBG1AllZc.dat>
};

__DM2 v16s32 SVRReg =
{
	0x00000000,0x00000000,0x00000000,0x00000000,
	0x00000040,0x00000000,0x00000000,0x00000000,
	0xffffffff,0x00000000,0x00000000,0x00000000,
	0xffffffff,0x00000006,0x00000000,0x00000000,
};

int main(void)
{
	int MulFactor = 0x62;
#ifdef  SHIFTBIT_EN
	int ShiftBit = 0x06;
	int zn_start_addr = (int)zeros;
#else
	int ShiftBit = 0x0;
	int zn_start_addr = (int)in_ZnAddr;
#endif
	int MaxIterNum = 6;

	unsigned int Ack = 0, CYC = 0, start = 0, spuend = 0, mpustart = 0, mpuend = 0;

	start = tick();
		LdpcDecBG1AllZc(
			(int)Config,
			Zc, MaxIterNum,
			ShiftBit, MulFactor,
			CodeRate,
			MPU_ADDR(zn_start_addr),
			MPU_ADDR(DecMatrixZcLatch),
			MPU_ADDR(Lmn0), MPU_ADDR(Lmn1), MPU_ADDR(Lmn2), MPU_ADDR(Lmn3),
			MPU_ADDR(CheckMatrix0), MPU_ADDR(CheckMatrix1),
			MPU_ADDR(DecOut)/*,
			MPU_ADDR(tmp_AZnSaveAddr),
			MPU_ADDR(tmp_BZnSaveAddr)*/
		);
	spuend = tick();

		mpustart = tick();
		SVRReg[0] = MPU_ADDR(Config);
		LdpcDecBG1AllZcAsm(SVRReg);
		__ucps2_getStatB();
		__ucps2_delay();
		Ack = __ucps2_getKI(5);
		CYC = __ucps2_getKI(9);
		mpuend = tick();

	printf("Zc = %4u:\nAck = 32'h%08x,\nCYC = 32'd%08d,\nSpuTick = 32'd%08u,\nMpuTick = 32'd%08u.\n",
		Zc, Ack, CYC, spuend - start, mpuend - mpustart);
	return 0;
}
#endif
