From 502f0f429a261628fe5e43582280012541c40804 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joachim=20Stro=CC=88mbergson?= Date: Fri, 24 Apr 2015 15:16:23 +0200 Subject: (1) Adding auto generated testbench for verilog. (2) Update of the test generator. (3) Update of the Makefile to run test generator. --- src/model/c/src/findn_test.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/model/c/src/findn_test.c (limited to 'src/model/c/src/findn_test.c') 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 +#include + +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; +} -- cgit v1.2.3