Zip.h 2.0 KB

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