📄 led_dmledres.c
字号:
/* ============================================================================
*
* TEXAS INSTRUMENTS INCORPORATED PROPRIETARY INFORMATION
*
* Property of Texas Instruments. For Unrestricted Internal Use Only
* Unauthorized reproduction and/or distribution is strictly prohibited.
* This product is protected under copyright law and trade secret law as an
* unpublished work.
* Created 2004, (C) Copyright 2004 Texas Instruments. All rights reserved.
*
* Component: RESLED - Results via SPY for DFT SW simulation on OMAP3xx
*
* Filename: led_dmledres.c
*
* Description: Contains functions to collect, check & dump simulation results
*
* The OMAP3 Library has an interface called led_dmled.h that provides
* the declarations of functions that MUST be implemented by any
* project that uses the OMAP3 Library.
*
* Available Functions:
* Common
* RES_SetDMLED - Sets a value in results table
* ARM11 only
* RES_SetLCTnDMLED - Sets the location in memory
* RES_Init_SimRes - Initialize simulated result space with BABE
* RES_ResComp - Compare the expected and simulated result.
* RES_EndDMLED - End spy simulation by writing 'illegal' value.
* RES_GetFinalStatus - Gets final error status
*
* Domain: All
*
* Board: Simulation only
*
* Fucntional Specifcation Version: Not valid
*
* Validating Test Cases: None
*
* ========================================================================== */
/* ============================================================================
* STANDARD INCLUDE FILES
* ========================================================================== */
/* ============================================================================
* PROJECT SPECIFIC INCLUDE FILES
* ========================================================================== */
#include "led_top.h"
#include "led_dmled.h"
/* ============================================================================
* LOCAL TYPES AND DEFINITIONS
* ========================================================================== */
/* ----------------------------------------------------------------------------
* Definition: RES_BUF_SIZE
* DESCRIPTION: Number of UWORD16 Elements in Results buffer
* ---------------------------------------------------------------------------*/
#define RES_BUF_SIZE 64 /* 256 bytes = 128 halfwords = 64 words */
/* ----------------------------------------------------------------------------
* Definition: RES_FIRST_DATA_LOCATION
* DESCRIPTION: Offset in table where first result is written to
* ---------------------------------------------------------------------------*/
#define RES_FIRST_DATA_LOCATION 3
/* ----------------------------------------------------------------------------
* Definition: RES_BUF_SPACE
* DESCRIPTION: Number of UWORD16 Elements available space
* ---------------------------------------------------------------------------*/
#define RES_BUF_SPACE ((RES_BUF_SIZE*2)- RES_FIRST_DATA_LOCATION)
/* ----------------------------------------------------------------------------
* Definition: RES_RES_BUF_SPACE
* DESCRIPTION: Size of array header in UWORD16 elements
* ---------------------------------------------------------------------------*/
#define RES_ARRAY_HEADER_SIZE 2
/* ----------------------------------------------------------------------------
* Definition: RES_THE_END
* DESCRIPTION: this is correct value to write to cause test to end
* ---------------------------------------------------------------------------*/
#define RES_THE_END 0xFFFF
/* ----------------------------------------------------------------------------
* Definition: RES_INT_START_ADDR
* DESCRIPTION: Hardwire internal TESTSRAM location for simulated SPY results
* -------------------------------------------------------------------------- */
#define RES_SIM_SPY_ADDR 0x20000040
/* ----------------------------------------------------------------------------
* Definition: RES_EXP_SPY_ADDR
* DESCRIPTION: Hardwire internal TESTSRAM location for expectedd SPY results
* -------------------------------------------------------------------------- */
#define RES_EXP_SPY_ADDR 0x20000304
/* ----------------------------------------------------------------------------
* Definition: RES_EXTNL_SPY_ADDR
* DESCRIPTION: External EMIFS CS1 location for simulated SPY results 0x05000000
* -------------------------------------------------------------------------- */
#define RES_EXTNL_SPY_ADDR 0x05000000
/* ----------------------------------------------------------------------------
* Definition: RES_RANGE_MASK_VAL
* DESCRIPTION: result code mask for lower byte containing good and bad values
* -------------------------------------------------------------------------- */
#define RES_RANGE_MASK_VAL 0x00FF
/* ----------------------------------------------------------------------------
* Definition: RES_INIT_DATA
* DESCRIPTION: Simulated result internal memory space initialisation data
* -------------------------------------------------------------------------- */
#define RES_INIT_DATA 0xBABEBABE
/* ============================================================================
* GLOBAL VARIABLES DECLARATIONS
* ========================================================================== */
/* internal table in memory of results values. The first element in this array
is used to indicate if a test passed or not. The other elements in array
contain various result values which are written as the test progresses */
/* ============================================================================
* LOCAL VARIABLES DECLARATIONS
* ===========================================================================*/
/* pointer to start of external table of results */
static UWORD16* res_pExtnlStart = NULL;
/* pointer to start of internal table of simulated results */
static UWORD16* res_pSimStart = (UWORD16*) RES_SIM_SPY_ADDR;
/* pointer to start of internal table of expected results */
static UWORD16* res_pExpStart = (UWORD16*) RES_EXP_SPY_ADDR;
/* offset in elements from start of table where next result will be stored */
static UWORD32 res_pTabOffset = (UWORD32) RES_FIRST_DATA_LOCATION;
/* ============================================================================
* LOCAL FUNCTIONS PROTOTYPES
* ========================================================================== */
/* ============================================================================
* FUNCTIONS
* ========================================================================== */
UWORD16 RES_SetLCTnDMLED ( const UWORD32 startAddress ) {
UWORD16 returnCode = RET_OK;
/* setup up external EMIFS Spy pointer */
res_pExtnlStart = (UWORD16*) startAddress;
/* reset internal pointer for simulated results */
res_pSimStart = (UWORD16*) RES_SIM_SPY_ADDR;
/* reset internal pointer for expected results */
res_pExpStart = (UWORD16*) RES_EXP_SPY_ADDR;
/* Set offset to point tofirst data location */
res_pTabOffset = RES_FIRST_DATA_LOCATION;
/* Set First Element to 0xAAAA */
*(res_pSimStart + 0x0 ) = 0x5555;
*(res_pExtnlStart + 0x0 ) = 0x5555;
/* Set Second Element to 0x5555 */
*(res_pSimStart + 0x1 ) = 0xAAAA;
*(res_pExtnlStart + 0x1 ) = 0xAAAA;
/* Set Global Status in the Third Element to No Error 0x0000 */
*(res_pSimStart + 0x2) = 0x0000;
*(res_pExtnlStart + 0x2) = 0x0000;
return returnCode;
} // RES_SetLCTnDMLED
/* ==================== Function Separator ============================= */
UWORD16 RES_Init_SimRes( void ) {
UWORD32 value;
UWORD16 returnCode = RET_OK;
value = RES_SIM_SPY_ADDR;
while (value < (RES_SIM_SPY_ADDR+(RES_BUF_SIZE*4)) ) {
REG32(value) = RES_INIT_DATA; // 32bit accesses 0xBABEBABE
value = value + 0x4;
}
return returnCode;
} // RES_Init_SimRes
/* ==================== Function Separator ============================= */
UWORD16 RES_ResComp( const UWORD16 numArray ) {
UWORD16* SimValue = (UWORD16*) RES_SIM_SPY_ADDR;
UWORD16* ExpValue = (UWORD16*) RES_EXP_SPY_ADDR;
UWORD16 counter = 0;
UWORD16 curValue = 0;
UWORD16 rescomp = 0;
/* assign address values to the pointers */
SimValue = (UWORD16*) (RES_SIM_SPY_ADDR);
ExpValue = (UWORD16*) RES_EXP_SPY_ADDR;
rescomp = CTEDM_NORESCOMP; // Compare == 0x0
if (rescomp == 0x0) {
/* while there are elements in array to compare */
while (counter < numArray) {
if ( (*(SimValue + counter)) != (*(ExpValue + counter)) ) {
curValue++;
}
counter++;
}
}
/* Set Global Status in the Third Element to no. of Error */
*(res_pSimStart + 0x2) |= curValue;
*(res_pExtnlStart + 0x2) = (*(res_pSimStart + 0x2));
if (curValue == 0) {
// indicate that test finished OK
*(res_pExtnlStart + res_pTabOffset) = RES_TST_PASSED;
*(res_pSimStart + res_pTabOffset) = RES_TST_PASSED;
} else {
// indicate that test failed
*(res_pExtnlStart + res_pTabOffset) = RES_TST_FAILED;
*(res_pSimStart + res_pTabOffset) = RES_TST_FAILED;
}
res_pTabOffset++;
return (curValue);
}
/*==================== Function Separator =============================*/
UWORD16 RES_SetDMLED( const UWORD16 status ) {
UWORD16 returnCode = RET_OK;
/* write value to res_pTabOffset element of external result table */
*(res_pExtnlStart + res_pTabOffset) = status;
/* write value to an element of internal result table */
*(res_pSimStart + res_pTabOffset) = status;
/* Set offset to point to next element */
res_pTabOffset++;
return returnCode;
}
/* ==================== Function Separator ============================= */
UWORD16 RES_EndDMLED( void ) {
UWORD32 gpio_base_addr, gpio2_base_addr;
UWORD32 gpio_execpin, gpio_syncpin, gpio_statpin;
UWORD16 returnCode = RET_OK;
*(res_pSimStart + res_pTabOffset) = 0xF1F1;
res_pTabOffset++;
gpio_base_addr = (CTEDM_GPIO_ADDR_LSB + (65536*CTEDM_GPIO_ADDR_MSB));
gpio2_base_addr = (CTEDM_GPIO2_ADDR_LSB + (65536*CTEDM_GPIO2_ADDR_MSB));
gpio_execpin = CTEDM_GPIO_EXEC_PIN; // 0x00 GPIO2
gpio_syncpin = CTEDM_GPIO_SYNC_PIN; // 0x0D GPIO1 = 0-13
gpio_statpin = CTEDM_GPIO_STAT_PIN; // 0x12 GPIO1 = 0-18
DMLED_Results(gpio2_base_addr, gpio_execpin, gpio_syncpin, gpio_statpin, gpio_base_addr);
/* write end marker to last element in array */
*(res_pExtnlStart + ((RES_BUF_SIZE*2)-2) ) = RES_THE_END;
return returnCode;
}
/*==================== Function Separator =============================*/
UWORD16 RES_GetFinalStatus( UWORD16 *const pFinalRes ) {
UWORD16 returnCode = RET_OK;
UWORD32 curOffset = 0;
UWORD16 curValue = 0;
UWORD16 curValueMsk = 0;
UWORD16 arraySize = 0;
UWORD16 ErrorCount = 0;
/* skip first value as it reserved for global result */
for (curOffset = RES_FIRST_DATA_LOCATION; curOffset < res_pTabOffset; curOffset++ )
{
/* get result range */
curValue = *(res_pSimStart + curOffset);
curValueMsk = *(res_pSimStart + curOffset) & RES_RANGE_MASK_VAL;
if (curValue == RESULT_SEPARATOR)
{
/* check for result separator */
}
else if (curValue == START_ARRAY_DATA)
{
while ( (curValue != END_ARRAY_DATA) && (curOffset < res_pTabOffset) )
{
curOffset++;
curValue = *(res_pSimStart + curOffset);
}
} /* check for Start and End array data */
else if ((curValueMsk >= RES_MIN_BAD_VAL) && (curValueMsk <= RES_MAX_BAD_VAL))
{
/* increase error count for result */
ErrorCount++;
} /* else if start of an array */
else if (curValueMsk == RES_START_ARRAY)
{
/* jump to next value in the array */
curOffset++;
/* save array size */
arraySize = *(res_pSimStart + curOffset);
/* skip the array values */
curOffset += arraySize;
}
}
*(res_pSimStart + 0x2) |= (ErrorCount << 8);
*(res_pExtnlStart + 0x2) = (*(res_pSimStart + 0x2));
if (ErrorCount == 0) {
// indicate that test finished OK
*(res_pExtnlStart + res_pTabOffset) = RES_TST_PASSED;
*(res_pSimStart + res_pTabOffset) = RES_TST_PASSED;
} else {
// indicate that test failed
*(res_pExtnlStart + res_pTabOffset) = RES_TST_FAILED;
*(res_pSimStart + res_pTabOffset) = RES_TST_FAILED;
}
/* get final result size for comparism */
*pFinalRes = res_pTabOffset;
res_pTabOffset++;
return returnCode;
}
/* ============================================================================
* LOCAL FUNCTIONS
* =============================================================================
*/
/* EOF */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -