Class: SystemRDL::Model::Instance

Inherits:
Object
  • Object
show all
Defined in:
lib/systemrdl/model/instance.rb

Direct Known Subclasses

AddrMap, Field, Reg

Class Attribute Summary collapse

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(inst, parent) ⇒ Instance

Returns a new instance of Instance.



6
7
8
9
10
11
12
13
14
# File 'lib/systemrdl/model/instance.rb', line 6

def initialize(inst, parent)
  @name = inst.element_name
  @layer = inst.layer
  @parent = parent
  @instances = build_sub_instances(inst)
  @properties = build_properties(inst)
  @token_range = inst.token_range
  freeze
end

Class Attribute Details

.propertiesObject (readonly)

Returns the value of attribute properties.



23
24
25
# File 'lib/systemrdl/model/instance.rb', line 23

def properties
  @properties
end

Instance Attribute Details

#instancesObject (readonly)

Returns the value of attribute instances.



19
20
21
# File 'lib/systemrdl/model/instance.rb', line 19

def instances
  @instances
end

#layerObject (readonly)

Returns the value of attribute layer.



17
18
19
# File 'lib/systemrdl/model/instance.rb', line 17

def layer
  @layer
end

#nameObject (readonly)

Returns the value of attribute name.



16
17
18
# File 'lib/systemrdl/model/instance.rb', line 16

def name
  @name
end

#parentObject (readonly)

Returns the value of attribute parent.



18
19
20
# File 'lib/systemrdl/model/instance.rb', line 18

def parent
  @parent
end

#token_rangeObject (readonly)

Returns the value of attribute token_range.



20
21
22
# File 'lib/systemrdl/model/instance.rb', line 20

def token_range
  @token_range
end

Instance Method Details

#full_nameObject



47
48
49
50
51
52
53
54
55
56
# File 'lib/systemrdl/model/instance.rb', line 47

def full_name
  elements = [self]
  current = @parent
  while current
    elements.unshift(current)
    current = current.parent
  end

  elements.map(&:name).join('.')
end

#pretty_print(pp) ⇒ Object



58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/systemrdl/model/instance.rb', line 58

def pretty_print(pp)
  pp.group(2, "#{self} {", '}') do
    @properties.each_value do |prop_value|
      pp.breakable
      pp.pp(prop_value)
    end
    @instances.each do |inst|
      pp.breakable
      pp.pp(inst)
    end
  end
end

#property(property_name) ⇒ Object



71
72
73
# File 'lib/systemrdl/model/instance.rb', line 71

def property(property_name)
  @properties[property_name]
end

#to_sObject



43
44
45
# File 'lib/systemrdl/model/instance.rb', line 43

def to_s
  "#{name} (#{layer})"
end