|
|
/*
|
/*
|
#ifndef __PEX_H__
|
#ifndef __PEX_H__
|
#include "pex.h"
|
#include "pex.h"
|
#endif
|
#endif
|
*/
|
*/
|
|
|
#include <cassert>
|
#include <cassert>
|
#include <cstdlib>
|
#include <cstdlib>
|
#include <cstring>
|
#include <cstring>
|
#include <iostream>
|
#include <iostream>
|
#include <iomanip>
|
#include <iomanip>
|
#include <climits>
|
#include <climits>
|
//#include <conio.h>
|
//#include <conio.h>
|
|
|
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
|
|
using namespace std;
|
using namespace std;
|
|
|
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
/*
|
/*
|
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
{
|
{
|
|
|
if(argc == 1) {
|
if(argc == 1) {
|
std::cerr << "usage: %s <device name>" << argv[0] << endl;
|
std::cerr << "usage: %s <device name>" << argv[0] << endl;
|
return -1;
|
return -1;
|
}
|
}
|
|
|
std ::cout << "Start testing device " << argv[1] << endl;
|
std ::cout << "Start testing device " << argv[1] << endl;
|
|
|
board *brd = new pex_board();
|
board *brd = new pex_board();
|
|
|
brd->brd_open(argv[1]);
|
brd->brd_open(argv[1]);
|
brd->brd_init();
|
brd->brd_init();
|
brd->brd_board_info();
|
brd->brd_board_info();
|
brd->brd_pld_info();
|
brd->brd_pld_info();
|
|
|
for(int i=0; i<16; i++)
|
for(int i=0; i<16; i++)
|
std ::cout << "BAR0[" << i << "] = 0x" << hex << brd->brd_bar0_read(i) << dec << endl;
|
std ::cout << "BAR0[" << i << "] = 0x" << hex << brd->brd_bar0_read(i) << dec << endl;
|
|
|
brd->brd_close();
|
brd->brd_close();
|
|
|
delete brd;
|
delete brd;
|
|
|
|
|
return 0;
|
return 0;
|
}
|
}
|
*/
|
*/
|
// FP_PEX8_TEST.cpp : Defines the entry point for the console application.
|
// FP_PEX8_TEST.cpp : Defines the entry point for the console application.
|
//
|
//
|
#include <locale.h>
|
#include <locale.h>
|
#include <unistd.h>
|
#include <unistd.h>
|
#include <stdlib.h>
|
#include <stdlib.h>
|
#include <stdio.h>
|
#include <stdio.h>
|
|
#include <signal.h>
|
|
|
#include "cl_wbpex.h"
|
#include "cl_wbpex.h"
|
//#include "tf_test.h"
|
//#include "tf_test.h"
|
//#include "tf_teststrm.h"
|
//#include "tf_teststrm.h"
|
//#include "tf_teststrmout.h"
|
//#include "tf_teststrmout.h"
|
//#include "useful.h"
|
//#include "useful.h"
|
#include "wb_teststrm.h"
|
#include "wb_teststrm.h"
|
#include "wb_teststrmout.h"
|
#include "wb_teststrmout.h"
|
|
|
CL_WBPEX g_Board;
|
CL_WBPEX g_Board;
|
|
|
U32 isTwoTest=0;
|
U32 isTwoTest=0;
|
|
|
static volatile int exit_flag = 0;
|
static volatile int exit_flag = 0;
|
|
|
void signa_handler(int signo)
|
void signa_handler(int signo)
|
{
|
{
|
exit_flag = 1;
|
exit_flag = 1;
|
}
|
}
|
|
|
|
|
void ShowWishboneInfo( CL_WBPEX *pBrd );
|
void ShowWishboneInfo( CL_WBPEX *pBrd );
|
|
|
//
|
//
|
//=== Console
|
//=== Console
|
//
|
//
|
//HANDLE hConsoleOut;
|
//HANDLE hConsoleOut;
|
|
|
|
|
int BRDC_main(int argc, BRDCHAR* argv[])
|
int BRDC_main(int argc, BRDCHAR* argv[])
|
{
|
{
|
// анализ командной строки
|
// анализ командной строки
|
setlocale( LC_ALL, "Russian" );
|
setlocale( LC_ALL, "Russian" );
|
|
signal(SIGINT, signa_handler);
|
|
|
TF_Test *pTest=NULL;
|
TF_Test *pTest=NULL;
|
TF_Test *pTest2=NULL;
|
TF_Test *pTest2=NULL;
|
|
|
BRDCHAR* fname = argv[1];
|
BRDCHAR* fname = argv[1];
|
BRDCHAR* fname2=NULL;
|
BRDCHAR* fname2=NULL;
|
if( argc<2 )
|
if( argc<2 )
|
{
|
{
|
fname=(BRDCHAR*)_BRDC("");
|
fname=(BRDCHAR*)_BRDC("");
|
}
|
}
|
if( argc==3 )
|
if( argc==3 )
|
{
|
{
|
fname2=argv[2];
|
fname2=argv[2];
|
}
|
}
|
|
|
|
|
//printf( "Файл инициализации: %s\n", fname );
|
//printf( "Файл инициализации: %s\n", fname );
|
try
|
try
|
{
|
{
|
CL_WBPEX *pBrd = &g_Board;
|
CL_WBPEX *pBrd = &g_Board;
|
|
|
int ret=pBrd->init();
|
int ret=pBrd->init();
|
|
|
if( 0==ret )
|
if( 0==ret )
|
{
|
{
|
BRDC_fprintf( stderr, _BRDC("Board PEXDRV open succesfully\n") );
|
BRDC_fprintf( stderr, _BRDC("Board PEXDRV open succesfully\n") );
|
|
|
|
|
/*
|
/*
|
for( trd=0; trd<8; trd++ )
|
for( trd=0; trd<8; trd++ )
|
pBrd->RegPokeInd( trd, 0, 1 );
|
pBrd->RegPokeInd( trd, 0, 1 );
|
|
|
for( trd=0; trd<8; trd++ )
|
for( trd=0; trd<8; trd++ )
|
for( int ii=1; ii<32; ii++ )
|
for( int ii=1; ii<32; ii++ )
|
pBrd->RegPokeInd( trd, ii, 0 );
|
pBrd->RegPokeInd( trd, ii, 0 );
|
|
|
for( trd=0; trd<8; trd++ )
|
for( trd=0; trd<8; trd++ )
|
pBrd->RegPokeInd( trd, 0, 0 );
|
pBrd->RegPokeInd( trd, 0, 0 );
|
*/
|
*/
|
|
|
} else
|
} else
|
{
|
{
|
BRDC_fprintf( stderr, _BRDC("Error during open PEXDRV: ret=0x%.8X\n"), ret );
|
BRDC_fprintf( stderr, _BRDC("Error during open PEXDRV: ret=0x%.8X\n"), ret );
|
//getch();
|
//getch();
|
exit(-1);
|
exit(-1);
|
}
|
}
|
|
|
//printf( "\nShowPldInfo\n" );
|
//printf( "\nShowPldInfo\n" );
|
ShowWishboneInfo( pBrd );
|
ShowWishboneInfo( pBrd );
|
//}
|
//}
|
|
|
|
|
//#if 0
|
//#if 0
|
if( fname[0]=='o' )
|
if( fname[0]=='o' )
|
pTest = new WB_TestStrmOut( fname, pBrd );
|
pTest = new WB_TestStrmOut( fname, pBrd );
|
else
|
else
|
pTest = new WB_TestStrm( fname, pBrd );
|
pTest = new WB_TestStrm( fname, pBrd );
|
|
|
Sleep( 10 );
|
Sleep( 10 );
|
|
|
if( fname2 )
|
if( fname2 )
|
{
|
{
|
isTwoTest=1;
|
isTwoTest=1;
|
if( fname2[0]=='o' )
|
if( fname2[0]=='o' )
|
pTest2 = new WB_TestStrmOut( fname2, pBrd );
|
pTest2 = new WB_TestStrmOut( fname2, pBrd );
|
else
|
else
|
pTest2 = new WB_TestStrm( fname2, pBrd );
|
pTest2 = new WB_TestStrm( fname2, pBrd );
|
}
|
}
|
|
|
pTest->Prepare();
|
pTest->Prepare();
|
if( pTest2 )
|
if( pTest2 )
|
pTest2->Prepare();
|
pTest2->Prepare();
|
|
|
Sleep( 10 );
|
Sleep( 10 );
|
pTest->Start();
|
pTest->Start();
|
Sleep( 10 );
|
Sleep( 10 );
|
if( pTest2 )
|
if( pTest2 )
|
pTest2->Start();
|
pTest2->Start();
|
|
|
//int key;
|
//int key;
|
int isFirstCallStep=1;
|
int isFirstCallStep=1;
|
int isStopped = 0;
|
int isStopped = 0;
|
for( ; ; )
|
for( ; ; )
|
{
|
{
|
|
|
|
|
if( exit_flag )
|
if( exit_flag )
|
{
|
{
|
if(!isStopped) {
|
if(!isStopped) {
|
pTest->Stop();
|
pTest->Stop();
|
if( pTest2 ) {
|
if( pTest2 ) {
|
pTest2->Stop();
|
pTest2->Stop();
|
}
|
}
|
BRDC_fprintf( stderr, _BRDC("\n\nCancel\n") );
|
BRDC_fprintf( stderr, _BRDC("\n\nCancel\n") );
|
isStopped = 1;
|
isStopped = 1;
|
}
|
}
|
}
|
}
|
|
|
if( exit_flag )
|
if( exit_flag )
|
{
|
{
|
if(isStopped) {
|
if(isStopped) {
|
|
|
if( pTest->isComplete() ) {
|
if( pTest->isComplete() ) {
|
|
|
if( pTest2 ) {
|
if( pTest2 ) {
|
if( pTest2->isComplete() )
|
if( pTest2->isComplete() )
|
break;
|
break;
|
} else {
|
} else {
|
break;
|
break;
|
}
|
}
|
}
|
}
|
}
|
}
|
}
|
}
|
|
|
|
|
//SetConsoleCursorPosition(hConsoleOut, rCursorPosition);
|
//SetConsoleCursorPosition(hConsoleOut, rCursorPosition);
|
if( isFirstCallStep || isTwoTest )
|
if( isFirstCallStep || isTwoTest )
|
{
|
{
|
|
|
BRDC_fprintf( stdout, _BRDC("%10s %10s %10s %10s %10s %10s %10s %10s\n"), _BRDC(""), _BRDC("BLOCK_WR"), _BRDC("BLOCK_RD"), _BRDC("BLOCK_OK"), _BRDC("BLOCK_ERR"), _BRDC("SPD_CURR"), _BRDC("SPD_AVR"), _BRDC("STATUS"));
|
BRDC_fprintf( stdout, _BRDC("%10s %10s %10s %10s %10s %10s %10s %10s\n"), _BRDC(""), _BRDC("BLOCK_WR"), _BRDC("BLOCK_RD"), _BRDC("BLOCK_OK"), _BRDC("BLOCK_ERR"), _BRDC("SPD_CURR"), _BRDC("SPD_AVR"), _BRDC("STATUS"));
|
BRDC_fprintf( stdout, _BRDC("\n"));
|
BRDC_fprintf( stdout, _BRDC("\n"));
|
}
|
}
|
|
|
if (isFirstCallStep)
|
if (isFirstCallStep)
|
{
|
{
|
//CONSOLE_SCREEN_BUFFER_INFO csbInfo;
|
//CONSOLE_SCREEN_BUFFER_INFO csbInfo;
|
//hConsoleOut = GetStdHandle( STD_OUTPUT_HANDLE );
|
//hConsoleOut = GetStdHandle( STD_OUTPUT_HANDLE );
|
//GetConsoleScreenBufferInfo(hConsoleOut, &csbInfo);
|
//GetConsoleScreenBufferInfo(hConsoleOut, &csbInfo);
|
//rCursorPosition=csbInfo.dwCursorPosition;
|
//rCursorPosition=csbInfo.dwCursorPosition;
|
isFirstCallStep=false;
|
isFirstCallStep=false;
|
|
|
}
|
}
|
|
|
pTest->Step();
|
pTest->Step();
|
if( isTwoTest )
|
if( isTwoTest )
|
BRDC_fprintf( stderr, "\n" );
|
BRDC_fprintf( stderr, "\n" );
|
if( pTest2 )
|
if( pTest2 )
|
pTest2->Step();
|
pTest2->Step();
|
if( isTwoTest )
|
if( isTwoTest )
|
BRDC_fprintf( stderr, "\n\n" );
|
BRDC_fprintf( stderr, "\n\n" );
|
|
|
Sleep( 400 );
|
Sleep( 400 );
|
|
|
fflush( stdout );
|
fflush( stdout );
|
}
|
}
|
pTest->GetResult();
|
pTest->GetResult();
|
if( pTest2 )
|
if( pTest2 )
|
pTest2->GetResult();
|
pTest2->GetResult();
|
|
|
|
|
delete pTest; pTest=NULL;
|
delete pTest; pTest=NULL;
|
delete pTest2; pTest2=NULL;
|
delete pTest2; pTest2=NULL;
|
|
|
}
|
}
|
catch( BRDCHAR* str )
|
catch( BRDCHAR* str )
|
{
|
{
|
BRDC_fprintf( stderr, _BRDC("Err: %s \n"), str );
|
BRDC_fprintf( stderr, _BRDC("Err: %s \n"), str );
|
}
|
}
|
catch( ... )
|
catch( ... )
|
{
|
{
|
BRDC_fprintf( stderr, _BRDC("Неизвестная ошибка выполнения программы\n") );
|
BRDC_fprintf( stderr, _BRDC("Неизвестная ошибка выполнения программы\n") );
|
}
|
}
|
|
|
|
|
BRDC_fprintf( stderr, "\n Press any key\n" );
|
BRDC_fprintf( stderr, "\n Press any key\n" );
|
//getch();
|
//getch();
|
|
|
//}
|
//}
|
return 0;
|
return 0;
|
//#endif
|
//#endif
|
}
|
}
|
|
|
|
|
|
|
void ShowWishboneInfo( CL_WBPEX *pBrd )
|
void ShowWishboneInfo( CL_WBPEX *pBrd )
|
{
|
{
|
|
|
|
|
{
|
{
|
U32 d, d1, d2, d3, d4, d5, ii;
|
U32 d, d1, d2, d3, d4, d5, ii;
|
U32 block_id, block_id_mod;
|
U32 block_id, block_id_mod;
|
U32 block_ver_major, block_ver_minor;
|
U32 block_ver_major, block_ver_minor;
|
const char *str;
|
const char *str;
|
|
|
BRDC_fprintf( stderr, _BRDC("FPGA WB\r\n") );
|
BRDC_fprintf( stderr, _BRDC("FPGA WB\r\n") );
|
|
|
|
|
/*
|
/*
|
d=pBrd->RegPeekInd( 0, 0x108 );
|
d=pBrd->RegPeekInd( 0, 0x108 );
|
if( d==0x4953 ) {
|
if( d==0x4953 ) {
|
BRDC_fprintf( stderr, _BRDC(" SIG= 0x%.4X - Ok \n"), d );
|
BRDC_fprintf( stderr, _BRDC(" SIG= 0x%.4X - Ok \n"), d );
|
} else {
|
} else {
|
BRDC_fprintf( stderr, _BRDC(" SIG= 0x%.4X - Ошибка, ожидается 0x4953 \n"), d );
|
BRDC_fprintf( stderr, _BRDC(" SIG= 0x%.4X - Ошибка, ожидается 0x4953 \n"), d );
|
throw( 1 );
|
throw( 1 );
|
}
|
}
|
|
|
d=pBrd->RegPeekInd( 0, 0x109 ); BRDC_fprintf( stderr, " Версия интерфейса ADM: %d.%d\n", d>>8, d&0xFF );
|
d=pBrd->RegPeekInd( 0, 0x109 ); BRDC_fprintf( stderr, " Версия интерфейса ADM: %d.%d\n", d>>8, d&0xFF );
|
d=pBrd->RegPeekInd( 0, 0x110 ); d1=pBrd->RegPeekInd( 0, 0x111 );
|
d=pBrd->RegPeekInd( 0, 0x110 ); d1=pBrd->RegPeekInd( 0, 0x111 );
|
BRDC_fprintf( stderr, " Базовый модуль: 0x%.4X v%d.%d\n", d, d1>>8, d1&0xFF );
|
BRDC_fprintf( stderr, " Базовый модуль: 0x%.4X v%d.%d\n", d, d1>>8, d1&0xFF );
|
|
|
d=pBrd->RegPeekInd( 0, 0x112 ); d1=pBrd->RegPeekInd( 0, 0x113 );
|
d=pBrd->RegPeekInd( 0, 0x112 ); d1=pBrd->RegPeekInd( 0, 0x113 );
|
BRDC_fprintf( stderr, " Субмодуль: 0x%.4X v%d.%d\n", d, d1>>8, d1&0xFF );
|
BRDC_fprintf( stderr, " Субмодуль: 0x%.4X v%d.%d\n", d, d1>>8, d1&0xFF );
|
|
|
d=pBrd->RegPeekInd( 0, 0x10B ); BRDC_fprintf( stderr, " Модификация прошивки ПЛИС: %d \n", d );
|
d=pBrd->RegPeekInd( 0, 0x10B ); BRDC_fprintf( stderr, " Модификация прошивки ПЛИС: %d \n", d );
|
d=pBrd->RegPeekInd( 0, 0x10A ); BRDC_fprintf( stderr, " Версия прошивки ПЛИС: %d.%d\n", d>>8, d&0xFF );
|
d=pBrd->RegPeekInd( 0, 0x10A ); BRDC_fprintf( stderr, " Версия прошивки ПЛИС: %d.%d\n", d>>8, d&0xFF );
|
d=pBrd->RegPeekInd( 0, 0x114 ); BRDC_fprintf( stderr, " Номер сборки прошивки ПЛИС: 0x%.4X\n", d );
|
d=pBrd->RegPeekInd( 0, 0x114 ); BRDC_fprintf( stderr, " Номер сборки прошивки ПЛИС: 0x%.4X\n", d );
|
*/
|
*/
|
|
|
BRDC_fprintf( stderr, "\nWB block info:\n\n" );
|
BRDC_fprintf( stderr, "\nWB block info:\n\n" );
|
for( ii=0; ii<2; ii++ ) {
|
for( ii=0; ii<2; ii++ ) {
|
|
|
d= pBrd->wb_block_read( ii, 0 );
|
d= pBrd->wb_block_read( ii, 0 );
|
block_id = d & 0xFFF; block_id_mod=(d>>12) & 0xF;
|
block_id = d & 0xFFF; block_id_mod=(d>>12) & 0xF;
|
|
|
d1=pBrd->wb_block_read( ii, 1 );
|
d1=pBrd->wb_block_read( ii, 1 );
|
block_ver_major=(d1>>8) & 0xFF;
|
block_ver_major=(d1>>8) & 0xFF;
|
block_ver_minor=d1&0xFF;
|
block_ver_minor=d1&0xFF;
|
/*
|
/*
|
d2=pBrd->RegPeekInd( ii, 0x102 );
|
d2=pBrd->RegPeekInd( ii, 0x102 );
|
d3=pBrd->RegPeekInd( ii, 0x103 );
|
d3=pBrd->RegPeekInd( ii, 0x103 );
|
d4=pBrd->RegPeekInd( ii, 0x104 );
|
d4=pBrd->RegPeekInd( ii, 0x104 );
|
d5=pBrd->RegPeekInd( ii, 0x105 );
|
d5=pBrd->RegPeekInd( ii, 0x105 );
|
*/
|
*/
|
|
|
switch( d ) {
|
switch( d ) {
|
case 0x1A: str="TEST_CHECK "; break;
|
case 0x1A: str="TEST_CHECK "; break;
|
case 0x1B: str="TEST_GENERATE "; break;
|
case 0x1B: str="TEST_GENERATE "; break;
|
|
|
|
|
default: str="UNKNOW "; break;
|
default: str="UNKNOW "; break;
|
}
|
}
|
//BRDC_fprintf( stderr, " %d 0x%.8X 0x%.8X \n", ii, d, d1 );
|
//BRDC_fprintf( stderr, " %d 0x%.8X 0x%.8X \n", ii, d, d1 );
|
|
|
BRDC_fprintf( stderr, " %d 0x%.4X %s ", ii, block_id, str );
|
BRDC_fprintf( stderr, " %d 0x%.4X %s ", ii, block_id, str );
|
if( block_id>0 ) {
|
if( block_id>0 ) {
|
BRDC_fprintf( stderr, " MOD: %-2d VER: %d.%d \n", block_id_mod, block_ver_major, block_ver_minor );
|
BRDC_fprintf( stderr, " MOD: %-2d VER: %d.%d \n", block_id_mod, block_ver_major, block_ver_minor );
|
} else {
|
} else {
|
BRDC_fprintf( stderr, "\n" );
|
BRDC_fprintf( stderr, "\n" );
|
}
|
}
|
|
|
}
|
}
|
|
|
|
|
BRDC_fprintf( stderr, "\r\n" );
|
BRDC_fprintf( stderr, "\r\n" );
|
|
|
}
|
}
|
}
|
}
|
|
|
|
|