Class: Reset

Inherits:
SignalElm show all
Includes:
BaseModule, ClassHDL::AssignDefOpertor
Defined in:
lib/tdl/elements/Reset.rb,
lib/tdl/class_hdl/hdl_redefine_opertor.rb

Overview

require_relative “./tdlerror” require_relative “./basefunc”

Constant Summary

Constants included from ClassHDL::AssignDefOpertor

ClassHDL::AssignDefOpertor::OP_SYMBOLS

Instance Attribute Summary collapse

Attributes inherited from BaseElm

#belong_to_module

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ClassHDL::AssignDefOpertor

curr_assign_block, curr_assign_block=, curr_assign_block_stack, curr_opertor_stack, included, init_op_methods, use_new_yield_opertors, use_old_cond_opertors, with_new_assign_block, with_new_opertor, with_normal_opertor, with_rollback_opertors

Methods included from BaseModule

#length, #to_s

Methods inherited from SignalElm

#[], inherited, #inst, subclass

Methods inherited from BaseElm

#matrix, #name_copy, #path_refs, recfg_nc, #s, #signal

Methods included from TdlSpace::ExCreateTP

#create_tp, #root_ref

Constructor Details

#initialize(name: "system_rst", active: "LOW", port: false, dsize: 1) ⇒ Reset

Returns a new instance of Reset.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/tdl/elements/Reset.rb', line 8

def initialize(name:"system_rst",active:"LOW",port:false,dsize:1)
    name_legal?(name)
    # @id = GlobalParam.CurrTdlModule.BindEleClassVars.Reset.id
    @dsize = dsize
    @name = name
    @port = port
    @active = active.to_s.downcase
    if @active.eql?("low") && @active.eql?("high")
        raise TdlError.new("RESET ACTIVE PARA #{@active} ERROR")
    end
    # if @port
    #     GlobalParam.CurrTdlModule.BindEleClassVars.Reset.ports << self if @id != 0
    # else
    #     GlobalParam.CurrTdlModule.BindEleClassVars.Reset.inst_stack << method(:inst).to_proc
    # end
    # if @id == 2
    #     raise TdlError.new("____________")
    # end
end

Instance Attribute Details

#activeObject (readonly)

Returns the value of attribute active.



5
6
7
# File 'lib/tdl/elements/Reset.rb', line 5

def active
  @active
end

#dsizeObject

Returns the value of attribute dsize.



6
7
8
# File 'lib/tdl/elements/Reset.rb', line 6

def dsize
  @dsize
end

#ghostObject

Returns the value of attribute ghost.



6
7
8
# File 'lib/tdl/elements/Reset.rb', line 6

def ghost
  @ghost
end

#idObject

Returns the value of attribute id.



6
7
8
# File 'lib/tdl/elements/Reset.rb', line 6

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/tdl/elements/Reset.rb', line 5

def name
  @name
end

#portObject

Returns the value of attribute port.



6
7
8
# File 'lib/tdl/elements/Reset.rb', line 6

def port
  @port
end

Class Method Details

.parse_ports(port_str) ⇒ Object

parse text for autogen method and constant ###



146
147
148
149
150
# File 'lib/tdl/elements/Reset.rb', line 146

def self.parse_ports(port_str)
    rh = super.parse_ports(port_str)
    rh[:type]   = Reset
    return rh
end

Instance Method Details

#high_signalObject



93
94
95
96
97
98
99
# File 'lib/tdl/elements/Reset.rb', line 93

def high_signal
    if(active.eql? "low")
        NqString.new("~").concat signal
    else
        signal
    end
end

#inst_portObject

def port_length

(@port.to_s + " ").length

end



44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/tdl/elements/Reset.rb', line 44

def inst_port

    # if @port
    #     (@port.to_s + " " + " "*sub_len + @name.to_s)
    # end

    if dsize.eql? 1
        n = ""
    else
        n = "[#{(@dsize-1)}:0]"
    end

    return [@port.to_s+n,@name.to_s,""]
end

#low_signalObject

def left_port_length

("/*  input" + " */ ").length

end

def right_port_length

(".#{@name.to_s} ").length

end

def ex_port(left_align_len = 7,right_align_len = 7)

if left_align_len >=  left_port_length
    sub_left_len = left_align_len -  left_port_length
else
    sub_left_len = 0
end

if right_align_len >=  right_port_length
    sub_right_len = right_align_len -  right_port_length
else
    sub_right_len = 0
end

if @port
    ("/*  input" + " "*sub_left_len + "*/ " + "."+@name.to_s + " "*sub_right_len)
end

end



85
86
87
88
89
90
91
# File 'lib/tdl/elements/Reset.rb', line 85

def low_signal
    if(active.eql? "low")
        signal
    else
        NqString.new("~").concat signal
    end
end