Class: IPXACT::Component
- Inherits:
-
Object
- Object
- IPXACT::Component
- Defined in:
- lib/ipxact/component.rb
Overview
Component is what an Platform is essentially made of. This class defines 6 attributes: (#instance_name}, #cpus, #subcomponents, #interconnections, #hierconnections and #ports. While interconnections, hierconnections and ports are mostly used by the GraphPathFinder class, the subcomponents are what most users will be querying. Subcomponents may be terminal or non-terminal, i.e. composed of other subcomponents. Finally, #cpus simply corresponds to the list of cpus the component is doted with.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#cpus ⇒ Array<Hash>
The list of cpus.
-
#hierconnections ⇒ Array<Hash>
The list of hierconnections.
-
#instance_name ⇒ String
readonly
The component’s instance name.
-
#interconnections ⇒ Array<Hash>
The list of interconnections.
-
#ipxact_id ⇒ IPXACT::Identifier
readonly
The component’s IPXACT identifier.
-
#ports ⇒ Array<Hash>
The list of ports.
-
#subcomponents ⇒ Array<Component>
The list of subcomponents.
Instance Method Summary collapse
-
#has_cpu? ⇒ Boolean
Returns true if the component has one or more cpus.
-
#initialize(instance_name, id_args) ⇒ Component
constructor
Creates a new Component instance.
-
#port(port_name) ⇒ Hash
Returns the port that matches the given name, if any.
-
#rec_get_subcomponent(instance_name) ⇒ Component
Commodity method for getting a component instance called
instance_name
, either from the direct subcomponents of the component, or from the subcomponents hierarchy. -
#rec_get_subcomponents(current_list = []) ⇒ Array<Component>
Commodity method for recursively getting all the subcomponents of the current component (except complex components, i.e. components that themselves have subcomponents).
-
#register_map ⇒ Array
Get the component’s register map, if any.
Constructor Details
#initialize(instance_name, id_args) ⇒ Component
Creates a new IPXACT::Component instance
58 59 60 61 62 63 64 65 |
# File 'lib/ipxact/component.rb', line 58 def initialize(instance_name, id_args) @subcomponents = {} @interconnections = {} @hierconnections = {} @ports = [] @ipxact_id = id_args.is_a?(Hash) ? IPXACT::Identifier.new(id_args) : id_args @instance_name = instance_name end |
Instance Attribute Details
#cpus ⇒ Array<Hash>
Returns the list of cpus.
43 44 45 |
# File 'lib/ipxact/component.rb', line 43 def cpus @cpus end |
#hierconnections ⇒ Array<Hash>
Returns the list of hierconnections.
37 38 39 |
# File 'lib/ipxact/component.rb', line 37 def hierconnections @hierconnections end |
#instance_name ⇒ String (readonly)
Returns The component’s instance name.
49 50 51 |
# File 'lib/ipxact/component.rb', line 49 def instance_name @instance_name end |
#interconnections ⇒ Array<Hash>
Returns the list of interconnections.
34 35 36 |
# File 'lib/ipxact/component.rb', line 34 def interconnections @interconnections end |
#ipxact_id ⇒ IPXACT::Identifier (readonly)
Returns the component’s IPXACT identifier.
46 47 48 |
# File 'lib/ipxact/component.rb', line 46 def ipxact_id @ipxact_id end |
#ports ⇒ Array<Hash>
Returns the list of ports.
40 41 42 |
# File 'lib/ipxact/component.rb', line 40 def ports @ports end |
#subcomponents ⇒ Array<Component>
Returns the list of subcomponents.
31 32 33 |
# File 'lib/ipxact/component.rb', line 31 def subcomponents @subcomponents end |
Instance Method Details
#has_cpu? ⇒ Boolean
Returns true if the component has one or more cpus
71 72 73 |
# File 'lib/ipxact/component.rb', line 71 def has_cpu? !(self.cpus.nil? || self.cpus.empty?) end |
#port(port_name) ⇒ Hash
Returns the port that matches the given name, if any.
103 104 105 |
# File 'lib/ipxact/component.rb', line 103 def port(port_name) ports.detect{|p| p[:name] == port_name} end |
#rec_get_subcomponent(instance_name) ⇒ Component
Commodity method for getting a component instance called instance_name
, either from the direct subcomponents of the component, or from the subcomponents hierarchy.
115 116 117 118 119 120 121 122 123 124 |
# File 'lib/ipxact/component.rb', line 115 def rec_get_subcomponent(instance_name) if subcomponents.has_key?(instance_name) subcomponents[instance_name] elsif subcomponents.empty? nil else subcomponents.collect{|sub_name, sub| sub.rec_get_subcomponent(instance_name)} \ .compact.first end end |
#rec_get_subcomponents(current_list = []) ⇒ Array<Component>
Commodity method for recursively getting all the subcomponents of the current component (except complex components, i.e. components that themselves have subcomponents).
132 133 134 135 136 137 138 139 140 141 |
# File 'lib/ipxact/component.rb', line 132 def rec_get_subcomponents(current_list = []) subcomponents.each do |s| if s[1].subcomponents.empty? current_list << s else s[1].rec_get_subcomponents(current_list) end end current_list end |
#register_map ⇒ Array
Get the component’s register map, if any.
87 88 89 90 91 92 93 94 |
# File 'lib/ipxact/component.rb', line 87 def register_map return nil \ unless ports.any?{|port| port[:type] == :slave} || ports.any?{|port| port[:port_data][:registers]} ports.select{|port| port[:type] == :slave && port[:port_data][:registers]} \ .first[:port_data][:registers] end |