From: Pavel Pisa Date: Sun, 30 Nov 2014 21:39:52 +0000 (+0100) Subject: RoCoN: included command to test approximation of reciprocal computation. X-Git-Url: http://rtime.felk.cvut.cz/gitweb/fpga/lx-cpu1/lx-rocon.git/commitdiff_plain/dfea3d5f15f5f15df479d00b1571c80390c00984 RoCoN: included command to test approximation of reciprocal computation. Signed-off-by: Pavel Pisa --- diff --git a/sw/app/rocon/appl_fpga.c b/sw/app/rocon/appl_fpga.c index a0db72d..51385d0 100644 --- a/sw/app/rocon/appl_fpga.c +++ b/sw/app/rocon/appl_fpga.c @@ -69,6 +69,10 @@ volatile uint32_t *fpga_lx_master_receiver_done_div = (volatile uint32_t *)FPGA_ volatile uint32_t *fpga_lx_master_reset = (volatile uint32_t *)FPGA_LX_MASTER_RESET; volatile uint32_t *fpga_lx_master_conf = (volatile uint32_t *)FPGA_CONFIGURATION_FILE_ADDRESS; +#define FPGA_FNCAPPROX_BASE 0x80023000 + +volatile uint32_t *fpga_fncapprox_base = (volatile uint32_t *)FPGA_FNCAPPROX_BASE; + /* BUS measurement - values (shifting all bits) */ #define MEAS_VAL1 0xAAAAAAAA #define MEAS_VAL2 0x55555555 diff --git a/sw/app/rocon/appl_fpga.h b/sw/app/rocon/appl_fpga.h index ad66654..0897d31 100644 --- a/sw/app/rocon/appl_fpga.h +++ b/sw/app/rocon/appl_fpga.h @@ -109,6 +109,12 @@ extern volatile uint32_t *fpga_lx_master_receiver_done_div; #define FPGA_LX_MASTER_CONTROL_ADDRESS_MASK 0x0000FF00 #define FPGA_LX_MASTER_CONTROL_DATA_LENGTH_MASK 0x000000FF +/* Function approximation block */ + +#define FPGA_FNCAPPROX_BASE 0x80023000 + +extern volatile uint32_t *fpga_fncapprox_base; + /* Configuration defines */ #define FPGA_CONFIGURATION_FILE_ADDRESS 0xA1C00000 diff --git a/sw/app/rocon/appl_tests.c b/sw/app/rocon/appl_tests.c index 387649e..ae19cf4 100644 --- a/sw/app/rocon/appl_tests.c +++ b/sw/app/rocon/appl_tests.c @@ -293,6 +293,39 @@ int cmd_do_testlxpwrstat(cmd_io_t *cmd_io, const struct cmd_des *des, char *para return 0; } +int cmd_do_testfncapprox(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[]) +{ + char *ps = param[1]; + unsigned long val; + unsigned long res; + long diff; + unsigned int xb; + uint32_t x; + uint32_t xl; + uint64_t yl; + + si_skspace(&ps); + if (si_ulong(&ps, &val, 0) < 0) + return -CMDERR_BADPAR; + + x = val; + xb = __builtin_clz(x); + xl = x << xb; + + *fpga_fncapprox_base = xl; + + res = *fpga_fncapprox_base; + + yl = (1LL << 62) / xl; + + diff = yl - res; + + printf("val=0x%08lx res=0x%08lx ref=0x%08lx diff=%ld\n", + val, res, (unsigned long)yl, diff); + + return 0; +} + cmd_des_t const cmd_des_test_memusage = {0, 0, "memusage", "report memory usage", cmd_do_test_memusage, { @@ -360,6 +393,11 @@ cmd_des_t const cmd_des_testlxpwrstat = {0, 0, cmd_do_testlxpwrstat, {(void *)0} }; +cmd_des_t const cmd_des_testfncapprox = {0, 0, + "testfncapprox", "test of function approximator", + cmd_do_testfncapprox, {(void *)0} + }; + cmd_des_t const *const cmd_appl_tests[] = { &cmd_des_test_memusage, @@ -376,5 +414,6 @@ cmd_des_t const *const cmd_appl_tests[] = #endif /*SDRAM_BASE*/ &cmd_des_testlxpwrrx, &cmd_des_testlxpwrstat, + &cmd_des_testfncapprox, NULL };