rggen 0.12.0 → 0.13.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +13 -2
  3. data/lib/rggen.rb +0 -1
  4. data/lib/rggen/default.rb +7 -0
  5. data/lib/rggen/default_setup_file.rb +1 -2
  6. data/lib/rggen/version.rb +1 -3
  7. metadata +25 -81
  8. data/lib/rggen/built_in.rb +0 -57
  9. data/lib/rggen/built_in/bit_field/bit_assignment.rb +0 -114
  10. data/lib/rggen/built_in/bit_field/comment.rb +0 -18
  11. data/lib/rggen/built_in/bit_field/initial_value.rb +0 -75
  12. data/lib/rggen/built_in/bit_field/name.rb +0 -41
  13. data/lib/rggen/built_in/bit_field/reference.rb +0 -139
  14. data/lib/rggen/built_in/bit_field/sv_rtl_top.rb +0 -89
  15. data/lib/rggen/built_in/bit_field/type.rb +0 -245
  16. data/lib/rggen/built_in/bit_field/type/rc_w0c_w1c.erb +0 -15
  17. data/lib/rggen/built_in/bit_field/type/rc_w0c_w1c.rb +0 -59
  18. data/lib/rggen/built_in/bit_field/type/reserved.erb +0 -3
  19. data/lib/rggen/built_in/bit_field/type/reserved.rb +0 -16
  20. data/lib/rggen/built_in/bit_field/type/ro.erb +0 -6
  21. data/lib/rggen/built_in/bit_field/type/ro.rb +0 -31
  22. data/lib/rggen/built_in/bit_field/type/rof.erb +0 -6
  23. data/lib/rggen/built_in/bit_field/type/rof.rb +0 -17
  24. data/lib/rggen/built_in/bit_field/type/rs_w0s_w1s.erb +0 -13
  25. data/lib/rggen/built_in/bit_field/type/rs_w0s_w1s.rb +0 -46
  26. data/lib/rggen/built_in/bit_field/type/rw_wo.erb +0 -9
  27. data/lib/rggen/built_in/bit_field/type/rw_wo.rb +0 -30
  28. data/lib/rggen/built_in/bit_field/type/rwc_rwe_rwl.erb +0 -16
  29. data/lib/rggen/built_in/bit_field/type/rwc_rwe_rwl.rb +0 -92
  30. data/lib/rggen/built_in/bit_field/type/w0trg_w1trg.erb +0 -9
  31. data/lib/rggen/built_in/bit_field/type/w0trg_w1trg.rb +0 -29
  32. data/lib/rggen/built_in/global/address_width.rb +0 -34
  33. data/lib/rggen/built_in/global/array_port_format.rb +0 -19
  34. data/lib/rggen/built_in/global/bus_width.rb +0 -35
  35. data/lib/rggen/built_in/global/fold_sv_interface_port.rb +0 -24
  36. data/lib/rggen/built_in/register/markdown.erb +0 -11
  37. data/lib/rggen/built_in/register/markdown.rb +0 -26
  38. data/lib/rggen/built_in/register/name.rb +0 -36
  39. data/lib/rggen/built_in/register/offset_address.rb +0 -106
  40. data/lib/rggen/built_in/register/size.rb +0 -95
  41. data/lib/rggen/built_in/register/sv_rtl_top.rb +0 -82
  42. data/lib/rggen/built_in/register/type.rb +0 -344
  43. data/lib/rggen/built_in/register/type/default_sv_ral.erb +0 -8
  44. data/lib/rggen/built_in/register/type/default_sv_rtl.erb +0 -15
  45. data/lib/rggen/built_in/register/type/external.erb +0 -11
  46. data/lib/rggen/built_in/register/type/external.rb +0 -128
  47. data/lib/rggen/built_in/register/type/indirect.rb +0 -327
  48. data/lib/rggen/built_in/register/type/indirect_sv_ral.erb +0 -13
  49. data/lib/rggen/built_in/register/type/indirect_sv_rtl.erb +0 -17
  50. data/lib/rggen/built_in/register_block/byte_size.rb +0 -61
  51. data/lib/rggen/built_in/register_block/markdown.erb +0 -8
  52. data/lib/rggen/built_in/register_block/markdown.rb +0 -36
  53. data/lib/rggen/built_in/register_block/name.rb +0 -38
  54. data/lib/rggen/built_in/register_block/protocol.rb +0 -100
  55. data/lib/rggen/built_in/register_block/protocol/apb.erb +0 -10
  56. data/lib/rggen/built_in/register_block/protocol/apb.rb +0 -89
  57. data/lib/rggen/built_in/register_block/protocol/axi4lite.erb +0 -11
  58. data/lib/rggen/built_in/register_block/protocol/axi4lite.rb +0 -125
  59. data/lib/rggen/built_in/register_block/sv_ral_block_model.erb +0 -11
  60. data/lib/rggen/built_in/register_block/sv_ral_package.rb +0 -65
  61. data/lib/rggen/built_in/register_block/sv_rtl_macros.erb +0 -9
  62. data/lib/rggen/built_in/register_block/sv_rtl_top.rb +0 -86
  63. data/lib/rggen/built_in/version.rb +0 -7
  64. data/lib/rggen/setup/default.rb +0 -30
  65. data/sample/block_0.md +0 -155
  66. data/sample/block_0.rb +0 -90
  67. data/sample/block_0.sv +0 -678
  68. data/sample/block_0.xlsx +0 -0
  69. data/sample/block_0.yml +0 -99
  70. data/sample/block_0_ral_pkg.sv +0 -184
  71. data/sample/block_1.md +0 -39
  72. data/sample/block_1.rb +0 -22
  73. data/sample/block_1.sv +0 -136
  74. data/sample/block_1.xlsx +0 -0
  75. data/sample/block_1.yml +0 -26
  76. data/sample/block_1_ral_pkg.sv +0 -68
  77. data/sample/config.json +0 -5
  78. data/sample/config.yml +0 -3
@@ -1,75 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RgGen.define_simple_feature(:bit_field, :initial_value) do
4
- register_map do
5
- property :initial_value, default: 0
6
- property :initial_value?, body: -> { !@initial_value.nil? }
7
-
8
- build do |value|
9
- @initial_value =
10
- begin
11
- Integer(value)
12
- rescue ArgumentError, TypeError
13
- error "cannot convert #{value.inspect} into initial value"
14
- end
15
- end
16
-
17
- verify(:component) do
18
- error_condition { settings[:require] && !initial_value? }
19
- message { 'no initial value is given' }
20
- end
21
-
22
- verify(:component) do
23
- error_condition { initial_value? && initial_value < min_initial_value }
24
- message do
25
- 'input initial value is less than minimum initial value: ' \
26
- "initial value #{initial_value} " \
27
- "minimum initial value #{min_initial_value}"
28
- end
29
- end
30
-
31
- verify(:component) do
32
- error_condition { initial_value? && initial_value > max_initial_value }
33
- message do
34
- 'input initial value is greater than maximum initial value: ' \
35
- "initial value #{initial_value} " \
36
- "maximum initial value #{max_initial_value}"
37
- end
38
- end
39
-
40
- verify(:component) do
41
- error_condition { initial_value? && !match_valid_condition? }
42
- message do
43
- "does not match the valid initial value condition: #{initial_value}"
44
- end
45
- end
46
-
47
- printable(:initial_value) do
48
- @initial_value &&
49
- begin
50
- print_width = (bit_field.width + 3) / 4
51
- format('0x%0*x', print_width, @initial_value)
52
- end
53
- end
54
-
55
- private
56
-
57
- def settings
58
- @settings ||=
59
- (bit_field.settings && bit_field.settings[:initial_value]) || {}
60
- end
61
-
62
- def min_initial_value
63
- bit_field.width == 1 ? 0 : -(2**(bit_field.width - 1))
64
- end
65
-
66
- def max_initial_value
67
- 2**bit_field.width - 1
68
- end
69
-
70
- def match_valid_condition?
71
- !settings.key?(:valid_condition) ||
72
- instance_exec(@initial_value, &settings[:valid_condition])
73
- end
74
- end
75
- end
@@ -1,41 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RgGen.define_simple_feature(:bit_field, :name) do
4
- register_map do
5
- property :name
6
- property :full_name, forward_to: :get_full_name
7
-
8
- input_pattern variable_name
9
-
10
- build do |value|
11
- @name =
12
- if pattern_matched?
13
- match_data.to_s
14
- else
15
- error "illegal input value for bit field name: #{value.inspect}"
16
- end
17
- end
18
-
19
- verify(:feature) do
20
- error_condition { !name }
21
- message { 'no bit field name is given' }
22
- end
23
-
24
- verify(:feature) do
25
- error_condition { duplicated_name? }
26
- message { "duplicated bit field name: #{name}" }
27
- end
28
-
29
- printable :name
30
-
31
- private
32
-
33
- def get_full_name(separator = '.')
34
- [register.name, name].join(separator)
35
- end
36
-
37
- def duplicated_name?
38
- register.bit_fields.any? { |bit_field| bit_field.name == name }
39
- end
40
- end
41
- end
@@ -1,139 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RgGen.define_simple_feature(:bit_field, :reference) do
4
- register_map do
5
- property :reference, forward_to: :reference_bit_field, verify: :all
6
- property :reference?, body: -> { use_reference? && !no_reference? }
7
- property :reference_width, forward_to: :required_width
8
- property :find_reference, forward_to: :find_reference_bit_field
9
-
10
- input_pattern /(#{variable_name})\.(#{variable_name})/
11
-
12
- build do |value|
13
- @input_reference =
14
- if pattern_matched?
15
- "#{match_data[1]}.#{match_data[2]}"
16
- else
17
- error "illegal input value for reference: #{value.inspect}"
18
- end
19
- end
20
-
21
- verify(:component) do
22
- error_condition { require_reference? && no_reference? }
23
- message { 'no reference bit field is given' }
24
- end
25
-
26
- verify(:component) do
27
- error_condition { reference? && @input_reference == bit_field.full_name }
28
- message { "self reference: #{@input_reference}" }
29
- end
30
-
31
- verify(:all) do
32
- error_condition { reference? && !reference_bit_field }
33
- message { "no such bit field found: #{@input_reference}" }
34
- end
35
-
36
- verify(:all) do
37
- error_condition do
38
- reference? && !register.array? && reference_bit_field.register.array?
39
- end
40
- message do
41
- 'bit field of array register is not allowed for ' \
42
- "reference bit field: #{@input_reference}"
43
- end
44
- end
45
-
46
- verify(:all) do
47
- error_condition { reference? && !match_array_size? }
48
- message do
49
- 'array size is not matched: ' \
50
- "own #{register.array_size} " \
51
- "reference #{reference_bit_field.register.array_size}"
52
- end
53
- end
54
-
55
- verify(:all) do
56
- error_condition do
57
- reference? && !bit_field.sequential? && reference_bit_field.sequential?
58
- end
59
- message do
60
- 'sequential bit field is not allowed for ' \
61
- "reference bit field: #{@input_reference}"
62
- end
63
- end
64
-
65
- verify(:all) do
66
- error_condition { reference? && !match_sequence_size? }
67
- message do
68
- 'sequence size is not matched: ' \
69
- "own #{bit_field.sequence_size} " \
70
- "reference #{reference_bit_field.sequence_size}"
71
- end
72
- end
73
-
74
- verify(:all) do
75
- error_condition { reference? && reference_bit_field.reserved? }
76
- message { "refer to reserved bit field: #{@input_reference}" }
77
- end
78
-
79
- verify(:all) do
80
- error_condition { reference? && !match_width? }
81
- message do
82
- "#{required_width} bits reference bit field is required: " \
83
- "#{reference_bit_field.width} bit(s) width"
84
- end
85
- end
86
-
87
- private
88
-
89
- def settings
90
- @settings ||=
91
- (bit_field.settings && bit_field.settings[:reference]) || {}
92
- end
93
-
94
- def use_reference?
95
- settings.fetch(:use, false)
96
- end
97
-
98
- def require_reference?
99
- use_reference? && settings[:require]
100
- end
101
-
102
- def no_reference?
103
- @input_reference.nil?
104
- end
105
-
106
- def reference_bit_field
107
- (reference? || nil) &&
108
- (@reference_bit_field ||= lookup_reference)
109
- end
110
-
111
- def find_reference_bit_field(bit_fields)
112
- (reference? || nil) &&
113
- bit_fields
114
- .find { |bit_field| bit_field.full_name == @input_reference }
115
- end
116
-
117
- def lookup_reference
118
- find_reference_bit_field(register_block.bit_fields)
119
- end
120
-
121
- def match_array_size?
122
- !(register.array? && reference_bit_field.register.array?) ||
123
- register.array_size == reference_bit_field.register.array_size
124
- end
125
-
126
- def match_sequence_size?
127
- !(bit_field.sequential? && reference_bit_field.sequential?) ||
128
- bit_field.sequence_size == reference_bit_field.sequence_size
129
- end
130
-
131
- def required_width
132
- settings[:width] || bit_field.width
133
- end
134
-
135
- def match_width?
136
- reference_bit_field.width >= required_width
137
- end
138
- end
139
- end
@@ -1,89 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RgGen.define_simple_feature(:bit_field, :sv_rtl_top) do
4
- sv_rtl do
5
- export :local_index
6
- export :loop_variables
7
- export :array_size
8
- export :value
9
-
10
- build do
11
- interface :bit_field, :bit_field_sub_if, {
12
- name: 'bit_field_sub_if',
13
- interface_type: 'rggen_bit_field_if',
14
- parameter_values: [bit_field.width]
15
- }
16
- end
17
-
18
- main_code :register do
19
- local_scope("g_#{bit_field.name}") do |scope|
20
- scope.loop_size loop_size
21
- scope.variables variables
22
- scope.body(&method(:body_code))
23
- end
24
- end
25
-
26
- pre_code :bit_field do |code|
27
- code << bit_field_if_connection << nl
28
- end
29
-
30
- def local_index
31
- (bit_field.sequential? || nil) &&
32
- create_identifier(index_name)
33
- end
34
-
35
- def index_name
36
- depth = (register.loop_variables&.size || 0) + 1
37
- loop_index(depth)
38
- end
39
-
40
- def loop_variables
41
- (inside_loop? || nil) &&
42
- [*register.loop_variables, local_index].compact
43
- end
44
-
45
- def array_size
46
- (inside_loop? || nil) &&
47
- [*register.array_size, bit_field.sequence_size].compact
48
- end
49
-
50
- def value(register_offset = nil, bit_field_offset = nil, width = nil)
51
- bit_field_offset ||= local_index
52
- width ||= bit_field.width
53
- register_block
54
- .register_if[register.index(register_offset)]
55
- .value[bit_field.lsb(bit_field_offset), width]
56
- end
57
-
58
- private
59
-
60
- def inside_loop?
61
- register.array? || bit_field.sequential?
62
- end
63
-
64
- def loop_size
65
- (bit_field.sequential? || nil) &&
66
- { index_name => bit_field.sequence_size }
67
- end
68
-
69
- def variables
70
- bit_field.declarations(:bit_field, :variable)
71
- end
72
-
73
- def body_code(code)
74
- bit_field.generate_code(:bit_field, :top_down, code)
75
- end
76
-
77
- def bit_field_if_connection
78
- macro_call(
79
- :rggen_connect_bit_field_if,
80
- [
81
- register.bit_field_if,
82
- bit_field.bit_field_sub_if,
83
- bit_field.lsb(local_index),
84
- bit_field.width
85
- ]
86
- )
87
- end
88
- end
89
- end
@@ -1,245 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RgGen.define_list_feature(:bit_field, :type) do
4
- register_map do
5
- base_feature do
6
- define_helpers do
7
- def read_write
8
- @readable = true
9
- @writable = true
10
- end
11
-
12
- def read_only
13
- @readable = true
14
- @writable = false
15
- end
16
-
17
- def write_only
18
- @readable = false
19
- @writable = true
20
- end
21
-
22
- def reserved
23
- @readable = false
24
- @writable = false
25
- end
26
-
27
- def readable?
28
- @readable.nil? || @readable
29
- end
30
-
31
- def writable?
32
- @writable.nil? || @writable
33
- end
34
-
35
- def volatile
36
- @volatility = -> { true }
37
- end
38
-
39
- def non_volatile
40
- @volatility = -> { false }
41
- end
42
-
43
- def volatile?(&block)
44
- @volatility = block
45
- end
46
-
47
- attr_reader :volatility
48
-
49
- def settings
50
- @settings ||= {}
51
- end
52
-
53
- def initial_value(**setting)
54
- settings[:initial_value] = setting
55
- end
56
-
57
- def reference(**setting)
58
- settings[:reference] = setting
59
- end
60
- end
61
-
62
- property :type
63
- property :readable?, forward_to_helper: true
64
- property :writable?, forward_to_helper: true
65
- property :read_only?, body: -> { readable? && !writable? }
66
- property :write_only?, body: -> { writable? && !readable? }
67
- property :reserved?, body: -> { !(readable? || writable?) }
68
- property :volatile?, forward_to: :volatility
69
- property :settings, forward_to_helper: true
70
-
71
- build { |value| @type = value }
72
-
73
- printable :type
74
-
75
- private
76
-
77
- def volatility
78
- if @volatility.nil?
79
- @volatility =
80
- helper.volatility.nil? || instance_exec(&helper.volatility)
81
- end
82
- @volatility
83
- end
84
- end
85
-
86
- default_feature do
87
- verify(:feature) do
88
- error_condition { !type }
89
- message { 'no bit field type is given' }
90
- end
91
-
92
- verify(:feature) do
93
- error_condition { type }
94
- message { "unknown bit field type: #{type.inspect}" }
95
- end
96
- end
97
-
98
- factory do
99
- convert_value do |value|
100
- types = target_features.keys
101
- types.find(&value.to_sym.method(:casecmp?)) || value
102
- end
103
-
104
- def select_feature(cell)
105
- target_features[cell.value]
106
- end
107
- end
108
- end
109
-
110
- sv_rtl do
111
- base_feature do
112
- private
113
-
114
- def array_port_format
115
- configuration.array_port_format
116
- end
117
-
118
- def full_name
119
- bit_field.full_name('_')
120
- end
121
-
122
- def width
123
- bit_field.width
124
- end
125
-
126
- def array_size
127
- bit_field.array_size
128
- end
129
-
130
- def initial_value
131
- hex(bit_field.initial_value, bit_field.width)
132
- end
133
-
134
- def mask
135
- reference_bit_field ||
136
- hex(2**bit_field.width - 1, bit_field.width)
137
- end
138
-
139
- def reference_bit_field
140
- bit_field.reference? &&
141
- bit_field
142
- .find_reference(register_block.bit_fields)
143
- .value(
144
- register.local_index,
145
- bit_field.local_index,
146
- bit_field.reference_width
147
- )
148
- end
149
-
150
- def bit_field_if
151
- bit_field.bit_field_sub_if
152
- end
153
-
154
- def loop_variables
155
- bit_field.loop_variables
156
- end
157
- end
158
-
159
- factory do
160
- def select_feature(_configuration, bit_field)
161
- target_features[bit_field.type]
162
- end
163
- end
164
- end
165
-
166
- sv_ral do
167
- base_feature do
168
- define_helpers do
169
- attr_setter :access
170
-
171
- def model_name(name = nil, &block)
172
- @model_name = name || block || @model_name
173
- @model_name
174
- end
175
- end
176
-
177
- export :access
178
- export :model_name
179
- export :constructors
180
-
181
- build do
182
- variable :register, :ral_model, {
183
- name: bit_field.name,
184
- data_type: model_name,
185
- array_size: array_size,
186
- random: true
187
- }
188
- end
189
-
190
- def access
191
- (helper.access || bit_field.type).to_s.upcase
192
- end
193
-
194
- def model_name
195
- if helper.model_name&.is_a?(Proc)
196
- instance_eval(&helper.model_name)
197
- else
198
- helper.model_name || :rggen_ral_field
199
- end
200
- end
201
-
202
- def constructors
203
- (bit_field.sequence_size&.times || [nil]).map do |index|
204
- macro_call(
205
- :rggen_ral_create_field_model, arguments(index)
206
- )
207
- end
208
- end
209
-
210
- private
211
-
212
- def array_size
213
- Array(bit_field.sequence_size)
214
- end
215
-
216
- def arguments(index)
217
- [
218
- ral_model[index], bit_field.lsb(index), bit_field.width,
219
- access, volatile, reset_value, valid_reset
220
- ]
221
- end
222
-
223
- def volatile
224
- bit_field.volatile? && 1 || 0
225
- end
226
-
227
- def reset_value
228
- hex(bit_field.initial_value, bit_field.width)
229
- end
230
-
231
- def valid_reset
232
- bit_field.initial_value? && 1 || 0
233
- end
234
- end
235
-
236
- default_feature do
237
- end
238
-
239
- factory do
240
- def select_feature(_configuration, bit_field)
241
- target_features[bit_field.type]
242
- end
243
- end
244
- end
245
- end