ipxact-ruby 0.11.2 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.11.2
1
+ 0.12.0
data/lib/ipxact.rb CHANGED
@@ -259,5 +259,6 @@ end
259
259
 
260
260
  require File.join File.dirname(__FILE__), 'ipxact/parser'
261
261
  require File.join File.dirname(__FILE__), 'ipxact/platform'
262
+ require File.join File.dirname(__FILE__), 'ipxact/register'
262
263
  require File.join File.dirname(__FILE__), 'ipxact/pathfinder/graph_pathfinder'
263
264
 
@@ -188,6 +188,15 @@ private
188
188
  # :access - The register's access (read-write,
189
189
  # read-only, write-only etc.), expressed as
190
190
  # a String.
191
+ # field_map - The list of register fields, if any. A
192
+ # field is composed of:
193
+ # :name - The field's name.
194
+ # :bitOffset - The field's offset.
195
+ # :bitWidth - The field's width.
196
+ # :access - The field's access (read-
197
+ # write, read-only, write-
198
+ # only, etc.), expressed
199
+ # as a String.
191
200
  #
192
201
  def self.extract_slave_data(bus_doc, host_component)
193
202
  memory_map_ref = bus_doc.xpath("./spirit:slave/spirit:memoryMapRef")
@@ -203,12 +212,23 @@ private
203
212
 
204
213
  registers_doc = address_block.xpath("./spirit:register")
205
214
  registers = registers_doc.collect do |register_doc|
206
- {
207
- :name => register_doc.xpath("./spirit:name").text,
208
- :offset => register_doc.xpath("./spirit:addressOffset").text,
209
- :size => register_doc.xpath("./spirit:size").text,
210
- :access => register_doc.xpath("./spirit:access").text
211
- }
215
+ register = IPXACT::Register.new
216
+ register[:name] = register_doc.xpath("./spirit:name").text
217
+ register[:offset] = register_doc.xpath("./spirit:addressOffset").text
218
+ register[:size] = register_doc.xpath("./spirit:size").text
219
+ register[:access] = register_doc.xpath("./spirit:access").text
220
+
221
+ fields_doc = register_doc.xpath("./spirit:field")
222
+ register.field_map = fields_doc.collect do |field_doc|
223
+ {
224
+ :name => field_doc.xpath('./spirit:name').text,
225
+ :bitOffset => field_doc.xpath('./spirit:bitOffset').text,
226
+ :bitWidth => field_doc.xpath('./spirit:bitWidth').text,
227
+ :access => field_doc.xpath('./spirit:access').text
228
+ }
229
+ end
230
+
231
+ register
212
232
  end
213
233
 
214
234
  address_block_data = {
@@ -0,0 +1,26 @@
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
+ # A {IPXACT::Register} holds the data relative to a component's registers. Most
18
+ # of the data is represented as a Ruby Hash, except for the registers's
19
+ # field_map, which corresponds to an array of Hashes.
20
+ #
21
+ # @author Guillaume Godet-Bar
22
+ #
23
+ class IPXACT::Register < Hash
24
+ attr_accessor :field_map
25
+
26
+ end
@@ -72,7 +72,61 @@ describe IPXACT::Component do
72
72
  :access => 'read-write'
73
73
  }
74
74
  )
75
+ end
76
+
77
+ it "should return an empty set if the current register has no field map" do
78
+ components = IPXACT::load_components(PLATFORM_PATH)
79
+ designs = IPXACT::load_designs(PLATFORM_PATH)
80
+ platform = IPXACT::Parser::PlatformData.parse_platform(["Leon2Platform", "1.1"], components, designs)
81
+
82
+ dma = platform.components['i_dma']
83
+ dma.should_not be_nil
84
+
85
+ registers = dma.register_map
86
+ registers.should include(
87
+ {
88
+ :name => 'sourceAddress',
89
+ :offset => '0x0',
90
+ :size => '32',
91
+ :access => 'read-write'
92
+ }
93
+ )
94
+
95
+ source_address_register = registers.select{|r| r[:name] == 'sourceAddress'}.first
96
+ source_address_register.field_map.should be_empty
97
+ end
98
+
99
+ it "should be able to get the bit fields for the 'control' register of a given dma device" do
100
+ components = IPXACT::load_components(PLATFORM_PATH)
101
+ designs = IPXACT::load_designs(PLATFORM_PATH)
102
+ platform = IPXACT::Parser::PlatformData.parse_platform(["Leon2Platform", "1.1"], components, designs)
103
+
104
+ dma = platform.components['i_dma']
105
+ dma.should_not be_nil
75
106
 
107
+ registers = dma.register_map
108
+ registers.should include(
109
+ {
110
+ :name => 'control',
111
+ :offset => '0x8',
112
+ :size => '32',
113
+ :access => 'read-write'
114
+ }
115
+ )
116
+
117
+ control_register = registers.select{|r| r[:name] == 'control'}.first
118
+ control_register.should_not be_nil
119
+ control_register.should be_a(IPXACT::Register)
120
+
121
+ fields = control_register.field_map
122
+ fields.should include(
123
+ {
124
+ :name => 'enable',
125
+ :bitOffset => '12',
126
+ :bitWidth => '1',
127
+ :access => 'write-only'
128
+ }
129
+ )
76
130
  end
77
131
 
78
132
  it "should raise an exception if the component has no register map" do
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 11
8
- - 2
9
- version: 0.11.2
7
+ - 12
8
+ - 0
9
+ version: 0.12.0
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-10-14 00:00:00 +02:00
17
+ date: 2010-11-13 00:00:00 +01:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -53,6 +53,7 @@ files:
53
53
  - lib/ipxact/parser/platform_data_parser.rb
54
54
  - lib/ipxact/pathfinder/graph_pathfinder.rb
55
55
  - lib/ipxact/platform.rb
56
+ - lib/ipxact/register.rb
56
57
  - schemas/abstractionDefinition.xsd
57
58
  - schemas/abstractor.xsd
58
59
  - schemas/autoConfigure.xsd