diff --git a/include/cmp_support.h b/include/cmp_support.h index fcae0d4113c900bfee2aa8bdc381c1460ac2f541..b67ebcd84430666e6254cc65fd48047cb324b122 100644 --- a/include/cmp_support.h +++ b/include/cmp_support.h @@ -244,6 +244,32 @@ struct fx_cob_par { }; +/** + * @brief method for lossy rounding + * @note This function is implemented as a macro for the sake of performance + * + * @param value the value to round + * @param round rounding parameter + * + * @return rounded value + */ + +#define round_fwd(value, round) ((uint32_t)(value) << (round)) + + +/** + * @brief inverse method for lossy rounding + * @note This function is implemented as a macro for the sake of performance + * + * @param value the value to round back + * @param round rounding parameter + * + * @return back rounded value + */ + +#define round_inv(value, round) ((uint32_t)(value) << (round)) + + int is_a_pow_of_2(unsigned int v); int ilog_2(uint32_t x); @@ -273,8 +299,8 @@ int rdcu_supported_cmp_mode_is_used(enum cmp_mode cmp_mode); int zero_escape_mech_is_used(enum cmp_mode cmp_mode); int multi_escape_mech_is_used(enum cmp_mode cmp_mode); -uint32_t round_fwd(uint32_t value, unsigned int round); -uint32_t round_inv(uint32_t value, unsigned int round); +/* unsigned int round_fwd(unsigned int value, unsigned int round); */ +/* unsigned int round_inv(unsigned int value, unsigned int round); */ unsigned int cmp_up_model(unsigned int data, unsigned int model, unsigned int model_value, unsigned int round); diff --git a/lib/cmp_support.c b/lib/cmp_support.c index c0f78e3ae644f466f519957dbf1e8ba64ce4ac66..3593cb0f26393855c44747237f2ac7bdcd9c4dcf 100644 --- a/lib/cmp_support.c +++ b/lib/cmp_support.c @@ -312,36 +312,6 @@ int cmp_aux_data_type_is_used(enum cmp_data_type data_type) } -/** - * @brief method for lossy rounding - * - * @param value the value to round - * @param round rounding parameter - * - * @return rounded value - */ - -inline __attribute__((always_inline)) uint32_t round_fwd(uint32_t value, unsigned int round) -{ - return value >> round; -} - - -/** - * @brief inverse method for lossy rounding - * - * @param value the value to round back - * @param round rounding parameter - * - * @return back rounded value - */ - -inline __attribute__((always_inline)) uint32_t round_inv(uint32_t value, unsigned int round) -{ - return value << round; -} - - /** * @brief implantation of the model update equation * @note check before that model_value is not greater than MAX_MODEL_VALUE