rggen-default-register-map 0.24.0 → 0.25.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 31786d4f412d28362fe13510c065488bdcc4f630e70323d8bfd00f18252d4889
4
- data.tar.gz: 2acbf4af3aecaf5b95e2f209b995a9c7a2638e19e3ded7b77c097f9161472e8d
3
+ metadata.gz: 4a0b6e48b3b6da6739cbe958694f2a1cf45f22532b41fcc47f7d1eb6cc10869e
4
+ data.tar.gz: 3eaf3ebd9bd36133bd024cf65858fee3349322c65a43071bfd8b0dd390e4b067
5
5
  SHA512:
6
- metadata.gz: 1b04ed8512a8cdc99e43864778926d59d1497d00a99c031eaea61887104d993ebdb84e8034ee6ae09fccd5e8b22b552761c0dbad1332c95aa96a9d47c9922a92
7
- data.tar.gz: a1ace1cd824758b1f6a349d4586d04b05bee0f48a2c17a6f4d49375a7895b80573d654871e0c254578fb79681a98d244323ebc3f6bcd548b4c0119a6f1ea1703
6
+ metadata.gz: e76010e8a516197774b91c23a738c4c7b510e351d083a4bdb9c4b2e6455037e801f451ffdfc2bb58f45a23cb3904ddd25995f8c2eddb40da4e1dde396c82f208
7
+ data.tar.gz: 33edbad2da7140c757901aa8bebdae1b17fbe81209e51864fde2ef7be7d41d8fd971ad7e861fa60075eeb27ab76a97347d6080e387811343fc72713e8932a17c
@@ -39,6 +39,7 @@ module RgGen
39
39
  'default_register_map/register/type',
40
40
  'default_register_map/register/type/external',
41
41
  'default_register_map/register/type/indirect',
42
+ 'default_register_map/register/type/reserved',
42
43
  'default_register_map/register_block/byte_size',
43
44
  'default_register_map/register_block/name',
44
45
  'default_register_map/register_file/name',
@@ -1,6 +1,19 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  RgGen.define_simple_feature(:bit_field, :bit_assignment) do
4
+ configuration do
5
+ property :bit_assignment, default: :width_first
6
+
7
+ input_pattern [width_first: /width_first/i, lsb_first: /lsb_first/i]
8
+ ignore_empty_value false
9
+
10
+ build do |value|
11
+ pattern_matched? ||
12
+ (error "illegal input value for bit assignment: #{value.inspect}")
13
+ @bit_assignment = match_index
14
+ end
15
+ end
16
+
4
17
  register_map do
5
18
  property :lsb, forward_to: :lsb_bit
6
19
  property :msb, forward_to: :msb_bit
@@ -15,7 +28,9 @@ RgGen.define_simple_feature(:bit_field, :bit_assignment) do
15
28
 
16
29
  build do |value|
17
30
  input_value = preprocess(value)
18
- helper.variable_keys.each { |key| parse_value(input_value, key) }
31
+ helper.variable_names.each do |key, variable_name|
32
+ parse_value(input_value, key, variable_name)
33
+ end
19
34
  end
20
35
 
21
36
  verify(:feature) do
@@ -64,13 +79,9 @@ RgGen.define_simple_feature(:bit_field, :bit_assignment) do
64
79
  define_helpers do
65
80
  def variable_names
66
81
  @variable_names ||= {
67
- lsb: :@lsb_base, width: :@width, sequence_size: :@sequence_size, step: :@step
82
+ width: :@width, lsb: :@lsb_base, sequence_size: :@sequence_size, step: :@step
68
83
  }.freeze
69
84
  end
70
-
71
- def variable_keys
72
- @variable_keys ||= variable_names.keys
73
- end
74
85
  end
75
86
 
76
87
  def preprocess(value)
@@ -87,13 +98,24 @@ RgGen.define_simple_feature(:bit_field, :bit_assignment) do
87
98
  match_data
88
99
  .to_s
89
100
  .split(':')
90
- .map.with_index { |value, i| [helper.variable_keys[i], value] }
101
+ .map.with_index { |value, i| [variable_key(i), value] }
91
102
  .to_h
92
103
  end
93
104
 
94
- def parse_value(input_value, key)
105
+ def variable_key(index)
106
+ @keys ||=
107
+ if configuration.bit_assignment == :width_first
108
+ helper.variable_names.keys
109
+ else
110
+ keys = helper.variable_names.keys
111
+ [keys[1], keys[0], *keys[2..-1]]
112
+ end
113
+ @keys[index]
114
+ end
115
+
116
+ def parse_value(input_value, key, variable_name)
95
117
  input_value.key?(key) &&
96
- instance_variable_set(helper.variable_names[key], Integer(input_value[key]))
118
+ instance_variable_set(variable_name, Integer(input_value[key]))
97
119
  rescue ArgumentError, TypeError
98
120
  error "cannot convert #{input_value[key].inspect} into " \
99
121
  "bit assignment(#{key.to_s.tr('_', ' ')})"
@@ -82,6 +82,11 @@ RgGen.define_list_feature(:bit_field, :type) do
82
82
 
83
83
  build { |value| @type = value }
84
84
 
85
+ build do |value|
86
+ @type = value
87
+ helper.reserved? && bit_field.document_only
88
+ end
89
+
85
90
  printable :type
86
91
 
87
92
  private
@@ -5,12 +5,9 @@ RgGen.define_simple_feature(:global, :address_width) do
5
5
  property :address_width, default: 32
6
6
 
7
7
  build do |value|
8
- @address_width =
9
- begin
10
- Integer(value)
11
- rescue ArgumentError, TypeError
12
- error "cannot convert #{value.inspect} into address width"
13
- end
8
+ @address_width = Integer(value)
9
+ rescue ArgumentError, TypeError
10
+ error "cannot convert #{value.inspect} into address width"
14
11
  end
15
12
 
16
13
  verify(:component) do
@@ -6,12 +6,9 @@ RgGen.define_simple_feature(:global, :bus_width) do
6
6
  property :byte_width, initial: -> { bus_width / 8 }
7
7
 
8
8
  build do |value|
9
- @bus_width =
10
- begin
11
- Integer(value)
12
- rescue ArgumentError, TypeError
13
- error "cannot convert #{value.inspect} into bus width"
14
- end
9
+ @bus_width = Integer(value)
10
+ rescue ArgumentError, TypeError
11
+ error "cannot convert #{value.inspect} into bus width"
15
12
  end
16
13
 
17
14
  verify(:feature) do
@@ -5,15 +5,12 @@ RgGen.define_simple_feature(:register, :offset_address) do
5
5
  property :offset_address, initial: -> { default_offset_address }
6
6
  property :expanded_offset_addresses, forward_to: :expand_addresses
7
7
  property :address_range, initial: -> { start_address..end_address }
8
- property :overlap?, forward_to: :overlap_address_range?
8
+ property :overlap?, body: ->(other) { overlap_address_range?(other, false) }
9
9
 
10
10
  build do |value|
11
- @offset_address =
12
- begin
13
- Integer(value)
14
- rescue ArgumentError, TypeError
15
- error "cannot convert #{value.inspect} into offset address"
16
- end
11
+ @offset_address = Integer(value)
12
+ rescue ArgumentError, TypeError
13
+ error "cannot convert #{value.inspect} into offset address"
17
14
  end
18
15
 
19
16
  verify(:feature) do
@@ -44,7 +41,7 @@ RgGen.define_simple_feature(:register, :offset_address) do
44
41
  verify(:component) do
45
42
  error_condition do
46
43
  files_and_registers.any? do |other|
47
- overlap_address_range?(other) && exclusive_range?(other)
44
+ overlap_address_range?(other, true)
48
45
  end
49
46
  end
50
47
  message do
@@ -96,8 +93,9 @@ RgGen.define_simple_feature(:register, :offset_address) do
96
93
  configuration.byte_width
97
94
  end
98
95
 
99
- def overlap_address_range?(other)
100
- overlap_range?(other) && competitive_access?(other)
96
+ def overlap_address_range?(other, sharable)
97
+ overlap_range?(other) &&
98
+ (exclusive_range?(other) || competitive_access?(other, sharable))
101
99
  end
102
100
 
103
101
  def overlap_range?(other)
@@ -106,13 +104,17 @@ RgGen.define_simple_feature(:register, :offset_address) do
106
104
  self_range.include?(othre_range.first) || othre_range.include?(self_range.first)
107
105
  end
108
106
 
109
- def competitive_access?(other)
110
- other.register_file? ||
107
+ def exclusive_range?(other)
108
+ other.register_file? || other.reserved? || register.reserved?
109
+ end
110
+
111
+ def competitive_access?(other, sharable)
112
+ !sharable_range?(other, sharable) &&
111
113
  [:writable?, :readable?].any? { |access| [register, other].all?(&access) }
112
114
  end
113
115
 
114
- def exclusive_range?(other)
115
- other.register_file? || !(shared_address? && register.match_type?(other))
116
+ def sharable_range?(other, sharable)
117
+ sharable && shared_address? && register.match_type?(other)
116
118
  end
117
119
 
118
120
  def shared_address?
@@ -40,6 +40,7 @@ RgGen.define_list_feature(:register, :type) do
40
40
  property :match_type?, body: ->(register) { register.type == type }
41
41
  property :writable?, initial: -> { writability }
42
42
  property :readable?, initial: -> { readability }
43
+ property :reserved?, initial: -> { !(writable? || readable?) }
43
44
  property :settings, forward_to_helper: true
44
45
 
45
46
  build do |value|
@@ -48,6 +49,10 @@ RgGen.define_list_feature(:register, :type) do
48
49
  helper.need_bit_fields? || register.need_no_children
49
50
  end
50
51
 
52
+ post_build do
53
+ reserved? && register.document_only
54
+ end
55
+
51
56
  verify(:component) do
52
57
  error_condition do
53
58
  helper.need_bit_fields? && register.bit_fields.empty?
@@ -62,22 +67,13 @@ RgGen.define_list_feature(:register, :type) do
62
67
  attr_reader :options
63
68
 
64
69
  def writability
65
- instance_exec(&(helper.writability || default_writability))
66
- end
67
-
68
- def default_writability
69
- -> { register.bit_fields.any?(&:writable?) }
70
+ block = helper.writability || -> { register.bit_fields.any?(&:writable?) }
71
+ instance_exec(&block)
70
72
  end
71
73
 
72
74
  def readability
73
- instance_exec(&(helper.readability || default_readability))
74
- end
75
-
76
- def default_readability
77
- lambda do
78
- block = ->(bit_field) { bit_field.readable? || bit_field.reserved? }
79
- register.bit_fields.any?(&block)
80
- end
75
+ block = helper.readability || -> { register.bit_fields.any?(&:readable?) }
76
+ instance_exec(&block)
81
77
  end
82
78
  end
83
79
 
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ RgGen.define_list_item_feature(:register, :type, :reserved) do
4
+ register_map do
5
+ writable? { false }
6
+ readable? { false }
7
+ no_bit_fields
8
+ support_array_register
9
+ end
10
+ end
@@ -6,13 +6,10 @@ RgGen.define_simple_feature(:register_block, :byte_size) do
6
6
  property :local_address_width
7
7
 
8
8
  build do |value|
9
- @byte_size =
10
- begin
11
- Integer(value)
12
- rescue ArgumentError, TypeError
13
- error "cannot convert #{value.inspect} into byte size"
14
- end
9
+ @byte_size = Integer(value)
15
10
  @local_address_width = (@byte_size - 1).bit_length
11
+ rescue ArgumentError, TypeError
12
+ error "cannot convert #{value.inspect} into byte size"
16
13
  end
17
14
 
18
15
  verify(:feature) do
@@ -7,12 +7,9 @@ RgGen.define_simple_feature(:register_file, :offset_address) do
7
7
  property :address_range, initial: -> { start_address..end_address }
8
8
 
9
9
  build do |value|
10
- @offset_address =
11
- begin
12
- Integer(value)
13
- rescue ArgumentError, TypeError
14
- error "cannot convert #{value.inspect} into offset address"
15
- end
10
+ @offset_address = Integer(value)
11
+ rescue ArgumentError, TypeError
12
+ error "cannot convert #{value.inspect} into offset address"
16
13
  end
17
14
 
18
15
  verify(:feature) do
@@ -13,7 +13,7 @@ RgGen.register_plugin RgGen::DefaultRegisterMap do |builder|
13
13
  builder.enable :register, [
14
14
  :name, :offset_address, :size, :type, :comment
15
15
  ]
16
- builder.enable :register, :type, [:external, :indirect]
16
+ builder.enable :register, :type, [:external, :indirect, :reserved]
17
17
  builder.enable :bit_field, [
18
18
  :name, :bit_assignment, :type, :initial_value, :reference, :comment
19
19
  ]
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RgGen
4
4
  module DefaultRegisterMap
5
- VERSION = '0.24.0'
5
+ VERSION = '0.25.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rggen-default-register-map
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.24.0
4
+ version: 0.25.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Taichi Ishitani
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-01-20 00:00:00.000000000 Z
11
+ date: 2021-02-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -66,6 +66,7 @@ files:
66
66
  - lib/rggen/default_register_map/register/type.rb
67
67
  - lib/rggen/default_register_map/register/type/external.rb
68
68
  - lib/rggen/default_register_map/register/type/indirect.rb
69
+ - lib/rggen/default_register_map/register/type/reserved.rb
69
70
  - lib/rggen/default_register_map/register_block/byte_size.rb
70
71
  - lib/rggen/default_register_map/register_block/name.rb
71
72
  - lib/rggen/default_register_map/register_file/name.rb
@@ -89,7 +90,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
89
90
  requirements:
90
91
  - - ">="
91
92
  - !ruby/object:Gem::Version
92
- version: '2.4'
93
+ version: '2.5'
93
94
  required_rubygems_version: !ruby/object:Gem::Requirement
94
95
  requirements:
95
96
  - - ">="
@@ -99,5 +100,5 @@ requirements: []
99
100
  rubygems_version: 3.2.3
100
101
  signing_key:
101
102
  specification_version: 4
102
- summary: rggen-default-register-map-0.24.0
103
+ summary: rggen-default-register-map-0.25.0
103
104
  test_files: []