Преглед изворни кода

CMSIS-DSP: Added scalar version of clipping functions.

Christophe Favergeon пре 5 година
родитељ
комит
0556e5fb2a
43 измењених фајлова са 1606 додато и 95 уклоњено
  1. 64 0
      Include/dsp/basic_math_functions.h
  2. 16 0
      Include/dsp/basic_math_functions_f16.h
  3. 4 0
      Source/BasicMathFunctions/BasicMathFunctions.c
  4. 1 0
      Source/BasicMathFunctions/BasicMathFunctionsF16.c
  5. 71 0
      Source/BasicMathFunctions/arm_clip_f16.c
  6. 77 0
      Source/BasicMathFunctions/arm_clip_f32.c
  7. 68 0
      Source/BasicMathFunctions/arm_clip_q15.c
  8. 68 0
      Source/BasicMathFunctions/arm_clip_q31.c
  9. 68 0
      Source/BasicMathFunctions/arm_clip_q7.c
  10. 2 0
      Testing/Include/Tests/BasicTestsF16.h
  11. 2 0
      Testing/Include/Tests/BasicTestsF32.h
  12. 2 0
      Testing/Include/Tests/BasicTestsQ15.h
  13. 2 0
      Testing/Include/Tests/BasicTestsQ31.h
  14. 2 0
      Testing/Include/Tests/BasicTestsQ7.h
  15. 32 0
      Testing/PatternGeneration/BasicMaths.py
  16. 102 84
      Testing/PatternGeneration/Tools.py
  17. 38 0
      Testing/Patterns/DSP/BasicMaths/BasicMathsF16/Input12_f16.txt
  18. 38 0
      Testing/Patterns/DSP/BasicMaths/BasicMathsF16/Reference12_f16.txt
  19. 38 0
      Testing/Patterns/DSP/BasicMaths/BasicMathsF16/Reference13_f16.txt
  20. 38 0
      Testing/Patterns/DSP/BasicMaths/BasicMathsF16/Reference14_f16.txt
  21. 38 0
      Testing/Patterns/DSP/BasicMaths/BasicMathsF32/Input12_f32.txt
  22. 38 0
      Testing/Patterns/DSP/BasicMaths/BasicMathsF32/Reference12_f32.txt
  23. 38 0
      Testing/Patterns/DSP/BasicMaths/BasicMathsF32/Reference13_f32.txt
  24. 38 0
      Testing/Patterns/DSP/BasicMaths/BasicMathsF32/Reference14_f32.txt
  25. 38 0
      Testing/Patterns/DSP/BasicMaths/BasicMathsQ15/Input28_q15.txt
  26. 38 0
      Testing/Patterns/DSP/BasicMaths/BasicMathsQ15/Reference28_q15.txt
  27. 38 0
      Testing/Patterns/DSP/BasicMaths/BasicMathsQ15/Reference29_q15.txt
  28. 38 0
      Testing/Patterns/DSP/BasicMaths/BasicMathsQ15/Reference30_q15.txt
  29. 38 0
      Testing/Patterns/DSP/BasicMaths/BasicMathsQ31/Input28_q31.txt
  30. 38 0
      Testing/Patterns/DSP/BasicMaths/BasicMathsQ31/Reference28_q31.txt
  31. 38 0
      Testing/Patterns/DSP/BasicMaths/BasicMathsQ31/Reference29_q31.txt
  32. 38 0
      Testing/Patterns/DSP/BasicMaths/BasicMathsQ31/Reference30_q31.txt
  33. 38 0
      Testing/Patterns/DSP/BasicMaths/BasicMathsQ7/Input28_q7.txt
  34. 38 0
      Testing/Patterns/DSP/BasicMaths/BasicMathsQ7/Reference28_q7.txt
  35. 38 0
      Testing/Patterns/DSP/BasicMaths/BasicMathsQ7/Reference29_q7.txt
  36. 38 0
      Testing/Patterns/DSP/BasicMaths/BasicMathsQ7/Reference30_q7.txt
  37. 45 4
      Testing/Source/Tests/BasicTestsF16.cpp
  38. 44 2
      Testing/Source/Tests/BasicTestsF32.cpp
  39. 43 0
      Testing/Source/Tests/BasicTestsQ15.cpp
  40. 41 0
      Testing/Source/Tests/BasicTestsQ31.cpp
  41. 43 0
      Testing/Source/Tests/BasicTestsQ7.cpp
  42. 39 4
      Testing/desc.txt
  43. 10 1
      Testing/desc_f16.txt

+ 64 - 0
Include/dsp/basic_math_functions.h

@@ -691,6 +691,70 @@ extern "C"
           uint8_t * pDst,
     uint32_t blockSize);
 
+  /**
+  @brief         Elementwise floating-point clipping
+  @param[in]     pSrc          points to input values
+  @param[out]    pDst          points to output clipped values
+  @param[in]     low           lower bound
+  @param[in]     high          higher bound
+  @param[in]     numSamples    number of samples to clip
+  @return        none
+ */
+
+void arm_clip_f32(const float32_t * pSrc, 
+  float32_t * pDst, 
+  float32_t low, 
+  float32_t high, 
+  uint32_t numSamples);
+
+  /**
+  @brief         Elementwise fixed-point clipping
+  @param[in]     pSrc          points to input values
+  @param[out]    pDst          points to output clipped values
+  @param[in]     low           lower bound
+  @param[in]     high          higher bound
+  @param[in]     numSamples    number of samples to clip
+  @return        none
+ */
+
+void arm_clip_q31(const q31_t * pSrc, 
+  q31_t * pDst, 
+  q31_t low, 
+  q31_t high, 
+  uint32_t numSamples);
+
+  /**
+  @brief         Elementwise fixed-point clipping
+  @param[in]     pSrc          points to input values
+  @param[out]    pDst          points to output clipped values
+  @param[in]     low           lower bound
+  @param[in]     high          higher bound
+  @param[in]     numSamples    number of samples to clip
+  @return        none
+ */
+
+void arm_clip_q15(const q15_t * pSrc, 
+  q15_t * pDst, 
+  q15_t low, 
+  q15_t high, 
+  uint32_t numSamples);
+
+  /**
+  @brief         Elementwise fixed-point clipping
+  @param[in]     pSrc          points to input values
+  @param[out]    pDst          points to output clipped values
+  @param[in]     low           lower bound
+  @param[in]     high          higher bound
+  @param[in]     numSamples    number of samples to clip
+  @return        none
+ */
+
+void arm_clip_q7(const q7_t * pSrc, 
+  q7_t * pDst, 
+  q7_t low, 
+  q7_t high, 
+  uint32_t numSamples);
+
 
 #ifdef   __cplusplus
 }

+ 16 - 0
Include/dsp/basic_math_functions_f16.h

@@ -142,6 +142,22 @@ extern "C"
         float16_t * pDst,
         uint32_t blockSize);
 
+  /**
+  @brief         Elementwise floating-point clipping
+  @param[in]     pSrc          points to input values
+  @param[out]    pDst          points to output clipped values
+  @param[in]     low           lower bound
+  @param[in]     high          higher bound
+  @param[in]     numSamples    number of samples to clip
+  @return        none
+ */
+
+void arm_clip_f16(const float16_t * pSrc, 
+  float16_t * pDst, 
+  float16_t low, 
+  float16_t high, 
+  uint32_t numSamples);
+
 #endif /* defined(ARM_FLOAT16_SUPPORTED)*/
 
 #ifdef   __cplusplus

+ 4 - 0
Source/BasicMathFunctions/BasicMathFunctions.c

@@ -73,3 +73,7 @@
 #include "arm_xor_u16.c"
 #include "arm_xor_u32.c"
 #include "arm_xor_u8.c"
+#include "arm_clip_f32.c"
+#include "arm_clip_q31.c"
+#include "arm_clip_q15.c"
+#include "arm_clip_q7.c"

+ 1 - 0
Source/BasicMathFunctions/BasicMathFunctionsF16.c

@@ -34,3 +34,4 @@
 #include "arm_offset_f16.c"
 #include "arm_scale_f16.c"
 #include "arm_sub_f16.c"
+#include "arm_clip_f16.c"

+ 71 - 0
Source/BasicMathFunctions/arm_clip_f16.c

@@ -0,0 +1,71 @@
+/* ----------------------------------------------------------------------
+ * Project:      CMSIS DSP Library
+ * Title:        arm_clip_f16.c
+ * Description:  Floating-point vector addition
+ *
+ *
+ * Target Processor: Cortex-M cores
+ * -------------------------------------------------------------------- */
+/*
+ * Copyright (C) 2010-2021 ARM Limited or its affiliates. All rights reserved.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the License); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "dsp/basic_math_functions_f16.h"
+
+/**
+  @ingroup groupMath
+ */
+
+
+/**
+  @addtogroup BasicClip
+  @{
+ */
+
+/**
+  @brief         Elementwise floating-point clipping
+  @param[in]     pSrc          points to input values
+  @param[out]    pDst          points to output clipped values
+  @param[in]     low           lower bound
+  @param[in]     high          higher bound
+  @param[in]     numSamples    number of samples to clip
+  @return        none
+ */
+
+#if defined(ARM_FLOAT16_SUPPORTED)
+
+void arm_clip_f16(const float16_t * pSrc, 
+  float16_t * pDst, 
+  float16_t low, 
+  float16_t high, 
+  uint32_t numSamples)
+{
+    for (uint32_t i = 0; i < numSamples; i++)
+    {                                        
+        if (pSrc[i] > high)                  
+            pDst[i] = high;                  
+        else if (pSrc[i] < low)              
+            pDst[i] = low;                   
+        else                                 
+            pDst[i] = pSrc[i];               
+    }
+}
+#endif /* defined(ARM_FLOAT16_SUPPORTED */
+
+/**
+  @} end of BasicClip group
+ */

+ 77 - 0
Source/BasicMathFunctions/arm_clip_f32.c

@@ -0,0 +1,77 @@
+/* ----------------------------------------------------------------------
+ * Project:      CMSIS DSP Library
+ * Title:        arm_clip_f32.c
+ * Description:  Floating-point vector addition
+ *
+ *
+ * Target Processor: Cortex-M cores
+ * -------------------------------------------------------------------- */
+/*
+ * Copyright (C) 2010-2021 ARM Limited or its affiliates. All rights reserved.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the License); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "dsp/basic_math_functions.h"
+
+/**
+  @ingroup groupMath
+ */
+
+/**
+  @defgroup BasicClip Elementwise clipping
+
+  Element-by-element clipping of a value.
+
+  The value is constrained between 2 bounds.
+
+  There are separate functions for floating-point, Q7, Q15, and Q31 data types.
+ */
+
+/**
+  @addtogroup BasicClip
+  @{
+ */
+
+/**
+  @brief         Elementwise floating-point clipping
+  @param[in]     pSrc          points to input values
+  @param[out]    pDst          points to output clipped values
+  @param[in]     low           lower bound
+  @param[in]     high          higher bound
+  @param[in]     numSamples    number of samples to clip
+  @return        none
+ */
+
+void arm_clip_f32(const float32_t * pSrc, 
+  float32_t * pDst, 
+  float32_t low, 
+  float32_t high, 
+  uint32_t numSamples)
+{
+    for (uint32_t i = 0; i < numSamples; i++)
+    {                                        
+        if (pSrc[i] > high)                  
+            pDst[i] = high;                  
+        else if (pSrc[i] < low)              
+            pDst[i] = low;                   
+        else                                 
+            pDst[i] = pSrc[i];               
+    }
+}
+
+/**
+  @} end of BasicClip group
+ */

+ 68 - 0
Source/BasicMathFunctions/arm_clip_q15.c

@@ -0,0 +1,68 @@
+/* ----------------------------------------------------------------------
+ * Project:      CMSIS DSP Library
+ * Title:        arm_clip_q15.c
+ * Description:  Floating-point vector addition
+ *
+ *
+ * Target Processor: Cortex-M cores
+ * -------------------------------------------------------------------- */
+/*
+ * Copyright (C) 2010-2021 ARM Limited or its affiliates. All rights reserved.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the License); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "dsp/basic_math_functions.h"
+
+/**
+  @ingroup groupMath
+ */
+
+
+/**
+  @addtogroup BasicClip
+  @{
+ */
+
+/**
+  @brief         Elementwise fixed-point clipping
+  @param[in]     pSrc          points to input values
+  @param[out]    pDst          points to output clipped values
+  @param[in]     low           lower bound
+  @param[in]     high          higher bound
+  @param[in]     numSamples    number of samples to clip
+  @return        none
+ */
+
+void arm_clip_q15(const q15_t * pSrc, 
+  q15_t * pDst, 
+  q15_t low, 
+  q15_t high, 
+  uint32_t numSamples)
+{
+    for (uint32_t i = 0; i < numSamples; i++)
+    {                                        
+        if (pSrc[i] > high)                  
+            pDst[i] = high;                  
+        else if (pSrc[i] < low)              
+            pDst[i] = low;                   
+        else                                 
+            pDst[i] = pSrc[i];               
+    }
+}
+
+/**
+  @} end of BasicClip group
+ */

+ 68 - 0
Source/BasicMathFunctions/arm_clip_q31.c

@@ -0,0 +1,68 @@
+/* ----------------------------------------------------------------------
+ * Project:      CMSIS DSP Library
+ * Title:        arm_clip_q31.c
+ * Description:  Floating-point vector addition
+ *
+ *
+ * Target Processor: Cortex-M cores
+ * -------------------------------------------------------------------- */
+/*
+ * Copyright (C) 2010-2021 ARM Limited or its affiliates. All rights reserved.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the License); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "dsp/basic_math_functions.h"
+
+/**
+  @ingroup groupMath
+ */
+
+
+/**
+  @addtogroup BasicClip
+  @{
+ */
+
+/**
+  @brief         Elementwise fixed-point clipping
+  @param[in]     pSrc          points to input values
+  @param[out]    pDst          points to output clipped values
+  @param[in]     low           lower bound
+  @param[in]     high          higher bound
+  @param[in]     numSamples    number of samples to clip
+  @return        none
+ */
+
+void arm_clip_q31(const q31_t * pSrc, 
+  q31_t * pDst, 
+  q31_t low, 
+  q31_t high, 
+  uint32_t numSamples)
+{
+    for (uint32_t i = 0; i < numSamples; i++)
+    {                                        
+        if (pSrc[i] > high)                  
+            pDst[i] = high;                  
+        else if (pSrc[i] < low)              
+            pDst[i] = low;                   
+        else                                 
+            pDst[i] = pSrc[i];               
+    }
+}
+
+/**
+  @} end of BasicClip group
+ */

+ 68 - 0
Source/BasicMathFunctions/arm_clip_q7.c

@@ -0,0 +1,68 @@
+/* ----------------------------------------------------------------------
+ * Project:      CMSIS DSP Library
+ * Title:        arm_clip_q7.c
+ * Description:  Floating-point vector addition
+ *
+ *
+ * Target Processor: Cortex-M cores
+ * -------------------------------------------------------------------- */
+/*
+ * Copyright (C) 2010-2021 ARM Limited or its affiliates. All rights reserved.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the License); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "dsp/basic_math_functions.h"
+
+/**
+  @ingroup groupMath
+ */
+
+
+/**
+  @addtogroup BasicClip
+  @{
+ */
+
+/**
+  @brief         Elementwise fixed-point clipping
+  @param[in]     pSrc          points to input values
+  @param[out]    pDst          points to output clipped values
+  @param[in]     low           lower bound
+  @param[in]     high          higher bound
+  @param[in]     numSamples    number of samples to clip
+  @return        none
+ */
+
+void arm_clip_q7(const q7_t * pSrc, 
+  q7_t * pDst, 
+  q7_t low, 
+  q7_t high, 
+  uint32_t numSamples)
+{
+    for (uint32_t i = 0; i < numSamples; i++)
+    {                                        
+        if (pSrc[i] > high)                  
+            pDst[i] = high;                  
+        else if (pSrc[i] < low)              
+            pDst[i] = low;                   
+        else                                 
+            pDst[i] = pSrc[i];               
+    }
+}
+
+/**
+  @} end of BasicClip group
+ */

+ 2 - 0
Testing/Include/Tests/BasicTestsF16.h

@@ -17,4 +17,6 @@ class BasicTestsF16:public Client::Suite
             Client::LocalPattern<float16_t> output;
             // Reference patterns are not loaded when we are in dump mode
             Client::RefPattern<float16_t> ref;
+
+            float16_t min,max;
     };

+ 2 - 0
Testing/Include/Tests/BasicTestsF32.h

@@ -17,4 +17,6 @@ class BasicTestsF32:public Client::Suite
             Client::LocalPattern<float32_t> output;
             // Reference patterns are not loaded when we are in dump mode
             Client::RefPattern<float32_t> ref;
+
+            float32_t min,max;
     };

+ 2 - 0
Testing/Include/Tests/BasicTestsQ15.h

@@ -28,4 +28,6 @@ class BasicTestsQ15:public Client::Suite
 
             /* Offset or scale value */
             q15_t scalar;
+
+            q15_t min,max;
     };

+ 2 - 0
Testing/Include/Tests/BasicTestsQ31.h

@@ -28,4 +28,6 @@ class BasicTestsQ31:public Client::Suite
 
             /* Offset or scale value */
             q31_t scalar;
+
+            q31_t min,max;
     };

+ 2 - 0
Testing/Include/Tests/BasicTestsQ7.h

@@ -28,4 +28,6 @@ class BasicTestsQ7:public Client::Suite
 
             /* Offset or scale value */
             q7_t scalar;
+
+            q7_t min,max;
     };

+ 32 - 0
Testing/PatternGeneration/BasicMaths.py

@@ -6,7 +6,24 @@ import Tools
 
 # Those patterns are used for tests and benchmarks.
 # For tests, there is the need to add tests for saturation
+def clipTest(config,format,nb):
+    config.setOverwrite(True)
+    minValues=[-0.5,-0.5,0.1]
+    maxValues=[-0.1, 0.5,0.5]
+    testSamples=np.arange(-0.9,0.9,0.1) 
+    config.writeInput(nb, testSamples)
+
+    i=0
+    for (mi,ma) in zip(minValues,maxValues):
+      ref = list(np.clip(testSamples,mi,ma))
+      config.writeReference(nb+i, ref)
+      i = i + 1
+    
+    
+    
+    config.setOverwrite(False)
 
+    return(i)
 
 def writeTests(config,format):
     NBSAMPLES=256
@@ -103,6 +120,13 @@ def writeTests(config,format):
     else:
        config.writeReference(11, ref)
 
+    # This function is used in other test functions for q31 and q15
+    # So we can't add tests here for q15 and q31.
+    # But we can for f32:
+    if format == Tools.F32 or format==Tools.F16:
+       clipTest(config,format,12)
+       return(13)
+
     return(11)
 
 
@@ -261,6 +285,8 @@ def writeTests2(config,format):
     if format == 7:
       config.writeReferenceS8(nb+3, ref, "Xor")
 
+    clipTest(config,format,nb+4)
+
 
 def generatePatterns():
     PATTERNDIR = os.path.join("Patterns","DSP","BasicMaths","BasicMaths")
@@ -271,6 +297,12 @@ def generatePatterns():
     configq31=Tools.Config(PATTERNDIR,PARAMDIR,"q31")
     configq15=Tools.Config(PATTERNDIR,PARAMDIR,"q15")
     configq7=Tools.Config(PATTERNDIR,PARAMDIR,"q7")
+
+    configf32.setOverwrite(False)
+    configf16.setOverwrite(False)
+    configq31.setOverwrite(False)
+    configq15.setOverwrite(False)
+    configq7.setOverwrite(False)
     
     writeTests(configf32,0)
     writeTests(configf16,16)

+ 102 - 84
Testing/PatternGeneration/Tools.py

@@ -160,11 +160,17 @@ class Config:
       self._patternDir = "%s%s" % (patternDir,ext.upper())
       self._paramDir = "%s%s" % (paramDir,ext.upper())
       self._ext = ext 
+      self._overwrite=True
 
       createMissingDir(self._patternDir)
       createMissingDir(self._paramDir)
 
-    
+    def setOverwrite(self,v):
+        self._overwrite=v
+
+    def canOverwrite(self,path):
+        return(self._overwrite or not os.path.exists(path))
+
     def inputP(self,i,name=None):
         """ Path to a reference pattern from the ID
       
@@ -467,13 +473,14 @@ class Config:
           Returns:
             Nothing
         """
-        with open(i,"w") as f:
-            # Write sample dimension nb sample header
-            #np.savetxt(i, data, newline="\n", header="W\n%d" % len(data),comments ="" )
-            f.write("D\n%d\n" % len(data))
-            for v in data:
-                f.write("// %f\n" % v)
-                f.write("%s\n" % float64_to_hex(v))
+        if self.canOverwrite(i):
+          with open(i,"w") as f:
+              # Write sample dimension nb sample header
+              #np.savetxt(i, data, newline="\n", header="W\n%d" % len(data),comments ="" )
+              f.write("D\n%d\n" % len(data))
+              for v in data:
+                  f.write("// %f\n" % v)
+                  f.write("%s\n" % float64_to_hex(v))
 
     def _writeVectorF32(self,i,data):
         """ Write pattern data
@@ -492,13 +499,14 @@ class Config:
           Returns:
             Nothing
         """
-        with open(i,"w") as f:
-            # Write sample dimension nb sample header
-            #np.savetxt(i, data, newline="\n", header="W\n%d" % len(data),comments ="" )
-            f.write("W\n%d\n" % len(data))
-            for v in data:
-                f.write("// %f\n" % v)
-                f.write("%s\n" % float_to_hex(v))
+        if self.canOverwrite(i):
+          with open(i,"w") as f:
+              # Write sample dimension nb sample header
+              #np.savetxt(i, data, newline="\n", header="W\n%d" % len(data),comments ="" )
+              f.write("W\n%d\n" % len(data))
+              for v in data:
+                  f.write("// %f\n" % v)
+                  f.write("%s\n" % float_to_hex(v))
 
     def _writeVectorF16(self,i,data):
         """ Write pattern data
@@ -517,13 +525,14 @@ class Config:
           Returns:
             Nothing
         """
-        with open(i,"w") as f:
-            # Write sample dimension nb sample header
-            #np.savetxt(i, data, newline="\n", header="W\n%d" % len(data),comments ="" )
-            f.write("H\n%d\n" % len(data))
-            for v in data:
-                f.write("// %f\n" % v)
-                f.write("%s\n" % float16_to_hex(v))
+        if self.canOverwrite(i):
+          with open(i,"w") as f:
+              # Write sample dimension nb sample header
+              #np.savetxt(i, data, newline="\n", header="W\n%d" % len(data),comments ="" )
+              f.write("H\n%d\n" % len(data))
+              for v in data:
+                  f.write("// %f\n" % v)
+                  f.write("%s\n" % float16_to_hex(v))
 
     def _writeVectorQ63(self,i,data):
         """ Write pattern data
@@ -542,13 +551,14 @@ class Config:
           Returns:
             Nothing
         """
-        with open(i,"w") as f:
-            # Write sample dimension nb sample header
-            #np.savetxt(i, data, newline="\n", header="W\n%d" % len(data),comments ="" )
-            f.write("D\n%d\n" % len(data))
-            for v in data:
-                f.write("// %f\n" % v)
-                f.write("%s\n" % to_q63(v))
+        if self.canOverwrite(i):
+          with open(i,"w") as f:
+              # Write sample dimension nb sample header
+              #np.savetxt(i, data, newline="\n", header="W\n%d" % len(data),comments ="" )
+              f.write("D\n%d\n" % len(data))
+              for v in data:
+                  f.write("// %f\n" % v)
+                  f.write("%s\n" % to_q63(v))
 
     def _writeVectorQ31(self,i,data):
         """ Write pattern data
@@ -567,13 +577,14 @@ class Config:
           Returns:
             Nothing
         """
-        with open(i,"w") as f:
-            # Write sample dimension nb sample header
-            #np.savetxt(i, data, newline="\n", header="W\n%d" % len(data),comments ="" )
-            f.write("W\n%d\n" % len(data))
-            for v in data:
-                f.write("// %f\n" % v)
-                f.write("%s\n" % to_q31(v))
+        if self.canOverwrite(i):
+          with open(i,"w") as f:
+              # Write sample dimension nb sample header
+              #np.savetxt(i, data, newline="\n", header="W\n%d" % len(data),comments ="" )
+              f.write("W\n%d\n" % len(data))
+              for v in data:
+                  f.write("// %f\n" % v)
+                  f.write("%s\n" % to_q31(v))
 
     def _writeVectorQ15(self,i,data):
         """ Write pattern data
@@ -592,13 +603,14 @@ class Config:
           Returns:
             Nothing
         """
-        with open(i,"w") as f:
-            # Write sample dimension nb sample header
-            #np.savetxt(i, data, newline="\n", header="W\n%d" % len(data),comments ="" )
-            f.write("H\n%d\n" % len(data))
-            for v in data:
-                f.write("// %f\n" % v)
-                f.write("%s\n" % to_q15(v))
+        if self.canOverwrite(i):
+          with open(i,"w") as f:
+              # Write sample dimension nb sample header
+              #np.savetxt(i, data, newline="\n", header="W\n%d" % len(data),comments ="" )
+              f.write("H\n%d\n" % len(data))
+              for v in data:
+                  f.write("// %f\n" % v)
+                  f.write("%s\n" % to_q15(v))
 
     def _writeVectorS16(self,i,data):
         """ Write pattern data
@@ -617,13 +629,14 @@ class Config:
           Returns:
             Nothing
         """
-        with open(i,"w") as f:
-            # Write sample dimension nb sample header
-            #np.savetxt(i, data, newline="\n", header="W\n%d" % len(data),comments ="" )
-            f.write("H\n%d\n" % len(data))
-            for v in data:
-                f.write("// %d\n" % v)
-                f.write("%s\n" % s16(v))
+        if self.canOverwrite(i):
+          with open(i,"w") as f:
+              # Write sample dimension nb sample header
+              #np.savetxt(i, data, newline="\n", header="W\n%d" % len(data),comments ="" )
+              f.write("H\n%d\n" % len(data))
+              for v in data:
+                  f.write("// %d\n" % v)
+                  f.write("%s\n" % s16(v))
 
     def _writeVectorS32(self,i,data):
         """ Write pattern data
@@ -642,13 +655,14 @@ class Config:
           Returns:
             Nothing
         """
-        with open(i,"w") as f:
-            # Write sample dimension nb sample header
-            #np.savetxt(i, data, newline="\n", header="W\n%d" % len(data),comments ="" )
-            f.write("W\n%d\n" % len(data))
-            for v in data:
-                f.write("// %d\n" % v)
-                f.write("%s\n" % s32(v))
+        if self.canOverwrite(i):
+          with open(i,"w") as f:
+              # Write sample dimension nb sample header
+              #np.savetxt(i, data, newline="\n", header="W\n%d" % len(data),comments ="" )
+              f.write("W\n%d\n" % len(data))
+              for v in data:
+                  f.write("// %d\n" % v)
+                  f.write("%s\n" % s32(v))
 
     def _writeVectorU32(self,i,data):
         """ Write pattern data
@@ -667,13 +681,14 @@ class Config:
           Returns:
             Nothing
         """
-        with open(i,"w") as f:
-            # Write sample dimension nb sample header
-            #np.savetxt(i, data, newline="\n", header="W\n%d" % len(data),comments ="" )
-            f.write("W\n%d\n" % len(data))
-            for v in data:
-                f.write("// %s\n" % v)
-                f.write("%s\n" % u32(v))
+        if self.canOverwrite(i):
+          with open(i,"w") as f:
+              # Write sample dimension nb sample header
+              #np.savetxt(i, data, newline="\n", header="W\n%d" % len(data),comments ="" )
+              f.write("W\n%d\n" % len(data))
+              for v in data:
+                  f.write("// %s\n" % v)
+                  f.write("%s\n" % u32(v))
 
     def _writeVectorQ7(self,i,data):
         """ Write pattern data
@@ -692,13 +707,14 @@ class Config:
           Returns:
             Nothing
         """
-        with open(i,"w") as f:
-            # Write sample dimension nb sample header
-            #np.savetxt(i, data, newline="\n", header="W\n%d" % len(data),comments ="" )
-            f.write("B\n%d\n" % len(data))
-            for v in data:
-                f.write("// %f\n" % v)
-                f.write("%s\n" % to_q7(v))
+        if self.canOverwrite(i):
+          with open(i,"w") as f:
+              # Write sample dimension nb sample header
+              #np.savetxt(i, data, newline="\n", header="W\n%d" % len(data),comments ="" )
+              f.write("B\n%d\n" % len(data))
+              for v in data:
+                  f.write("// %f\n" % v)
+                  f.write("%s\n" % to_q7(v))
 
     def _writeVectorS8(self,i,data):
         """ Write pattern data
@@ -717,13 +733,14 @@ class Config:
           Returns:
             Nothing
         """
-        with open(i,"w") as f:
-            # Write sample dimension nb sample header
-            #np.savetxt(i, data, newline="\n", header="W\n%d" % len(data),comments ="" )
-            f.write("B\n%d\n" % len(data))
-            for v in data:
-                f.write("// %d\n" % v)
-                f.write("%s\n" % s8(v))
+        if self.canOverwrite(i):
+          with open(i,"w") as f:
+              # Write sample dimension nb sample header
+              #np.savetxt(i, data, newline="\n", header="W\n%d" % len(data),comments ="" )
+              f.write("B\n%d\n" % len(data))
+              for v in data:
+                  f.write("// %d\n" % v)
+                  f.write("%s\n" % s8(v))
 
     def writeReference(self,j,data,name=None):
         if (self._ext == "f64"):
@@ -829,12 +846,13 @@ class Config:
             Nothing
         """
         i=self.paramP(j,name)
-        with open(i,"w") as f:
-            # Write sample dimension nb sample header
-            #np.savetxt(i, data, newline="\n", header="W\n%d" % len(data),comments ="" )
-            f.write("%d\n" % len(data))
-            for v in data:
-                f.write("%d\n" % v)
+        if self.canOverwrite(i):
+          with open(i,"w") as f:
+              # Write sample dimension nb sample header
+              #np.savetxt(i, data, newline="\n", header="W\n%d" % len(data),comments ="" )
+              f.write("%d\n" % len(data))
+              for v in data:
+                  f.write("%d\n" % v)
 
 
 

+ 38 - 0
Testing/Patterns/DSP/BasicMaths/BasicMathsF16/Input12_f16.txt

@@ -0,0 +1,38 @@
+H
+18
+// -0.900000
+0xbb33
+// -0.800000
+0xba66
+// -0.700000
+0xb99a
+// -0.600000
+0xb8cd
+// -0.500000
+0xb800
+// -0.400000
+0xb666
+// -0.300000
+0xb4cd
+// -0.200000
+0xb266
+// -0.100000
+0xae66
+// -0.000000
+0x8000
+// 0.100000
+0x2e66
+// 0.200000
+0x3266
+// 0.300000
+0x34cd
+// 0.400000
+0x3666
+// 0.500000
+0x3800
+// 0.600000
+0x38cd
+// 0.700000
+0x399a
+// 0.800000
+0x3a66

+ 38 - 0
Testing/Patterns/DSP/BasicMaths/BasicMathsF16/Reference12_f16.txt

@@ -0,0 +1,38 @@
+H
+18
+// -0.500000
+0xb800
+// -0.500000
+0xb800
+// -0.500000
+0xb800
+// -0.500000
+0xb800
+// -0.500000
+0xb800
+// -0.400000
+0xb666
+// -0.300000
+0xb4cd
+// -0.200000
+0xb266
+// -0.100000
+0xae66
+// -0.100000
+0xae66
+// -0.100000
+0xae66
+// -0.100000
+0xae66
+// -0.100000
+0xae66
+// -0.100000
+0xae66
+// -0.100000
+0xae66
+// -0.100000
+0xae66
+// -0.100000
+0xae66
+// -0.100000
+0xae66

+ 38 - 0
Testing/Patterns/DSP/BasicMaths/BasicMathsF16/Reference13_f16.txt

@@ -0,0 +1,38 @@
+H
+18
+// -0.500000
+0xb800
+// -0.500000
+0xb800
+// -0.500000
+0xb800
+// -0.500000
+0xb800
+// -0.500000
+0xb800
+// -0.400000
+0xb666
+// -0.300000
+0xb4cd
+// -0.200000
+0xb266
+// -0.100000
+0xae66
+// -0.000000
+0x8000
+// 0.100000
+0x2e66
+// 0.200000
+0x3266
+// 0.300000
+0x34cd
+// 0.400000
+0x3666
+// 0.500000
+0x3800
+// 0.500000
+0x3800
+// 0.500000
+0x3800
+// 0.500000
+0x3800

+ 38 - 0
Testing/Patterns/DSP/BasicMaths/BasicMathsF16/Reference14_f16.txt

@@ -0,0 +1,38 @@
+H
+18
+// 0.100000
+0x2e66
+// 0.100000
+0x2e66
+// 0.100000
+0x2e66
+// 0.100000
+0x2e66
+// 0.100000
+0x2e66
+// 0.100000
+0x2e66
+// 0.100000
+0x2e66
+// 0.100000
+0x2e66
+// 0.100000
+0x2e66
+// 0.100000
+0x2e66
+// 0.100000
+0x2e66
+// 0.200000
+0x3266
+// 0.300000
+0x34cd
+// 0.400000
+0x3666
+// 0.500000
+0x3800
+// 0.500000
+0x3800
+// 0.500000
+0x3800
+// 0.500000
+0x3800

+ 38 - 0
Testing/Patterns/DSP/BasicMaths/BasicMathsF32/Input12_f32.txt

@@ -0,0 +1,38 @@
+W
+18
+// -0.900000
+0xbf666666
+// -0.800000
+0xbf4ccccd
+// -0.700000
+0xbf333333
+// -0.600000
+0xbf19999a
+// -0.500000
+0xbf000000
+// -0.400000
+0xbecccccd
+// -0.300000
+0xbe99999a
+// -0.200000
+0xbe4ccccd
+// -0.100000
+0xbdcccccd
+// -0.000000
+0xa5800000
+// 0.100000
+0x3dcccccd
+// 0.200000
+0x3e4ccccd
+// 0.300000
+0x3e99999a
+// 0.400000
+0x3ecccccd
+// 0.500000
+0x3f000000
+// 0.600000
+0x3f19999a
+// 0.700000
+0x3f333333
+// 0.800000
+0x3f4ccccd

+ 38 - 0
Testing/Patterns/DSP/BasicMaths/BasicMathsF32/Reference12_f32.txt

@@ -0,0 +1,38 @@
+W
+18
+// -0.500000
+0xbf000000
+// -0.500000
+0xbf000000
+// -0.500000
+0xbf000000
+// -0.500000
+0xbf000000
+// -0.500000
+0xbf000000
+// -0.400000
+0xbecccccd
+// -0.300000
+0xbe99999a
+// -0.200000
+0xbe4ccccd
+// -0.100000
+0xbdcccccd
+// -0.100000
+0xbdcccccd
+// -0.100000
+0xbdcccccd
+// -0.100000
+0xbdcccccd
+// -0.100000
+0xbdcccccd
+// -0.100000
+0xbdcccccd
+// -0.100000
+0xbdcccccd
+// -0.100000
+0xbdcccccd
+// -0.100000
+0xbdcccccd
+// -0.100000
+0xbdcccccd

+ 38 - 0
Testing/Patterns/DSP/BasicMaths/BasicMathsF32/Reference13_f32.txt

@@ -0,0 +1,38 @@
+W
+18
+// -0.500000
+0xbf000000
+// -0.500000
+0xbf000000
+// -0.500000
+0xbf000000
+// -0.500000
+0xbf000000
+// -0.500000
+0xbf000000
+// -0.400000
+0xbecccccd
+// -0.300000
+0xbe99999a
+// -0.200000
+0xbe4ccccd
+// -0.100000
+0xbdcccccd
+// -0.000000
+0xa5800000
+// 0.100000
+0x3dcccccd
+// 0.200000
+0x3e4ccccd
+// 0.300000
+0x3e99999a
+// 0.400000
+0x3ecccccd
+// 0.500000
+0x3f000000
+// 0.500000
+0x3f000000
+// 0.500000
+0x3f000000
+// 0.500000
+0x3f000000

+ 38 - 0
Testing/Patterns/DSP/BasicMaths/BasicMathsF32/Reference14_f32.txt

@@ -0,0 +1,38 @@
+W
+18
+// 0.100000
+0x3dcccccd
+// 0.100000
+0x3dcccccd
+// 0.100000
+0x3dcccccd
+// 0.100000
+0x3dcccccd
+// 0.100000
+0x3dcccccd
+// 0.100000
+0x3dcccccd
+// 0.100000
+0x3dcccccd
+// 0.100000
+0x3dcccccd
+// 0.100000
+0x3dcccccd
+// 0.100000
+0x3dcccccd
+// 0.100000
+0x3dcccccd
+// 0.200000
+0x3e4ccccd
+// 0.300000
+0x3e99999a
+// 0.400000
+0x3ecccccd
+// 0.500000
+0x3f000000
+// 0.500000
+0x3f000000
+// 0.500000
+0x3f000000
+// 0.500000
+0x3f000000

+ 38 - 0
Testing/Patterns/DSP/BasicMaths/BasicMathsQ15/Input28_q15.txt

@@ -0,0 +1,38 @@
+H
+18
+// -0.900000
+0x8CCD
+// -0.800000
+0x999A
+// -0.700000
+0xA666
+// -0.600000
+0xB333
+// -0.500000
+0xC000
+// -0.400000
+0xCCCD
+// -0.300000
+0xD99A
+// -0.200000
+0xE666
+// -0.100000
+0xF333
+// -0.000000
+0x0000
+// 0.100000
+0x0CCD
+// 0.200000
+0x199A
+// 0.300000
+0x2666
+// 0.400000
+0x3333
+// 0.500000
+0x4000
+// 0.600000
+0x4CCD
+// 0.700000
+0x599A
+// 0.800000
+0x6666

+ 38 - 0
Testing/Patterns/DSP/BasicMaths/BasicMathsQ15/Reference28_q15.txt

@@ -0,0 +1,38 @@
+H
+18
+// -0.500000
+0xC000
+// -0.500000
+0xC000
+// -0.500000
+0xC000
+// -0.500000
+0xC000
+// -0.500000
+0xC000
+// -0.400000
+0xCCCD
+// -0.300000
+0xD99A
+// -0.200000
+0xE666
+// -0.100000
+0xF333
+// -0.100000
+0xF333
+// -0.100000
+0xF333
+// -0.100000
+0xF333
+// -0.100000
+0xF333
+// -0.100000
+0xF333
+// -0.100000
+0xF333
+// -0.100000
+0xF333
+// -0.100000
+0xF333
+// -0.100000
+0xF333

+ 38 - 0
Testing/Patterns/DSP/BasicMaths/BasicMathsQ15/Reference29_q15.txt

@@ -0,0 +1,38 @@
+H
+18
+// -0.500000
+0xC000
+// -0.500000
+0xC000
+// -0.500000
+0xC000
+// -0.500000
+0xC000
+// -0.500000
+0xC000
+// -0.400000
+0xCCCD
+// -0.300000
+0xD99A
+// -0.200000
+0xE666
+// -0.100000
+0xF333
+// -0.000000
+0x0000
+// 0.100000
+0x0CCD
+// 0.200000
+0x199A
+// 0.300000
+0x2666
+// 0.400000
+0x3333
+// 0.500000
+0x4000
+// 0.500000
+0x4000
+// 0.500000
+0x4000
+// 0.500000
+0x4000

+ 38 - 0
Testing/Patterns/DSP/BasicMaths/BasicMathsQ15/Reference30_q15.txt

@@ -0,0 +1,38 @@
+H
+18
+// 0.100000
+0x0CCD
+// 0.100000
+0x0CCD
+// 0.100000
+0x0CCD
+// 0.100000
+0x0CCD
+// 0.100000
+0x0CCD
+// 0.100000
+0x0CCD
+// 0.100000
+0x0CCD
+// 0.100000
+0x0CCD
+// 0.100000
+0x0CCD
+// 0.100000
+0x0CCD
+// 0.100000
+0x0CCD
+// 0.200000
+0x199A
+// 0.300000
+0x2666
+// 0.400000
+0x3333
+// 0.500000
+0x4000
+// 0.500000
+0x4000
+// 0.500000
+0x4000
+// 0.500000
+0x4000

+ 38 - 0
Testing/Patterns/DSP/BasicMaths/BasicMathsQ31/Input28_q31.txt

@@ -0,0 +1,38 @@
+W
+18
+// -0.900000
+0x8CCCCCCD
+// -0.800000
+0x9999999A
+// -0.700000
+0xA6666666
+// -0.600000
+0xB3333333
+// -0.500000
+0xC0000000
+// -0.400000
+0xCCCCCCCD
+// -0.300000
+0xD999999A
+// -0.200000
+0xE6666666
+// -0.100000
+0xF3333333
+// -0.000000
+0x00000000
+// 0.100000
+0x0CCCCCCD
+// 0.200000
+0x1999999A
+// 0.300000
+0x26666666
+// 0.400000
+0x33333333
+// 0.500000
+0x40000000
+// 0.600000
+0x4CCCCCCD
+// 0.700000
+0x5999999A
+// 0.800000
+0x66666666

+ 38 - 0
Testing/Patterns/DSP/BasicMaths/BasicMathsQ31/Reference28_q31.txt

@@ -0,0 +1,38 @@
+W
+18
+// -0.500000
+0xC0000000
+// -0.500000
+0xC0000000
+// -0.500000
+0xC0000000
+// -0.500000
+0xC0000000
+// -0.500000
+0xC0000000
+// -0.400000
+0xCCCCCCCD
+// -0.300000
+0xD999999A
+// -0.200000
+0xE6666666
+// -0.100000
+0xF3333333
+// -0.100000
+0xF3333333
+// -0.100000
+0xF3333333
+// -0.100000
+0xF3333333
+// -0.100000
+0xF3333333
+// -0.100000
+0xF3333333
+// -0.100000
+0xF3333333
+// -0.100000
+0xF3333333
+// -0.100000
+0xF3333333
+// -0.100000
+0xF3333333

+ 38 - 0
Testing/Patterns/DSP/BasicMaths/BasicMathsQ31/Reference29_q31.txt

@@ -0,0 +1,38 @@
+W
+18
+// -0.500000
+0xC0000000
+// -0.500000
+0xC0000000
+// -0.500000
+0xC0000000
+// -0.500000
+0xC0000000
+// -0.500000
+0xC0000000
+// -0.400000
+0xCCCCCCCD
+// -0.300000
+0xD999999A
+// -0.200000
+0xE6666666
+// -0.100000
+0xF3333333
+// -0.000000
+0x00000000
+// 0.100000
+0x0CCCCCCD
+// 0.200000
+0x1999999A
+// 0.300000
+0x26666666
+// 0.400000
+0x33333333
+// 0.500000
+0x40000000
+// 0.500000
+0x40000000
+// 0.500000
+0x40000000
+// 0.500000
+0x40000000

+ 38 - 0
Testing/Patterns/DSP/BasicMaths/BasicMathsQ31/Reference30_q31.txt

@@ -0,0 +1,38 @@
+W
+18
+// 0.100000
+0x0CCCCCCD
+// 0.100000
+0x0CCCCCCD
+// 0.100000
+0x0CCCCCCD
+// 0.100000
+0x0CCCCCCD
+// 0.100000
+0x0CCCCCCD
+// 0.100000
+0x0CCCCCCD
+// 0.100000
+0x0CCCCCCD
+// 0.100000
+0x0CCCCCCD
+// 0.100000
+0x0CCCCCCD
+// 0.100000
+0x0CCCCCCD
+// 0.100000
+0x0CCCCCCD
+// 0.200000
+0x1999999A
+// 0.300000
+0x26666666
+// 0.400000
+0x33333333
+// 0.500000
+0x40000000
+// 0.500000
+0x40000000
+// 0.500000
+0x40000000
+// 0.500000
+0x40000000

+ 38 - 0
Testing/Patterns/DSP/BasicMaths/BasicMathsQ7/Input28_q7.txt

@@ -0,0 +1,38 @@
+B
+18
+// -0.900000
+0x8D
+// -0.800000
+0x9A
+// -0.700000
+0xA6
+// -0.600000
+0xB3
+// -0.500000
+0xC0
+// -0.400000
+0xCD
+// -0.300000
+0xDA
+// -0.200000
+0xE6
+// -0.100000
+0xF3
+// -0.000000
+0x00
+// 0.100000
+0x0D
+// 0.200000
+0x1A
+// 0.300000
+0x26
+// 0.400000
+0x33
+// 0.500000
+0x40
+// 0.600000
+0x4D
+// 0.700000
+0x5A
+// 0.800000
+0x66

+ 38 - 0
Testing/Patterns/DSP/BasicMaths/BasicMathsQ7/Reference28_q7.txt

@@ -0,0 +1,38 @@
+B
+18
+// -0.500000
+0xC0
+// -0.500000
+0xC0
+// -0.500000
+0xC0
+// -0.500000
+0xC0
+// -0.500000
+0xC0
+// -0.400000
+0xCD
+// -0.300000
+0xDA
+// -0.200000
+0xE6
+// -0.100000
+0xF3
+// -0.100000
+0xF3
+// -0.100000
+0xF3
+// -0.100000
+0xF3
+// -0.100000
+0xF3
+// -0.100000
+0xF3
+// -0.100000
+0xF3
+// -0.100000
+0xF3
+// -0.100000
+0xF3
+// -0.100000
+0xF3

+ 38 - 0
Testing/Patterns/DSP/BasicMaths/BasicMathsQ7/Reference29_q7.txt

@@ -0,0 +1,38 @@
+B
+18
+// -0.500000
+0xC0
+// -0.500000
+0xC0
+// -0.500000
+0xC0
+// -0.500000
+0xC0
+// -0.500000
+0xC0
+// -0.400000
+0xCD
+// -0.300000
+0xDA
+// -0.200000
+0xE6
+// -0.100000
+0xF3
+// -0.000000
+0x00
+// 0.100000
+0x0D
+// 0.200000
+0x1A
+// 0.300000
+0x26
+// 0.400000
+0x33
+// 0.500000
+0x40
+// 0.500000
+0x40
+// 0.500000
+0x40
+// 0.500000
+0x40

+ 38 - 0
Testing/Patterns/DSP/BasicMaths/BasicMathsQ7/Reference30_q7.txt

@@ -0,0 +1,38 @@
+B
+18
+// 0.100000
+0x0D
+// 0.100000
+0x0D
+// 0.100000
+0x0D
+// 0.100000
+0x0D
+// 0.100000
+0x0D
+// 0.100000
+0x0D
+// 0.100000
+0x0D
+// 0.100000
+0x0D
+// 0.100000
+0x0D
+// 0.100000
+0x0D
+// 0.100000
+0x0D
+// 0.200000
+0x1A
+// 0.300000
+0x26
+// 0.400000
+0x33
+// 0.500000
+0x40
+// 0.500000
+0x40
+// 0.500000
+0x40
+// 0.500000
+0x40

+ 45 - 4
Testing/Source/Tests/BasicTestsF16.cpp

@@ -34,6 +34,21 @@ float16_t *outp=output.ptr();
 
     } 
 
+    void BasicTestsF16::test_clip_f16()
+    {
+        const float16_t *inp=input1.ptr();
+        float16_t *outp=output.ptr();
+
+        arm_clip_f16(inp,outp,this->min, this->max,input1.nbSamples());
+
+        ASSERT_EMPTY_TAIL(output);
+
+        ASSERT_SNR(output,ref,(float16_t)SNR_THRESHOLD);
+
+        ASSERT_REL_ERROR(output,ref,REL_ERROR);
+
+    } 
+
     void BasicTestsF16::test_sub_f16()
     {
 
@@ -300,12 +315,38 @@ float16_t *outp=output.ptr();
           ref.reload(BasicTestsF16::REF_ABS_F16_ID,mgr,nb);
         break;
 
-       }
-      
+        case BasicTestsF16::TEST_CLIP_F16_33:
+          input1.reload(BasicTestsF16::INPUT_CLIP_F16_ID,mgr);
+          ref.reload(BasicTestsF16::REF_CLIP1_F16_ID,mgr);
+          // Must be coherent with Python script used to generate test patterns
+          this->min=-0.5f16;
+          this->max=-0.1f16;
+        break;
 
-       input1.reload(BasicTestsF16::INPUT1_F16_ID,mgr,nb);
-       input2.reload(BasicTestsF16::INPUT2_F16_ID,mgr,nb);
+        case BasicTestsF16::TEST_CLIP_F16_34:
+          input1.reload(BasicTestsF16::INPUT_CLIP_F16_ID,mgr);
+          ref.reload(BasicTestsF16::REF_CLIP2_F16_ID,mgr);
+          // Must be coherent with Python script used to generate test patterns
+          this->min=-0.5f16;
+          this->max=0.5f16;
+        break;
+
+        case BasicTestsF16::TEST_CLIP_F16_35:
+          input1.reload(BasicTestsF16::INPUT_CLIP_F16_ID,mgr);
+          ref.reload(BasicTestsF16::REF_CLIP3_F16_ID,mgr);
+          // Must be coherent with Python script used to generate test patterns
+          this->min=0.1f16;
+          this->max=0.5f16;
+        break;
 
+       }
+      
+       if (id < TEST_CLIP_F16_33)
+       {
+         input1.reload(BasicTestsF16::INPUT1_F16_ID,mgr,nb);
+         input2.reload(BasicTestsF16::INPUT2_F16_ID,mgr,nb);
+       }
+       
        output.create(ref.nbSamples(),BasicTestsF16::OUT_SAMPLES_F16_ID,mgr);
     }
 

+ 44 - 2
Testing/Source/Tests/BasicTestsF32.cpp

@@ -31,6 +31,21 @@ float32_t *outp=output.ptr();
 
     } 
 
+    void BasicTestsF32::test_clip_f32()
+    {
+        const float32_t *inp=input1.ptr();
+        float32_t *outp=output.ptr();
+
+        arm_clip_f32(inp,outp,this->min, this->max,input1.nbSamples());
+
+        ASSERT_EMPTY_TAIL(output);
+
+        ASSERT_SNR(output,ref,(float32_t)SNR_THRESHOLD);
+
+        ASSERT_REL_ERROR(output,ref,REL_ERROR);
+
+    } 
+
     void BasicTestsF32::test_sub_f32()
     {
         GET_F32_PTR();
@@ -291,11 +306,38 @@ float32_t *outp=output.ptr();
           ref.reload(BasicTestsF32::REF_ABS_F32_ID,mgr,nb);
         break;
 
+        case BasicTestsF32::TEST_CLIP_F32_33:
+          input1.reload(BasicTestsF32::INPUT_CLIP_F32_ID,mgr);
+          ref.reload(BasicTestsF32::REF_CLIP1_F32_ID,mgr);
+          // Must be coherent with Python script used to generate test patterns
+          this->min=-0.5f;
+          this->max=-0.1f;
+        break;
+
+        case BasicTestsF32::TEST_CLIP_F32_34:
+          input1.reload(BasicTestsF32::INPUT_CLIP_F32_ID,mgr);
+          ref.reload(BasicTestsF32::REF_CLIP2_F32_ID,mgr);
+          // Must be coherent with Python script used to generate test patterns
+          this->min=-0.5f;
+          this->max=0.5f;
+        break;
+
+        case BasicTestsF32::TEST_CLIP_F32_35:
+          input1.reload(BasicTestsF32::INPUT_CLIP_F32_ID,mgr);
+          ref.reload(BasicTestsF32::REF_CLIP3_F32_ID,mgr);
+          // Must be coherent with Python script used to generate test patterns
+          this->min=0.1f;
+          this->max=0.5f;
+        break;
+
        }
       
 
-       input1.reload(BasicTestsF32::INPUT1_F32_ID,mgr,nb);
-       input2.reload(BasicTestsF32::INPUT2_F32_ID,mgr,nb);
+       if (id < TEST_CLIP_F32_33)
+       {
+         input1.reload(BasicTestsF32::INPUT1_F32_ID,mgr,nb);
+         input2.reload(BasicTestsF32::INPUT2_F32_ID,mgr,nb);
+       }
 
        output.create(ref.nbSamples(),BasicTestsF32::OUT_SAMPLES_F32_ID,mgr);
     }

+ 43 - 0
Testing/Source/Tests/BasicTestsQ15.cpp

@@ -42,6 +42,21 @@ uint16_t *outp=outputLogical.ptr();
 
     } 
 
+    void BasicTestsQ15::test_clip_q15()
+    {
+        const q15_t *inp=input1.ptr();
+        q15_t *outp=output.ptr();
+
+        arm_clip_q15(inp,outp,this->min, this->max,input1.nbSamples());
+
+        ASSERT_EMPTY_TAIL(output);
+
+        ASSERT_SNR(output,ref,(float32_t)SNR_THRESHOLD);
+
+        ASSERT_NEAR_EQ(output,ref,ABS_ERROR_Q15);
+
+    } 
+
     void BasicTestsQ15::test_sub_q15()
     {
         GET_Q15_PTR();
@@ -628,6 +643,34 @@ uint16_t *outp=outputLogical.ptr();
           input1.reload(BasicTestsQ15::INPUT1_Q15_ID,mgr,nb);
           input2.reload(BasicTestsQ15::INPUT2_Q15_ID,mgr,nb);
         break;
+
+        case BasicTestsQ15::TEST_CLIP_Q15_57:
+          input1.reload(BasicTestsQ15::INPUT_CLIP_Q15_ID,mgr);
+          ref.reload(BasicTestsQ15::REF_CLIP1_Q15_ID,mgr);
+          output.create(ref.nbSamples(),BasicTestsQ15::OUT_SAMPLES_ID,mgr);
+          // Must be coherent with Python script used to generate test patterns
+          this->min=0xC000;
+          this->max=0xF333;
+        break;
+
+        case BasicTestsQ15::TEST_CLIP_Q15_58:
+          input1.reload(BasicTestsQ15::INPUT_CLIP_Q15_ID,mgr);
+          ref.reload(BasicTestsQ15::REF_CLIP2_Q15_ID,mgr);
+          output.create(ref.nbSamples(),BasicTestsQ15::OUT_SAMPLES_ID,mgr);
+          // Must be coherent with Python script used to generate test patterns
+          this->min=0xC000;
+          this->max=0x4000;
+        break;
+
+        case BasicTestsQ15::TEST_CLIP_Q15_59:
+          input1.reload(BasicTestsQ15::INPUT_CLIP_Q15_ID,mgr);
+          ref.reload(BasicTestsQ15::REF_CLIP3_Q15_ID,mgr);
+          output.create(ref.nbSamples(),BasicTestsQ15::OUT_SAMPLES_ID,mgr);
+          // Must be coherent with Python script used to generate test patterns
+          this->min=0x0CCD;
+          this->max=0x4000;
+        break;
+
           
 
        }

+ 41 - 0
Testing/Source/Tests/BasicTestsQ31.cpp

@@ -40,6 +40,21 @@ uint32_t *outp=outputLogical.ptr();
 
     } 
 
+    void BasicTestsQ31::test_clip_q31()
+    {
+        const q31_t *inp=input1.ptr();
+        q31_t *outp=output.ptr();
+
+        arm_clip_q31(inp,outp,this->min, this->max,input1.nbSamples());
+
+        ASSERT_EMPTY_TAIL(output);
+
+        ASSERT_SNR(output,ref,(float32_t)SNR_THRESHOLD);
+
+        ASSERT_NEAR_EQ(output,ref,ABS_ERROR_Q31);
+
+    } 
+
     void BasicTestsQ31::test_sub_q31()
     {
         GET_Q31_PTR();
@@ -625,6 +640,32 @@ uint32_t *outp=outputLogical.ptr();
         break;
         
 
+        case BasicTestsQ31::TEST_CLIP_Q31_57:
+          input1.reload(BasicTestsQ31::INPUT_CLIP_Q31_ID,mgr);
+          ref.reload(BasicTestsQ31::REF_CLIP1_Q31_ID,mgr);
+          output.create(ref.nbSamples(),BasicTestsQ31::OUT_SAMPLES_ID,mgr);
+          // Must be coherent with Python script used to generate test patterns
+          this->min=0xC0000000;
+          this->max=0xF3333333;
+        break;
+
+        case BasicTestsQ31::TEST_CLIP_Q31_58:
+          input1.reload(BasicTestsQ31::INPUT_CLIP_Q31_ID,mgr);
+          ref.reload(BasicTestsQ31::REF_CLIP2_Q31_ID,mgr);
+          output.create(ref.nbSamples(),BasicTestsQ31::OUT_SAMPLES_ID,mgr);
+          // Must be coherent with Python script used to generate test patterns
+          this->min=0xC0000000;
+          this->max=0x40000000;
+        break;
+
+        case BasicTestsQ31::TEST_CLIP_Q31_59:
+          input1.reload(BasicTestsQ31::INPUT_CLIP_Q31_ID,mgr);
+          ref.reload(BasicTestsQ31::REF_CLIP3_Q31_ID,mgr);
+          output.create(ref.nbSamples(),BasicTestsQ31::OUT_SAMPLES_ID,mgr);
+          // Must be coherent with Python script used to generate test patterns
+          this->min=0x0CCCCCCD;
+          this->max=0x40000000;
+        break;
 
        }
       

+ 43 - 0
Testing/Source/Tests/BasicTestsQ7.cpp

@@ -33,6 +33,21 @@ uint8_t *outp=outputLogical.ptr();
 
     } 
 
+    void BasicTestsQ7::test_clip_q7()
+    {
+        const q7_t *inp=input1.ptr();
+        q7_t *outp=output.ptr();
+
+        arm_clip_q7(inp,outp,this->min, this->max,input1.nbSamples());
+
+        ASSERT_EMPTY_TAIL(output);
+
+        ASSERT_SNR(output,ref,(float32_t)SNR_THRESHOLD);
+
+        ASSERT_NEAR_EQ(output,ref,ABS_ERROR_Q7);
+
+    } 
+
     void BasicTestsQ7::test_sub_q7()
     {
         GET_Q7_PTR();
@@ -640,6 +655,34 @@ uint8_t *outp=outputLogical.ptr();
           input1.reload(BasicTestsQ7::INPUT1_Q7_ID,mgr,nb);
           input2.reload(BasicTestsQ7::INPUT2_Q7_ID,mgr,nb);
         break;
+
+        case BasicTestsQ7::TEST_CLIP_Q7_57:
+          input1.reload(BasicTestsQ7::INPUT_CLIP_Q7_ID,mgr);
+          ref.reload(BasicTestsQ7::REF_CLIP1_Q7_ID,mgr);
+          output.create(ref.nbSamples(),BasicTestsQ7::OUT_SAMPLES_ID,mgr);
+          // Must be coherent with Python script used to generate test patterns
+          this->min=0xC0;
+          this->max=0xF3;
+        break;
+
+        case BasicTestsQ7::TEST_CLIP_Q7_58:
+          input1.reload(BasicTestsQ7::INPUT_CLIP_Q7_ID,mgr);
+          ref.reload(BasicTestsQ7::REF_CLIP2_Q7_ID,mgr);
+          output.create(ref.nbSamples(),BasicTestsQ7::OUT_SAMPLES_ID,mgr);
+          // Must be coherent with Python script used to generate test patterns
+          this->min=0xC0;
+          this->max=0x40;
+        break;
+
+        case BasicTestsQ7::TEST_CLIP_Q7_59:
+          input1.reload(BasicTestsQ7::INPUT_CLIP_Q7_ID,mgr);
+          ref.reload(BasicTestsQ7::REF_CLIP3_Q7_ID,mgr);
+          output.create(ref.nbSamples(),BasicTestsQ7::OUT_SAMPLES_ID,mgr);
+          // Must be coherent with Python script used to generate test patterns
+          this->min=0x0D;
+          this->max=0x40;
+        break;
+
         
 
        }

+ 39 - 4
Testing/desc.txt

@@ -631,7 +631,9 @@ group Root {
    
               Pattern INPUT1_F32_ID : Input1_f32.txt 
               Pattern INPUT2_F32_ID : Input2_f32.txt 
-   
+
+              Pattern INPUT_CLIP_F32_ID : Input12_f32.txt 
+              
               Pattern REF_ADD_F32_ID : Reference1_f32.txt
               Pattern REF_SUB_F32_ID : Reference2_f32.txt
               Pattern REF_MULT_F32_ID : Reference3_f32.txt
@@ -643,6 +645,10 @@ group Root {
               Pattern REF_DOT_4N1_F32_ID : Reference9_f32.txt
               Pattern REF_ABS_F32_ID : Reference10_f32.txt
               Pattern REF_DOT_LONG_F32_ID : Reference11_f32.txt
+
+              Pattern REF_CLIP1_F32_ID : Reference12_f32.txt
+              Pattern REF_CLIP2_F32_ID : Reference13_f32.txt
+              Pattern REF_CLIP3_F32_ID : Reference14_f32.txt
    
               Output  OUT_SAMPLES_F32_ID : Output
               Output  OUT_STATE_F32_ID : State
@@ -688,6 +694,9 @@ group Root {
                 Test long    arm_scale_f32:test_scale_f32
                 Test long    arm_dot_prod_f32:test_dot_prod_f32
                 Test long    arm_abs_f32:test_abs_f32
+                Test 1       arm_clip_f32:test_clip_f32
+                Test 2       arm_clip_f32:test_clip_f32
+                Test 3       arm_clip_f32:test_clip_f32
               }
            }
 
@@ -705,7 +714,9 @@ group Root {
  
               Pattern INPUT1_BITWISE_Q31_ID : BitwiseInput24_s32.txt
               Pattern INPUT2_BITWISE_Q31_ID : BitwiseInput25_s32.txt
-  
+
+              Pattern INPUT_CLIP_Q31_ID : Input28_q31.txt 
+              
               Pattern REF_ADD_Q31_ID : Reference1_q31.txt
               Pattern REF_SUB_Q31_ID : Reference2_q31.txt
               Pattern REF_MULT_Q31_ID : Reference3_q31.txt
@@ -737,6 +748,10 @@ group Root {
               Pattern REF_NOT_Q31_ID : Not26_s32.txt
               Pattern REF_XOR_Q31_ID : Xor27_s32.txt
 
+              Pattern REF_CLIP1_Q31_ID : Reference28_q31.txt
+              Pattern REF_CLIP2_Q31_ID : Reference29_q31.txt
+              Pattern REF_CLIP3_Q31_ID : Reference30_q31.txt
+
               Output  OUT_SAMPLES_ID : Output
               Output  OUT_STATE_Q31_ID : State
    
@@ -816,6 +831,9 @@ group Root {
                 Test long    arm_scale_q31:test_scale_q31
                 Test long    arm_dot_prod_q31:test_dot_prod_q31
                 Test long    arm_abs_q31:test_abs_q31
+                Test 1       arm_clip_q31:test_clip_q31
+                Test 2       arm_clip_q31:test_clip_q31
+                Test 3       arm_clip_q31:test_clip_q31
 
               }
            }
@@ -835,6 +853,8 @@ group Root {
               Pattern INPUT1_BITWISE_Q15_ID : BitwiseInput24_s16.txt
               Pattern INPUT2_BITWISE_Q15_ID : BitwiseInput25_s16.txt 
 
+              Pattern INPUT_CLIP_Q15_ID : Input28_q15.txt 
+              
               Pattern REF_ADD_Q15_ID : Reference1_q15.txt
               Pattern REF_SUB_Q15_ID : Reference2_q15.txt
               Pattern REF_MULT_Q15_ID : Reference3_q15.txt
@@ -866,6 +886,10 @@ group Root {
               Pattern REF_NOT_Q15_ID : Not26_s16.txt
               Pattern REF_XOR_Q15_ID : Xor27_s16.txt
 
+              Pattern REF_CLIP1_Q15_ID : Reference28_q15.txt
+              Pattern REF_CLIP2_Q15_ID : Reference29_q15.txt
+              Pattern REF_CLIP3_Q15_ID : Reference30_q15.txt
+
               Output  OUT_SAMPLES_ID : Output
               Output  OUT_STATE_Q15_ID : State
    
@@ -945,7 +969,9 @@ group Root {
                 Test long    arm_scale_q15:test_scale_q15
                 Test long    arm_dot_prod_q15:test_dot_prod_q15
                 Test long    arm_abs_q15:test_abs_q15
-
+                Test 1       arm_clip_q15:test_clip_q15
+                Test 2       arm_clip_q15:test_clip_q15
+                Test 3       arm_clip_q15:test_clip_q15
               }
            }
 
@@ -963,7 +989,9 @@ group Root {
 
               Pattern INPUT1_BITWISE_Q7_ID : BitwiseInput24_s8.txt
               Pattern INPUT2_BITWISE_Q7_ID : BitwiseInput25_s8.txt 
-  
+
+              Pattern INPUT_CLIP_Q7_ID : Input28_q7.txt 
+             
               Pattern REF_ADD_Q7_ID : Reference1_q7.txt
               Pattern REF_SUB_Q7_ID : Reference2_q7.txt
               Pattern REF_MULT_Q7_ID : Reference3_q7.txt
@@ -995,6 +1023,10 @@ group Root {
               Pattern REF_NOT_Q7_ID : Not26_s8.txt
               Pattern REF_XOR_Q7_ID : Xor27_s8.txt
 
+              Pattern REF_CLIP1_Q7_ID : Reference28_q7.txt
+              Pattern REF_CLIP2_Q7_ID : Reference29_q7.txt
+              Pattern REF_CLIP3_Q7_ID : Reference30_q7.txt
+
               Output  OUT_SAMPLES_ID : Output
               Output  OUT_STATE_Q7_ID : State
    
@@ -1074,6 +1106,9 @@ group Root {
                 Test long    arm_scale_q7:test_scale_q7
                 Test long    arm_dot_prod_q7:test_dot_prod_q7
                 Test long    arm_abs_q7:test_abs_q7
+                Test 1       arm_clip_q7:test_clip_q7
+                Test 2       arm_clip_q7:test_clip_q7
+                Test 3       arm_clip_q7:test_clip_q7
               }
            }
         }

+ 10 - 1
Testing/desc_f16.txt

@@ -217,7 +217,9 @@ group Root {
    
               Pattern INPUT1_F16_ID : Input1_f16.txt 
               Pattern INPUT2_F16_ID : Input2_f16.txt 
-   
+
+              Pattern INPUT_CLIP_F16_ID : Input12_f16.txt 
+              
               Pattern REF_ADD_F16_ID : Reference1_f16.txt
               Pattern REF_SUB_F16_ID : Reference2_f16.txt
               Pattern REF_MULT_F16_ID : Reference3_f16.txt
@@ -229,6 +231,10 @@ group Root {
               Pattern REF_DOT_4N1_F16_ID : Reference9_f16.txt
               Pattern REF_ABS_F16_ID : Reference10_f16.txt
               Pattern REF_DOT_LONG_F16_ID : Reference11_f16.txt
+
+              Pattern REF_CLIP1_F16_ID : Reference12_f16.txt
+              Pattern REF_CLIP2_F16_ID : Reference13_f16.txt
+              Pattern REF_CLIP3_F16_ID : Reference14_f16.txt
    
               Output  OUT_SAMPLES_F16_ID : Output
               Output  OUT_STATE_F16_ID : State
@@ -274,6 +280,9 @@ group Root {
                 Test long    arm_scale_f16:test_scale_f16
                 Test long    arm_dot_prod_f16:test_dot_prod_f16
                 Test long    arm_abs_f16:test_abs_f16
+                Test 1       arm_clip_f16:test_clip_f16
+                Test 2       arm_clip_f16:test_clip_f16
+                Test 3       arm_clip_f16:test_clip_f16
               }
            }