biquad_f32_ae32.S 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. // Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #include "esp_platform.h"
  15. // This is bi quad filter form II for ESP32 processor.
  16. .text
  17. .align 4
  18. .global dsps_biquad_f32_ae32
  19. .type dsps_biquad_f32_ae32,@function
  20. // The function implements the following C code:
  21. //esp_err_t dsps_biquad_f32_ae32(const float* input, float* output, int len, float* coef, float* w)
  22. // {
  23. // for (int i=0 ; i< len ; i++)
  24. // {
  25. // float d0 = input[i] - coef[3]*w[0] - coef[4]*w[1]; (input[i] - a[1]*w[0] - a[2]*w[1];)
  26. // output[i] = coef[0]*d0 + coef[1]*w[0] + coef[2]*w[1];
  27. // w[1] = w[0];
  28. // w[0] = d0;
  29. // }
  30. // return ESP_OK;
  31. // }
  32. dsps_biquad_f32_ae32:
  33. // input - a2
  34. // output - a3
  35. // len - a4
  36. // coeffs - a5
  37. // w- a6
  38. // f0 - b0
  39. // f1 - b1
  40. // f2 - b2
  41. // f3 - a1
  42. // f4 - a2
  43. // f5 - w0
  44. // f6 - w1
  45. entry a1, 16
  46. // Array increment for floating point data should be 4
  47. lsi f0, a5, 0
  48. lsi f1, a5, 4
  49. lsi f2, a5, 8
  50. lsi f3, a5, 12
  51. lsi f4, a5, 16
  52. neg.s f5, f3 // -a[1]
  53. neg.s f6, f4 // -a[2]
  54. lsi f7, a6, 0 // w[0]
  55. lsi f8, a6, 4 // w[1]
  56. addi a3, a3, -4 // i-- // preset a3
  57. lsi f9, a2, 0 // f9 = x[i]
  58. loopnez a4, loop_bq_end_m_ae32
  59. madd.s f9, f7, f5 // f9 += -a1*w0
  60. addi a3, a3, 4 // out++;
  61. mul.s f10, f1, f7 // f10 = b1*w0
  62. madd.s f9, f8, f6 // f9 += -a2*w1
  63. madd.s f10, f9, f0 // f10 += b0*d0
  64. addi a2, a2, 4 // in++;
  65. madd.s f10, f2, f8 // f10+= b2*w1, f10 - result
  66. mov.s f8, f7 // w1 = w0
  67. mov.s f7, f9 // w0 = d0
  68. lsi f9, a2, 0 // f9 = x[i]
  69. ssi f10, a3, 0 // y[i] = result
  70. loop_bq_end_m_ae32:
  71. // Store delay line
  72. ssi f7, a6, 0
  73. ssi f8, a6, 4
  74. movi.n a2, 0 // return status ESP_OK
  75. retw.n