Skip to content

Commit

Permalink
core/math/fixed: implement BrFixedFMac{2,3,4}()
Browse files Browse the repository at this point in the history
  • Loading branch information
vs49688 committed May 25, 2024
1 parent 73cc6ca commit bc4cbea
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
10 changes: 5 additions & 5 deletions core/inc/math_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,17 +122,17 @@ br_fixed_ls BR_PUBLIC_ENTRY BrFixedRcp(br_fixed_ls a);

/* result = a*b + c*d - a & c are fractions
*/
br_fixed_ls BR_ASM_CALL BrFixedFMac2(br_fixed_lsf a, br_fixed_ls b, br_fixed_lsf c, br_fixed_ls d);
br_fixed_ls BR_PUBLIC_ENTRY BrFixedFMac2(br_fixed_lsf a, br_fixed_ls b, br_fixed_lsf c, br_fixed_ls d);

/* result = a*b + c*d + e*f - a,c & e are fractions
*/
br_fixed_ls BR_ASM_CALL BrFixedFMac3(br_fixed_lsf a, br_fixed_ls b, br_fixed_lsf c, br_fixed_ls d, br_fixed_lsf e,
br_fixed_ls f);
br_fixed_ls BR_PUBLIC_ENTRY BrFixedFMac3(br_fixed_lsf a, br_fixed_ls b, br_fixed_lsf c, br_fixed_ls d, br_fixed_lsf e,
br_fixed_ls f);

/* result = a*b + c*d + e*f + g*h (a,c,e,g are fractions)
*/
br_fixed_ls BR_ASM_CALL BrFixedFMac4(br_fixed_ls a, br_fixed_ls b, br_fixed_ls c, br_fixed_ls d, br_fixed_ls e,
br_fixed_ls f, br_fixed_ls g, br_fixed_ls h);
br_fixed_ls BR_PUBLIC_ENTRY BrFixedFMac4(br_fixed_lsf a, br_fixed_ls b, br_fixed_lsf c, br_fixed_ls d, br_fixed_lsf e,
br_fixed_ls f, br_fixed_lsf g, br_fixed_ls h);

/*
* Misc. support functions
Expand Down
17 changes: 17 additions & 0 deletions core/math/fixed.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,23 @@ br_fixed_ls BR_PUBLIC_ENTRY BrFixedRcp(br_fixed_ls a)
return BrFixedDiv(BR_ONE_LS, a);
}

br_fixed_ls BR_PUBLIC_ENTRY BrFixedFMac2(br_fixed_lsf a, br_fixed_ls b, br_fixed_lsf c, br_fixed_ls d)
{
return BrFixedMac2(a << 1, b, c << 1, d);
}

br_fixed_ls BR_PUBLIC_ENTRY BrFixedFMac3(br_fixed_lsf a, br_fixed_ls b, br_fixed_lsf c, br_fixed_ls d, br_fixed_lsf e,
br_fixed_ls f)
{
return BrFixedMac3(a << 1, b, c << 1, d, e << 1, f);
}

br_fixed_ls BR_PUBLIC_ENTRY BrFixedFMac4(br_fixed_lsf a, br_fixed_ls b, br_fixed_lsf c, br_fixed_ls d, br_fixed_lsf e,
br_fixed_ls f, br_fixed_lsf g, br_fixed_ls h)
{
return BrFixedMac4(a << 1, b, c << 1, d, e << 1, f, g << 1, h);
}

/*
* Given a 16-bit input, generate the output value of a function
* using a 256-word lookup table with interpolation between entries.
Expand Down

0 comments on commit bc4cbea

Please sign in to comment.