class SdlTopImplement

Attributes

top_module[R]

Public Class Methods

build(top_name,resource_yaml) click to toggle source

class methods

# File lib/tdl/sdlimplement/sdl_impl_module.rb, line 362
def self.build(top_name,resource_yaml)
    hash = YAML::load(File.open(resource_yaml))
    pm = SdlImplParam.new(hash['params'])

    hash.each do |k,v|
        SdlImplModule.new(k,v)  if(k != 'params') && (k != 'implement')
    end

    if TopModule.sim && hash['implement']['tb_modules']
        imlp_top = SdlTopImplement.new(top_name,File.dirname(resource_yaml),hash['implement']['tb_modules'],hash['implement']['tb'],pm,hash['params']['yaml']['pins'])
    else
        imlp_top = SdlTopImplement.new(top_name,File.dirname(resource_yaml),hash['implement']['modules'],hash['implement']['tb'],pm,hash['params']['yaml']['pins'])
    end

    # hash['implement']['ex_up_code']
    imlp_top.top_module.ex_up_code  = (hash['implement']['ex_up_code'].join("\n")+"\n") if hash['implement']['ex_up_code']

    imlp_top.top_module.gen_sv_module

    if(hash['implement']['constraints'])
        hash['implement']['constraints'].each do |e|
            Constraints.add_const e
        end
    end

    imlp_top.top_module.create_xdc  if hash['implement']['xdc']

end
new(top_name,out_sv_path,need_modules,tbs,implparams,pins_yaml) click to toggle source
# File lib/tdl/sdlimplement/sdl_impl_module.rb, line 189
def initialize(top_name,out_sv_path,need_modules,tbs,implparams,pins_yaml)
    @pins_yaml = TopModule.load_ppins(pins_yaml) if pins_yaml
    @tbs = tbs || []
    @implparams = implparams
    @out_sv_path = out_sv_path

    @top_module = TopModule.new(name: top_name,out_sv_path: out_sv_path)


    @_sure_array_ = []
    need_modules.each do |m|
        inspect_dependent(m)
        rel = SdlImplModule.modules_hash(m)
        @_sure_array_ << rel.dependent(sure:true) if rel
    end

    @_sure_array_ = @_sure_array_.flatten

    @module_pool = []

    need_modules.each do |m|
        rel = SdlImplModule.modules_hash(m)
        @module_pool << rel
        @module_pool << rel.dependent(sure:false,pool: @_sure_array_) if rel
    end

    @module_pool.flatten!
    @module_pool = @module_pool.uniq
    ## implement
    need_modules.each do |m|
        instance_itgt_module SdlImplModule.modules_hash(m)
    end

    # @top_module.gen_sv_module
    inspect_pool
end

Public Instance Methods

inspect_dependent(impl_module_str) click to toggle source
# File lib/tdl/sdlimplement/sdl_impl_module.rb, line 233
def inspect_dependent(impl_module_str)
    md = SdlImplModule.modules_hash(impl_module_str)
    sure_array = md.dependent(sure:true)

    use_array = md.dependent(sure:false,pool: sure_array.flatten )

    dep_array = SdlImplModule.inspect_dependent_verb(0,use_array)

    Dir.mkdir(File.join(@out_sv_path,"/inspect/")) unless File.exist? File.join(@out_sv_path,"/inspect/")
    Dir.mkdir(File.join(@out_sv_path,"/inspect/dependent/")) unless File.exist? File.join(@out_sv_path,"/inspect/dependent/")
    File.open(File.join(@out_sv_path,"/inspect/dependent/","#{md.class_name}.txt"),'w') do |f|
        f.puts dep_array
    end
end
inspect_pool() click to toggle source
# File lib/tdl/sdlimplement/sdl_impl_module.rb, line 226
def inspect_pool
    Dir.mkdir(File.join(@out_sv_path,"/inspect/")) unless File.exist? File.join(@out_sv_path,"/inspect/")
    File.open(File.join(@out_sv_path,"/inspect/","#{@top_module.module_name}_include.txt"),'w') do |f|
        f.puts @module_pool.map { |e|  e.key_name }.join("\n")
    end
end
inspect_sdl(target_class,argv_hash) click to toggle source
# File lib/tdl/sdlimplement/sdl_impl_module.rb, line 330
def inspect_sdl(target_class,argv_hash)
    Dir.mkdir(File.join(@out_sv_path,"/inspect/")) unless File.exist? File.join(@out_sv_path,"/inspect/")
    Dir.mkdir(File.join(@out_sv_path,"/inspect/sdl_example/")) unless File.exist? File.join(@out_sv_path,"/inspect/sdl_example/")
    str = ""
    argv_hash.each do |k,v|
        if k.to_s == "pins_map"
            vv = v.dup
            v.keys.select { |e|  e.is_a? String }.each do |kk|
                vv.delete kk
            end

            hash_str = ""
            vv.each do |vvk,vvv|
                hash_str    += "        #{vvk}: #{vvv},\n"
            end
            str += "    #{k.to_s}:{\n#{hash_str}\n    }\n"
        else
            str += "    #{k.to_s}:#{v.to_s.gsub('#',"")},\n"
        end
    end

    File.open(File.join(@out_sv_path,"/inspect/sdl_example/","#{target_class.to_s}_example.rb"),'w') do |f|
        # f.puts dep_array
        f.puts "#{target_class.to_s}.new("
        f.puts str
        f.puts ")"

    end
end
instance_itgt_module(impl_module) click to toggle source
# File lib/tdl/sdlimplement/sdl_impl_module.rb, line 259
def instance_itgt_module(impl_module)
    ## check define
    if impl_module.nickname
        str = "itgt_#{impl_module.class_name}_#{impl_module.nickname}"
    else
        str = "itgt_#{impl_module.class_name}"
    end

    if respond_to?(str)
        return send(str)
    end

    unless File.exist? impl_module.path
        raise TdlError.new("Implemet Module[#{impl_module.key_name}] Path[#{impl_module.path}] dont exist !!!")
    end
    require_relative(impl_module.path)


    argv_hash = {}

    impl_module.common_argvs.each do |ca|
        rel = impl_module.send(ca)
        if (ca.to_sym == :pins_map) && rel
            argv_hash[ca.to_sym] = @pins_yaml[rel]
        elsif rel
            argv_hash[ca.to_sym] = rel
        end
    end

    impl_module.real_require.each do |k,rel|
        if @module_pool.include? rel
            argv_hash[k.to_sym] = instance_itgt_module(rel)
        else
            TdlError.new("#{rel.key_name} is not in module_pool !!!")
        end
    end

    argv_hash[:top_module]  = @top_module

    if @tbs.include?(impl_module.key_name)
        argv_hash[:tb]          = true
    end

    ## other attr
    other_rep0 = /params-yaml-(?<name>.+)/
    other_rep1 = /params-var-(?<name>.+)/

    impl_module.other.keys.each do |k|
        rel = impl_module.other.send(k)
        if other_rep0.match(rel.to_s) || other_rep1.match(rel.to_s)
            argv_hash[k.to_sym] =  @implparams.send($~[:name])
        else
            argv_hash[k.to_sym] = rel
        end
    end


    ## define itgt methods
    target_class = eval("#{impl_module.class_name}")
    inspect_sdl(target_class,argv_hash)

    _inst_ = target_class.send(:new,argv_hash)

    define_singleton_method(str) do
        _inst_
    end

    return _inst_

end
pool_hash(name_str,nickname=nil) click to toggle source
# File lib/tdl/sdlimplement/sdl_impl_module.rb, line 248
def pool_hash(name_str,nickname=nil)
    @module_pool.select do |e|
        if nickname
            e.classname == name_str && e.nickname == nickname
        else
            e.classname == name_str
        end
    end[0]
end