赞
踩
改进算法MNX 如下所示,^ : 表示顺序写入;不带^表示逆序:
^(w0); ^(r0,w1); (r1,w0);(r0)
伪代码,m表示读取,M表示写入:
- for (i = 0; i < n; i++){M(i)=0;}
-
- for (i = 0; i < n; i++){
- if (m(i)=0){M(i)=1;}Else{return fail;}
- }
-
- for (i = n-1; i >=0; i--){
- if (m(i)=1){M(i)=0;}Else{return fail;}
- }
-
- for (i = n-1; i >=0; i--){
- if (m(i)=0){;}Else{return fail;}
- }
C实现,其中start_addr, finish_addr是RAM的开始地址与结束地址;而MARCH_DATA_CODE为背景数据;
以32bit为示例,可以选择如下一项或者几项进行覆盖测试。
- /*
- * background data list:
- * 1. 0x00000000
- 2. 0x33333333
- 3. 0x55555555
- 4. 0x0F0F0F0F
- 5. 0x00FF00FF
- 6. 0x0000FFFF
- * _SRAM_Err_Region 指示Err区域地址以及content
- * DETECT_RAM_EN : 是否检测到首次就直接退出,或者全部扫测完成
- */
- UINT32 _SRAM_MarchX ( UINT32* start_addr, UINT32* finish_addr, UINT32 MARCH_DATA_CODE )
- {
- UINT32 res = NO_ERROR;
- UINT32 volatile* pAddr32;
- UINT32 cell[1];
-
- for ( pAddr32 = start_addr; pAddr32 < finish_addr; pAddr32 ++ )
- {
- * ( pAddr32 + 0 ) = MARCH_DATA_CODE;
- }
-
- for ( pAddr32 = start_addr; pAddr32 < finish_addr; pAddr32 ++ )
- {
- * ( cell + 0 ) = * ( pAddr32 + 0 );
-
- if ( * ( cell + 0 ) == MARCH_DATA_CODE )
- {
- * ( pAddr32 + 0 ) = ~MARCH_DATA_CODE;
- }
- else
- {
- _SRAM_Err_Region ( ( UINT32 ) ( pAddr32 + 0 ), cell, 4 );
-
- res = SRAM_TEST_FAILED;
-
- #if (DETECT_RAM_EN>0)
- return res;
- #endif
- }
- }
-
- for ( pAddr32 = finish_addr - 1; pAddr32 >= start_addr + 1; pAddr32 -- )
- {
- * ( cell + 0 ) = * ( pAddr32 + 0 );
-
- if ( * ( cell + 0 ) == ~MARCH_DATA_CODE )
- {
- * ( pAddr32 + 0 ) = MARCH_DATA_CODE;
- }
- else
- {
- _SRAM_Err_Region ( ( UINT32 ) ( pAddr32 + 0 ), cell, 4 );
-
- res = SRAM_TEST_FAILED;
-
- #if (DETECT_RAM_EN>0)
- return res;
- #endif
- }
- }
-
- for ( pAddr32 = finish_addr - 1; pAddr32 >= start_addr + 1; pAddr32 -- )
- {
- * ( cell + 0 ) = * ( pAddr32 + 0 );
-
- if ( * ( cell + 0 ) == MARCH_DATA_CODE )
- {
- ;
- }
- else
- {
- _SRAM_Err_Region ( ( UINT32 ) ( pAddr32 + 0 ), cell, 4 );
-
- res = SRAM_TEST_FAILED;
-
- #if (DETECT_RAM_EN>0)
- return res;
- #endif
- }
- }
-
- return res;
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。