Class: ClassHDL::ImplicitPortBase
- Inherits:
-
Object
- Object
- ClassHDL::ImplicitPortBase
show all
- Defined in:
- lib/tdl/class_hdl/hdl_module_def.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of ImplicitPortBase.
170
171
172
173
174
175
176
177
|
# File 'lib/tdl/class_hdl/hdl_module_def.rb', line 170
def initialize(sdlm,args={})
@chain = []
@sdlm = sdlm
unless @sdlm
raise TdlError.new("ImplicitPortBase<#{args.to_s}> dont have belong_to_module")
end
@up_args = args
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
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
|
# File 'lib/tdl/class_hdl/hdl_module_def.rb', line 251
def method_missing(method,*args,&block)
if @sdlm.respond_to?(method)
if @sdlm.send(method).is_a?(EnumStruct)
self.speciel_type = @sdlm.send(method).typedef_name
self.sub_type = @sdlm.send(method) self
elsif @sdlm.send(method).is_a?(StructMeta)
self.speciel_type = @sdlm.send(method).name
self.sub_type = @sdlm.send(method) self
else
if @sdlm.head_import_packages.map{ |e| e.to_s }.include?(method.to_s )
package_name = method.to_s
return ImplicitPortBasePackage.new(self,package_name)
else
ClassHDL::AssignDefOpertor.with_rollback_opertors(:old) do
args = args[0] || {}
@up_args = @up_args.merge(args)
self.-(method)
end
end
end
else
ClassHDL::AssignDefOpertor.with_rollback_opertors(:old) do
args = args[0] || {}
@up_args = @up_args.merge(args)
self.-(method)
end
end
end
|
Instance Attribute Details
#_struct_q ⇒ Object
Returns the value of attribute _struct_q.
169
170
171
|
# File 'lib/tdl/class_hdl/hdl_module_def.rb', line 169
def _struct_q
@_struct_q
end
|
#chain ⇒ Object
Returns the value of attribute chain.
169
170
171
|
# File 'lib/tdl/class_hdl/hdl_module_def.rb', line 169
def chain
@chain
end
|
#sdlm ⇒ Object
Returns the value of attribute sdlm.
169
170
171
|
# File 'lib/tdl/class_hdl/hdl_module_def.rb', line 169
def sdlm
@sdlm
end
|
#speciel_type ⇒ Object
Returns the value of attribute speciel_type.
169
170
171
|
# File 'lib/tdl/class_hdl/hdl_module_def.rb', line 169
def speciel_type
@speciel_type
end
|
#sub_type ⇒ Object
Returns the value of attribute sub_type.
169
170
171
|
# File 'lib/tdl/class_hdl/hdl_module_def.rb', line 169
def sub_type
@sub_type
end
|
Instance Method Details
#-(name) ⇒ Object
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
|
# File 'lib/tdl/class_hdl/hdl_module_def.rb', line 193
def - (name)
if name !~ /\w+/
raise TDLError.new("PORT #{name} Illegle ")
end
if name.is_a? StringBandItegration
raise TDLError.new("简化定义模式不允许传入 StringBandItegration 类型")
end
args = @up_args
if $_implicit_curr_itgt_.slast
name = name.to_inp($_implicit_curr_itgt_.last)
end
if @chain.any?
unless @_struct_q
args[:dsize] = @chain.last
if @chain[1]
args[:dimension] = @chain[0,@chain.size-1]
end
else
args[:dimension] = @chain
end
end
sdlm_port(name,args)
end
|
#[](*a) ⇒ Object
286
287
288
289
290
291
292
293
294
295
296
297
298
|
# File 'lib/tdl/class_hdl/hdl_module_def.rb', line 286
def [](*a)
if a.empty?
raise TdlError.new("参数不能为空")
end
new_dla = self.class.new(@sdlm,@up_args)
new_dla.chain = @chain + a
new_dla._struct_q = _struct_q
new_dla.speciel_type = speciel_type
new_dla.sub_type = sub_type
new_dla
end
|
#add_struct_method(obj) ⇒ Object
300
301
302
303
304
305
306
307
308
|
# File 'lib/tdl/class_hdl/hdl_module_def.rb', line 300
def add_struct_method(obj)
if sub_type.is_a? StructMeta
@sub_type.struct_slots.each do |e|
obj.define_singleton_method(e.name) do
TdlSpace::ArrayChain.create(obj: "#{obj.name}.#{e.name}".to_nq, belong_to_module: obj.belong_to_module)
end
end
end
end
|
#clock(*args) ⇒ Object
225
226
227
228
229
230
231
232
233
234
235
236
|
# File 'lib/tdl/class_hdl/hdl_module_def.rb', line 225
def clock(*args)
if args.any?
if args[0].is_a? Hash
@clock_freqM = args[0][:freqM]
else
@clock_freqM = args[0]
end
else
@clock_freqM = nil
end
return self
end
|
#logic ⇒ Object
183
184
185
186
|
# File 'lib/tdl/class_hdl/hdl_module_def.rb', line 183
def logic
@speciel_type = 'logic'
return self
end
|
#reset(*args) ⇒ Object
238
239
240
241
242
243
244
245
246
247
248
249
|
# File 'lib/tdl/class_hdl/hdl_module_def.rb', line 238
def reset(*args)
if args.any?
if args[0].is_a? Hash
@reset_active = args[0][:active]
else
@reset_active = args[0]
end
else
@reset_active = nil
end
return self
end
|
#sdlm_port(method = nil, args = {}) ⇒ Object
179
180
181
|
# File 'lib/tdl/class_hdl/hdl_module_def.rb', line 179
def sdlm_port(method=nil,args={})
raise TDLError.new "ImplicitPortBase slot <#{method}>"
end
|
#wire ⇒ Object
188
189
190
191
|
# File 'lib/tdl/class_hdl/hdl_module_def.rb', line 188
def wire
@speciel_type = 'wire'
return self
end
|