Zip.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /* ----------------------------------------------------------------------
  2. * Project: CMSIS DSP Library
  3. * Title: Zip.h
  4. * Description: Node to zip a pair of stream
  5. *
  6. *
  7. * Target Processor: Cortex-M and Cortex-A cores
  8. * --------------------------------------------------------------------
  9. *
  10. * Copyright (C) 2021-2023 ARM Limited or its affiliates. All rights reserved.
  11. *
  12. * SPDX-License-Identifier: Apache-2.0
  13. *
  14. * Licensed under the Apache License, Version 2.0 (the License); you may
  15. * not use this file except in compliance with the License.
  16. * You may obtain a copy of the License at
  17. *
  18. * www.apache.org/licenses/LICENSE-2.0
  19. *
  20. * Unless required by applicable law or agreed to in writing, software
  21. * distributed under the License is distributed on an AS IS BASIS, WITHOUT
  22. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  23. * See the License for the specific language governing permissions and
  24. * limitations under the License.
  25. */
  26. #ifndef _ZIP_H_
  27. #define _ZIP_H_
  28. template<typename IN1, int inputSize1,typename IN2,int inputSize2,typename OUT,int outputSize>
  29. class Zip;
  30. template<typename IN, int inputSize,int outputSize>
  31. class Zip<IN,inputSize,IN,inputSize,IN,outputSize>: public GenericNode21<IN,inputSize,IN,inputSize,IN,outputSize>
  32. {
  33. public:
  34. Zip(FIFOBase<IN> &src1,FIFOBase<IN> &src2,FIFOBase<IN> &dst):
  35. GenericNode21<IN,inputSize,IN,inputSize,IN,outputSize>(src1,src2,dst){};
  36. int prepareForRunning() final
  37. {
  38. if (this->willOverflow() ||
  39. this->willUnderflow1() ||
  40. this->willUnderflow2()
  41. )
  42. {
  43. return(CG_SKIP_EXECUTION_ID_CODE); // Skip execution
  44. }
  45. return(0);
  46. };
  47. int run() final
  48. {
  49. IN *a1=this->getReadBuffer1();
  50. IN *a2=this->getReadBuffer2();
  51. IN *b=this->getWriteBuffer1();
  52. for(int i = 0; i<inputSize; i++)
  53. {
  54. b[2*i] = a1[i];
  55. b[2*i+1] = a2[i];
  56. }
  57. return(0);
  58. };
  59. };
  60. #endif