1 #ifndef CC_INVERSION_H__ 2 #define CC_INVERSION_H__ 8 template <
class data_T,
int N>
16 x(
x.width - 2,
x.width - NB - 1) =
i;
20 template <
class data_T,
int N>
26 ap_uint<NB> y =
x(
x.width - 2,
x.width - NB - 1);
27 return (
unsigned)y(NB - 1, 0);
30 template <
class data_T,
class table_T,
int N>
33 for (
unsigned i = 0;
i <
N;
i++) {
34 float x = real_val_from_idx<data_T, N>(
i);
35 table_T inv_x = 1 /
x;
40 template <
class in_t,
class table_t,
int N>
43 init_invert_table<in_t, table_t, N>(inv_table);
47 for (
int b = 0;
b <
in.width;
b++) {
53 in_t in_shifted =
in << (
in.width - msb - 1);
55 int idx = idx_from_real_val<in_t, N>(in_shifted);
56 table_t inv_in = inv_table[
idx];
58 table_t
out = inv_in << (
in.width - msb - 1);
constexpr int ceillog2(int x)
float real_val_from_idx(unsigned i)
void init_invert_table(table_T table_out[N])
unsigned idx_from_real_val(data_T x)
table_t invert_with_shift(in_t in)