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,8 +0,0 @@
1
- function new(string name);
2
- super.new(name, <%= register.width%>, 0);
3
- endfunction
4
- function void build();
5
- <% field_model_constructors.each do |constructor| %>
6
- <%= constructor %>
7
- <% end%>
8
- endfunction
@@ -1,15 +0,0 @@
1
- rggen_default_register #(
2
- .READABLE (<%= readable %>),
3
- .WRITABLE (<%= writable %>),
4
- .ADDRESS_WIDTH (<%= address_width %>),
5
- .OFFSET_ADDRESS (<%= offset_address %>),
6
- .BUS_WIDTH (<%= bus_width %>),
7
- .DATA_WIDTH (<%= width %>),
8
- .VALID_BITS (<%= valid_bits %>),
9
- .REGISTER_INDEX (<%= register_index %>)
10
- ) u_register (
11
- .i_clk (<%= register_block.clock %>),
12
- .i_rst_n (<%= register_block.reset %>),
13
- .register_if (<%= register_if %>),
14
- .bit_field_if (<%= bit_field_if %>)
15
- );
@@ -1,11 +0,0 @@
1
- rggen_external_register #(
2
- .ADDRESS_WIDTH (<%= address_width %>),
3
- .BUS_WIDTH (<%= bus_width %>),
4
- .START_ADDRESS (<%= start_address %>),
5
- .END_ADDRESS (<%= end_address %>)
6
- ) u_register (
7
- .i_clk (<%= register_block.clock %>),
8
- .i_rst_n (<%= register_block.reset %>),
9
- .register_if (<%= register_if %>),
10
- .bus_if (<%= bus_if %>)
11
- );
@@ -1,128 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RgGen.define_list_item_feature(:register, :type, :external) do
4
- register_map do
5
- writable? { true }
6
- readable? { true }
7
- no_bit_fields
8
-
9
- verify(:component) do
10
- error_condition { register.size && register.size.length > 1 }
11
- message do
12
- 'external register type supports single size definition only'
13
- end
14
- end
15
- end
16
-
17
- sv_rtl do
18
- build do
19
- if configuration.fold_sv_interface_port?
20
- interface_port :register_block, :bus_if, {
21
- name: "#{register.name}_bus_if",
22
- interface_type: 'rggen_bus_if',
23
- modport: 'master'
24
- }
25
- else
26
- output :register_block, :valid, {
27
- name: "o_#{register.name}_valid",
28
- data_type: :logic, width: 1
29
- }
30
- output :register_block, :address, {
31
- name: "o_#{register.name}_address",
32
- data_type: :logic, width: address_width
33
- }
34
- output :register_block, :write, {
35
- name: "o_#{register.name}_write",
36
- data_type: :logic, width: 1
37
- }
38
- output :register_block, :write_data, {
39
- name: "o_#{register.name}_data",
40
- data_type: :logic, width: bus_width
41
- }
42
- output :register_block, :strobe, {
43
- name: "o_#{register.name}_strobe",
44
- data_type: :logic, width: byte_width
45
- }
46
- input :register_block, :ready, {
47
- name: "i_#{register.name}_ready",
48
- data_type: :logic, width: 1
49
- }
50
- input :register_block, :status, {
51
- name: "i_#{register.name}_status",
52
- data_type: :logic, width: 2
53
- }
54
- input :register_block, :read_data, {
55
- name: "i_#{register.name}_data",
56
- data_type: :logic, width: bus_width
57
- }
58
- interface :register, :bus_if, {
59
- name: 'bus_if', interface_type: 'rggen_bus_if',
60
- parameter_values: [address_width, bus_width],
61
- variables: [
62
- 'valid', 'address', 'write', 'write_data', 'strobe',
63
- 'ready', 'status', 'read_data'
64
- ]
65
- }
66
- end
67
- end
68
-
69
- main_code :register, from_template: true
70
- main_code :register do |code|
71
- unless configuration.fold_sv_interface_port?
72
- [
73
- [valid, bus_if.valid],
74
- [address, bus_if.address],
75
- [write, bus_if.write],
76
- [write_data, bus_if.write_data],
77
- [strobe, bus_if.strobe],
78
- [bus_if.ready, ready],
79
- [bus_if.status, "rggen_status'(#{status})"],
80
- [bus_if.read_data, read_data]
81
- ].map { |lhs, rhs| code << assign(lhs, rhs) << nl }
82
- end
83
- end
84
-
85
- private
86
-
87
- def address_width
88
- register_block.local_address_width
89
- end
90
-
91
- def byte_width
92
- configuration.byte_width
93
- end
94
-
95
- def start_address
96
- hex(register.offset_address, address_width)
97
- end
98
-
99
- def end_address
100
- address = register.offset_address + register.byte_size - 1
101
- hex(address, address_width)
102
- end
103
- end
104
-
105
- sv_ral do
106
- build do
107
- parameter :register_block, :model_type, {
108
- name: model_name,
109
- data_type: 'type',
110
- default: 'rggen_ral_block'
111
- }
112
- parameter :register_block, :integrate_model, {
113
- name: "INTEGRATE_#{model_name}",
114
- data_type: 'bit',
115
- default: 1
116
- }
117
- end
118
-
119
- model_name { register.name.upcase }
120
-
121
- constructor do
122
- macro_call(
123
- 'rggen_ral_create_block_model',
124
- [ral_model, offset_address, 'this', integrate_model]
125
- )
126
- end
127
- end
128
- end
@@ -1,327 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RgGen.define_list_item_feature(:register, :type, :indirect) do
4
- register_map do
5
- define_helpers do
6
- index_verifier = Class.new do
7
- def initialize(&block)
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)
35
- end
36
-
37
- def index_verifiers
38
- @index_verifiers ||= []
39
- end
40
- end
41
-
42
- define_struct :index_entry, [:name, :value] do
43
- def value_index?
44
- !array_index?
45
- end
46
-
47
- def array_index?
48
- value.nil?
49
- end
50
-
51
- def distinguishable?(other)
52
- name == other.name && value != other.value &&
53
- [self, other].all?(&:value_index?)
54
- end
55
-
56
- def find_index_field(bit_fields)
57
- bit_fields.find { |bit_field| bit_field.full_name == name }
58
- end
59
- end
60
-
61
- property :index_entries
62
- property :collect_index_fields do |bit_fields|
63
- index_entries.map { |entry| entry.find_index_field(bit_fields) }
64
- end
65
-
66
- byte_size { byte_width }
67
- support_array_register
68
- support_overlapped_address
69
-
70
- input_pattern [
71
- /(#{variable_name}\.#{variable_name})/,
72
- /(#{variable_name}\.#{variable_name}):(#{integer})?/
73
- ], match_automatically: false
74
-
75
- build do
76
- @index_entries = parse_index_entries
77
- end
78
-
79
- verify(:component) do
80
- error_condition do
81
- register.array? &&
82
- register.array_size.length < array_index_fields.length
83
- end
84
- message { 'too many array indices are given' }
85
- end
86
-
87
- verify(:component) do
88
- error_condition do
89
- register.array? &&
90
- register.array_size.length > array_index_fields.length
91
- end
92
- message { 'less array indices are given' }
93
- end
94
-
95
- verify(:all) do
96
- check_error do
97
- index_entries.each(&method(:verify_indirect_index))
98
- end
99
- end
100
-
101
- verify_index do
102
- error_condition do |index|
103
- !index_entries.one? { |other| other.name == index.name }
104
- end
105
- message do |index|
106
- "same bit field is used as indirect index more than once: #{index.name}"
107
- end
108
- end
109
-
110
- verify_index do
111
- error_condition { |index| !index_field(index) }
112
- message do |index|
113
- "no such bit field for indirect index is found: #{index.name}"
114
- end
115
- end
116
-
117
- verify_index do
118
- error_condition do |index|
119
- index_field(index).register.name == register.name
120
- end
121
- message do |index|
122
- "own bit field is not allowed for indirect index: #{index.name}"
123
- end
124
- end
125
-
126
- verify_index do
127
- error_condition { |index| index_field(index).register.array? }
128
- message do |index|
129
- 'bit field of array register is not allowed ' \
130
- "for indirect index: #{index.name}"
131
- end
132
- end
133
-
134
- verify_index do
135
- error_condition { |index| index_field(index).sequential? }
136
- message do |index|
137
- 'sequential bit field is not allowed ' \
138
- "for indirect index: #{index.name}"
139
- end
140
- end
141
-
142
- verify_index do
143
- error_condition { |index| index_field(index).reserved? }
144
- message do |index|
145
- 'reserved bit field is not allowed ' \
146
- "for indirect index: #{index.name}"
147
- end
148
- end
149
-
150
- verify_index do
151
- error_condition do |index|
152
- !index.array_index? &&
153
- (index.value > (2**index_field(index).width - 1))
154
- end
155
- message do |index|
156
- 'bit width of indirect index is not enough for ' \
157
- "index value #{index.value}: #{index.name}"
158
- end
159
- end
160
-
161
- verify_index do
162
- error_condition do |index|
163
- index.array_index? &&
164
- (array_index_value(index) > 2**index_field(index).width)
165
- end
166
- message do |index|
167
- 'bit width of indirect index is not enough for ' \
168
- "array size #{array_index_value(index)}: #{index.name}"
169
- end
170
- end
171
-
172
- verify(:all) do
173
- error_condition { !distinguishable? }
174
- message { 'cannot be distinguished from other registers' }
175
- end
176
-
177
- private
178
-
179
- def parse_index_entries
180
- (!options.empty? && options.map(&method(:create_index_entry))) ||
181
- (error 'no indirect indices are given')
182
- end
183
-
184
- def create_index_entry(value)
185
- input_values = split_value(value)
186
- if input_values.size == 2
187
- index_entry.new(input_values[0], convert_index_value(input_values[1]))
188
- elsif input_values.size == 1
189
- index_entry.new(input_values[0])
190
- else
191
- error 'too many arguments for indirect index ' \
192
- "are given: #{value.inspect}"
193
- end
194
- end
195
-
196
- def split_value(value)
197
- input_value = Array(value)
198
- field_name = input_value.first
199
- if sting_or_symbol?(field_name) && match_pattern(field_name)
200
- [*match_data.captures, *input_value[1..-1]]
201
- else
202
- error "illegal input value for indirect index: #{value.inspect}"
203
- end
204
- end
205
-
206
- def sting_or_symbol?(value)
207
- [String, Symbol].any?(&value.method(:is_a?))
208
- end
209
-
210
- def convert_index_value(value)
211
- Integer(value)
212
- rescue ArgumentError, TypeError
213
- error "cannot convert #{value.inspect} into indirect index value"
214
- end
215
-
216
- def verify_indirect_index(index)
217
- helper.index_verifiers.each { |verifier| verifier.verify(self, index) }
218
- end
219
-
220
- def index_field(index)
221
- @index_fields ||= {}
222
- @index_fields[index.name] ||=
223
- index.find_index_field(register_block.bit_fields)
224
- end
225
-
226
- def array_index_fields
227
- @array_index_fields ||= index_entries.select(&:array_index?)
228
- end
229
-
230
- def array_index_value(index)
231
- @array_index_values ||=
232
- array_index_fields
233
- .map.with_index { |entry, i| [entry.name, register.array_size[i]] }
234
- .to_h
235
- @array_index_values[index.name]
236
- end
237
-
238
- def distinguishable?
239
- register_block
240
- .registers.select { |other| share_same_range?(other) }
241
- .all? { |other| distinguishable_indices?(other.index_entries) }
242
- end
243
-
244
- def share_same_range?(other)
245
- register.name != other.name && register.overlap?(other)
246
- end
247
-
248
- def distinguishable_indices?(other_entries)
249
- index_entries.any? do |entry|
250
- other_entries.any?(&entry.method(:distinguishable?))
251
- end
252
- end
253
- end
254
-
255
- sv_rtl do
256
- build do
257
- logic :register, :indirect_index, { width: index_width }
258
- end
259
-
260
- main_code :register do |code|
261
- code << indirect_index_assignment << nl
262
- code << process_template(File.join(__dir__, 'indirect_sv_rtl.erb'))
263
- end
264
-
265
- private
266
-
267
- def index_fields
268
- @index_fields ||=
269
- register.collect_index_fields(register_block.bit_fields)
270
- end
271
-
272
- def index_width
273
- @index_width ||= index_fields.map(&:width).inject(:+)
274
- end
275
-
276
- def index_values
277
- loop_variables = register.loop_variables
278
- register.index_entries.zip(index_fields).map do |entry, field|
279
- if entry.array_index?
280
- loop_variables.shift[0, field.width]
281
- else
282
- hex(entry.value, field.width)
283
- end
284
- end
285
- end
286
-
287
- def indirect_index_assignment
288
- assign(indirect_index, concat(index_fields.map(&:value)))
289
- end
290
- end
291
-
292
- sv_ral do
293
- unmapped
294
- offset_address { register.offset_address }
295
-
296
- main_code :ral_package do
297
- class_definition(model_name) do |sv_class|
298
- sv_class.base 'rggen_ral_indirect_reg'
299
- sv_class.variables variables
300
- sv_class.body { model_body }
301
- end
302
- end
303
-
304
- private
305
-
306
- def model_body
307
- process_template(File.join(__dir__, 'indirect_sv_ral.erb'))
308
- end
309
-
310
- def index_properties
311
- array_position = -1
312
- register.index_entries.zip(index_fields).map do |entry, field|
313
- value =
314
- if entry.value_index?
315
- hex(entry.value, field.width)
316
- else
317
- "array_index[#{array_position += 1}]"
318
- end
319
- [*entry.name.split('.'), value]
320
- end
321
- end
322
-
323
- def index_fields
324
- register.collect_index_fields(register_block.bit_fields)
325
- end
326
- end
327
- end