rggen-default-register-map 0.16.0 → 0.17.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4ed4f7d03fe2c3b316ce912c5080070214841e66c0b6c6e84d77beb2873c845d
|
4
|
+
data.tar.gz: 52521afda2eaea55d94fa19310b6c02db2fcb0d5f3ca5af7d7a22f62d5144aa8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 29148e29d7cdc8ac258f538a2c4c090746a6350d43d4cec5aa201af6b2dd59de421a916c55d727aad48fc7a52051fd7b8670d6cdd4e7908ae859c403ffb28d7a
|
7
|
+
data.tar.gz: dd74e27ee704d145f6009e544308c6884361d27a63c4f6e75e428f25a9656b0e62a8098a8982a2efac548a226564787907b20d72865ac97e4b7f549c05d6cb08
|
@@ -2,16 +2,35 @@
|
|
2
2
|
|
3
3
|
RgGen.define_simple_feature(:bit_field, :initial_value) do
|
4
4
|
register_map do
|
5
|
-
property :initial_value
|
6
|
-
property :
|
5
|
+
property :initial_value
|
6
|
+
property :initial_values
|
7
|
+
property :initial_value?, forward_to: :initial_value_set?
|
8
|
+
property :fixed_initial_value?, forward_to: :fixed?
|
9
|
+
property :initial_value_array?, forward_to: :array?
|
10
|
+
|
11
|
+
input_pattern parameterized: /default:(#{integer})/,
|
12
|
+
array: /#{integer}(?:[,\n]#{integer})+/
|
7
13
|
|
8
14
|
build do |value|
|
9
|
-
@
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
15
|
+
@input_format =
|
16
|
+
if value.is_a?(Hash) || match_index == :parameterized
|
17
|
+
:parameterized
|
18
|
+
elsif value.is_a?(Array) || match_index == :array
|
19
|
+
:array
|
20
|
+
else
|
21
|
+
:single
|
14
22
|
end
|
23
|
+
@initial_value, @initial_values = parse_initial_value(value)
|
24
|
+
end
|
25
|
+
|
26
|
+
define_helpers do
|
27
|
+
def verify_initial_value(&block)
|
28
|
+
initial_value_verifiers << create_verifier(&block)
|
29
|
+
end
|
30
|
+
|
31
|
+
def initial_value_verifiers
|
32
|
+
@initial_value_verifiers ||= []
|
33
|
+
end
|
15
34
|
end
|
16
35
|
|
17
36
|
verify(:component) do
|
@@ -20,40 +39,130 @@ RgGen.define_simple_feature(:bit_field, :initial_value) do
|
|
20
39
|
end
|
21
40
|
|
22
41
|
verify(:component) do
|
23
|
-
error_condition
|
42
|
+
error_condition do
|
43
|
+
@input_format == :array && !bit_field.sequential?
|
44
|
+
end
|
24
45
|
message do
|
25
|
-
'
|
26
|
-
"initial value #{initial_value} " \
|
27
|
-
"minimum initial value #{min_initial_value}"
|
46
|
+
'arrayed initial value is not allowed for non sequential bit field'
|
28
47
|
end
|
29
48
|
end
|
30
49
|
|
31
50
|
verify(:component) do
|
32
|
-
error_condition
|
33
|
-
|
34
|
-
'input initial value is greater than maximum initial value: ' \
|
35
|
-
"initial value #{initial_value} " \
|
36
|
-
"maximum initial value #{max_initial_value}"
|
51
|
+
error_condition do
|
52
|
+
@input_format == :array && initial_values.size > bit_field.sequence_size
|
37
53
|
end
|
54
|
+
message { 'too many initial values are given' }
|
38
55
|
end
|
39
56
|
|
40
57
|
verify(:component) do
|
41
|
-
error_condition
|
42
|
-
|
43
|
-
|
58
|
+
error_condition do
|
59
|
+
@input_format == :array && initial_values.size < bit_field.sequence_size
|
60
|
+
end
|
61
|
+
message { 'few initial values are given' }
|
62
|
+
end
|
63
|
+
|
64
|
+
verify(:component) do
|
65
|
+
check_error do
|
66
|
+
Array(initial_value || initial_values)
|
67
|
+
.each(&method(:verify_initial_value))
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
verify_initial_value do
|
72
|
+
error_condition { |value| value < min_initial_value }
|
73
|
+
message do |value|
|
74
|
+
'input initial value is less than minimum initial value: ' \
|
75
|
+
"initial value #{value} minimum initial value #{min_initial_value}"
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
verify_initial_value do
|
80
|
+
error_condition { |value| value > max_initial_value }
|
81
|
+
message do |value|
|
82
|
+
'input initial value is greater than maximum initial value: ' \
|
83
|
+
"initial value #{value} maximum initial value #{max_initial_value}"
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
verify_initial_value do
|
88
|
+
error_condition { |value| !match_valid_condition?(value) }
|
89
|
+
message do |value|
|
90
|
+
"does not match the valid initial value condition: #{value}"
|
44
91
|
end
|
45
92
|
end
|
46
93
|
|
47
94
|
printable(:initial_value) do
|
48
|
-
@
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
95
|
+
if @input_format == :parameterized
|
96
|
+
"default: #{format_value(initial_value)}"
|
97
|
+
elsif @input_format == :array
|
98
|
+
initial_values.map(&method(:format_value))
|
99
|
+
elsif initial_value?
|
100
|
+
format_value(initial_value)
|
101
|
+
end
|
53
102
|
end
|
54
103
|
|
55
104
|
private
|
56
105
|
|
106
|
+
def initial_value_format
|
107
|
+
@initial_value_format ||=
|
108
|
+
if @input_format == :parameterized
|
109
|
+
bit_field.sequential? && :array || :single
|
110
|
+
else
|
111
|
+
@input_format
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
def array?
|
116
|
+
initial_value_format == :array
|
117
|
+
end
|
118
|
+
|
119
|
+
def fixed?
|
120
|
+
[:array, :single].include?(@input_format)
|
121
|
+
end
|
122
|
+
|
123
|
+
def parse_initial_value(input_value)
|
124
|
+
if @input_format == :parameterized
|
125
|
+
[parse_parameterized_initial_value(input_value), nil]
|
126
|
+
elsif @input_format == :array
|
127
|
+
[nil, parse_arrayed_initial_value(input_value)]
|
128
|
+
else
|
129
|
+
[parse_value(input_value), nil]
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
def parse_parameterized_initial_value(input_value)
|
134
|
+
value =
|
135
|
+
if pattern_matched?
|
136
|
+
match_data.captures.first
|
137
|
+
else
|
138
|
+
input_value
|
139
|
+
.fetch(:default) { error 'no default value is given' }
|
140
|
+
end
|
141
|
+
parse_value(value)
|
142
|
+
end
|
143
|
+
|
144
|
+
def parse_arrayed_initial_value(input_value)
|
145
|
+
values =
|
146
|
+
if pattern_matched?
|
147
|
+
input_value.split(/[,\n]/)
|
148
|
+
else
|
149
|
+
input_value
|
150
|
+
end
|
151
|
+
values.map(&method(:parse_value))
|
152
|
+
end
|
153
|
+
|
154
|
+
def parse_value(value)
|
155
|
+
Integer(value)
|
156
|
+
rescue ArgumentError, TypeError
|
157
|
+
error "cannot convert #{value.inspect} into initial value"
|
158
|
+
end
|
159
|
+
|
160
|
+
def verify_initial_value(value)
|
161
|
+
helper.initial_value_verifiers.each do |verifier|
|
162
|
+
verifier.verify(self, value)
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
57
166
|
def settings
|
58
167
|
@settings ||=
|
59
168
|
(bit_field.settings && bit_field.settings[:initial_value]) || {}
|
@@ -67,9 +176,18 @@ RgGen.define_simple_feature(:bit_field, :initial_value) do
|
|
67
176
|
2**bit_field.width - 1
|
68
177
|
end
|
69
178
|
|
70
|
-
def match_valid_condition?
|
179
|
+
def match_valid_condition?(value)
|
71
180
|
!settings.key?(:valid_condition) ||
|
72
|
-
instance_exec(
|
181
|
+
instance_exec(value, &settings[:valid_condition])
|
182
|
+
end
|
183
|
+
|
184
|
+
def initial_value_set?
|
185
|
+
[@initial_value, @initial_values].any?
|
186
|
+
end
|
187
|
+
|
188
|
+
def format_value(value)
|
189
|
+
print_width = (bit_field.width + 3) / 4
|
190
|
+
format('0x%0*x', print_width, value)
|
73
191
|
end
|
74
192
|
end
|
75
193
|
end
|
@@ -3,35 +3,8 @@
|
|
3
3
|
RgGen.define_list_item_feature(:register, :type, :indirect) do
|
4
4
|
register_map do
|
5
5
|
define_helpers do
|
6
|
-
|
7
|
-
|
8
|
-
instance_eval(&block)
|
9
|
-
end
|
10
|
-
|
11
|
-
def error_condition(&block)
|
12
|
-
@error_condition = block
|
13
|
-
end
|
14
|
-
|
15
|
-
def message(&block)
|
16
|
-
@message = block
|
17
|
-
end
|
18
|
-
|
19
|
-
def verify(feature, index)
|
20
|
-
error?(feature, index) && raise_error(feature, index)
|
21
|
-
end
|
22
|
-
|
23
|
-
def error?(feature, index)
|
24
|
-
feature.instance_exec(index, &@error_condition)
|
25
|
-
end
|
26
|
-
|
27
|
-
def raise_error(feature, index)
|
28
|
-
error_message = feature.instance_exec(index, &@message)
|
29
|
-
feature.__send__(:error, error_message)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
define_method(:verify_index) do |&block|
|
34
|
-
index_verifiers << index_verifier.new(&block)
|
6
|
+
def verify_index(&block)
|
7
|
+
index_verifiers << create_verifier(&block)
|
35
8
|
end
|
36
9
|
|
37
10
|
def index_verifiers
|
@@ -95,7 +68,7 @@ RgGen.define_list_item_feature(:register, :type, :indirect) do
|
|
95
68
|
register.array? &&
|
96
69
|
register.array_size.length > array_index_fields.length
|
97
70
|
end
|
98
|
-
message { '
|
71
|
+
message { 'few array indices are given' }
|
99
72
|
end
|
100
73
|
|
101
74
|
verify(:all) do
|
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.
|
4
|
+
version: 0.17.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: 2019-
|
11
|
+
date: 2019-11-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -92,5 +92,5 @@ requirements: []
|
|
92
92
|
rubygems_version: 3.0.3
|
93
93
|
signing_key:
|
94
94
|
specification_version: 4
|
95
|
-
summary: rggen-default-register-map-0.
|
95
|
+
summary: rggen-default-register-map-0.17.0
|
96
96
|
test_files: []
|