#include "xmk.h"
#include "sys/init.h"
#include "platform.h"
#include "xparameters.h"
#include "xbasic_types.h"
#include "xstatus.h"
#include "testplb_02.h"
#include <stdio.h>
Xuint32 *baseaddr_p = (Xuint32 *)XPAR_TESTPLB_02_0_BASEADDR;
int main()
{
Xuint32 baseaddr;
Xuint32 DataIN = 0;
Xuint32 DataOUT = 0;
init_platform();
// Check that the peripheral exists
XASSERT_NONVOID(baseaddr_p != XNULL);
baseaddr = (Xuint32) baseaddr_p;
TESTPLB_02_mReset(baseaddr);
// Reset read and write packet FIFOs to initial state
TESTPLB_02_mResetWriteFIFO(baseaddr);
TESTPLB_02_mResetReadFIFO(baseaddr);
DataOUT = TESTPLB_02_mReadFromFIFO(baseaddr, 0);
//**************************************
// DataOUT is 0, where as it should be B"101010...." as in the reset.
// So in a nut shell, FPGA doesnot reset correctly.
// Rest of the code works fine.
//***************************************
DataIN = 131074; //2*2
TESTPLB_02_mWriteToFIFO(baseaddr, 0, DataIN);
DataOUT = TESTPLB_02_mReadFromFIFO(baseaddr, 0);
if(DataOUT != 4)
{
DataOUT = DataOUT;
}
DataIN = 327685; //5*5
TESTPLB_02_mWriteToFIFO(baseaddr, 0, DataIN);
DataOUT = TESTPLB_02_mReadFromFIFO(baseaddr, 0);
if(DataOUT != 25)
{
DataOUT = DataOUT;
}
DataIN = 524296; //8*8
TESTPLB_02_mWriteToFIFO(baseaddr, 0, DataIN);
DataOUT = TESTPLB_02_mReadFromFIFO(baseaddr, 0);
if(DataOUT != 64)
{
DataOUT = DataOUT;
}
DataIN = 524295; //7*8
TESTPLB_02_mWriteToFIFO(baseaddr, 0, DataIN);
DataOUT = TESTPLB_02_mReadFromFIFO(baseaddr, 0);
if(DataOUT != 56)
{
DataOUT = DataOUT;
}
// Stay in an infinite loop
while(1){
}
// Reset the read and write FIFOs
TESTPLB_02_mResetWriteFIFO(baseaddr);
TESTPLB_02_mResetReadFIFO(baseaddr);
return 0;
}