ipxact-ruby 0.11.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.autotest +15 -0
- data/.gitignore +2 -0
- data/README.html +89 -0
- data/README.mdown +91 -0
- data/Rakefile +31 -0
- data/VERSION +1 -0
- data/autotest/discover.rb +17 -0
- data/lib/ipxact.rb +263 -0
- data/lib/ipxact/component.rb +235 -0
- data/lib/ipxact/parser.rb +27 -0
- data/lib/ipxact/parser/bus_data_parser.rb +229 -0
- data/lib/ipxact/parser/component_data_parser.rb +309 -0
- data/lib/ipxact/parser/platform_data_parser.rb +63 -0
- data/lib/ipxact/pathfinder/graph_pathfinder.rb +191 -0
- data/lib/ipxact/platform.rb +43 -0
- data/schemas/abstractionDefinition.xsd +332 -0
- data/schemas/abstractor.xsd +156 -0
- data/schemas/autoConfigure.xsd +226 -0
- data/schemas/busDefinition.xsd +99 -0
- data/schemas/busInterface.xsd +640 -0
- data/schemas/commonStructures.xsd +189 -0
- data/schemas/component.xsd +253 -0
- data/schemas/configurable.xsd +82 -0
- data/schemas/constraints.xsd +283 -0
- data/schemas/design.xsd +105 -0
- data/schemas/designConfig.xsd +144 -0
- data/schemas/file.xsd +560 -0
- data/schemas/fileType.xsd +86 -0
- data/schemas/generator.xsd +240 -0
- data/schemas/identifier.xsd +93 -0
- data/schemas/index.xsd +67 -0
- data/schemas/memoryMap.xsd +1007 -0
- data/schemas/model.xsd +291 -0
- data/schemas/port.xsd +441 -0
- data/schemas/signalDrivers.xsd +220 -0
- data/schemas/simpleTypes.xsd +90 -0
- data/schemas/subInstances.xsd +256 -0
- data/spec/integration/bus_data_extraction_spec.rb +105 -0
- data/spec/integration/data_calculation_spec.rb +133 -0
- data/spec/integration/data_construction_spec.rb +52 -0
- data/spec/integration/general_spec.rb +121 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/PV/pv_initiator_port.h +135 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/PV/pv_initiator_port.tpp +247 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/PV/pv_initiator_port_base.h +189 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/PV/pv_router.h +205 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/PV/pv_router.tpp +278 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/PV/pv_slave_base.h +115 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/PV/pv_slave_base.tpp +126 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/PV/pv_target_port.h +168 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/PV/pv_target_port_base.h +133 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/PV/pv_tlm_if.h +280 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/PV/user_types.h +38 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/SystemTLM1/Leon2Platform/Leon2Platform.xml +77 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/SystemTLM1/Leon2Platform/design_Leon2Platform.xml +156 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/SystemTLM1/Leon2Platform/tlmsrc/Leon2Platform.h +149 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/SystemTLM1/apbSubSystem/apbSubSystem.xml +406 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/SystemTLM1/apbSubSystem/design_apbSubSystem.xml +135 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/SystemTLM1/apbSubSystem/tlmsrc/apbSubSystem.h +133 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/SystemTLM2/Leon2Platform/Leon2Platform.xml +77 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/SystemTLM2/Leon2Platform/design_Leon2Platform.xml +157 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/SystemTLM2/Leon2Platform/tlmsrc/Leon2Platform.h +150 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/SystemTLM2/apbSubSystem/apbSubSystem.xml +422 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/SystemTLM2/apbSubSystem/designConfig_apbSubSystem.xml +79 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/SystemTLM2/apbSubSystem/design_apbSubSystem.xml +184 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/SystemTLM2/apbSubSystem/tlmsrc/apbSubSystem.h +164 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/SystemTLM3/Leon2Platform/Leon2Platform.xml +105 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/SystemTLM3/Leon2Platform/design_Leon2Platform.xml +157 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/SystemTLM3/Leon2Platform/tlmsrc/Leon2Platform.h +152 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/SystemTLM3/apbSubSystem/apbSubSystem.xml +429 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/SystemTLM3/apbSubSystem/designConfig_apbSubSystem.xml +64 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/SystemTLM3/apbSubSystem/design_apbSubSystem.xml +150 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/SystemTLM3/apbSubSystem/tlmsrc/apbSubSystem.h +167 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/ahbbus/1.4/ahbbus22.xml +236 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/ahbbus/1.4/tlmsrc/ahbbus.h +52 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/ahbram/1.4/ahbram.xml +184 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/ahbram/1.4/tlmsrc/ahbram.cc +93 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/ahbram/1.4/tlmsrc/ahbram.h +77 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/apbbus/1.4/apbbus8.xml +544 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/apbbus/1.4/tlmsrc/apbbus.h +55 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/apbmst/1.4/apbmst.xml +209 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/apbmst/1.4/tlmsrc/apbmst.h +53 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/apbram/1.0/apbram.xml +395 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/apbram/1.0/hdlsrc/apbram.cc +89 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/apbram/1.0/hdlsrc/apbram.h +69 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/apbram/1.0/hdlsrc/apbram.v +82 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/apbram/1.0/hdlsrc/apbram.vhd +132 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/cgu/1.4/cgu.xml +686 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/cgu/1.4/tlmsrc/cgu.cc +121 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/cgu/1.4/tlmsrc/cgu.h +81 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/cgu/1.5/cgu.xml +707 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/cgu/1.5/tlmsrc/cgu.cc +121 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/cgu/1.5/tlmsrc/cgu.h +81 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/dma/1.4/dma.xml +272 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/dma/1.4/tlmsrc/dma.cc +230 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/dma/1.4/tlmsrc/dma.h +116 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/irqctrl/1.4/irqctrl.xml +530 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/irqctrl/1.4/tlmsrc/irqctrl.cc +211 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/irqctrl/1.4/tlmsrc/irqctrl.h +108 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/processor/1.4/processor.xml +423 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/processor/1.4/tlmsrc/processor.cc +331 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/processor/1.4/tlmsrc/processor.h +121 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/pv2apb/1.0/pv2apb.xml +240 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/pv2apb/1.0/tlmsrc/pv2apb.cc +153 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/pv2apb/1.0/tlmsrc/pv2apb.h +77 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/pv2tac/1.0/pv2tac.xml +154 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/pv2tac/1.0/tlmsrc/pv2tac.cc +114 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/pv2tac/1.0/tlmsrc/pv2tac.h +67 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/rgu/1.4/rgu.xml +766 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/rgu/1.4/tlmsrc/rgu.cc +126 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/rgu/1.4/tlmsrc/rgu.h +105 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/scmlAdaptor/1.0/scmlAdaptor.xml +154 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/scmlAdaptor/1.0/tlmsrc/scmladaptor.cc +100 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/scmlAdaptor/1.0/tlmsrc/scmladaptor.h +62 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/serial_device/1.0/serial_device.xml +151 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/serial_device/1.0/tlmsrc/serial_device.h +85 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/timers/1.4/timers.xml +460 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/timers/1.4/tlmsrc/timers.cc +201 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/timers/1.4/tlmsrc/timers.h +102 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/uart_scml/1.0/tlmsrc/inc/uart.h +152 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/uart_scml/1.0/tlmsrc/inc/uart_fifo.h +113 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/uart_scml/1.0/tlmsrc/inc/uart_memory_map.h +96 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/uart_scml/1.0/tlmsrc/inc/uart_types.h +60 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/uart_scml/1.0/tlmsrc/src/uart.cc +125 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/uart_scml/1.0/tlmsrc/src/uart_interrupt_handler.cc +136 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/uart_scml/1.0/tlmsrc/src/uart_register_bank.cc +129 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/uart_scml/1.0/tlmsrc/src/uart_serial_tx_rx.cc +145 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/uart_scml/1.0/uart_scml.xml +372 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/uart_tac/1.0/tlmsrc/include/Leon2_uart.h +216 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/uart_tac/1.0/tlmsrc/include/def_Leon2_uart.h +34 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/uart_tac/1.0/tlmsrc/include/tlm_field.h +72 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/uart_tac/1.0/tlmsrc/include/tlm_register.h +129 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/uart_tac/1.0/tlmsrc/include/tlmreg_Leon2_uart.h +133 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/uart_tac/1.0/tlmsrc/src/Leon2_uart.cc +316 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/uart_tac/1.0/tlmsrc/src/tlmreg_Leon2_uart.cc +197 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/uart_tac/1.0/tlmsrc/src/user_specific_Leon2_uart.cc +146 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/uart_tac/1.0/uart_tac.xml +222 -0
- data/spec/unit/component_spec.rb +98 -0
- data/spec/unit/graph_pathfinder_spec.rb +128 -0
- data/spec/unit/interconnect_spec.rb +177 -0
- data/spec/unit/ipxact_spec.rb +69 -0
- data/spec/unit/platform_spec.rb +34 -0
- metadata +225 -0
data/.autotest
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
|
2
|
+
require 'autotest/growl'
|
3
|
+
|
4
|
+
Autotest.add_hook(:initialize) {|at|
|
5
|
+
at.add_exception %r{^\.git} # ignore Version Control System
|
6
|
+
at.add_exception %r{^./tmp} # ignore temp files, lest autotest will run again, and again...
|
7
|
+
at.clear_mappings # take out the default (test/test*rb)
|
8
|
+
at.add_mapping(%r{^.*\.rb$}) {|f, _|
|
9
|
+
Dir['spec/**/*.rb']
|
10
|
+
}
|
11
|
+
at.add_mapping(%r{^ipxact/.*\.rb$}) {|f, _|
|
12
|
+
Dir['spec/*.rb']
|
13
|
+
}
|
14
|
+
nil
|
15
|
+
}
|
data/.gitignore
ADDED
data/README.html
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<!DOCTYPE html PUBLIC
|
3
|
+
"-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN"
|
4
|
+
"http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd">
|
5
|
+
<html xml:lang='en' xmlns:svg='http://www.w3.org/2000/svg' xmlns='http://www.w3.org/1999/xhtml'>
|
6
|
+
<head><meta content='application/xhtml+xml;charset=utf-8' http-equiv='Content-type' /><title>IPXACT-Ruby</title><link href='style.css' rel='stylesheet' type='text/css' />
|
7
|
+
</head>
|
8
|
+
<body>
|
9
|
+
<h1 id='ipxactruby'>IPXACT-Ruby</h1>
|
10
|
+
|
11
|
+
<p><strong>IPXACT-Ruby</strong> is a ruby library for extracting data from an <strong>IPXACT</strong> platform description. It was developed at <a href='http://tima-sls.imag.fr'>TIMA Laboratory</a>, France, for simplifying recurring platform parsing tasks. As such, this gem relies heavily on Aaron Patterson’s <a href='http://nokogiri.org'>Nokogiri gem</a> for parsing the XML data. This gem also provides methods for computing values that cannot be explicitly defined using the <strong>IPXACT</strong> format, such as component base addresses, relative to other components. Finally, please note that, in its current state, the <strong>IPXACT-Ruby</strong> gem does not handle all the aspects of the <strong>IPXACT</strong> format, but focuses on its <strong>Component</strong> and <strong>Design</strong> concepts .</p>
|
12
|
+
|
13
|
+
<h2 id='history'>History</h2>
|
14
|
+
|
15
|
+
<p>XXX Latest changes</p>
|
16
|
+
|
17
|
+
<h2 id='ipxact_format'>IPXACT format</h2>
|
18
|
+
|
19
|
+
<p><strong>IPXACT</strong> is an XML format for describing electronic components and their designs. First managed by the SPIRIT Consortium, the evolution of the format is now supervised by <a href='http://www.accelera.org'>Accelera</a>. Additionally, the <strong>IPXACT</strong> format is now an IEEE standard, under the reference <a href='http://standards.ieee.org/getieee/1685/index.html'>IEEE-1685</a>. Its full specification may be downloaded <a href='http://www.accellera.org/pressroom/2010/Get_1685_01Jun10.pdf'>here</a>.</p>
|
20
|
+
|
21
|
+
<h2 id='basic_usage'>Basic Usage</h2>
|
22
|
+
|
23
|
+
<p>An IPXACT platform is basically composed of two types of elements:</p>
|
24
|
+
|
25
|
+
<ul>
|
26
|
+
<li>
|
27
|
+
<p>Component files, which describe the structure of an IPXACT component</p>
|
28
|
+
|
29
|
+
<p>component_docs = IPXACT::load_components(COMPONENT_PATH) design_docs = IPXACT::load_designs(DESIGN_PATH)</p>
|
30
|
+
</li>
|
31
|
+
|
32
|
+
<li>
|
33
|
+
<p>Design files</p>
|
34
|
+
</li>
|
35
|
+
</ul>
|
36
|
+
|
37
|
+
<p>The whole platform will then be parsed by the IPXACT gem:</p>
|
38
|
+
|
39
|
+
<pre><code>platform = IPXACT::Parser::PlatformData.parse_platform(<platform_name>, component_docs, design_docs)</code></pre>
|
40
|
+
|
41
|
+
<p>Or if you’d rather specify the platform’s version that should be loaded:</p>
|
42
|
+
|
43
|
+
<pre><code>platform = IPXACT::Parser::PlatformData.parse_platform([<platform_name>, <platform_version>], \
|
44
|
+
component_docs, design_docs)</code></pre>
|
45
|
+
|
46
|
+
<p>In most cases, when methods require identifying a component you may use either specification:</p>
|
47
|
+
|
48
|
+
<ul>
|
49
|
+
<li><code><component_name></code> will fetch the most recent component.</li>
|
50
|
+
|
51
|
+
<li><code>[<component_name, <component_version>]</code> wil get the component with the specified version, thus allowing different component versions to coexist in the same path.</li>
|
52
|
+
</ul>
|
53
|
+
|
54
|
+
<p>Additionally, the same approach may be used for setting parsing constraints, which are passed as a final argument (<code>Array</code>) to the <code>parse_platform</code> method.</p>
|
55
|
+
|
56
|
+
<p>When builder the platform object, IPXACT will combine component and design descriptions, identify hierarchical components and parse subcomponents when possible. In fact, in platform should be considered as a component except for a basic method aliasing (the <code>subcomponents</code> and <code>subcomponents=</code> methods are respectively aliased to <code>components</code> and <code>components=</code>, for the sake of DSL legibility). Thus, a component is composed of:</p>
|
57
|
+
|
58
|
+
<ul>
|
59
|
+
<li><code>subcomponents</code></li>
|
60
|
+
|
61
|
+
<li><code>ports</code></li>
|
62
|
+
|
63
|
+
<li><code>interconnections</code>, which define how its subcomponents are connected with one another.</li>
|
64
|
+
|
65
|
+
<li><code>hierconnections</code>, which correspond the components’ connections between its ports and its subcomponents.</li>
|
66
|
+
</ul>
|
67
|
+
|
68
|
+
<p>For more information, please refer to the specs provided with the gem.</p>
|
69
|
+
|
70
|
+
<h2 id='installation'>Installation</h2>
|
71
|
+
|
72
|
+
<p>Standard gem install command:</p>
|
73
|
+
|
74
|
+
<pre><code>gem install ipxact</code></pre>
|
75
|
+
|
76
|
+
<h2 id='support'>Support</h2>
|
77
|
+
|
78
|
+
<ul>
|
79
|
+
<li>guillaume (dot) godetbar (at) gmail (dot) com</li>
|
80
|
+
</ul>
|
81
|
+
|
82
|
+
<h2 id='license'>License</h2>
|
83
|
+
|
84
|
+
<p>Copyright (C) 2010 TIMA Laboratory</p>
|
85
|
+
|
86
|
+
<p>This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.</p>
|
87
|
+
|
88
|
+
<p>This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.</p>
|
89
|
+
</body></html>
|
data/README.mdown
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
CSS: style.css
|
2
|
+
|
3
|
+
|
4
|
+
IPXACT-Ruby
|
5
|
+
===========
|
6
|
+
|
7
|
+
**IPXACT-Ruby** is a ruby library for extracting data from an **IPXACT** platform description. It was developed at [TIMA Laboratory](http://tima-sls.imag.fr), France, for simplifying recurring platform parsing tasks. As such, this gem relies heavily on Aaron Patterson's [Nokogiri gem](http://nokogiri.org) for parsing the XML data. This gem also provides methods for computing values that cannot be explicitly defined using the **IPXACT** format, such as component base addresses, relative to other components.
|
8
|
+
Finally, please note that, in its current state, the **IPXACT-Ruby** gem does not handle all the aspects of the **IPXACT** format, but focuses on its **Component** and **Design** concepts .
|
9
|
+
|
10
|
+
|
11
|
+
History
|
12
|
+
-------
|
13
|
+
|
14
|
+
XXX Latest changes
|
15
|
+
|
16
|
+
|
17
|
+
IPXACT format
|
18
|
+
-------------
|
19
|
+
|
20
|
+
**IPXACT** is an XML format for describing electronic components and their designs. First managed by the SPIRIT Consortium, the evolution of the format is now supervised by [Accelera](http://www.accelera.org). Additionally, the **IPXACT** format is now an IEEE standard, under the reference [IEEE-1685](http://standards.ieee.org/getieee/1685/index.html). Its full specification may be downloaded [here](http://www.accellera.org/pressroom/2010/Get_1685_01Jun10.pdf).
|
21
|
+
|
22
|
+
|
23
|
+
Basic Usage
|
24
|
+
-----------
|
25
|
+
An IPXACT platform is basically composed of two types of elements:
|
26
|
+
|
27
|
+
* Component files, which describe the structure of an IPXACT component
|
28
|
+
|
29
|
+
|
30
|
+
component_docs = IPXACT::load_components(COMPONENT_PATH)
|
31
|
+
design_docs = IPXACT::load_designs(DESIGN_PATH)
|
32
|
+
|
33
|
+
* Design files
|
34
|
+
|
35
|
+
The whole platform will then be parsed by the IPXACT gem:
|
36
|
+
|
37
|
+
platform = IPXACT::Parser::PlatformData.parse_platform(<platform_name>, component_docs, design_docs)
|
38
|
+
|
39
|
+
Or if you'd rather specify the platform's version that should be loaded:
|
40
|
+
|
41
|
+
platform = IPXACT::Parser::PlatformData.parse_platform([<platform_name>, <platform_version>], \
|
42
|
+
component_docs, design_docs)
|
43
|
+
|
44
|
+
In most cases, when methods require identifying a component you may use either specification:
|
45
|
+
|
46
|
+
* `<component_name>` will fetch the most recent component.
|
47
|
+
* `[<component_name, <component_version>]` wil get the component with the specified version, thus allowing different component versions to coexist in the same path.
|
48
|
+
|
49
|
+
Additionally, the same approach may be used for setting parsing constraints, which are passed as a final argument (`Array`) to the `parse_platform` method.
|
50
|
+
|
51
|
+
When builder the platform object, IPXACT will combine component and design
|
52
|
+
descriptions, identify hierarchical components and parse subcomponents when
|
53
|
+
possible. In fact, in platform should be considered as a component except for a
|
54
|
+
basic method aliasing (the `subcomponents` and `subcomponents=` methods are
|
55
|
+
respectively aliased to `components` and `components=`, for the sake of DSL
|
56
|
+
legibility). Thus, a component is composed of:
|
57
|
+
|
58
|
+
* `subcomponents`
|
59
|
+
* `ports`
|
60
|
+
* `interconnections`, which define how its subcomponents are connected with one another.
|
61
|
+
* `hierconnections`, which correspond the components' connections between its ports and its subcomponents.
|
62
|
+
|
63
|
+
For more information, please refer to the specs provided with the gem.
|
64
|
+
|
65
|
+
|
66
|
+
Installation
|
67
|
+
------------
|
68
|
+
|
69
|
+
Standard gem install command:
|
70
|
+
|
71
|
+
gem install ipxact-ruby
|
72
|
+
|
73
|
+
Support
|
74
|
+
-------
|
75
|
+
|
76
|
+
* guillaume (dot) godetbar (at) gmail (dot) com
|
77
|
+
|
78
|
+
License
|
79
|
+
-------
|
80
|
+
|
81
|
+
Copyright (C) 2010 TIMA Laboratory
|
82
|
+
|
83
|
+
This program is free software: you can redistribute it and/or modify
|
84
|
+
it under the terms of the GNU General Public License as published by
|
85
|
+
the Free Software Foundation, either version 3 of the License, or
|
86
|
+
(at your option) any later version.
|
87
|
+
|
88
|
+
This program is distributed in the hope that it will be useful,
|
89
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
90
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
91
|
+
GNU General Public License for more details.
|
data/Rakefile
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# Copyright (C) 2010 TIMA Laboratory
|
2
|
+
#
|
3
|
+
# This program is free software: you can redistribute it and/or modify
|
4
|
+
# it under the terms of the GNU General Public License as published by
|
5
|
+
# the Free Software Foundation, either version 3 of the License, or
|
6
|
+
# (at your option) any later version.
|
7
|
+
#
|
8
|
+
# This program is distributed in the hope that it will be useful,
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
11
|
+
# GNU General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU General Public License
|
14
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
15
|
+
#
|
16
|
+
|
17
|
+
begin
|
18
|
+
require 'jeweler'
|
19
|
+
Jeweler::Tasks.new do |gemspec|
|
20
|
+
gemspec.name = "ipxact-ruby"
|
21
|
+
gemspec.summary = "Ruby library for parsing IPXACT specifications and extracting relevant information."
|
22
|
+
gemspec.email = "guillaume.godetbar@gmail.com "
|
23
|
+
gemspec.homepage = "http://tima-sls.imag.fr"
|
24
|
+
gemspec.authors = ["Guillaume Godet-Bar"]
|
25
|
+
gemspec.files = FileList["{spec,schemas,autotest}/**/*", "lib/ipxact.rb", "lib/ipxact/*", "lib/ipxact/parser/*", "lib/ipxact/pathfinder/graph_pathfinder.rb", ".autotest", ".gitignore", "Rakefile", "VERSION"]
|
26
|
+
gemspec.add_dependency 'nokogiri'
|
27
|
+
end
|
28
|
+
rescue LoadError
|
29
|
+
puts "Jeweler not available. Install it with: gem install jeweler"
|
30
|
+
end
|
31
|
+
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.11.1
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# Copyright (C) 2010 TIMA Laboratory
|
2
|
+
#
|
3
|
+
# This program is free software: you can redistribute it and/or modify
|
4
|
+
# it under the terms of the GNU General Public License as published by
|
5
|
+
# the Free Software Foundation, either version 3 of the License, or
|
6
|
+
# (at your option) any later version.
|
7
|
+
#
|
8
|
+
# This program is distributed in the hope that it will be useful,
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
11
|
+
# GNU General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU General Public License
|
14
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
15
|
+
#
|
16
|
+
|
17
|
+
Autotest.add_discovery { "rspec2" }
|
data/lib/ipxact.rb
ADDED
@@ -0,0 +1,263 @@
|
|
1
|
+
# Copyright (C) 2010 TIMA Laboratory
|
2
|
+
#
|
3
|
+
# This program is free software: you can redistribute it and/or modify
|
4
|
+
# it under the terms of the GNU General Public License as published by
|
5
|
+
# the Free Software Foundation, either version 3 of the License, or
|
6
|
+
# (at your option) any later version.
|
7
|
+
#
|
8
|
+
# This program is distributed in the hope that it will be useful,
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
11
|
+
# GNU General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU General Public License
|
14
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
15
|
+
#
|
16
|
+
|
17
|
+
require 'nokogiri'
|
18
|
+
require 'set'
|
19
|
+
|
20
|
+
# Root and commodity module for the IPXACT Ruby library. In particular, this
|
21
|
+
# module should be used for loading the component design files.
|
22
|
+
#
|
23
|
+
# @example Default initialization process
|
24
|
+
# component_docs = IPXACT::load_components("my/component/path")
|
25
|
+
# design_docs = IPXACT::load_designs("my/design/path")
|
26
|
+
# platform = IPXACT::Parser::PlatformData::parse_platform("platform_id",
|
27
|
+
# component_docs, design_docs)
|
28
|
+
# @author Guillaume Godet-Bar
|
29
|
+
#
|
30
|
+
module IPXACT
|
31
|
+
|
32
|
+
# Path to the +design.xsd+ file
|
33
|
+
DESIGN_SCHEMA_PATH = File.join File.dirname(__FILE__), '../schemas/design.xsd'
|
34
|
+
|
35
|
+
# Path to the +component.xsd+ file
|
36
|
+
COMPONENT_SCHEMA_PATH = File.join File.dirname(__FILE__), '../schemas/component.xsd'
|
37
|
+
|
38
|
+
# Returns whether the XML file is an IPXACT component (i.e., it is consistent
|
39
|
+
# with the +component.xsd+ schema.
|
40
|
+
#
|
41
|
+
# @param [String] file_path path to the file that should be tested
|
42
|
+
#
|
43
|
+
# @return [Boolean] whether the file is a valid IPXACT component
|
44
|
+
#
|
45
|
+
def self.is_valid_component?(path)
|
46
|
+
raise ArgumentError unless path.is_a? String
|
47
|
+
|
48
|
+
component_schema_file = File.open(COMPONENT_SCHEMA_PATH)
|
49
|
+
component_schema = Nokogiri::XML::Schema(component_schema_file)
|
50
|
+
component_schema_file.close
|
51
|
+
|
52
|
+
component_file = File.open(path)
|
53
|
+
component_doc = Nokogiri::XML(component_file)
|
54
|
+
component_file.close
|
55
|
+
|
56
|
+
component_schema.validate(component_doc).size == 0
|
57
|
+
end
|
58
|
+
|
59
|
+
# Returns whether the XML file is an IPXACT design (i.e., it is consistent
|
60
|
+
# with the +design.xsd+ schema).
|
61
|
+
#
|
62
|
+
# @param [String] file_path path to the file that should be tested
|
63
|
+
#
|
64
|
+
# @return [Boolean] whether the file is a valid IPXACT design
|
65
|
+
#
|
66
|
+
def self.is_valid_design?(path)
|
67
|
+
raise ArgumentError unless path.is_a? String
|
68
|
+
|
69
|
+
design_schema_file = File.open(DESIGN_SCHEMA_PATH)
|
70
|
+
design_schema = Nokogiri::XML::Schema design_schema_file
|
71
|
+
design_schema_file.close
|
72
|
+
|
73
|
+
design_file = File.open(path)
|
74
|
+
design_doc = Nokogiri::XML(design_file)
|
75
|
+
design_file.close
|
76
|
+
|
77
|
+
design_schema.validate(design_doc).size == 0
|
78
|
+
end
|
79
|
+
|
80
|
+
# Returns the component's identifier (i.e., name, library, vendor, version).
|
81
|
+
#
|
82
|
+
# @param [String] path The path to the component's XML file
|
83
|
+
#
|
84
|
+
# @return [Hash] The component's identifier or nil if the path is invalid
|
85
|
+
#
|
86
|
+
def self.identifier(path)
|
87
|
+
if is_valid_design?(path) || is_valid_component?(path)
|
88
|
+
ipxact_file = File.open(path)
|
89
|
+
ipxact_doc = Nokogiri::XML(ipxact_file)
|
90
|
+
ipxact_file.close
|
91
|
+
|
92
|
+
{
|
93
|
+
:name => ipxact_doc.xpath("./*/spirit:name").first.text,
|
94
|
+
:vendor => ipxact_doc.xpath("./*/spirit:vendor").first.text,
|
95
|
+
:library => ipxact_doc.xpath("./*/spirit:library").first.text,
|
96
|
+
:version => ipxact_doc.xpath("./*/spirit:version").first.text
|
97
|
+
}
|
98
|
+
else
|
99
|
+
nil
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
|
104
|
+
# Loads the components from an IPXACT XML specification.
|
105
|
+
#
|
106
|
+
# @param [String] components_path path to the components of the target
|
107
|
+
# platform. All subdirectories will be
|
108
|
+
# scanned and all valid files (i.e., from an
|
109
|
+
# XML and +component.xsd+ schema point of
|
110
|
+
# view) are loaded into the resulting
|
111
|
+
# structure.
|
112
|
+
#
|
113
|
+
# @return [Hash] a Hash that associates the name and version of the component
|
114
|
+
# with the IPXACT XML (Nokogiri) structure of the component. No
|
115
|
+
# post-processing is made on this structure, which should not be used for
|
116
|
+
# any serious work (i.e.,its values may be modified when instantiating any
|
117
|
+
# design file linked to the components).
|
118
|
+
# @raise a generic exception if no component could be found.
|
119
|
+
#
|
120
|
+
def self.load_components(components_path)
|
121
|
+
component_schema_file = File.open(COMPONENT_SCHEMA_PATH)
|
122
|
+
component_schema = Nokogiri::XML::Schema(component_schema_file)
|
123
|
+
component_schema_file.close
|
124
|
+
|
125
|
+
xml_files = Dir.glob(File.join(components_path, "**", "*.xml"))
|
126
|
+
|
127
|
+
component_docs = xml_files.inject({}) do |acc, file|
|
128
|
+
component_file = File.open(file)
|
129
|
+
component_doc = Nokogiri::XML(component_file)
|
130
|
+
component_file.close
|
131
|
+
|
132
|
+
version_tag = component_doc.xpath("/spirit:component/spirit:version")
|
133
|
+
version = version_tag.first.nil? ? "0" : version_tag.first.text
|
134
|
+
|
135
|
+
name_tag = component_doc.xpath("/spirit:component/spirit:name")
|
136
|
+
name = name_tag.first.nil? ? nil : name_tag.first.text
|
137
|
+
|
138
|
+
unless name.nil?
|
139
|
+
key = [component_doc.xpath("/spirit:component/spirit:name").first.text, version]
|
140
|
+
acc[key] = component_doc \
|
141
|
+
if component_schema.validate(component_doc).size == 0
|
142
|
+
end
|
143
|
+
acc
|
144
|
+
end
|
145
|
+
|
146
|
+
raise 'No valid component was found!' if component_docs.keys.empty?
|
147
|
+
|
148
|
+
component_docs
|
149
|
+
end
|
150
|
+
|
151
|
+
# Loads the designs from an IPXACT XML specification.
|
152
|
+
#
|
153
|
+
# @param [String] designs_path a path to the design instances of the target
|
154
|
+
# platform. All subdirectories will be scanned and all valid
|
155
|
+
# files (i.e., from an XML and design.xsd schema point of
|
156
|
+
# view) are loaded into the resulting structure.
|
157
|
+
#
|
158
|
+
# @return [Hash] a Hash that associates the name and version of the design
|
159
|
+
# with the IPXACT XML (Nokogiri) structure of the design. Should not be used,
|
160
|
+
# as this is 'raw' IPXACT data.
|
161
|
+
#
|
162
|
+
# @raise a generic exception if no design document could be found.
|
163
|
+
#
|
164
|
+
def self.load_designs(designs_path)
|
165
|
+
design_schema_file = File.open(DESIGN_SCHEMA_PATH)
|
166
|
+
design_schema = Nokogiri::XML::Schema design_schema_file
|
167
|
+
design_schema_file.close
|
168
|
+
|
169
|
+
xml_files = Dir.glob(File.join(designs_path, "**", "*.xml"))
|
170
|
+
|
171
|
+
design_docs = xml_files.inject({}) do |acc, xml_file|
|
172
|
+
design_file = File.open(xml_file)
|
173
|
+
design_doc = Nokogiri::XML(design_file)
|
174
|
+
design_file.close
|
175
|
+
|
176
|
+
if design_schema.validate(design_doc).size == 0
|
177
|
+
|
178
|
+
design_name = design_doc.xpath("./spirit:design/spirit:name").text
|
179
|
+
design_version = design_doc.xpath("./spirit:design/spirit:version").text
|
180
|
+
|
181
|
+
acc[[design_name, design_version]] = design_doc
|
182
|
+
end
|
183
|
+
|
184
|
+
acc
|
185
|
+
end
|
186
|
+
|
187
|
+
raise 'No valid design could be found!' if design_docs.keys.empty?
|
188
|
+
|
189
|
+
design_docs
|
190
|
+
|
191
|
+
end
|
192
|
+
|
193
|
+
# Decides whether version_a is strictly more recent than version_b. Accepts
|
194
|
+
# any relaxed version of semantic versioning markup (i.e., +X(\.Y(\.Z)?)?+).
|
195
|
+
#
|
196
|
+
# @param [String] version_a a version number
|
197
|
+
# @param [String] version_b a version number
|
198
|
+
#
|
199
|
+
# @return [Boolean] a Boolean that states if +version_a > version_b+
|
200
|
+
#
|
201
|
+
def self.is_most_recent_version?(version_a, version_b)
|
202
|
+
split_a = version_a.split('.')
|
203
|
+
split_b = version_b.split('.')
|
204
|
+
|
205
|
+
split_a.each_with_index do |el,i|
|
206
|
+
return true if split_b.size <= i && el.to_i != 0
|
207
|
+
return true if el.to_i > split_b[i].to_i
|
208
|
+
end
|
209
|
+
|
210
|
+
false
|
211
|
+
end
|
212
|
+
|
213
|
+
# Decides whether version_a and version_b are the same version. Accepts any
|
214
|
+
# relaxed version of the semantic versioning markup (i.e., +X(\.Y(\.Z)?)?+).
|
215
|
+
# When comparing versions with different lengths, the method will 'pad' the
|
216
|
+
# shortest version string with 0s.
|
217
|
+
#
|
218
|
+
# @example
|
219
|
+
# IPXACT::is_same_version('1.0', '1.1')
|
220
|
+
# # => false
|
221
|
+
#
|
222
|
+
# IPXACT::is_same_version('1.0', '1.0')
|
223
|
+
# # => true
|
224
|
+
#
|
225
|
+
# IPXACT::is_same_version('1.0.0', '1.0')
|
226
|
+
# # => true
|
227
|
+
#
|
228
|
+
# IPXACT::is_same_version('1.0.1', '1.0')
|
229
|
+
# # => false
|
230
|
+
#
|
231
|
+
# @return [Boolean] a Boolean that states if +version_a == version_b+
|
232
|
+
# (relaxed equivalence)
|
233
|
+
#
|
234
|
+
def self.is_same_version?(version_a, version_b)
|
235
|
+
return !(self.is_most_recent_version?(version_a, version_b) || self.is_most_recent_version?(version_b, version_a))
|
236
|
+
end
|
237
|
+
|
238
|
+
# Parses an IPXACT reference element (i.e., any +spirit:hierarchyRef+ or
|
239
|
+
# +spirit:componentRef+).
|
240
|
+
#
|
241
|
+
# @param [Nokogiri::Node] reference The IPXACT reference, as an XML
|
242
|
+
# (Nokogiri) fragment
|
243
|
+
#
|
244
|
+
# @return [Hash] a Hash with the following keys:
|
245
|
+
# +:library+ the referenced element's library;
|
246
|
+
# +:name+ the referenced element's name;
|
247
|
+
# +:vendor+ the referenced element's vendor;
|
248
|
+
# +:version+ the referenced element's version.
|
249
|
+
#
|
250
|
+
def self.parse_reference(reference)
|
251
|
+
{
|
252
|
+
:library => reference['library'],
|
253
|
+
:name => reference['name'],
|
254
|
+
:vendor => reference['vendor'],
|
255
|
+
:version => reference['version']
|
256
|
+
}
|
257
|
+
end
|
258
|
+
end
|
259
|
+
|
260
|
+
require File.join File.dirname(__FILE__), 'ipxact/parser'
|
261
|
+
require File.join File.dirname(__FILE__), 'ipxact/platform'
|
262
|
+
require File.join File.dirname(__FILE__), 'ipxact/pathfinder/graph_pathfinder'
|
263
|
+
|