libraries / Mitov / Mitov_DigitalsToUnsigned.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_DIGITALS_TO_UNSIGNED_h
  11#define _MITOV_DIGITALS_TO_UNSIGNED_h
  12
  13#include <Mitov.h>
  14
  15namespace Mitov
  16{
  17        template<int C_NUM_INPUTS> class DigitalsToUnsigned : 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                        uint32_t AValue = 0;
  25                        for( uint32_t i = C_NUM_INPUTS; i--; )
  26                                if( inherited::InputPins[ i ].Value )
  27                                        AValue |= ((uint32_t)1) << i;
  28
  29                        return AValue;
  30                }
  31
  32        };
  33//---------------------------------------------------------------------------
  34}
  35
  36#endif