Class: SignalElm
- Inherits:
-
BaseElm
show all
- Defined in:
- lib/tdl/elements/originclass.rb,
lib/tdl/class_hdl/hdl_redefine_opertor.rb
Constant Summary
collapse
- @@child =
[]
Instance Attribute Summary
Attributes inherited from BaseElm
#belong_to_module, #name
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from BaseElm
#matrix, #name_copy, #path_refs, recfg_nc, #s, #signal
#create_tp, #root_ref
Class Method Details
.inherited(subclass) ⇒ Object
221
222
223
224
225
|
# File 'lib/tdl/elements/originclass.rb', line 221
def self.inherited(subclass)
unless @@child.include? subclass
@@child << subclass
end
end
|
.parse_ports(port_str) ⇒ Object
parse text for autogen method and constant ###
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
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
|
# File 'lib/tdl/elements/originclass.rb', line 232
def self.parse_ports(port_str)
normal_ports = []
del_ports = []
if port_str
normal_ports = port_str.map do |e|
me = e.match(/(?<in_out>input|output|inout)\s*(logic|wire|reg|bit)?\s*(?<vector>\[.*?\])?\s+(?<name>\w+)\s*(?<array>\[.*?\])?/)
if me
del_ports << e
h = Hash.new
h[:type] = Logic
h[:name] = me["name"].downcase
h[:origin_name] = me["name"]
h[:in_out] = me["in_out"]
if me["vector"]
h[:vector] = me["vector"]
end
if me["array"]
h[:array] = me["array"]
end
h[:port_left_len] = 4+6+1+(h[:vector] ? h[:vector].length : 0) +6
h[:port_right_len]= 4+h[:origin_name].length
h[:inst_ex_port] = lambda { |ml,mr|
if ml >= h[:port_left_len]
ll = ml - h[:port_left_len]
else
ll = 1
end
if mr >= h[:port_right_len]
rl = mr - h[:port_right_len]
else
rl = 1
end
"/* #{(h[:in_out]=="output") ? h[:in_out] : h[:in_out]+" "} #{h[:vector]}" +" "*(ll) + "*/ " + ".#{h[:origin_name]}"+" "*(rl)+" (\#{align_signal(#{h[:name]},q_mark=false)})"
}
yield h
h
else
nil
end
end
end
return_port_str = port_str - del_ports
return return_port_str
end
|
.subclass ⇒ Object
227
228
229
|
# File 'lib/tdl/elements/originclass.rb', line 227
def self.subclass
@@child
end
|
Instance Method Details
#[](a, b = nil) ⇒ Object
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
|
# File 'lib/tdl/elements/originclass.rb', line 283
def [](a,b=nil)
if a.is_a? ClassHDL::OpertorChain
a.slaver = true
end
if b.is_a? ClassHDL::OpertorChain
b.slaver = true
end
if a== :all
square = ""
elsif b
square = "[#{a}:#{b}]"
else
square = "[#{a}]"
end
NqString.new("#{name}#{square}")
end
|
#inst ⇒ Object
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
|
# File 'lib/tdl/elements/originclass.rb', line 304
def inst
unless @ghost
if dsize.eql?(1)
"logic #{signal};"
else
if (@dsize.is_a? Numeric) && @dsize < 0
str = "logic [0:#{(-@dsize-1)}] #{signal};"
else
str = "logic [#{(@dsize-1)}:0] #{signal};"
end
end
else
""
end
end
|