PandA-2024.02
|
mathematical utility function not provided by standard libraries More...
#include <boost/version.hpp>
#include <boost/math/common_factor_rt.hpp>
#include <limits>
#include <type_traits>
Go to the source code of this file.
Macros | |
#define | EXACT_POWER_OF_2_OR_ZERO_P(x) (((x) & ((x)-1)) == 0) |
Test whether a value is zero of a power of two. More... | |
Functions | |
template<typename Integer > | |
Integer | GreatestCommonDivisor (const Integer first, const Integer second) |
Return the greatest common divisor. More... | |
template<typename Integer > | |
Integer | LeastCommonMultiple (const Integer first, const Integer second) |
Return the least common multiple of two integers. More... | |
template<typename T > | |
T | compute_n_bytes (T bitsize) |
template<typename T , std::enable_if_t< std::is_unsigned< T >::value, bool > = true> | |
T | floor_log2 (T x) |
Given X, an unsigned number, return the largest int Y such that 2**Y <= X. If X is 0, return -1. More... | |
template<typename T , std::enable_if_t< std::is_unsigned< T >::value, bool > = true> | |
T | exact_log2 (T x) |
Return the logarithm of X, base 2, considering X unsigned, if X is a power of 2. More... | |
template<typename T , std::enable_if_t< std::is_unsigned< T >::value, bool > = true> | |
T | ceil_log2 (T x) |
Return the smallest n such that 2**n >= X. More... | |
return | static_cast< T > (x) |
template<typename T , std::enable_if_t< std::is_unsigned< T >::value, bool > = true> | |
constexpr T | get_aligned_bitsize (T bitsize) |
template<typename T , std::enable_if_t< std::is_unsigned< T >::value, bool > = true> | |
constexpr T | get_aligned_bitsize (T bitsize, T align) |
template<typename T , std::enable_if_t< std::is_unsigned< T >::value, bool > = true> | |
constexpr T | get_aligned_ac_bitsize (T bitsize) |
template<typename T , std::enable_if_t< std::is_unsigned< T >::value, bool > = true> | |
T | resize_1_8_pow2 (T value) |
Variables | |
template<typename T , std::enable_if_t< std::is_unsigned< T >::value, bool > = true> | |
x = x >> 2 | |
Return the smallest n such that 2^n >= _x. More... | |
mathematical utility function not provided by standard libraries
Definition in file math_function.hpp.
Test whether a value is zero of a power of two.
Definition at line 97 of file math_function.hpp.
Referenced by IR_lowering::division_by_a_constant(), and IR_lowering::expand_MC().
|
inline |
Return the smallest n such that 2**n >= X.
Definition at line 152 of file math_function.hpp.
References floor_log2(), static_cast< T >(), symmetry::value, and x.
Referenced by top_entity_cs::add_context_switch_port(), top_entity_cs::add_context_switch_port_kernel(), top_entity_cs::add_input_register(), datapath_cs::add_ports(), controller_cs::add_selector_register_file_port(), Bit_Value::backward_transfer(), top_entity_parallel_cs::BW_loop_iter(), choose_multiplier(), fu_binding_cs::connect_selector_kernel(), IR_lowering::division_by_a_constant(), mem_dominator_allocation_cs::Exec(), memory_allocation::finalize_memory_allocation(), fu_binding_cs::instantiate_component_kernel(), datapath_parallel_cs::instantiate_component_parallel(), cs_interface::instantiate_component_parallel(), ReadWrite_m_axiModuleGenerator::InternalExec(), BuiltinWaitCallNModuleGenerator::InternalExec(), BuiltinWaitCallModuleGenerator::InternalExec(), datapath_parallel_cs::InternalExec(), fu_binding_cs::set_atomic_memory_parameter(), Range::shl(), Range::shr(), and reg_binding_cs::specialise_reg().
|
inline |
Definition at line 91 of file math_function.hpp.
Referenced by memory::add_internal_symbol(), memory_allocation::allocate_parameters(), IR_lowering::array_ref_lowering(), memory::compute_next_base_address(), DiscrepancyAnalysisCWriter::DeclareLocalVariables(), mem_dominator_allocation::InternalExec(), and DiscrepancyAnalysisCWriter::WriteExtraInitCode().
|
inline |
Return the logarithm of X, base 2, considering X unsigned, if X is a power of 2.
Otherwise, returns -1.
Definition at line 141 of file math_function.hpp.
References floor_log2(), and symmetry::value.
Referenced by synth_mult().
|
inline |
Given X, an unsigned number, return the largest int Y such that 2**Y <= X. If X is 0, return -1.
Definition at line 101 of file math_function.hpp.
References symmetry::value.
Referenced by ceil_log2(), IR_lowering::division_by_a_constant(), exact_log2(), IR_lowering::expand_MC(), IR_lowering::expand_sdiv_pow2(), IR_lowering::expand_smod_pow2(), and synth_mult().
|
inline |
Definition at line 197 of file math_function.hpp.
References symmetry::value.
Referenced by InterfaceInfer::interface_info::update().
|
inline |
Definition at line 180 of file math_function.hpp.
References max, and symmetry::value.
Referenced by InterfaceInfer::Exec(), fu_binding::fill_array_ref_memory(), tree_manipulation::GetCustomIntegerType(), and InterfaceInfer::interface_info::update().
|
inline |
Definition at line 191 of file math_function.hpp.
References max, and symmetry::value.
Integer GreatestCommonDivisor | ( | const Integer | first, |
const Integer | second | ||
) |
Return the greatest common divisor.
first | is the first operand |
second | is the second operand |
Definition at line 65 of file math_function.hpp.
Integer LeastCommonMultiple | ( | const Integer | first, |
const Integer | second | ||
) |
Return the least common multiple of two integers.
first | is the first operand |
second | is the second operand |
Definition at line 81 of file math_function.hpp.
|
inline |
Definition at line 203 of file math_function.hpp.
References max.
Referenced by FunctionalUnitStep::AnalyzeFu(), AllocationInformation::estimate_mux_area(), AllocationInformation::estimate_mux_time(), AllocationInformation::estimate_muxNto1_area(), AllocationInformation::estimate_muxNto1_delay(), AllocationInformation::get_correction_time(), AllocationInformation::GetCondExprTimeLatency(), AllocationInformation::GetCycleLatency(), AllocationInformation::GetNodeTypePrec(), AllocationInformation::GetPhiConnectionLatency(), AllocationInformation::GetStatementArea(), and AllocationInformation::GetTimeLatency().
return static_cast< T > | ( | x | ) |
x = x >> 2 |
Return the smallest n such that 2^n >= _x.
Definition at line 170 of file math_function.hpp.
Referenced by __attribute__(), a_ctz_64(), a_ctz_l(), a_fetch_add(), a_swap(), AddRoundKey_InversMixColumn(), ceil_log2(), chi(), Circle(), CircleFill(), ConvertHexToNumber(), cordic_atan2(), execute(), fill(), fillVal(), filter(), fixedpt_ln(), gcd(), helm_factor_impl(), helm_naive(), hls_fp_accumulator(), init_array(), invert_mod2n(), laplacian(), line(), load_image_data(), main(), make_inverse_image(), mandelbrot(), MixColumn_AddRoundKey(), NaturalVersionOrder(), op_vertex_order_by_map::op_vertex_order_by_map(), PrioritySorter::operator()(), edge_integer_order_by_map::operator()(), pi(), plot_test(), print_array(), DesignFlowStep::PrintFinalIR(), ref_fp_accumulator(), rho(), save_image_data(), sharpen(), sobel(), theta(), times2(), ullong_to_double(), and expr_pack_expansion::visit().