Skip to content
Snippets Groups Projects
Commit 7f829514 authored by Dominik Loidolt's avatar Dominik Loidolt
Browse files

Function macro optimisation

parent 0e99cb37
No related branches found
No related tags found
1 merge request!13Function macro optimisation
......@@ -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);
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment