Method: NotifierPlugin::AdapterGenerator::EntryPort#generate
- Defined in:
- lib/tecsgen/plugin/NotifierPlugin.rb
#generate(context) ⇒ Object
ソース・ヘッダーの記述を生成する.
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 |
# File 'lib/tecsgen/plugin/NotifierPlugin.rb', line 220 def generate(context) header_file = context.header_file return if @props.empty? ct = @port.get_celltype header_file.print "/*\n * #{@global_name}\n" cells = @props.group_by {|prop| prop.cell } subscripts = @props.group_by {|prop| prop.subscript } no_cellidx = false if !(ct.has_INIB? || ct.has_CB?) # CB, INIB最適化により,CB, INIBが両方不要になったケース. # CELLIDXが不要であるので,セルについて一般化しても意味 # はないので,添字による一般化を選択する. generalize_by_cell_idx = false no_cellidx = true # 全てのセルを同一視する. cells = { @props[0].cell => @props } header_file.print " * No INIB & CB: generalized by subscript\n" elsif @port.get_array_size # 一般化パターンの分類を行うために,受け口側セルや添字の # パターン数を分析して,最適な方を選択する. generalize_by_cell_idx = cells.length >= subscripts.length if generalize_by_cell_idx header_file.print " * more cells than subscripts: generalized by cell\n" else header_file.print " * more subscripts than cells: generalized by subscript\n" end else # 常にCELLIDXで一般化 generalize_by_cell_idx = true header_file.print " * non-array entry port: generalized by cell\n" end header_file.print " */\n\n" if generalize_by_cell_idx # CELLIDXについて一般化 subscripts.each {|subscript, props| if subscript fn_name = "#{@global_name}_adap_#{subscript}" else # 受け口配列でない場合 fn_name = "#{@global_name}_adap" end generate_inner context, fn_name, :generic, subscript, ct props.each {|prop| handle = adapter_handle_for_entry_property(prop) # セルのCELLIDXを得る if ct.has_INIB? || ct.has_CB? idx = ct.get_name_array(prop.cell)[7] else idx = "0" end header_file.print "\#define #{handle[0]} &#{fn_name}\n" header_file.print "\#define #{handle[1]} #{idx}\n\n" } } else # 添字について一般化 cells.each {|cell, props| if no_cellidx # CB/INIB なし fn_name = "#{@global_name}_adap" else fn_name = "#{@global_name}_adap_#{cell.get_global_name}" end generate_inner context, fn_name, cell, :generic props.each {|prop| handle = adapter_handle_for_entry_property(prop) header_file.print "\#define #{handle[0]} &#{fn_name}\n" header_file.print "\#define #{handle[1]} #{prop.subscript || 0}\n\n" } } end end |