class ItegrationVerb

$implicit_curr_itgt = []

动态删除 silence_ block

Attributes

init_inst[RW]
inst_index[RW]
names_pool[RW]
nickname[RW]
pins_map[RW]
top_module[RW]

Public Class Methods

constraints_block(&block) click to toggle source

约束 block

# 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_pop() click to toggle source
# File lib/tdl/exlib/itegration_verb.rb, line 310
def self.curr_itgt_pop
    $_implicit_curr_itgt_.pop
end
curr_itgt_push(itgt) click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# File lib/tdl/exlib/itegration_verb.rb, line 860
def self.get_instance_var(name)
    _inst_ccc_ = instance_variable_get("@_#{name}_")
end
inherited(subclass) click to toggle source
        blocks = blocks_hash[key]
        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

# File lib/tdl/exlib/itegration_verb.rb, line 581
def self.inherited(subclass)
    unless @@child.include? subclass
        @@child << subclass
    end
end
new(name_str=nil,pins_map={},top_module=nil) click to toggle source
# 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
record_instance_var_block(name,default=[],&block) click to toggle source
            _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

# 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) click to toggle source
# 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={}) click to toggle source

测试向量实现 作用于是 top_module

# 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) click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# 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) click to toggle source

关于 当前 itgt stack 操作

# 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

Public Instance Methods

cal_inst_index(base=0) click to toggle source
# 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) click to toggle source
# 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_itgt() click to toggle source
# File lib/tdl/exlib/itegration_verb.rb, line 278
def child_inst_itgt
    @child_inst_itgt ||=[]
end
delete_silence(name) click to toggle source
# 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) click to toggle source

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

# 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) click to toggle source
# 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
inst() click to toggle source

define_singleton_method(:inst) do

# 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_constraints() click to toggle source
# 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
set_itgt_var(name,value) click to toggle source
# 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_inst() click to toggle source
# 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_vector() click to toggle source
# 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_inst() click to toggle source

测试用例 实例化

# 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

Private Instance Methods

_names_pool_inst() click to toggle source

def self.[](key)

@@_curr_all_itegration_ ||= {}
@@_curr_all_itegration_[key.to_s]

end

def self.[]=(key,value)

@@_curr_all_itegration_ ||= {}
@@_curr_all_itegration_[key.to_s] = value

end

# File lib/tdl/exlib/itegration_verb.rb, line 597
def _names_pool_inst
    @names_pool = NameSPoolHash.new
    @names_pool.nickname = @nickname
    @names_pool.itgt = self
end