annotate example/synthesizer/spe/Exec.cc @ 2048:6796d85f3d6b draft

remove error
author Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
date Thu, 28 Jan 2016 00:05:49 +0900
parents 6849865f96eb
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2020
6849865f96eb add synthesizer project
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 #include <stdio.h>
6849865f96eb add synthesizer project
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2 #include <string.h>
6849865f96eb add synthesizer project
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 #include "Exec.h"
6849865f96eb add synthesizer project
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 #include "Func.h"
6849865f96eb add synthesizer project
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
5
6849865f96eb add synthesizer project
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 /* これは必須 */
6849865f96eb add synthesizer project
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 SchedDefineTask1(Exec,wordcount);
6849865f96eb add synthesizer project
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
8
6849865f96eb add synthesizer project
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 static int
6849865f96eb add synthesizer project
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 wordcount(SchedTask *s, void *rbuf, void *wbuf)
6849865f96eb add synthesizer project
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
11 {
6849865f96eb add synthesizer project
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 char *i_data = (char *)rbuf;
6849865f96eb add synthesizer project
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 unsigned long long *o_data = (unsigned long long*)wbuf;
6849865f96eb add synthesizer project
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 unsigned long long *head_tail_flag = o_data +2;
6849865f96eb add synthesizer project
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 int length = (int)s->get_inputSize(0);
6849865f96eb add synthesizer project
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
16 int word_flag = 0;
6849865f96eb add synthesizer project
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 int word_num = 0;
6849865f96eb add synthesizer project
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
18 int line_num = 0;
6849865f96eb add synthesizer project
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
19 int i = 0;
6849865f96eb add synthesizer project
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
20
6849865f96eb add synthesizer project
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
21 head_tail_flag[0] = (i_data[0] != 0x20) && (i_data[0] != 0x0A);
6849865f96eb add synthesizer project
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
22 word_num -= 1-head_tail_flag[0];
6849865f96eb add synthesizer project
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
23
6849865f96eb add synthesizer project
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
24 for (; i < length; i++) {
6849865f96eb add synthesizer project
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
25 if (i_data[i] == 0x20) {
6849865f96eb add synthesizer project
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
26 word_flag = 1;
6849865f96eb add synthesizer project
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
27 } else if (i_data[i] == 0x0A) {
6849865f96eb add synthesizer project
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
28 line_num += 1;
6849865f96eb add synthesizer project
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
29 word_flag = 1;
6849865f96eb add synthesizer project
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
30 } else {
6849865f96eb add synthesizer project
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
31 word_num += word_flag;
6849865f96eb add synthesizer project
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
32 word_flag = 0;
6849865f96eb add synthesizer project
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
33 }
6849865f96eb add synthesizer project
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
34 }
6849865f96eb add synthesizer project
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
35
6849865f96eb add synthesizer project
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
36 word_num += word_flag;
6849865f96eb add synthesizer project
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
37 head_tail_flag[1] = (i_data[i-1] != 0x20) && (i_data[i-1] != 0x0A);
6849865f96eb add synthesizer project
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
38
6849865f96eb add synthesizer project
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
39 // s->printf("SPE word %d line %d\n",word_num,line_num);
6849865f96eb add synthesizer project
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
40
6849865f96eb add synthesizer project
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
41 o_data[0] = (unsigned long long)word_num;
6849865f96eb add synthesizer project
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
42 o_data[1] = (unsigned long long)line_num;
6849865f96eb add synthesizer project
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
43
6849865f96eb add synthesizer project
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
44 return 0;
6849865f96eb add synthesizer project
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
45 }