-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
92 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
CPPFLAGS=-I../../src | ||
|
||
../../src/PoorManFloatConst.h: main | ||
./main >../../src/PoorManFloatConst.h | ||
|
||
main: main.o PoorManFloat.o | ||
|
||
main.o: main.cpp | ||
|
||
PoorManFloat.o: PoorManFloat.cpp | ||
|
||
PoorManFloat.cpp: ../../src/PoorManFloat.cpp | ||
cp ../../src/PoorManFloat.cpp PoorManFloat.cpp | ||
|
||
clean: | ||
rm -f PoorManFloat.cpp | ||
rm -f main main.o PoorManFloat.o |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# generate pmf constants | ||
|
||
Those constants are stored in PoorManFloatConst.h and are autogenerated | ||
by invoking make. This builds main from main.cpp. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#include <stdio.h> | ||
|
||
#include <PoorManFloat.h> | ||
|
||
void out(const char *name, pmf_logarithmic value) { | ||
printf("#define %s ((pmf_logarithmic)0x%04x)\n", name, value); | ||
} | ||
|
||
int main() { | ||
puts("// Autogenerated by extras/gen_pmf_const/main"); | ||
puts("// DO NOT EDIT"); | ||
puts("#ifndef POORMANFLOATCONST_H"); | ||
puts("#define POORMANFLOATCONST_H"); | ||
puts(""); | ||
puts("#include <PoorManFloat.h>"); | ||
puts(""); | ||
|
||
pmf_logarithmic x; | ||
|
||
x = pmfl_from((uint8_t)1); | ||
out("PMF_CONST_1", x); | ||
|
||
x = pmfl_shr(pmfl_from((uint8_t)3), 1); | ||
out("PMF_CONST_3_DIV_2", x); | ||
|
||
x = pmfl_multiply(pmfl_from((uint32_t)16e6), pmfl_from((uint32_t)8e6)); | ||
out("PMF_CONST_128E12", x); | ||
|
||
x = pmfl_from((uint32_t)16e6); | ||
out("PMF_CONST_16E6", x); | ||
|
||
x = pmfl_from((uint16_t)500); | ||
out("PMF_CONST_500", x); | ||
|
||
x = pmfl_from((uint16_t)1000); | ||
out("PMF_CONST_1000", x); | ||
|
||
x = pmfl_from((uint16_t)2000); | ||
out("PMF_CONST_2000", x); | ||
|
||
x = pmfl_from((uint16_t)32000); | ||
out("PMF_CONST_32000", x); | ||
|
||
x = pmfl_divide(pmfl_from((uint32_t)16e6), pmfl_sqrt(pmfl_from((uint8_t)2))); | ||
out("PMF_CONST_16E6_DIV_SQRT_OF_2", x); | ||
|
||
x = pmfl_from((uint32_t)21e6); | ||
out("PMF_CONST_21E6", x); | ||
|
||
x = pmfl_from((uint16_t)42000); | ||
out("PMF_CONST_42000", x); | ||
|
||
x = pmfl_divide(pmfl_from((uint32_t)21e6), pmfl_sqrt(pmfl_from((uint8_t)2))); | ||
out("PMF_CONST_21E6_DIV_SQRT_OF_2", x); | ||
|
||
x = pmfl_square(pmfl_from((uint32_t)21e6)); | ||
x = pmfl_shr(x, 1); | ||
out("PMF_CONST_2205E11", x); | ||
|
||
puts("#endif"); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters