ipxact-ruby 0.12.0 → 0.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/lib/ipxact/component.rb +28 -0
- data/lib/ipxact/parser/component_data_parser.rb +5 -0
- data/spec/unit/component_spec.rb +47 -0
- metadata +3 -3
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.12.
|
|
1
|
+
0.12.1
|
data/lib/ipxact/component.rb
CHANGED
|
@@ -38,6 +38,9 @@ class IPXACT::Component < Hash
|
|
|
38
38
|
|
|
39
39
|
# @return [Array<Hash>] the list of ports
|
|
40
40
|
attr_accessor :ports
|
|
41
|
+
|
|
42
|
+
# @return [Array<Hash>] the list of cpus
|
|
43
|
+
attr_accessor :cpus
|
|
41
44
|
|
|
42
45
|
# Creates a new {IPXACT::Component} instance
|
|
43
46
|
#
|
|
@@ -59,6 +62,14 @@ class IPXACT::Component < Hash
|
|
|
59
62
|
:name => name})
|
|
60
63
|
end
|
|
61
64
|
|
|
65
|
+
# Returns true if the component has one or more cpus
|
|
66
|
+
#
|
|
67
|
+
# @return [Boolean]
|
|
68
|
+
#
|
|
69
|
+
def has_cpu?
|
|
70
|
+
!(self.cpus.nil? || self.cpus.empty?)
|
|
71
|
+
end
|
|
72
|
+
|
|
62
73
|
# Calculates an optimal path in the subcomponent graph between
|
|
63
74
|
# +subcomponent_start+ and +subcomponent_end+. This computation takes into
|
|
64
75
|
# account hierarchical subcomponents, and identifies optimal sub-paths in
|
|
@@ -186,6 +197,23 @@ class IPXACT::Component < Hash
|
|
|
186
197
|
end
|
|
187
198
|
end
|
|
188
199
|
|
|
200
|
+
# Commodity method for recursively getting all the subcomponents of the
|
|
201
|
+
# current component (except complex components, i.e. components that
|
|
202
|
+
# themselves have subcomponents).
|
|
203
|
+
#
|
|
204
|
+
# @return [Array<Component>] the current component's subcomponents
|
|
205
|
+
#
|
|
206
|
+
def rec_get_subcomponents(current_list = [])
|
|
207
|
+
subcomponents.each do |s|
|
|
208
|
+
if s[1].subcomponents.empty?
|
|
209
|
+
current_list << s
|
|
210
|
+
else
|
|
211
|
+
s[1].rec_get_subcomponents(current_list)
|
|
212
|
+
end
|
|
213
|
+
end
|
|
214
|
+
current_list
|
|
215
|
+
end
|
|
216
|
+
|
|
189
217
|
# Prepares the connection structure for the {IPXACT::GraphPathFinder} class.
|
|
190
218
|
# Traverses the hierarchy of subcomponents in order to create a flattened
|
|
191
219
|
# representation of the subcomponents graph. In particular, the method
|
|
@@ -82,11 +82,16 @@ module IPXACT::Parser::ComponentData
|
|
|
82
82
|
IPXACT::Parser::BusData.parse_bus(a_bus_interface, root_component, variables)
|
|
83
83
|
end
|
|
84
84
|
|
|
85
|
+
cpus = root_component.xpath(".//spirit:cpu").collect do |a_cpu|
|
|
86
|
+
{ :name => a_cpu.xpath("./spirit:name").first.text }
|
|
87
|
+
end
|
|
88
|
+
|
|
85
89
|
component = IPXACT::Component.new(instance_name, component_name, component_vendor, component_version)
|
|
86
90
|
component.interconnections = interconnections
|
|
87
91
|
component.hierconnections = hierconnections
|
|
88
92
|
component.subcomponents = instances
|
|
89
93
|
component.ports = ports
|
|
94
|
+
component.cpus = cpus
|
|
90
95
|
component
|
|
91
96
|
end
|
|
92
97
|
|
data/spec/unit/component_spec.rb
CHANGED
|
@@ -149,4 +149,51 @@ describe IPXACT::Component do
|
|
|
149
149
|
(dma[:name] + '/' + dma[:vendor] + '/x/y').should == 'dma/spiritconsortium.org/x/y'
|
|
150
150
|
|
|
151
151
|
end
|
|
152
|
+
|
|
153
|
+
it "should be able to detect that a dma has no cpu" do
|
|
154
|
+
components = IPXACT::load_components(PLATFORM_PATH)
|
|
155
|
+
designs = IPXACT::load_designs(PLATFORM_PATH)
|
|
156
|
+
platform = IPXACT::Parser::PlatformData.parse_platform(["Leon2Platform", "1.1"], components, designs)
|
|
157
|
+
|
|
158
|
+
dma = platform.components['i_dma']
|
|
159
|
+
dma.should_not have_cpu
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
it "should be able to detect that a Leon2 processor is in fact a cpu" do
|
|
163
|
+
components = IPXACT::load_components(PLATFORM_PATH)
|
|
164
|
+
designs = IPXACT::load_designs(PLATFORM_PATH)
|
|
165
|
+
platform = IPXACT::Parser::PlatformData.parse_platform(["Leon2Platform", "1.1"], components, designs)
|
|
166
|
+
|
|
167
|
+
leon2 = platform.components['i_proc']
|
|
168
|
+
leon2.should have_cpu
|
|
169
|
+
leon2.cpus.should have(1).cpu
|
|
170
|
+
leon2.cpus.first[:name].should == "processor"
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
it "should return an empty list getting the recursive list of dma subcomponents" do
|
|
174
|
+
components = IPXACT::load_components(PLATFORM_PATH)
|
|
175
|
+
designs = IPXACT::load_designs(PLATFORM_PATH)
|
|
176
|
+
platform = IPXACT::Parser::PlatformData.parse_platform(["Leon2Platform", "1.1"], components, designs)
|
|
177
|
+
|
|
178
|
+
dma = platform.components['i_dma']
|
|
179
|
+
dma.rec_get_subcomponents.should be_empty
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
it "should return an array with 4 elements when considering the recursive list of the apb subsystem subcomponents" do
|
|
183
|
+
components = IPXACT::load_components(PLATFORM_PATH)
|
|
184
|
+
designs = IPXACT::load_designs(PLATFORM_PATH)
|
|
185
|
+
platform = IPXACT::Parser::PlatformData.parse_platform(["Leon2Platform", "1.1"], components, designs)
|
|
186
|
+
|
|
187
|
+
sub = platform.components['i_sub']
|
|
188
|
+
sub.rec_get_subcomponents.size.should == 4
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
it "should return an array with 10 elements when considering the recursive list of the platform components" do
|
|
192
|
+
components = IPXACT::load_components(PLATFORM_PATH)
|
|
193
|
+
designs = IPXACT::load_designs(PLATFORM_PATH)
|
|
194
|
+
platform = IPXACT::Parser::PlatformData.parse_platform(["Leon2Platform", "1.1"], components, designs)
|
|
195
|
+
|
|
196
|
+
platform.rec_get_subcomponents.size.should == 10
|
|
197
|
+
end
|
|
198
|
+
|
|
152
199
|
end
|
metadata
CHANGED
|
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
|
5
5
|
segments:
|
|
6
6
|
- 0
|
|
7
7
|
- 12
|
|
8
|
-
-
|
|
9
|
-
version: 0.12.
|
|
8
|
+
- 1
|
|
9
|
+
version: 0.12.1
|
|
10
10
|
platform: ruby
|
|
11
11
|
authors:
|
|
12
12
|
- Guillaume Godet-Bar
|
|
@@ -14,7 +14,7 @@ autorequire:
|
|
|
14
14
|
bindir: bin
|
|
15
15
|
cert_chain: []
|
|
16
16
|
|
|
17
|
-
date: 2010-
|
|
17
|
+
date: 2010-12-06 00:00:00 +01:00
|
|
18
18
|
default_executable:
|
|
19
19
|
dependencies:
|
|
20
20
|
- !ruby/object:Gem::Dependency
|