Class: HRP2KernelObjectPlugin

Inherits:
CelltypePlugin show all
Defined in:
lib/tecsgen/plugin/HRP2KernelObjectPlugin.rb

Overview

celltype プラグインの共通の親クラス

Constant Summary collapse

@@checked =

カーネルオブジェクトセルタイプの管理 HRP2KernelObjectPluginクラスに対してメソッド呼出しを行うことを想定

false
@@celltype_list =
[]
@@region_list =
[]

Constants inherited from Plugin

Plugin::PluginArgProc

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from CelltypePlugin

gen_post_code, #new_cell

Methods inherited from Plugin

#cdl_error, #check_plugin_arg, #gen_cdl_file, #gen_ep_func?, #gen_postamble, #gen_preamble, #new_cell, #parse_plugin_arg, #print_msg, #set_locale, #set_silent

Methods inherited from Node

#cdl_error, #cdl_error2, #cdl_error3, #cdl_info, #cdl_info2, #cdl_warning, #cdl_warning2, #get_locale, #locale_str, #set_locale

Constructor Details

#initialize(celltype, option) ⇒ HRP2KernelObjectPlugin

@celltype

Celltype

@option

String :オプション文字列



132
133
134
135
136
# File 'lib/tecsgen/plugin/HRP2KernelObjectPlugin.rb', line 132

def initialize(celltype, option)
  super
    # それぞれのカーネルオブジェクトを解析対象セルタイプに追加
    HRP2KernelObjectPlugin.set_celltype(celltype)
end

Class Method Details

.check_referenced_cellsObject



323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
# File 'lib/tecsgen/plugin/HRP2KernelObjectPlugin.rb', line 323

def self.check_referenced_cells
    dbgPrint "===== begin check registered celltype =====\n"
    self.get_celltype_list.each {|ct|
        dbgPrint(ct.get_name.to_s + "\n")
    }
    dbgPrint "===== end check registered celltype =====\n"

=begin
    Cell.get_cell_list2.each { |cell|
        cell.get_celltype.get_port_list.each{ |p|
            next if p.get_port_type != :CALL
            j = cell.get_join_list.get_item(p.get_name)
            printf "===== check call port : "
            # p p.get_name.to_s
            next if j.nil? # 未結合の場合
            if @@celltype_list.include?(j.get_celltype)
                # j.get_cell.set_referenced_region(cell.get_region)
                # j.get_cell.set_referenced_region(cell.get_region, j.get_port_name)
                j.get_cell.set_referenced_cell(cell, j.get_port_name)
                printf "===== check joined rhs cell : "
                # p j.get_cell.get_name.to_s
                printf "===== check joined rhs port_name : "
                # p j.get_port_name
            end
        }
    }
=end
    @@checked = true
end

.get_celltype_listObject



357
358
359
# File 'lib/tecsgen/plugin/HRP2KernelObjectPlugin.rb', line 357

def self.get_celltype_list
  return @@celltype_list
end

.include_celltype?(celltype) ⇒ Boolean

Returns:

  • (Boolean)


369
370
371
# File 'lib/tecsgen/plugin/HRP2KernelObjectPlugin.rb', line 369

def self.include_celltype?(celltype)
  return @@celltype_list.include?(celltype)
end

.include_region(region) ⇒ Object



365
366
367
# File 'lib/tecsgen/plugin/HRP2KernelObjectPlugin.rb', line 365

def self.include_region(region)
  return @@region_list.include?(region)
end

.isCheckedObject



319
320
321
# File 'lib/tecsgen/plugin/HRP2KernelObjectPlugin.rb', line 319

def self.isChecked
  return @@checked
end

.set_celltype(celltype) ⇒ Object



353
354
355
# File 'lib/tecsgen/plugin/HRP2KernelObjectPlugin.rb', line 353

def self.set_celltype(celltype)
  @@celltype_list << celltype
end

.set_region_list(region) ⇒ Object



361
362
363
# File 'lib/tecsgen/plugin/HRP2KernelObjectPlugin.rb', line 361

def self.set_region_list(region)
  @@region_list << region
end

Instance Method Details

#gen_factory(file) ⇒ Object



166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
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
307
308
309
310
311
# File 'lib/tecsgen/plugin/HRP2KernelObjectPlugin.rb', line 166

def gen_factory(file)
  puts "===== begin #{@celltype.get_name} plugin ====="

    # 対象となるすべてのセルについて、受け口に結合されている
    # セルの所属ドメインを解析
    if !HRP2KernelObjectPlugin.isChecked
      HRP2KernelObjectPlugin.check_referenced_cells
    else
      puts "***** already checked"
    end

    # 追記するために AppFile を使う(文字コード変換されない)
    file2 = AppFile.open("#{$gen}/tecsgen.cfg")
    file2.print "\n/* Generated by #{self.class.name} */\n\n"

    @celltype.get_cell_list.each {|cell|
      if cell.is_generate?
        puts "===== begin check my domain #{cell.get_name} ====="
          # attrの値をハッシュに入れる
          val = {}
          @celltype.get_attribute_list.each{|a|
              # p a.get_name
            if a.get_type.is_a?(ArrayType)
              val[a.get_name] = []
                if j = cell.get_join_list.get_item(a.get_name)
                    # セル生成時に初期化する場合
                  j.get_rhs.each {|elem|
                    val[a.get_name] << elem.to_s
                  }
                elsif i = a.get_initializer
                    # セルタイプの初期化値を使う場合
                  i.each {|elem|
                    val[a.get_name] << elem.to_s
                  }
                else
                  raise "attribute is not initialized"
                end
            else
              if j = cell.get_join_list.get_item(a.get_name)
                  # セル生成時に初期化する場合
                val[a.get_name] = j.get_rhs.to_s
              elsif i = a.get_initializer
                  # セルタイプの初期化値を使う場合
                val[a.get_name] = i.to_s
              else
                raise "attribute is not initialized"
              end
            end
          }
          # generate.rbを参考に
          # $id$を置換
          if val[:id].nil? != true
            puts val[:id]
              # val[:id] = val[:id].gsub( /(^|[^\$])\$id\$/, "\\1#{@celltype.get_name.to_s}_#{cell.get_name.to_s}" )
              val[:id] = @celltype.subst_name(val[:id], @celltype.get_name_array(cell))
          end
          # $cbp$の代わり
          index = cell.get_id - @celltype.get_id_base
          cell_CB_name = "#{@celltype.get_global_name}_CB_tab[#{index}]"
          cell_domain_root = cell.get_region.get_domain_root
          cell_domain_type = cell.get_region.get_domain_root.get_domain_type

          # CRE_XXX/DEF_XXXの生成
          if cell_domain_type.get_option.to_s != "OutOfDomain"
              # 保護ドメインに属する場合
            if !HRP2KernelObjectPlugin.include_region(cell_domain_root.get_name.to_s)
                # その保護ドメインの.cfgが生成されていない場合
              HRP2KernelObjectPlugin.set_region_list(cell_domain_root.get_name.to_s)
                puts "~~~~~ #{cell_domain_root.get_name} is registered!"

                # if cell.get_region.get_param == :KERNEL_DOMAIN
                if cell_domain_type.get_option.to_s == "trusted"
                    # file2.print "#{cell.get_region.get_name.to_s}{\n"
                  file2.print "KERNEL_DOMAIN{\n"
                else
                  file2.print "DOMAIN(#{cell_domain_root.get_name}){\n"
                end
                file2.puts "\tINCLUDE(\"#{$gen}/tecsgen_#{cell_domain_root.get_name}.cfg\");"
                file2.puts "}\n"
            else
              dbgPrint "~~~~~ #{cell.get_region.get_name} is included in"
                # p @@region_list
            end
              file3 = AppFile.open("#{$gen}/tecsgen_#{cell_domain_root.get_name}.cfg")
              print_cfg_cre(file3, cell, val, "")
              file3.close
          else
              # 無所属の場合
            puts "~~~~~ #{cell_domain_root.get_name} is OutOfDomain"
              print_cfg_cre(file2, cell, val, "")
          end

          puts "===== end check my domain #{cell.get_name} ====="
          # SAC_XXXの生成
          if !val[:accessPattern].nil?
            puts "===== begin check regions #{cell.get_name} ====="
              # p val[:accessPattern]
              # p val[:accessPattern].class

              # ep = [ :eTaskActivate, :eTaskControl, :eTaskManage, :eTaskRefer ]
              # 各カーネルオブジェクトの受け口名を取得
              # ep = get_entry_ports_name_list()
              i = 0
              acv = []
              # アクセス許可ベクタの生成
              val[:accessPattern].each {|acptnx|
                  # アクセス許可パターンの生成
                if acptnx != "OMIT"
                  acv << acptnx
                    # p acv[i]
                elsif cell_domain_type.get_option.to_s == "trusted"
                  acv << "TACP_KERNEL"
                    # p acv[i]
                elsif cell_domain_type.get_option.to_s != "OutOfDomain"
                  acv << "TACP(#{cell_domain_root.get_name})"
                else
                  acv << "TACP_SHARED"
                end

                  i += 1
              }

              dbgPrint "acv = "
              p acv

              # 各種SACの生成
              domainOption = cell_domain_type.get_option
              # if cell.get_region.get_region_type == :DOMAIN
              if domainOption != "OutOfDomain"
                  # 保護ドメインに属する場合
                file3 = AppFile.open("#{$gen}/tecsgen_#{cell.get_region.get_name}.cfg")
                  print_cfg_sac(file3, val, acv)
                  file3.close
              else
                  # 無所属の場合
                print_cfg_sac(file2, val, acv)
              end

              puts "===== end check regions #{cell.get_name} ====="
          end
      end
    }

    puts "===== end #{@celltype.get_name} plugin ====="
    file2.close
end

#get_entry_ports_name_listObject

HRP2KernelObjectPlugin#get_entry_ports_name_list

カーネルオブジェクトの各種アクセスの種別の受け口名を取得



158
159
160
# File 'lib/tecsgen/plugin/HRP2KernelObjectPlugin.rb', line 158

def get_entry_ports_name_list
  raise "called virtual method get_entry_ports_name_list in #{@celltype.get_name} plugin"
end

HRP2KernelObjectPlugin#print_cfg_cre

各種カーネルオブジェクトのCRE_*の出力

file

FILE: 出力先ファイル

val

string: カーネルオブジェクトの属性の解析結果

tab

string: インデント用のtab



143
144
145
# File 'lib/tecsgen/plugin/HRP2KernelObjectPlugin.rb', line 143

def print_cfg_cre(file, cell, val, tab)
  raise "called virtual method print_cfg_cre in #{@celltype.get_name} plugin"
end

HRP2KernelObjectPlugin#print_cfg_sac

各種カーネルオブジェクトのSAC_*の出力

file

FILE: 出力先ファイル

val

string: カーネルオブジェクトの属性の解析結果

acv

string: アクセスベクタ



152
153
154
# File 'lib/tecsgen/plugin/HRP2KernelObjectPlugin.rb', line 152

def print_cfg_sac(file, val, acv)
  raise "called virtual method print_cfg_sac in #{@celltype.get_name} plugin"
end

#string_cfg_cre(cell, val) ⇒ Object



162
163
164
# File 'lib/tecsgen/plugin/HRP2KernelObjectPlugin.rb', line 162

def string_cfg_cre(cell, val)
  raise "called virtual method string_cfg_cre in #{@celltype.get_name} plugin"
end