Class: SignalElm

Inherits:
BaseElm show all
Defined in:
lib/tdl/elements/originclass.rb,
lib/tdl/class_hdl/hdl_redefine_opertor.rb

Direct Known Subclasses

Clock, Logic, Reset

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

Methods included from TdlSpace::ExCreateTP

#root_ref

Methods included from AxiTdl::TestUnitTrack

#tracked_by_dve

Class Method Details

.inherited(subclass) ⇒ Object



196
197
198
199
200
# File 'lib/tdl/elements/originclass.rb', line 196

def self.inherited(subclass)
    unless @@child.include? subclass
        @@child << subclass
    end
end

.parse_ports(port_str) ⇒ Object

parse text for autogen method and constant ###



207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
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
# File 'lib/tdl/elements/originclass.rb', line 207

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>\[.*?\])?/)
            # me = e.match(/(?<in_out>input|output|inout)\s*(logic|wire)?\s*(?<vector>\[.*?\])?\s*(?<name>\w+)/)
            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

.subclassObject



202
203
204
# File 'lib/tdl/elements/originclass.rb', line 202

def self.subclass
    @@child
end

Instance Method Details

#[](a, b = nil) ⇒ Object



258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
# File 'lib/tdl/elements/originclass.rb', line 258

def [](a,b=nil)
    if a.is_a? ClassHDL::OpertorChain
        a.slaver = true
    end

    if b.is_a? ClassHDL::OpertorChain
        b.slaver = true
    end

    # b = a unless b
    if a== :all
        square = ""
    elsif b
        square = "[#{a}:#{b}]"
    else
        square = "[#{a}]"
    end

    NqString.new("#{name}#{square}")
end

#instObject



279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
# File 'lib/tdl/elements/originclass.rb', line 279

def inst
    unless @ghost
        # "logic  #{signal};"
        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