]> rtime.felk.cvut.cz Git - fpga/lx-cpu1/lx-rocon.git/commitdiff
RoCoN: new file for application specific commands and sqrtll tests added.
authorPavel Pisa <ppisa@pikron.com>
Sat, 31 May 2014 08:37:32 +0000 (10:37 +0200)
committerPavel Pisa <ppisa@pikron.com>
Sat, 31 May 2014 08:37:32 +0000 (10:37 +0200)
Signed-off-by: Pavel Pisa <ppisa@pikron.com>
sw/app/rocon/Makefile.omk
sw/app/rocon/appl_cmdproc.c
sw/app/rocon/appl_cmds.c [new file with mode: 0644]
sw/app/rocon/appl_main.c
sw/app/rocon/math_sqrtll_test.c [new file with mode: 0644]

index f6b7d925f36cdceb2aa84bad8bb71b2b9c6059f7..a9db28fae2c4658cca690c8d8b647ed1523b8b63 100644 (file)
@@ -64,6 +64,7 @@ endif
 
 ifeq ($(CONFIG_OC_CMDPROC),y)
 rocon_SOURCES += appl_cmdproc.c
+rocon_SOURCES += appl_cmds.c
 ifneq ($(CONFIG_APP_ROCON_WITH_SIM_POSIX),y)
 rocon_SOURCES += appl_tests.c
 rocon_SOURCES += appl_dprint.c
@@ -116,6 +117,7 @@ endif
 ifeq ($(CONFIG_PXMC),y)
 ifeq ($(CONFIG_PXMC_COORDMV),y)
 rocon_SOURCES += appl_coordmv.c math_sqrtll.c
+rocon_SOURCES += math_sqrtll_test.c
 lib_LOADLIBES += pxmc_coordmv
 endif
 ifneq ($(CONFIG_APP_ROCON_WITH_SIM_POSIX),y)
index 826e8e010d1b210cf18a7f97c97187d7e02523b6..8c32e13185a70c0c7c1d1e0431eac913b0c95905 100644 (file)
@@ -9,6 +9,7 @@ extern cmd_des_t const *cmd_pxmc_base[];
 extern cmd_des_t const *cmd_appl_tests[];
 extern cmd_des_t const *cmd_pxmc_ptable[];
 extern cmd_des_t const *cmd_pxmc_coordmv[];
+extern cmd_des_t const *cmd_appl_specific[];
 
 extern cmd_des_t const cmd_des_dprint;
 
@@ -34,6 +35,7 @@ cmd_des_t const *cmd_list_main[] =
   CMD_DES_INCLUDE_SUBLIST(cmd_pxmc_ptable),
 #endif
   CMD_DES_INCLUDE_SUBLIST(cmd_pxmc_coordmv),
+  CMD_DES_INCLUDE_SUBLIST(cmd_appl_specific),
   &cmd_des_dprint,
   NULL
 };
diff --git a/sw/app/rocon/appl_cmds.c b/sw/app/rocon/appl_cmds.c
new file mode 100644 (file)
index 0000000..6376eeb
--- /dev/null
@@ -0,0 +1,47 @@
+/*******************************************************************
+  Motion and Robotic System (MARS) aplication components
+
+  appl_cmds.c - application specific commands - mainly global
+                PXMC state manipulation for RoCoN
+
+  Copyright (C) 2001-2014 by Pavel Pisa - originator
+                          pisa@cmp.felk.cvut.cz
+            (C) 2001-2014 by PiKRON Ltd. - originator
+                    http://www.pikron.com
+
+  This file can be used and copied according to next
+  license alternatives
+   - GPL - GNU Public License
+   - other license provided by project originators
+
+ *******************************************************************/
+
+#include <cpu_def.h>
+#include <system_def.h>
+#include <pxmc.h>
+#include <pxmc_coordmv.h>
+#include <cmd_proc.h>
+#include <pxmc_cmds.h>
+#include <utils.h>
+
+#include "appl_defs.h"
+
+int sqrtll_main(int argc, char *argv[]);
+
+int cmd_do_sqrtll(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
+{
+  char *ps;
+  ps = param[1];
+  sqrtll_main(!ps?1: !*ps? 1: 2, param);
+  return 0;
+}
+
+cmd_des_t const cmd_des_sqrtll={0, 0,"sqrtll","test 64-bit square root computation",
+                       cmd_do_sqrtll,
+                       {0,0}};
+
+
+cmd_des_t const *const cmd_appl_specific[]={
+  &cmd_des_sqrtll,
+  NULL
+};
index 3e2fd80847cee79a8026c9b2f48290bdffb34409..7ddcb7b2c4bc2a705b31eb040266ad408a764897 100644 (file)
@@ -458,7 +458,7 @@ int main()
 #ifdef CONFIG_PXMC
   fpga_reconfiguaration_initiated = pxmc_done;
   fpga_reconfiguaration_finished = pxmc_initialize;
-  printf("setup pxmc_initialize hook for FPGA\n", i);
+  printf("setup pxmc_initialize hook for FPGA\n");
 #endif /*CONFIG_PXMC*/
 
   appl_run_at_slow_sfi_setup();
diff --git a/sw/app/rocon/math_sqrtll_test.c b/sw/app/rocon/math_sqrtll_test.c
new file mode 100644 (file)
index 0000000..8436cb2
--- /dev/null
@@ -0,0 +1,67 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+#ifdef OMK_FOR_TARGET
+ #include <cpu_def.h>
+ #include <system_def.h>
+ #include <lt_timer.h>
+ unsigned long sqrtll(unsigned long long x);
+ #define main sqrtll_main
+ #ifdef LPC_TIM0
+  #define sqrtll_ticks() (LPC_TIM0->TC)
+ #endif /*LPC_TIM0*/
+#else /*OMK_FOR_TARGET*/
+ #include "math_sqrtll.c"
+ #define lt_mstime_update() do {} while(0)
+ #define cli() do {} while(0)
+ #define sti() do {} while(0)
+ int actual_msec;
+#endif /*OMK_FOR_TARGET*/
+
+#ifndef sqrtll_ticks
+  #define sqrtll_ticks() 0
+#endif
+
+int main(int argc, char *argv[])
+{
+  unsigned long long sqr;
+  unsigned long res,inp,incr,cnt,time;
+  unsigned short spent;
+
+  char *s="a";
+
+  if (argc>=2)
+    s=argv[1];
+
+  if(*s!='a'){
+    inp=strtoul(s,NULL,0);
+    sqr=(unsigned long long int)inp*inp;
+    cli();
+    spent=sqrtll_ticks();
+    res=sqrtll(sqr);
+    spent=sqrtll_ticks()-spent;
+    sti();
+    printf("sqrtll: inp=%lu, res=%lu, spent=%u\n",inp,res,(int)spent);
+  }else{
+    inp=0; incr=1; cnt=0;
+    lt_mstime_update();
+    time=actual_msec;
+    do{
+      sqr=(unsigned long long int)inp*inp;
+      res=sqrtll(sqr);
+      if(0||(inp!=res)){
+        printf("sqrt error %lu -> %lu diff %ld sqr 0x%llx\n",inp,res,inp-res,sqr);
+        res=sqrtll(sqr);
+      }
+      inp+=incr; cnt++;
+      if(inp&0xfff) continue;
+      if(inp&((incr<<19)-1)) continue;
+      incr<<=1;
+      printf(".");fflush(NULL);
+    }while(inp);
+    lt_mstime_update();
+    time=actual_msec-time;
+    printf("\nsqrtll OK, spent %ld cnt %ld\n",time,cnt);
+  }
+  return 0;
+}