📄 fbr.c
字号:
/**
*** Copyright (c) 2001 Equator Technologies, Inc.
**/
//*********************************************************************
//
// File: sema.c :
//
// Example program showing how to interact synchronize the vlx threads
// with vliw threads. The vliw polls a semaphore cleared by the vlx.
// (initial value is non-zero, vliw waits for it to be zeroed).
//
//*********************************************************************
#define S_PASS 0
#define S_FAIL_SEMA 1
#define S_FAIL_DATA 2
#define S_FAIL_OTHER 3
//
// Example program showing how to interact with the I/O side of the VLX
//
#include <eti/ds.h>
#include <mm.h>
#include <eti/vlx.h>
#include <eti/mapca/vlxm_piomap.h>
#include "vlxasm.h" // pick up the VLX binary labels
#include "common.h"
//----------------------------------
//
// Global Variables
//
//----------------------------------
extern VLX_BIN vlxasm; // vlx binary struct
PVLX_BIN vlxBin = &vlxasm; // pointer to vlx binary struct
//----------------------------------
//
// main()
//
//----------------------------------
main()
{
//
// Declarations
//
int i,j;
int succeeded=S_PASS;
SCODE status;
volatile unsigned short* pVlMemI;
volatile unsigned short* pVlMemD0;
volatile unsigned short* pVlMemD1;
volatile unsigned short* pVlMemData;
short expectedData;
int errCnt = 0;
char* status_string[4] = {
"S_PASS",
"S_FAIL_SEMA",
"S_FAIL_DATA",
"S_FAIL_OTHER"
};
//
// Code
//
kprintf("\nIn main()...\n");
pVlMemI = (volatile unsigned short *) VlxLookupCM1();
pVlMemD0 = (volatile unsigned short *) (pVlMemI + _VLMEM_DATA0_OFFSET_SHORT);
pVlMemD1 = (volatile unsigned short *) (pVlMemI + _VLMEM_DATA1_OFFSET_SHORT);
#if 0
kprintf("\npVlMemI = 0x%lx\n", pVlMemI );
kprintf("pVlMemD0 = 0x%lx\n", pVlMemD0 );
kprintf("pVlMemD1 = 0x%lx\n", pVlMemD1 );
#endif
//
// Load Vlx Binary from DRAM to VlMem
//
status = VlxLoadBinaryByValue(
vlxBin, // Pointer to the binary struct
((vlxBin->BinaryByteLength + 1) >> 1), // Length to transfer is in 16-bit quantities
VLXLAB_PCSTART, // transfer from the beginning of the vlx program code...
0, // ...which is the beginning of CM1 (offset 0)
VLX_LOAD_PIO // Use PIO writes to do the transfer
);
if (status==S_ERROR) {
kprintf("ERROR : VlxLoadBinaryByValue returned S_ERROR\n");
exit(1);
}
// Printout sema before VlxKick()
kprintf("\nBefore Kicking Vlx...\n");
pVlMemData = (volatile unsigned short *) (pVlMemI + VLXLAB_D1_SEMA);
kprintf("pVlMemData (SEMA) = 0x%lx\n", pVlMemData );
kprintf("\n*pVlMemData = 0x%x\n", *pVlMemData );
//
// Kick the Vlx so it starts processing
//
kprintf("\nReset and Kick Vlx...\n");
VlxResetPC(); // this makes the starting PC for the VLx be 0.
VlxKick(); // this turns on the VLx clock.
//
// Semaphore Polling Loop
//
kprintf("\nWaiting for vlx to clear semaphore...\n");
i=0;
while(*(volatile unsigned short*)pVlMemData != 0) {
if( i++ > SEMA_TIMEOUT_CYCLES ) break;
}
//
// Check for time-out
//
kprintf("*pVlMemData = 0x%x\n", *pVlMemData );
if ( i > SEMA_TIMEOUT_CYCLES ) {
kprintf("ERROR...semaphore timed out, resume.\n");
succeeded = S_FAIL_SEMA;
exit(3);
} else {
kprintf("...semaphore cleared, resume.\n");
}
//
// Tell the VLx the show is over
//
kprintf("\nHalt Vlx...\n");
VlxStop(); // turns off the VLx clock
//
// Check Data : FBRCNT set to infinite loop
//
kprintf("Checking Data for FBRCNT set to infinite loop \n");
pVlMemData = (volatile unsigned short *) (pVlMemI + VLXLAB_D0_DATA_INF);
expectedData = 0x100;
errCnt = 0;
for ( i = 0 ; i < 255 ; i++ ) {
if ( *(volatile unsigned short*)pVlMemData != expectedData ) {
succeeded = S_FAIL_DATA;
kprintf(" MISCOMPARE : data[%d] = 0x%x -- expected = 0x%x \n", i, *(volatile unsigned short*)pVlMemData , expectedData);
errCnt++;
}
pVlMemData++;
expectedData--;
}
if (errCnt == 0) {
kprintf("\n++++++++++ Loop 1 of 2 successfully matched all expected data ++++++++++ \n\n");
} else {
kprintf("\n---------- Loop 1 of 2 had errors ---------- \n\n");
}
//
// Check Data : FBRCNT set to finite loop
//
kprintf("Checking Data for FBRCNT set to finite loop \n");
pVlMemData = (volatile unsigned short *) (pVlMemI + VLXLAB_D0_DATA_FIN);
expectedData = 0x100;
errCnt=0;
for ( i = 0 ; i < 255 ; i++ ) {
if ( i < 64 ) {
if ( *(volatile unsigned short*)pVlMemData != expectedData ) {
succeeded = S_FAIL_DATA;
kprintf(" MISCOMPARE : data[%d] = 0x%x (@ 0x%08x) -- expected = 0x%x \n"
, i, *(volatile unsigned short*)pVlMemData, pVlMemData, expectedData);
errCnt++;
}
} else {
if ( *(volatile unsigned short*)pVlMemData != 0 ) {
succeeded = S_FAIL_DATA;
kprintf(" MISCOMPARE : data[%d] = 0x%x (@ 0x%08x) -- expected = 0x%x \n"
, i, *(volatile unsigned short*)pVlMemData, pVlMemData, 0);
errCnt++;
}
}
pVlMemData++;
expectedData--;
}
if (errCnt == 0) {
kprintf("\n++++++++++ Loop 2 of 2 successfully matched all expected data ++++++++++ \n\n");
} else {
kprintf("\n---------- Loop 2 of 2 had errors ---------- \n\n");
}
if (succeeded==S_PASS) {
kprintf("\nPASSED!!\n\n");
} else {
kprintf("\nFAILED!! code %d ... Try again...\n\n", succeeded );
}
kprintf("\nStatus : %d\n", succeeded);
kprintf("\tstatus_string = %s \n", status_string[succeeded] );
kprintf("\nend\n");
exit(0);
} // end main()
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -