diff --git a/Include/arm_math.h b/Include/arm_math.h index ffd79a9e..24872cfc 100644 --- a/Include/arm_math.h +++ b/Include/arm_math.h @@ -909,7 +909,11 @@ __STATIC_FORCEINLINE q31_t read_q15x2 ( { q31_t val; +#ifdef __ARM_FEATURE_UNALIGNED memcpy (&val, pQ15, 4); +#else + val = (pQ15[1] << 16) | (pQ15[0] & 0x0FFFF) ; +#endif return (val); } @@ -924,10 +928,14 @@ __STATIC_FORCEINLINE q31_t read_q15x2_ia ( { q31_t val; +#ifdef __ARM_FEATURE_UNALIGNED memcpy (&val, *pQ15, 4); - *pQ15 += 2; +#else + val = ((*pQ15)[1] << 16) | ((*pQ15)[0] & 0x0FFFF); +#endif - return (val); + *pQ15 += 2; + return (val); } /** @@ -940,9 +948,13 @@ __STATIC_FORCEINLINE q31_t read_q15x2_da ( { q31_t val; +#ifdef __ARM_FEATURE_UNALIGNED memcpy (&val, *pQ15, 4); - *pQ15 -= 2; +#else + val = ((*pQ15)[1] << 16) | ((*pQ15)[0] & 0x0FFFF); +#endif + *pQ15 -= 2; return (val); } @@ -957,9 +969,14 @@ __STATIC_FORCEINLINE void write_q15x2_ia ( q31_t value) { q31_t val = value; - +#ifdef __ARM_FEATURE_UNALIGNED memcpy (*pQ15, &val, 4); - *pQ15 += 2; +#else + (*pQ15)[0] = (val & 0x0FFFF); + (*pQ15)[1] = (val >> 16) & 0x0FFFF; +#endif + + *pQ15 += 2; } /** @@ -974,7 +991,12 @@ __STATIC_FORCEINLINE void write_q15x2 ( { q31_t val = value; +#ifdef __ARM_FEATURE_UNALIGNED memcpy (pQ15, &val, 4); +#else + pQ15[0] = val & 0x0FFFF; + pQ15[1] = val >> 16; +#endif } @@ -988,7 +1010,13 @@ __STATIC_FORCEINLINE q31_t read_q7x4_ia ( { q31_t val; + +#ifdef __ARM_FEATURE_UNALIGNED memcpy (&val, *pQ7, 4); +#else + val =(((*pQ7)[3] & 0x0FF) << 24) | (((*pQ7)[2] & 0x0FF) << 16) | (((*pQ7)[1] & 0x0FF) << 8) | ((*pQ7)[0] & 0x0FF); +#endif + *pQ7 += 4; return (val); @@ -1003,8 +1031,11 @@ __STATIC_FORCEINLINE q31_t read_q7x4_da ( q7_t ** pQ7) { q31_t val; - +#ifdef __ARM_FEATURE_UNALIGNED memcpy (&val, *pQ7, 4); +#else + val = ((((*pQ7)[3]) & 0x0FF) << 24) | ((((*pQ7)[2]) & 0x0FF) << 16) | ((((*pQ7)[1]) & 0x0FF) << 8) | ((*pQ7)[0] & 0x0FF); +#endif *pQ7 -= 4; return (val); @@ -1021,8 +1052,15 @@ __STATIC_FORCEINLINE void write_q7x4_ia ( q31_t value) { q31_t val = value; - +#ifdef __ARM_FEATURE_UNALIGNED memcpy (*pQ7, &val, 4); +#else + (*pQ7)[0] = val & 0x0FF; + (*pQ7)[1] = (val >> 8) & 0x0FF; + (*pQ7)[2] = (val >> 16) & 0x0FF; + (*pQ7)[3] = (val >> 24) & 0x0FF; + +#endif *pQ7 += 4; } diff --git a/PythonWrapper/README.md b/PythonWrapper/README.md index 23419fec..26791715 100644 --- a/PythonWrapper/README.md +++ b/PythonWrapper/README.md @@ -22,9 +22,6 @@ The package is working with Python 2 and 3. ## Building -The build is using a customized arm_math.h in folder cmsisdsp_pkg/src to be able to compile on windows. - -As a consequence, if you build on an ARM computer, you won't get the optimizations of the CMSIS library. It is possible to get them by replacing the customized arm_math.h by the official one. Since the CMSIS-DSP wrapper is using numpy, you must first install it if not already done. So, for instance to install it locally you could do: diff --git a/Testing/FrameworkSource/Timing.cpp b/Testing/FrameworkSource/Timing.cpp index 7d770a27..b51be60a 100644 --- a/Testing/FrameworkSource/Timing.cpp +++ b/Testing/FrameworkSource/Timing.cpp @@ -106,6 +106,11 @@ void cycleMeasurementStart() { #ifndef EXTBENCH #ifdef CORTEXM + /* + TODO: + This code is likely to be wrong. Don't rely on it for benchmarks. + + */ SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk; SysTick->LOAD = SYSTICK_INITIAL_VALUE; diff --git a/Testing/Source/Tests/SupportTestsQ15.cpp b/Testing/Source/Tests/SupportTestsQ15.cpp index baf7a40a..072f3c07 100755 --- a/Testing/Source/Tests/SupportTestsQ15.cpp +++ b/Testing/Source/Tests/SupportTestsQ15.cpp @@ -10,6 +10,9 @@ #define ABS_Q31_ERROR ((q31_t)40000) #define ABS_Q7_ERROR ((q7_t)10) +#if defined ( __CC_ARM ) +#pragma diag_suppress 170 +#endif void SupportTestsQ15::test_copy_q15() { @@ -88,6 +91,72 @@ } + __ALIGNED(2) static const q15_t testReadQ15[2]={-2,1}; + __ALIGNED(2) static q15_t testWriteQ15[2]={0,0}; + + void SupportTestsQ15::test_read_q15x2() + { + q31_t result=0; + + result = read_q15x2((q15_t*)testReadQ15); + + printf("%08X\n",result); + + ASSERT_TRUE(result == 0x0001FFFE); + + } + + void SupportTestsQ15::test_read_q15x2_ia() + { + q31_t result=0; + q15_t *p = (q15_t*)testReadQ15; + + result = read_q15x2_ia(&p); + + ASSERT_TRUE(result == 0x0001FFFE); + ASSERT_TRUE(p == testReadQ15 + 2); + } + + void SupportTestsQ15::test_read_q15x2_da() + { + q31_t result=0; + q15_t *p = (q15_t*)testReadQ15; + + result = read_q15x2_da(&p); + + ASSERT_TRUE(result == 0x0001FFFE); + ASSERT_TRUE(p == testReadQ15 - 2); + } + + void SupportTestsQ15::test_write_q15x2_ia() + { + q31_t val = 0x0001FFFE; + q15_t *p = testWriteQ15; + + testWriteQ15[0] = 0; + testWriteQ15[1] = 0; + + write_q15x2_ia(&p,val); + + ASSERT_TRUE(testWriteQ15[0] == -2); + ASSERT_TRUE(testWriteQ15[1] == 1); + ASSERT_TRUE(p == testWriteQ15 + 2); + + } + + void SupportTestsQ15::test_write_q15x2() + { + q31_t val = 0x0001FFFE; + + testWriteQ15[0] = 0; + testWriteQ15[1] = 0; + + write_q15x2(testWriteQ15,val); + + ASSERT_TRUE(testWriteQ15[0] == -2); + ASSERT_TRUE(testWriteQ15[1] == 1); + } + void SupportTestsQ15::setUp(Testing::testID_t id,std::vector& paramsArgs,Client::PatternMgr *mgr) { diff --git a/Testing/Source/Tests/SupportTestsQ7.cpp b/Testing/Source/Tests/SupportTestsQ7.cpp index d84b27f8..ff3569ec 100755 --- a/Testing/Source/Tests/SupportTestsQ7.cpp +++ b/Testing/Source/Tests/SupportTestsQ7.cpp @@ -10,6 +10,9 @@ #define ABS_Q31_ERROR ((q31_t)(1<<24)) #define ABS_Q7_ERROR ((q7_t)10) +#if defined ( __CC_ARM ) +#pragma diag_suppress 170 +#endif void SupportTestsQ7::test_copy_q7() { @@ -90,6 +93,53 @@ } + static const q7_t testReadQ7[4]={-4,-3,-2,1}; + static q7_t testWriteQ7[4]={0,0,0,0}; + + void SupportTestsQ7::test_read_q7x4_ia() + { + q31_t result=0; + q7_t *p = (q7_t*)testReadQ7; + + result = read_q7x4_ia(&p); + printf("%08X\n",result); + + ASSERT_TRUE(result == 0x01FEFDFC); + ASSERT_TRUE(p == testReadQ7 + 4); + } + + void SupportTestsQ7::test_read_q7x4_da() + { + + q31_t result=0; + q7_t *p = (q7_t*)testReadQ7; + + result = read_q7x4_da(&p); + + ASSERT_TRUE(result == 0x01FEFDFC); + ASSERT_TRUE(p == testReadQ7 - 4); + } + + void SupportTestsQ7::test_write_q7x4_ia() + { + q31_t val = 0x01FEFDFC; + q7_t *p = (q7_t*)testWriteQ7; + + testWriteQ7[0] = 0; + testWriteQ7[1] = 0; + testWriteQ7[2] = 0; + testWriteQ7[3] = 0; + + write_q7x4_ia(&p,val); + + ASSERT_TRUE(testWriteQ7[0] == -4); + ASSERT_TRUE(testWriteQ7[1] == -3); + ASSERT_TRUE(testWriteQ7[2] == -2); + ASSERT_TRUE(testWriteQ7[3] == 1); + ASSERT_TRUE(p == testWriteQ7 + 4); + + } + void SupportTestsQ7::setUp(Testing::testID_t id,std::vector& paramsArgs,Client::PatternMgr *mgr) { diff --git a/Testing/desc.txt b/Testing/desc.txt index c150e9c0..fae0e388 100644 --- a/Testing/desc.txt +++ b/Testing/desc.txt @@ -390,6 +390,11 @@ group Root { test_q15_q7 nb=7:test_q15_q7 test_q15_q7 nb=8n:test_q15_q7 test_q15_q7 nb=8n+1:test_q15_q7 + test_read_q15x2:test_read_q15x2 + test_read_q15x2_ia:test_read_q15x2_ia + test_read_q15x2_da:test_read_q15x2_da + test_write_q15x2_ia:test_write_q15x2_ia + test_write_q15x2:test_write_q15x2 } } @@ -421,6 +426,9 @@ group Root { test_q7_q15 nb=15:test_q7_q15 test_q7_q15 nb=16n:test_q7_q15 test_q7_q15 nb=16n+1:test_q7_q15 + test_read_q7x4_ia:test_read_q7x4_ia + test_read_q7x4_da:test_read_q7x4_da + test_write_q7x4_ia:test_write_q7x4_ia } }