📄 vswap.c
字号:
/**
*** Copyright (c) 2001 Equator Technologies, Inc.
**/
//#define CONFIG_OVERRIDE_DEFAULT_YIELD_HANDLER
#define CONFIG_NO_YIELD_HANDLER
//#define _CONFIG_DEBUG_GB
//#define _CONFIG_DEBUG_LIMIT_NUM_SWAPS
// Declare standard virtual registers
register void (*pGbStallHandler)() asm ("greg0");
#include "vdata.h"
#include "vdata.c"
#include <vlxapi/vlxstd.h>
void Exit (short flag);
int main()
{
//---------------------------------------------
// Declarations
//---------------------------------------------
short swapcount = 0;
short iter_i;
short swap_unit; // Number of shorts to shift before channel swapping
short* pGbStateBuffer; // Temp buffer to store state
short nswap;
short* pDebugBuffer = &debug_buffer[0];
//---------------------------------------------
// EXECUTION
//---------------------------------------------
//
// Read parameters from core
//
swap_unit = data_from_core.swap_unit_size >>> 1; // Convert from bytes to shorts
nswap = data_from_core.nswap;
status.swap_unit = swap_unit;
status.nswap = nswap;
status.swapcount = swapcount;
pGbStallHandler = &VlxGbStallHandler;
// Swap out quiescent state
//VlxGbReadState( (unsigned short*)(&gb_config_quiescent) );
VlxGbReadState( (&gb_config_quiescent) );
//
// Configure stream 1
//
VlxGbConfigDS(gb_config1.ds_ctrl);
VlxGbSetOptions( GB_ENABLE_INPUT_AND_FILTER );
VlxGbAlignI();
VlxGbAdvIB(0);
// Initial Gb input shifts for stream 1
for ( iter_i = 0 ; iter_i < swap_unit ; iter_i++ ) {
VlxGbAdvIB(16);
}
//
// First channel swap
//
VlxGbSetOptions( GB_DISABLE_INPUT );
vlx_mnop(4); // Delay to ensure gbpend settles
// Save current state in gb_swap_buffer
// ~ note that this writes garbage into the GB internal state
VlxChannelSwap( &gb_swap_buffer );
// Restore initial state (does not write the vlmem buffer)
VlxGbWriteState( &gb_config_quiescent );
swapcount++; // Update swap count.
status.swapcount = swapcount;
// Configure for Stream 2
// Note that the channel swap routine disables input, so we need to
// turn it back on here!
VlxGbConfigDS(gb_config2.ds_ctrl);
VlxGbSetOptions( GB_ENABLE_INPUT_AND_FILTER );
VlxGbAlignI();
VlxGbAdvIB(0);
while ( swapcount < nswap ) {
for ( iter_i = 0 ; iter_i < swap_unit ; iter_i++ ) {
VlxGbAdvIB(16);
}
//
// Swap channels
//
VlxGbSetOptions( GB_DISABLE_INPUT );
vlx_mnop(4); // Delay to ensure gbpend settles
VlxChannelSwap( &gb_swap_buffer ); // Get last state from the swap buffer
swapcount++; // Update swap count.
status.swapcount = swapcount;
#ifdef _CONFIG_DEBUG_LIMIT_NUM_SWAPS
if ( swapcount == 2 ) {
Exit (VLX_STATUS_FORCED_END);
}
#endif
VlxGbSetOptions( GB_ENABLE_INPUT_AND_FILTER );
} // end while ( swapcount < nswap )
// Last one
for ( iter_i = 0 ; iter_i < swap_unit ; iter_i++ ) {
VlxGbAdvIB(16);
}
Exit (VLX_STATUS_END);
} // end main()
//----------------------------------------------------
// Function : Exit
// Purpose : Exit loop (singals semaphore, enters idle loop)
//----------------------------------------------------
void Exit (short flag)
{
status.exit_code = flag;
// Singal Semaphore
semaEnd.data[0] = 0;
semaEnd.data[1] = 0;
semaEnd.data[2] = 0;
semaEnd.data[3] = 0;
while(1);
} // end Exit()
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -