Class: ClassHDL::ImplicitInstModule

Inherits:
Object
  • Object
show all
Defined in:
lib/tdl/class_hdl/hdl_module_def.rb

Instance Method Summary collapse

Constructor Details

#initialize(name, sdlm) ⇒ ImplicitInstModule

Returns a new instance of ImplicitInstModule.



70
71
72
73
74
75
76
# File 'lib/tdl/class_hdl/hdl_module_def.rb', line 70

def initialize(name,sdlm)
    @name = name
    @sdlm = sdlm
    unless SdlModule.exist_module?(@name)
        raise TdlError.new("Cant find module `#{name}` !!!")
    end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(dname, *args, &block) ⇒ Object



91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/tdl/class_hdl/hdl_module_def.rb', line 91

def method_missing(dname,*args,&block)
    # if dname !~ /\w+/
    #     raise TDLError.new("#{@name} cont instance name #{dname}")
    # end

    # if $_implicit_curr_itgt_.last 
    #     @sdlm.Itgt_Instance(@name,dname.to_s.to_inp,&block)
    # else 
    #     @sdlm.Instance(@name,dname.to_s,&block)
    # end
    rel = nil
    AssignDefOpertor.with_rollback_opertors(:old) do 
        if block_given?
            rel = inst(dname,&block)
        else
            ## 当没有block 判断 sdlm是否相应方法
            # if @sdlm.has_signal?(dname)
            # if SdlModule.call_module(@name).has_signal?(dname)
            if SdlModule.call_module(@name).respond_to?(dname)
                rel =  SdlModule.call_module(@name).signal(dname)
            else 
                # super 
                raise TdlError.new( "Cant find signal `#{dname}` in module `#{@name}` path: #{SdlModule.call_module(@name).real_sv_path } !!!" )
            end
        end
    end
    return rel
end

Instance Method Details

#inst(dname, &block) ⇒ Object



78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/tdl/class_hdl/hdl_module_def.rb', line 78

def inst(dname,&block)
    if dname !~ /\w+/
        raise TdlError.new("#{@name} cont instance name #{dname}")
    end

    ## 有必要加一级封装代理
    if $_implicit_curr_itgt_.slast 
        @sdlm.Itgt_Instance(@name,dname.to_s.to_inp,&block)
    else 
        @sdlm.Instance(@name,dname.to_s,&block)
    end
end