libraries / Mitov / Mitov_PriorityEncoder.hon commit Added link to project report (97a3ba0)
   1////////////////////////////////////////////////////////////////////////////////
   2//                                                                            //
   3//     This software is supplied under the terms of a license agreement or    //
   4//     nondisclosure agreement with Mitov Software and may not be copied      //
   5//     or disclosed except in accordance with the terms of that agreement.    //
   6//         Copyright(c) 2002-2016 Mitov Software. All Rights Reserved.        //
   7//                                                                            //
   8////////////////////////////////////////////////////////////////////////////////
   9
  10#ifndef _MITOV_PRIORITY_ENCODER_h
  11#define _MITOV_PRIORITY_ENCODER_h
  12
  13#include <Mitov.h>
  14
  15namespace Mitov
  16{
  17        template<int C_NUM_INPUTS> class PriorityEncoder : public Mitov::BasicCommonMultiInput<bool, uint32_t, C_NUM_INPUTS>
  18        {
  19                typedef Mitov::BasicCommonMultiInput<bool, uint32_t, C_NUM_INPUTS> inherited;
  20
  21        protected:
  22                virtual uint32_t CalculateOutput() override
  23                {
  24                        for( uint32_t i = C_NUM_INPUTS; i--; )
  25                                if( inherited::InputPins[ i ].Value )
  26                                        return i;
  27
  28                        return 0;
  29                }
  30
  31        };
  32//---------------------------------------------------------------------------
  33}
  34
  35#endif