Class: ItegrationVerb

Inherits:
Object
  • Object
show all
Extended by:
ItegrationAttr
Defined in:
lib/tdl/exlib/itegration_verb.rb,
lib/tdl/exlib/itegration_verb.rb

Overview

动态删除 silence_ block

Direct Known Subclasses

ABlock, ClockManage

Constant Summary collapse

@@child =
[]
@@_inst_test_unit_blocks_ =

添加测试用例

[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ItegrationAttr

compact_link_itgt, has_attr, has_flag, itegration_explort, itegration_hash, itegration_link, link_explort, link_itgt, param

Constructor Details

#initialize(name_str = nil, pins_map = {}, top_module = nil) ⇒ ItegrationVerb

Returns a new instance of ItegrationVerb.



346
347
348
349
350
351
352
353
354
355
356
357
358
359
# File 'lib/tdl/exlib/itegration_verb.rb', line 346

def initialize(name_str=nil,pins_map={},top_module=nil)
    @top_module = top_module
    if name_str.to_s.strip.empty?
        @nickname = ""
    else
        @nickname =  "#{name_str.to_s.strip}_"
    end
    @pins_map = pins_map
    _names_pool_inst()
    # @itgt_links = ItgtLinks.new(self)
    ## 为child module 生成方法
    # init_children_modules()
    # init_children_modules_post()
end

Instance Attribute Details

#init_instObject

Returns the value of attribute init_inst.



274
275
276
# File 'lib/tdl/exlib/itegration_verb.rb', line 274

def init_inst
  @init_inst
end

#inst_indexObject

Returns the value of attribute inst_index.



275
276
277
# File 'lib/tdl/exlib/itegration_verb.rb', line 275

def inst_index
  @inst_index
end

#names_poolObject

Returns the value of attribute names_pool.



273
274
275
# File 'lib/tdl/exlib/itegration_verb.rb', line 273

def names_pool
  @names_pool
end

#nicknameObject

Returns the value of attribute nickname.



273
274
275
# File 'lib/tdl/exlib/itegration_verb.rb', line 273

def nickname
  @nickname
end

#pins_mapObject

Returns the value of attribute pins_map.



273
274
275
# File 'lib/tdl/exlib/itegration_verb.rb', line 273

def pins_map
  @pins_map
end

#top_moduleObject

Returns the value of attribute top_module.



272
273
274
# File 'lib/tdl/exlib/itegration_verb.rb', line 272

def top_module
  @top_module
end

Class Method Details

.constraints_block(&block) ⇒ Object

约束 block



930
931
932
933
934
# File 'lib/tdl/exlib/itegration_verb.rb', line 930

def self.constraints_block(&block)
    carray = self.record_instance_var_block("constraints_array",[])
    carray << block if block_given?
    self.set_instance_var("constraints_array",carray)
end

.curr_itgt_popObject



310
311
312
# File 'lib/tdl/exlib/itegration_verb.rb', line 310

def self.curr_itgt_pop
    $_implicit_curr_itgt_.pop
end

.curr_itgt_push(itgt) ⇒ Object



306
307
308
# File 'lib/tdl/exlib/itegration_verb.rb', line 306

def self.curr_itgt_push(itgt)
    $_implicit_curr_itgt_ << itgt
end

.def_test_unit(name, path, &block) ⇒ Object



780
781
782
783
784
785
786
# File 'lib/tdl/exlib/itegration_verb.rb', line 780

def self.def_test_unit(name,path,&block)
    # @@_inst_test_unit_blocks_ = instance_variable_get("@_inst_test_unit_blocks_")
    @@_inst_test_unit_blocks_ ||= []
    @@_inst_test_unit_blocks_ << [name.to_s, path, block]
    # instance_variable_set("@_inst_test_unit_blocks_",_inst_test_unit_blocks_)
    @@_inst_test_unit_blocks_
end

.flag_match(attr) ⇒ Object



320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
# File 'lib/tdl/exlib/itegration_verb.rb', line 320

def self.flag_match(attr)
    explort_flags = get_itgt_var('itegration_flag_collect')
    unless attr
        return true
    end

    if attr.empty?
        return true
    end

    unless explort_flags
        explort_flags = []
    end

    explort_flags = explort_flags.map{ |e| e.to_s }.sort
    attr = attr.map { |e| e.to_s }.sort

    if(explort_flags & attr) == attr
        return true
    else
        return false
    end
end

.get_instance_var(name) ⇒ Object



860
861
862
# File 'lib/tdl/exlib/itegration_verb.rb', line 860

def self.get_instance_var(name)
    _inst_ccc_ = instance_variable_get("@_#{name}_")
end

.inherited(subclass) ⇒ Object

blocks = blocks_hash

        if blocks.length ==  1
            block = blocks[0]
            sdlm.instance_exec(self,&block)
        elsif blocks.length >  1
            # block = Proc.new do
                blocks.each do |b|
                    # b.call
                    sdlm.instance_exec(self,&b)
                end
            # end
        else
            next
        end
    end
end
ItegrationVerb.curr_itgt_pop

end



581
582
583
584
585
# File 'lib/tdl/exlib/itegration_verb.rb', line 581

def self.inherited(subclass)
    unless @@child.include? subclass
        @@child << subclass
    end
end

.record_instance_var_block(name, default = [], &block) ⇒ Object

sdl_eval_dir_hash[name] = dir if dir

            instance_variable_set("@_sdl_eval_dir_hash_",_sdl_eval_dir_hash_)
            instance_variable_set("@_sdl_eval_blocks_post_hash_",_blocks_hash_)
        end
    end
end

end



840
841
842
843
844
845
846
847
848
849
850
851
# File 'lib/tdl/exlib/itegration_verb.rb', line 840

def self.record_instance_var_block(name,default=[],&block)
    _inst_ccc_ = instance_variable_get("@_#{name}_")
    _inst_ccc_ ||= default
    if _inst_ccc_.is_a? Array
        _inst_ccc_ << block if block_given?
    elsif _inst_ccc_.is_a? Hash
        _inst_ccc_[name.to_s] = block if block_given?
    else
        _inst_ccc_ = block
    end
    instance_variable_set("@_#{name}_",_inst_ccc_)
end

.set_instance_var(name, value) ⇒ Object



853
854
855
856
857
858
# File 'lib/tdl/exlib/itegration_verb.rb', line 853

def self.set_instance_var(name,value)
    _inst_ccc_ = instance_variable_get("@_#{name}_")
    # _inst_ccc_ ||= default
    _inst_ccc_ = value
    instance_variable_set("@_#{name}_",_inst_ccc_)
end

.techbench_block(name, default_tb_argvs_hash = {}) ⇒ Object

测试向量实现 作用于是 top_module



865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
# File 'lib/tdl/exlib/itegration_verb.rb', line 865

def self.techbench_block(name,default_tb_argvs_hash={})
    hash = self.record_instance_var_block("techbench_name_hash",{})
    ## args hash
    argvs_hash = self.get_instance_var("techbench_argvs_hash") || {}
    # self.set_instance_var("techbench_argvs_hash",{}) unless argvs_hash
    argvs_hash[name.to_s] = default_tb_argvs_hash
    set_instance_var("techbench_argvs_hash",argvs_hash)
    ##需要激活的block
    self.define_singleton_method("#{name}_tb_eval") do |&block|
        ## 把 block 塞到数组中
        hash[name.to_s] = self.record_instance_var_block("techbench_#{name}_blocks",[],&block)
        self.set_instance_var("techbench_name_hash",hash)
        hash[name.to_s]
    end

    ## 生成实例方法
    self.class_exec do

        define_method(:active_techbench_vector) do |name,tb_argvs_hash={}|
            hash = get_itgt_var("active_techbench_vector",{})
            _default_tb_argvs_hash = self.class.get_instance_var("techbench_argvs_hash")[name.to_s] || {}
            hash[name.to_s] = _default_tb_argvs_hash.merge(tb_argvs_hash)
            set_itgt_var('active_techbench_vector',hash)
        end
    end

end

.test_unit_inst(&filter_block) ⇒ Object



493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
# File 'lib/tdl/exlib/itegration_verb.rb', line 493

def self.test_unit_inst(&filter_block)
    # blocks = self.instance_variable_get("@_inst_test_unit_blocks_")
    # blocks = instance_variable_get("@_inst_test_unit_blocks_") || []
    blocks = @@_inst_test_unit_blocks_ || []
    return unless blocks
    return if blocks.empty?
    return unless TopModule.sim

    ItegrationVerb.curr_itgt_push nil

    blocks.each do |b|
        # @top_module.techbench.instance_exec(self,&b.clone)
        if !(block_given?) || filter_block.call(b[0])
            sdlm = TestUnitModule.new(name: b[0],out_sv_path: b[1])
            $_implicit_curr_itgt_.with_none_itgt do 
                sdlm.input - "from_up_pass"
                sdlm.output.logic - "to_down_pass"
            end
            sdlm.instance_exec(nil,&b[2])

            if b[1] && File.exist?(b[1])
                sdlm.gen_sv_module
            else 
                sdlm.origin_sv = true 
            end
        end
    end

    ItegrationVerb.curr_itgt_pop

end

.top_module_eval(&block) ⇒ Object



764
765
766
767
768
769
# File 'lib/tdl/exlib/itegration_verb.rb', line 764

def self.top_module_eval(&block)
    _inst_blocks_ = instance_variable_get("@_inst_blocks_")
    _inst_blocks_ ||= []
    _inst_blocks_ << block
    instance_variable_set("@_inst_blocks_",_inst_blocks_)
end

.top_module_techbench_eval(&block) ⇒ Object



771
772
773
774
775
776
# File 'lib/tdl/exlib/itegration_verb.rb', line 771

def self.top_module_techbench_eval(&block)
    _inst_tb_blocks_ = instance_variable_get("@_inst_tb_blocks_")
    _inst_tb_blocks_ ||= []
    _inst_tb_blocks_ << block
    instance_variable_set("@_inst_tb_blocks_",_inst_tb_blocks_)
end

.with_new_itgt(itgt, &block) ⇒ Object

关于 当前 itgt stack 操作



299
300
301
302
303
304
# File 'lib/tdl/exlib/itegration_verb.rb', line 299

def self.with_new_itgt(itgt,&block)
    $_implicit_curr_itgt_ << itgt
    rel = block.call
    $_implicit_curr_itgt_.pop
    return rel
end

Instance Method Details

#cal_inst_index(base = 0) ⇒ Object



283
284
285
286
287
288
289
290
291
292
293
294
295
296
# File 'lib/tdl/exlib/itegration_verb.rb', line 283

def cal_inst_index(base=0)
    if @inst_index
        if base > @inst_index
            @inst_index = base
        end
    else
        @inst_index = base
    end

    child_inst_itgt.each do |e|
        e.cal_inst_index(@inst_index + 1)
    end

end

#check_same_method(name) ⇒ Object



626
627
628
629
630
# File 'lib/tdl/exlib/itegration_verb.rb', line 626

def check_same_method(name)
    if respond_to? name.to_s
        raise TdlError.new("Itegration `#{to_s}` can't Redefine method #{name}")
    end
end

#child_inst_itgtObject



278
279
280
# File 'lib/tdl/exlib/itegration_verb.rb', line 278

def child_inst_itgt
    @child_inst_itgt ||=[]
end

#delete_silence(name) ⇒ Object



953
954
955
# File 'lib/tdl/exlib/itegration_verb.rb', line 953

def delete_silence(name)
    get_itgt_var('explort_silence_hash').delete(name.to_s)
end

#flag_match(attr) ⇒ Object

判断当前itgt class export flag 是否匹配参数



316
317
318
# File 'lib/tdl/exlib/itegration_verb.rb', line 316

def flag_match(attr)
    self.class.flag_match(attr)
end

#get_itgt_var(name, default = [], &block) ⇒ Object



603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
# File 'lib/tdl/exlib/itegration_verb.rb', line 603

def get_itgt_var(name,default=[],&block)
    unless instance_variable_get("@_#{name}_")
        if block_given?
            rel = block.call(default)
        else
            rel = default
        end
        instance_variable_set("@_#{name}_",rel)
        container = instance_variable_get("@_#{name}_")
    else
        container = instance_variable_get("@_#{name}_")
    end

    return container
end


719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
# File 'lib/tdl/exlib/itegration_verb.rb', line 719

def implicit_link_eval
    @top_module.implicit_itgt_collect   ||= []
    #生成link 数组便是 当前 itgt引用
    container = self.class.get_itgt_var('itegration_link_collect')
    container.each do |e|
        container_attrs = self.class.get_itgt_var('itegration_link_hash')[e]
        mark = false
        ## 先从 已经加入的隐性itgt搜索
        @top_module.implicit_itgt_collect.each do |i|
            explort_attrs = i.class.get_itgt_var('itegration_explort_collect')
            if (explort_attrs & container_attrs).sort == container_attrs.sort
                mark = true

                define_singleton_method(e) do
                    ItegrationVerbAgent.new(i)
                end
                i.implicit_link_eval
                break
            end
        end
        next if mark    ## 找到了 就处理下一个Link
        ##
        ## 如果没有找到 再从 ItegrationVerb children里面找到比加入
        ## 去除隐性引入
        unless TopModule.itgt_implicit_reject
            @@child.each do |c|
                explort_attrs = c.get_itgt_var('itegration_explort_collect')
                if (explort_attrs & container_attrs).sort == container_attrs.sort
                    isp = @top_module.add_itegration(c.to_s,nickname:'implicit',implicit:true)
                    @top_module.implicit_itgt_collect << isp
                    ## 如果是隐性添加,先不要加入pin_map

                    define_singleton_method(e) do
                        ItegrationVerbAgent.new(isp)
                    end
                    mark = true
                    break
                end
            end
        end

    end
end

#instObject

define_singleton_method(:inst) do



400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
# File 'lib/tdl/exlib/itegration_verb.rb', line 400

def inst
    # 先生成子模块
    ## 执行 生成 sdl module
    # inst_child_module()

    blocks = self.class.instance_variable_get("@_inst_blocks_")
    ItegrationVerb.curr_itgt_push(self)

    if blocks.length ==  1
        block = blocks[0]
        @top_module.instance_exec(self,&block.clone)
        ItegrationVerb.curr_itgt_pop
    elsif blocks.length >  1
        # block = Proc.new do
            blocks.each do |b|
                @top_module.instance_exec(self,&b.clone)
            end
        # end
        ItegrationVerb.curr_itgt_pop
    else
        ItegrationVerb.curr_itgt_pop
        return
    end

    ## 执行 生成 sdl module
    # inst_child_module_post()

    ## 执行top module techbench eval
    tb_inst()
    ## 执行测试向量
    techbench_vector()
    ## 执行 约束
    inst_constraints()
    ## 执行单元测试
    ## 改到 运行 top_module _exec_add_test_unit 那边执行
    # test_unit_inst()
end

#inst_constraintsObject



936
937
938
939
940
941
942
943
944
945
# File 'lib/tdl/exlib/itegration_verb.rb', line 936

def inst_constraints()
    carray = self.class.get_instance_var("constraints_array")
    return unless carray
    # $_implicit_curr_itgt_ = self
    ItegrationVerb.curr_itgt_push self
    carray.each do |b|
        @top_module.constraint.instance_exec(self,&b.clone)
    end
    ItegrationVerb.curr_itgt_pop
end


633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
# File 'lib/tdl/exlib/itegration_verb.rb', line 633

def link_eval
    @top_module.implicit_itgt_collect   ||= []
    #生成link 数组便是 当前 itgt引用
    container = self.class.get_itgt_var('itegration_link_collect')
    container.each do |e|
        container_attrs = self.class.get_itgt_var('itegration_link_hash')[e]
        flag_attrs = self.class.get_itgt_var('itegration_flag_hash',{})[e]
        mark = false
        ## 先从 top_module 显式加入的itgt搜索
        @top_module.itgt_collect.each do |i|
            explort_attrs = i.class.get_itgt_var('itegration_explort_collect')
            # explort_flags = i.class.get_itgt_var('itegration_flag_collect')
            if ((explort_attrs & container_attrs).sort == container_attrs.sort  &&  i.flag_match(flag_attrs))
                mark = true
                unless self.respond_to? e
                    define_singleton_method(e) do
                        ## 如果从其他模块调用则出发 dynac_active
                        ItegrationVerbAgent.new(i)
                    end
                    i.link_eval
                    i.child_inst_itgt << self
                end
                # cal_inst_index(i)
                break
            end
        end
        if mark    ## 找到了 就处理下一个Link
            next
        else
            ## 处理 compact link
            compact_container = self.class.get_itgt_var('itegration_compact_link_collect',[])
            if compact_container.include? e
                unless self.respond_to? e
                    define_singleton_method(e) do
                        nil
                    end
                end
                next
            end
        end
        ## 先从 已经加入的隐性itgt搜索
        ## 去除隐性引入
        unless TopModule.itgt_implicit_reject
            @top_module.implicit_itgt_collect.each do |i|
                explort_attrs = i.class.get_itgt_var('itegration_explort_collect')
                if ((explort_attrs & container_attrs).sort == container_attrs.sort && i.flag_match(flag_attrs))
                    # puts "Itgt Good"
                    mark = true
                    unless self.respond_to? e
                        define_singleton_method(e) do
                            ## 如果从其他模块调用则出发 dynac_active
                            ItegrationVerbAgent.new(i)
                        end
                        i.link_eval
                        i.child_inst_itgt << self
                    end
                    break
                end
            end
            next if mark    ## 找到了 就处理下一个Link
            ## 如果没有找到 再从 ItegrationVerb children里面找到比加入
            @@child.each do |c|
                explort_attrs = c.get_itgt_var('itegration_explort_collect')
                # puts explort_attrs
                if ((explort_attrs & container_attrs).sort == container_attrs.sort && c.flag_match(flag_attrs))
                    # puts "Child Good"
                    isp = @top_module.add_itegration(c.to_s,nickname:'implicit',implicit:true)
                    @top_module.implicit_itgt_collect << isp
                    ## 如果是隐性添加,先不要加入pin_map
                    define_singleton_method(e) do
                        ItegrationVerbAgent.new(isp)
                    end
                    isp.link_eval
                    isp.child_inst_itgt << self
                    mark = true
                    break
                end
            end
        end

        unless mark
            raise TdlError.new("<#{self}>没有找到符合Link 的上级 Itgt:\n    ATTR: #{container_attrs.inspect}\n    FLAG: #{flag_attrs.inspect}\n")
        end
    end
end

#set_itgt_var(name, value) ⇒ Object



619
620
621
622
623
# File 'lib/tdl/exlib/itegration_verb.rb', line 619

def set_itgt_var(name,value)
    # rel = get_itgt_var(name)
    instance_variable_set("@_#{name}_",value)
    container = instance_variable_get("@_#{name}_")
end

#tb_instObject



438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
# File 'lib/tdl/exlib/itegration_verb.rb', line 438

def tb_inst
    # define_singleton_method(:tb_inst) do
    blocks = self.class.instance_variable_get("@_inst_tb_blocks_")
    return unless blocks
    ItegrationVerb.curr_itgt_push self

    if blocks.length ==  1
        block = blocks[0]
        @top_module.techbench.instance_exec(self,&block.clone)
    elsif blocks.length >  1
        # block = Proc.new do
            blocks.each do |b|
                # b.call
                @top_module.techbench.instance_exec(self,&b.clone)
            end
        # end
    else
        ;
    end
    ItegrationVerb.curr_itgt_pop
end

#techbench_vectorObject



893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
# File 'lib/tdl/exlib/itegration_verb.rb', line 893

def techbench_vector
    ## 先获取需要激活的tb
    hash = get_itgt_var("active_techbench_vector",{})
    ## 从 class 获取 techbench_name_hash
    class_block_hash = self.class.get_instance_var('techbench_name_hash')
    ## 根据 需要激活的 tb name 激活 block
    ItegrationVerb.curr_itgt_push self
    hash.each do |key,value|
        blocks = class_block_hash[key.to_s]
        unless blocks
            raise TdlError.new("Itgt Class <#{self.class.to_s}> 没有定义 techbench <#{key}>")
        end

        tb_argvs_hash = value
        # $_implicit_curr_itgt_ = self

        if blocks.length ==  1
            block = blocks[0]
            ## 在top module 的上下文下激活blocks
            @top_module.instance_exec(self,tb_argvs_hash,&block.clone)
        elsif blocks.length >  1
            # block = Proc.new do
                blocks.each do |b|
                    # b.call
                    ## 在top module 的上下文下激活blocks
                    @top_module.instance_exec(self,tb_argvs_hash,&b.clone)
                end
            # end
        else
            next
        end

    end
    ItegrationVerb.curr_itgt_pop
end

#test_unit_instObject

测试用例 实例化



461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
# File 'lib/tdl/exlib/itegration_verb.rb', line 461

def test_unit_inst

    blocks = self.class.instance_variable_get("@_inst_test_unit_blocks_")
    return unless blocks
    return if blocks.empty?
    ItegrationVerb.curr_itgt_push self

    unless TopModule.sim
        ItegrationVerb.curr_itgt_pop
        return 
    end

    blocks.each do |b|
        # @top_module.techbench.instance_exec(self,&b.clone)
        sdlm = TestUnitModule.new(name: b[0],out_sv_path: b[1])
        $_implicit_curr_itgt_.with_none_itgt do 
            sdlm.input - "from_up_pass"
            sdlm.output.logic - "to_down_pass"
        end
        sdlm.instance_exec(self,&b[2])

        if b[1] && File.exist?(b[1])
            sdlm.gen_sv_module
        else 
            sdlm.origin_sv = true 
        end
    end

    ItegrationVerb.curr_itgt_pop

end