PIPS
freia_spoc.h
Go to the documentation of this file.
1 /*
2 
3  $Id: freia_spoc.h 23146 2016-07-12 09:08:28Z coelho $
4 
5  Copyright 1989-2016 MINES ParisTech
6 
7  This file is part of PIPS.
8 
9  PIPS is free software: you can redistribute it and/or modify it
10  under the terms of the GNU General Public License as published by
11  the Free Software Foundation, either version 3 of the License, or
12  any later version.
13 
14  PIPS is distributed in the hope that it will be useful, but WITHOUT ANY
15  WARRANTY; without even the implied warranty of MERCHANTABILITY or
16  FITNESS FOR A PARTICULAR PURPOSE.
17 
18  See the GNU General Public License for more details.
19 
20  You should have received a copy of the GNU General Public License
21  along with PIPS. If not, see <http://www.gnu.org/licenses/>.
22 
23 */
24 
25 /*
26  * data structures that describe FREIA SPoC target.
27  */
28 
29 #ifndef HWAC_FREIA_SPOC_H_
30 # define HWAC_FREIA_SPOC_H_
31 
32 /* all SPoC hardware parts as a bitfield */
33 typedef enum {
34  spoc_nothing = 0x00000000,
35  // Inputs
36  spoc_input_0 = 0x00000001,
37  spoc_input_1 = 0x00000002,
38  // Outputs
39  spoc_output_0 = 0x00000004,
40  spoc_output_1 = 0x00000008,
41  // Morpho
42  spoc_poc_0 = 0x00000010,
43  spoc_poc_1 = 0x00000020,
44  // ALU
45  spoc_alu = 0x00000040,
46  // ThreasHold
47  spoc_th_0 = 0x00000100,
48  spoc_th_1 = 0x00000200,
49  // Measures
50  spoc_measure_0 = 0x00004000,
51  spoc_measure_1 = 0x00008000,
52  // Links...
53  spoc_alu_in0 = 0x01000000, // redundant with spoc_alu_op_t.use_in0
54  spoc_alu_in1 = 0x02000000, // redundant with spoc_alu_op_t.use_in1
55  spoc_alu_out0 = 0x04000000,
56  spoc_alu_out1 = 0x08000000,
57  // others?
58  spoc_not_implemented = 0xffffffff
60 
61 typedef enum {
69 
70 /* all SPoC ALU operations */
71 typedef enum {
73  // arithmetic operations
106  // comparisons
113  // logical operations
125  // array generation
127  // mask & replace constant
132  // and so on
134 
135 /* ALU operation full description */
136 typedef struct {
137  spoc_alu_t op; // operation
138  spoc_alu_t flipped; // flipped call
139  string setting; // macro for the operation
140  bool use_cst; // whether a constant is needed
141  bool use_in0; // whether first input is used
142  bool use_in1; // whether second input is used
143 } spoc_alu_op_t;
144 
145 typedef enum {
151 
152 typedef struct {
154  uint32_t connectivity; // 0, 6, 8...
155 } spoc_poc_t;
156 
157 /* description of a SPoC hardware configuration
158  * should be precise enough to generate a full AIPO function.
159  */
160 typedef struct {
161  // what is used within the SPOC (vs strictly necessary???)
163  spoc_poc_t poc[2];
165  // threshold: nothing needed
167  // links: not sure...
168 } spoc_hw_t;
169 
170 typedef enum {
171  // important, in hardware order
172  spoc_type_sni = -3, // spoc not implemented
173  spoc_type_oth = -2, // for anything else...
174  spoc_type_nop = -1, // no-operation, used by copy?
175  spoc_type_inp = 0, // used for input
180  spoc_type_out = 5 // output...
182 
183 /****************************************************** SPOC CODE GENERATION */
184 
185 #define spoc_depth_prop "HWAC_SPOC_DEPTH"
186 
187 // what about something simpler like "freia-spoc.h"?
188 #define FREIA_SPOC_INCLUDES \
189  "#include <freiaCommon.h>\n" \
190  "#include <freiaMediumGrain.h>\n" \
191  "#include <freiaCoarseGrain.h>\n" \
192  "#include <spoc.h>\n"
193 
194 #define FREIA_SPOC_DECL \
195  " spoc_instr si;\n" \
196  " spoc_param sp;\n" \
197  " freia_microcode mcode;\n" \
198  " freia_dynamic_param dynparam;\n" \
199  " freia_op_param param;\n" \
200  " freia_status ret;\n"
201 
202 #define FREIA_SPOC_CALL_START \
203  "\n" \
204  " mcode.raw = (freia_ptr) &si;\n" \
205  " mcode.size = sizeof(spoc_instr);\n" \
206  "\n" \
207  " dynparam.raw = (freia_ptr) &sp;\n" \
208  " dynparam.size = sizeof(spoc_param);\n" \
209  "\n"
210 
211 #define FREIA_SPOC_CALL_REDUC \
212  " redres.raw = (freia_ptr) &reduc;\n" \
213  " redres.size = sizeof(spoc_reduction);\n" \
214  "\n"
215 
216 #define FREIA_SPOC_CALL_END \
217  " ret = freia_cg_write_microcode(&mcode);\n" \
218  " ret |= freia_cg_write_dynamic_param(&dynparam);\n" \
219  "\n"
220 
221 #endif /* !HWAC_FREIA_SPOC_H_ */
spoc_hw_parts_t
all SPoC hardware parts as a bitfield
Definition: freia_spoc.h:33
@ spoc_not_implemented
Definition: freia_spoc.h:58
@ spoc_measure_0
Definition: freia_spoc.h:50
@ spoc_th_0
Definition: freia_spoc.h:47
@ spoc_output_0
Definition: freia_spoc.h:39
@ spoc_alu_in1
Definition: freia_spoc.h:54
@ spoc_input_0
Definition: freia_spoc.h:36
@ spoc_measure_1
Definition: freia_spoc.h:51
@ spoc_alu_out1
Definition: freia_spoc.h:56
@ spoc_output_1
Definition: freia_spoc.h:40
@ spoc_alu
Definition: freia_spoc.h:45
@ spoc_nothing
Definition: freia_spoc.h:34
@ spoc_input_1
Definition: freia_spoc.h:37
@ spoc_alu_in0
Definition: freia_spoc.h:53
@ spoc_poc_1
Definition: freia_spoc.h:43
@ spoc_poc_0
Definition: freia_spoc.h:42
@ spoc_th_1
Definition: freia_spoc.h:48
@ spoc_alu_out0
Definition: freia_spoc.h:55
spoc_poc_op_t
Definition: freia_spoc.h:145
@ spoc_poc_erode
Definition: freia_spoc.h:147
@ spoc_poc_conv
Definition: freia_spoc.h:149
@ spoc_poc_unused
Definition: freia_spoc.h:146
@ spoc_poc_dilate
Definition: freia_spoc.h:148
spoc_alu_t
all SPoC ALU operations
Definition: freia_spoc.h:71
@ alu_sup_0cst
Definition: freia_spoc.h:111
@ alu_sub_1cst
Definition: freia_spoc.h:83
@ alu_div_10
Definition: freia_spoc.h:99
@ alu_or
Definition: freia_spoc.h:117
@ alu_mul_0cst
Definition: freia_spoc.h:96
@ alu_div_01
Definition: freia_spoc.h:98
@ alu_subsat_0cst
Definition: freia_spoc.h:88
@ alu_sub_0cst
Definition: freia_spoc.h:82
@ alu_abssub_1cst
Definition: freia_spoc.h:94
@ alu_inf_01
Definition: freia_spoc.h:107
@ alu_sup_01
Definition: freia_spoc.h:110
@ alu_copy_cst
Definition: freia_spoc.h:126
@ alu_subsat_01
Definition: freia_spoc.h:86
@ alu_sub_10
Definition: freia_spoc.h:81
@ alu_sup_1cst
Definition: freia_spoc.h:112
@ alu_add
Definition: freia_spoc.h:74
@ alu_xor_1cst
Definition: freia_spoc.h:122
@ alu_subsat_cst1
Definition: freia_spoc.h:91
@ alu_subsat_1cst
Definition: freia_spoc.h:89
@ alu_repcst_0
Definition: freia_spoc.h:130
@ alu_abssub
Definition: freia_spoc.h:92
@ alu_subsat_10
Definition: freia_spoc.h:87
@ alu_addsat
Definition: freia_spoc.h:77
@ alu_sub_cst0
Definition: freia_spoc.h:84
@ alu_and
Definition: freia_spoc.h:114
@ alu_add_1cst
Definition: freia_spoc.h:76
@ alu_sub_cst1
Definition: freia_spoc.h:85
@ alu_addsat_1cst
Definition: freia_spoc.h:79
@ alu_log2_1
Definition: freia_spoc.h:105
@ alu_log2_0
Definition: freia_spoc.h:104
@ alu_div_0cst
Definition: freia_spoc.h:100
@ alu_or_1cst
Definition: freia_spoc.h:119
@ alu_xor_0cst
Definition: freia_spoc.h:121
@ alu_unused
Definition: freia_spoc.h:72
@ alu_div_cst0
Definition: freia_spoc.h:102
@ alu_abssub_0cst
Definition: freia_spoc.h:93
@ alu_addsat_0cst
Definition: freia_spoc.h:78
@ alu_xor
Definition: freia_spoc.h:120
@ alu_div_1cst
Definition: freia_spoc.h:101
@ alu_mul_1cst
Definition: freia_spoc.h:97
@ alu_or_0cst
Definition: freia_spoc.h:118
@ alu_and_1cst
Definition: freia_spoc.h:116
@ alu_add_0cst
Definition: freia_spoc.h:75
@ alu_mask_1
Definition: freia_spoc.h:129
@ alu_repcst_1
Definition: freia_spoc.h:131
@ alu_inf_1cst
Definition: freia_spoc.h:109
@ alu_not_0
Definition: freia_spoc.h:123
@ alu_not_1
Definition: freia_spoc.h:124
@ alu_div_cst1
Definition: freia_spoc.h:103
@ alu_sub_01
Definition: freia_spoc.h:80
@ alu_mul
Definition: freia_spoc.h:95
@ alu_mask_0
Definition: freia_spoc.h:128
@ alu_and_0cst
Definition: freia_spoc.h:115
@ alu_subsat_cst0
Definition: freia_spoc.h:90
@ alu_inf_0cst
Definition: freia_spoc.h:108
spoc_measure_t
Definition: freia_spoc.h:61
@ measure_min
Definition: freia_spoc.h:65
@ measure_vol
Definition: freia_spoc.h:67
@ measure_none
Definition: freia_spoc.h:62
@ measure_max_coord
Definition: freia_spoc.h:64
@ measure_min_coord
Definition: freia_spoc.h:66
@ measure_max
Definition: freia_spoc.h:63
spoc_hardware_type
Definition: freia_spoc.h:170
@ spoc_type_sni
Definition: freia_spoc.h:172
@ spoc_type_out
Definition: freia_spoc.h:180
@ spoc_type_mes
Definition: freia_spoc.h:179
@ spoc_type_nop
Definition: freia_spoc.h:174
@ spoc_type_oth
Definition: freia_spoc.h:173
@ spoc_type_inp
Definition: freia_spoc.h:175
@ spoc_type_thr
Definition: freia_spoc.h:178
@ spoc_type_alu
Definition: freia_spoc.h:177
@ spoc_type_poc
Definition: freia_spoc.h:176
#define uint32_t
Definition: stdint.in.h:156
ALU operation full description.
Definition: freia_spoc.h:136
spoc_alu_t op
Definition: freia_spoc.h:137
string setting
Definition: freia_spoc.h:139
spoc_alu_t flipped
Definition: freia_spoc.h:138
description of a SPoC hardware configuration should be precise enough to generate a full AIPO functio...
Definition: freia_spoc.h:160
uint32_t used
Definition: freia_spoc.h:162
spoc_alu_t alu
Definition: freia_spoc.h:164
spoc_poc_op_t op
Definition: freia_spoc.h:153
uint32_t connectivity
Definition: freia_spoc.h:154