aboutsummaryrefslogtreecommitdiff
path: root/src/model/c/src/findn_test.c
diff options
context:
space:
mode:
authorJoachim StroĢˆmbergson <joachim@secworks.se>2015-04-24 15:16:23 +0200
committerJoachim StroĢˆmbergson <joachim@secworks.se>2015-04-24 15:16:23 +0200
commit502f0f429a261628fe5e43582280012541c40804 (patch)
treea53cf2bac9474091157c4df56e75a333b3376e26 /src/model/c/src/findn_test.c
parent7a6c9b5eb5a3d27be80c68eab583bd05e45bd310 (diff)
(1) Adding auto generated testbench for verilog. (2) Update of the test generator. (3) Update of the Makefile to run test generator.
Diffstat (limited to 'src/model/c/src/findn_test.c')
-rw-r--r--src/model/c/src/findn_test.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/model/c/src/findn_test.c b/src/model/c/src/findn_test.c
new file mode 100644
index 0000000..3c4a2fe
--- /dev/null
+++ b/src/model/c/src/findn_test.c
@@ -0,0 +1,25 @@
+#include <stdio.h>
+#include <stdint.h>
+
+uint32_t findN(uint32_t length, uint32_t *E) {
+ uint32_t n = -1;
+ for (int i = 0; i < 32 * length; i++) {
+ uint32_t ei_ = E[length - 1 - (i / 32)];
+ uint32_t ei = (ei_ >> (i % 32)) & 1;
+
+ printf("ei_ = 0x%08x, ei = 0x%08x\n", ei_, ei);
+ if (ei == 1) {
+ n = i;
+ }
+ }
+ return n + 1;
+}
+
+
+int main(void) {
+ uint32_t my_e[4] = {0x5a00aaaa, 0x555555, 0x80808080, 0x01010101};
+
+ printf("Result: %08d\n", findN(1, &my_e[0]));
+
+ return 0;
+}