rggen-systemverilog 0.24.0 → 0.25.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rggen/systemverilog/common.rb +0 -2
  3. data/lib/rggen/systemverilog/common/factories.rb +1 -1
  4. data/lib/rggen/systemverilog/common/feature.rb +1 -1
  5. data/lib/rggen/systemverilog/common/utility.rb +1 -1
  6. data/lib/rggen/systemverilog/common/utility/class_definition.rb +12 -4
  7. data/lib/rggen/systemverilog/common/utility/data_object.rb +1 -2
  8. data/lib/rggen/systemverilog/common/utility/function_definition.rb +16 -4
  9. data/lib/rggen/systemverilog/common/utility/identifier.rb +6 -7
  10. data/lib/rggen/systemverilog/common/utility/local_scope.rb +9 -7
  11. data/lib/rggen/systemverilog/common/utility/module_definition.rb +12 -4
  12. data/lib/rggen/systemverilog/common/utility/package_definition.rb +4 -4
  13. data/lib/rggen/systemverilog/ral.rb +1 -1
  14. data/lib/rggen/systemverilog/ral/bit_field/type.rb +2 -2
  15. data/lib/rggen/systemverilog/ral/bit_field/type/rof.rb +5 -0
  16. data/lib/rggen/systemverilog/rtl.rb +1 -3
  17. data/lib/rggen/systemverilog/rtl/bit_field/sv_rtl_top.rb +1 -1
  18. data/lib/rggen/systemverilog/rtl/bit_field/type/rc_w0c_w1c_wc_woc.rb +3 -3
  19. data/lib/rggen/systemverilog/rtl/bit_field/type/ro.rb +1 -1
  20. data/lib/rggen/systemverilog/rtl/bit_field/type/rs_w0s_w1s_ws_wos.rb +2 -2
  21. data/lib/rggen/systemverilog/rtl/bit_field/type/rw_w1_wo_wo1.rb +1 -1
  22. data/lib/rggen/systemverilog/rtl/bit_field/type/rwc.rb +2 -2
  23. data/lib/rggen/systemverilog/rtl/bit_field/type/{rwl.erb → rwe_rwl.erb} +2 -2
  24. data/lib/rggen/systemverilog/rtl/bit_field/type/rwe_rwl.rb +34 -0
  25. data/lib/rggen/systemverilog/rtl/bit_field/type/rws.rb +3 -3
  26. data/lib/rggen/systemverilog/rtl/bit_field/type/w0crs_w0src_w1crs_w1src_wcrs_wsrc.rb +1 -1
  27. data/lib/rggen/systemverilog/rtl/bit_field/type/w0t_w1t.rb +1 -1
  28. data/lib/rggen/systemverilog/rtl/bit_field/type/w0trg_w1trg.rb +1 -1
  29. data/lib/rggen/systemverilog/rtl/bit_field/type/wrc_wrs.rb +1 -1
  30. data/lib/rggen/systemverilog/rtl/bit_field_index.rb +1 -2
  31. data/lib/rggen/systemverilog/rtl/feature.rb +8 -6
  32. data/lib/rggen/systemverilog/rtl/partial_sum.rb +5 -6
  33. data/lib/rggen/systemverilog/rtl/register/type/external.rb +8 -16
  34. data/lib/rggen/systemverilog/rtl/register_block/protocol/apb.rb +10 -10
  35. data/lib/rggen/systemverilog/rtl/register_block/protocol/axi4lite.rb +23 -23
  36. data/lib/rggen/systemverilog/rtl/register_block/sv_rtl_top.rb +2 -6
  37. data/lib/rggen/systemverilog/rtl/register_index.rb +13 -11
  38. data/lib/rggen/systemverilog/rtl/register_type.rb +4 -3
  39. data/lib/rggen/systemverilog/version.rb +1 -1
  40. metadata +7 -25
  41. data/lib/rggen/systemverilog/ral/bit_field/type/reserved_rof.rb +0 -5
  42. data/lib/rggen/systemverilog/rtl/bit_field/type/reserved.erb +0 -18
  43. data/lib/rggen/systemverilog/rtl/bit_field/type/reserved.rb +0 -7
  44. data/lib/rggen/systemverilog/rtl/bit_field/type/rwe.erb +0 -18
  45. data/lib/rggen/systemverilog/rtl/bit_field/type/rwe.rb +0 -26
  46. data/lib/rggen/systemverilog/rtl/bit_field/type/rwl.rb +0 -26
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2cfff9e2a346d5c02dc5a6401e8b36fdd15d20b9d4d4030b5fcc56880521ccd4
4
- data.tar.gz: 75bd4c611fa964f30df059fe39d547daf688322ed1076654744381dc38a67068
3
+ metadata.gz: f2fe4d8d918cc5291f84654d19f75670ef8fb49e9405e6b2dba2d2fb418ffacb
4
+ data.tar.gz: a51b6c2fb4589c9c149132132c4087ed01bbfb6a31feccb5247d2056a90c7ede
5
5
  SHA512:
6
- metadata.gz: 3c5e0b0b5c3352532161411d2ce6e8ca8728231377c7453953a1c1804b8c08bd134ba487264d7a63c192744278184de7923f598dfbde80096a41b6040467af45
7
- data.tar.gz: 37a27563ccee405d16d2778728e186331bdb9a7711b73d017eb1bf3fd4479000c2bf54621dbab43b903897755a05026a3c7ae25cb68b1624cef63a250bf3eda0
6
+ metadata.gz: b6c24fe9065345f7f8ba93bfa1fa3e481f5852a0025f0cfd20b9728475d96f359f028de870dc2523c145b84b009d4eb2ddbbd82b3cd286ba6217b6bc8a0b68c5
7
+ data.tar.gz: c6a97f80b046acfbde8882fa85371267ba776d90bec180595c146fa9b44913a42453e348c17979a74253baeb00ed5e70448d10d6ba03a796048bdd42ded9a4b7
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'facets/kernel/attr_singleton'
4
-
5
3
  require_relative 'version'
6
4
 
7
5
  require_relative 'common/utility/identifier'
@@ -3,7 +3,7 @@
3
3
  module RgGen
4
4
  module SystemVerilog
5
5
  module Common
6
- class ComponentFactory < Core::OutputBase::ComponentFactory
6
+ class ComponentFactory < Core::OutputBase::SourceFileComponentFactory
7
7
  end
8
8
 
9
9
  class FeatureFactory < Core::OutputBase::FeatureFactory
@@ -73,7 +73,7 @@ module RgGen
73
73
 
74
74
  def add_identifier(entity, name)
75
75
  instance_variable_set("@#{name}", entity.identifier)
76
- attr_singleton_reader(name)
76
+ singleton_exec { attr_reader name }
77
77
  export(name)
78
78
  end
79
79
 
@@ -13,7 +13,7 @@ module RgGen
13
13
  private
14
14
 
15
15
  def create_identifier(name)
16
- Identifier.new(name)
16
+ name && Identifier.new(name)
17
17
  end
18
18
 
19
19
  def assign(lhs, rhs)
@@ -13,10 +13,14 @@ module RgGen
13
13
  private
14
14
 
15
15
  def header_code(code)
16
- code << [:class, space, name]
16
+ class_header_begin(code)
17
17
  parameter_declarations(code)
18
18
  class_inheritance(code)
19
- code << semicolon
19
+ class_header_end(code)
20
+ end
21
+
22
+ def class_header_begin(code)
23
+ code << ['class', space, name]
20
24
  end
21
25
 
22
26
  def parameter_declarations(code)
@@ -28,7 +32,11 @@ module RgGen
28
32
 
29
33
  def class_inheritance(code)
30
34
  return unless base
31
- code << [space, :extends, space, base]
35
+ code << [space, 'extends', space, base]
36
+ end
37
+
38
+ def class_header_end(code)
39
+ code << semicolon
32
40
  end
33
41
 
34
42
  def pre_body_code(code)
@@ -36,7 +44,7 @@ module RgGen
36
44
  end
37
45
 
38
46
  def footer_code
39
- :endclass
47
+ 'endclass'
40
48
  end
41
49
  end
42
50
  end
@@ -25,8 +25,7 @@ module RgGen
25
25
 
26
26
  def declaration
27
27
  declaration_snippets
28
- .select(&:itself)
29
- .reject(&:empty?)
28
+ .select { |snippet| snippet && !snippet.empty? }
30
29
  .join(' ')
31
30
  end
32
31
 
@@ -19,11 +19,15 @@ module RgGen
19
19
  private
20
20
 
21
21
  def header_code(code)
22
- code << :function
22
+ function_header_begin(code)
23
23
  return_type_declaration(code)
24
- code << [space, name]
24
+ function_name(code)
25
25
  argument_declarations(code)
26
- code << semicolon
26
+ function_header_end(code)
27
+ end
28
+
29
+ def function_header_begin(code)
30
+ code << 'function'
27
31
  end
28
32
 
29
33
  def return_type_declaration(code)
@@ -31,14 +35,22 @@ module RgGen
31
35
  code << [space, return_type.declaration]
32
36
  end
33
37
 
38
+ def function_name(code)
39
+ code << space << name
40
+ end
41
+
34
42
  def argument_declarations(code)
35
43
  wrap(code, '(', ')') do
36
44
  add_declarations_to_header(code, Array(arguments))
37
45
  end
38
46
  end
39
47
 
48
+ def function_header_end(code)
49
+ code << semicolon
50
+ end
51
+
40
52
  def footer_code
41
- :endfunction
53
+ 'endfunction'
42
54
  end
43
55
  end
44
56
  end
@@ -80,13 +80,12 @@ module RgGen
80
80
  end
81
81
 
82
82
  def __serialized_index__(array_index)
83
- index_values =
84
- array_index
85
- .reverse
86
- .zip(__index_factors__)
87
- .map { |i, f| __calc_index_value__(i, f) }
88
- index = __reduce_array__(index_values.reverse, :+, 0)
89
- integer?(index) ? index : "(#{index})"
83
+ array_index
84
+ .reverse
85
+ .zip(__index_factors__)
86
+ .map { |i, f| __calc_index_value__(i, f) }
87
+ .yield_self { |values| __reduce_array__(values.reverse, :+, 0) }
88
+ .yield_self { |index| integer?(index) && index || "(#{index})" }
90
89
  end
91
90
 
92
91
  def __index_factors__
@@ -17,13 +17,13 @@ module RgGen
17
17
  private
18
18
 
19
19
  def header_code(code)
20
- code << [:generate, space] if @top_scope
20
+ code << ['generate', space] if @top_scope
21
21
  code << "if (1) begin : #{name}" << nl
22
22
  end
23
23
 
24
24
  def footer_code(code)
25
- code << :end
26
- code << [space, :endgenerate] if @top_scope
25
+ code << 'end'
26
+ code << [space, 'endgenerate'] if @top_scope
27
27
  end
28
28
 
29
29
  def pre_body_code(code)
@@ -58,10 +58,12 @@ module RgGen
58
58
  end
59
59
 
60
60
  def post_body_code(code)
61
- (loop_size&.size || 0).times do
62
- code.indent -= 2
63
- code << :end << nl
64
- end
61
+ loop_size&.size&.times { generate_for_end(code) }
62
+ end
63
+
64
+ def generate_for_end(code)
65
+ code.indent -= 2
66
+ code << 'end' << nl
65
67
  end
66
68
  end
67
69
  end
@@ -23,11 +23,15 @@ module RgGen
23
23
  private
24
24
 
25
25
  def header_code(code)
26
- code << [:module, space, name]
26
+ module_header_begin(code)
27
27
  package_import_declaration(code)
28
28
  parameter_declarations(code)
29
29
  port_declarations(code)
30
- code << semicolon
30
+ module_header_end(code)
31
+ end
32
+
33
+ def module_header_begin(code)
34
+ code << 'module' << space << name
31
35
  end
32
36
 
33
37
  def package_import_declaration(code)
@@ -41,7 +45,7 @@ module RgGen
41
45
  def pacakge_import_items
42
46
  Array(@package_imports).map.with_index do |package, i|
43
47
  if i.zero?
44
- [:import, "#{package}::*"].join(space)
48
+ ['import', "#{package}::*"].join(space)
45
49
  else
46
50
  [space(6), "#{package}::*"].join(space)
47
51
  end
@@ -62,12 +66,16 @@ module RgGen
62
66
  end
63
67
  end
64
68
 
69
+ def module_header_end(code)
70
+ code << semicolon
71
+ end
72
+
65
73
  def pre_body_code(code)
66
74
  add_declarations_to_body(code, Array(variables))
67
75
  end
68
76
 
69
77
  def footer_code
70
- :endmodule
78
+ 'endmodule'
71
79
  end
72
80
  end
73
81
  end
@@ -30,7 +30,7 @@ module RgGen
30
30
  private
31
31
 
32
32
  def header_code(code)
33
- code << [:package, space, name, semicolon]
33
+ code << ['package', space, name, semicolon]
34
34
  end
35
35
 
36
36
  def pre_body_code(code)
@@ -41,18 +41,18 @@ module RgGen
41
41
  def package_import_declaration(code)
42
42
  declarations =
43
43
  Array(@package_imports)
44
- .map { |package| [:import, space, package, '::*'] }
44
+ .map { |package| ['import', space, package, '::*'] }
45
45
  add_declarations_to_body(code, declarations)
46
46
  end
47
47
 
48
48
  def file_include_directives(code)
49
49
  Array(@include_files).each do |file|
50
- code << [:'`include', space, string(file), nl]
50
+ code << ['`include', space, string(file), nl]
51
51
  end
52
52
  end
53
53
 
54
54
  def footer_code
55
- :endpackage
55
+ 'endpackage'
56
56
  end
57
57
  end
58
58
  end
@@ -19,7 +19,7 @@ module RgGen
19
19
 
20
20
  plugin.files [
21
21
  'ral/bit_field/type',
22
- 'ral/bit_field/type/reserved_rof',
22
+ 'ral/bit_field/type/rof',
23
23
  'ral/bit_field/type/rwc_rws',
24
24
  'ral/bit_field/type/rwe_rwl',
25
25
  'ral/bit_field/type/w0trg_w1trg',
@@ -29,12 +29,12 @@ RgGen.define_list_feature(:bit_field, :type) do
29
29
 
30
30
  def model_name
31
31
  name = helper.model_name
32
- name.is_a?(Proc) && instance_eval(&name) || name || :rggen_ral_field
32
+ name.is_a?(Proc) && instance_eval(&name) || name || 'rggen_ral_field'
33
33
  end
34
34
 
35
35
  def constructors
36
36
  (bit_field.sequence_size&.times || [nil]).map do |index|
37
- macro_call(:rggen_ral_create_field, arguments(index))
37
+ macro_call('rggen_ral_create_field', arguments(index))
38
38
  end
39
39
  end
40
40
 
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ RgGen.define_list_item_feature(:bit_field, :type, :rof) do
4
+ sv_ral { access 'RO' }
5
+ end
@@ -25,14 +25,12 @@ module RgGen
25
25
  'rtl/bit_field/sv_rtl_top',
26
26
  'rtl/bit_field/type',
27
27
  'rtl/bit_field/type/rc_w0c_w1c_wc_woc',
28
- 'rtl/bit_field/type/reserved',
29
28
  'rtl/bit_field/type/ro',
30
29
  'rtl/bit_field/type/rof',
31
30
  'rtl/bit_field/type/rs_w0s_w1s_ws_wos',
32
31
  'rtl/bit_field/type/rw_w1_wo_wo1',
33
32
  'rtl/bit_field/type/rwc',
34
- 'rtl/bit_field/type/rwe',
35
- 'rtl/bit_field/type/rwl',
33
+ 'rtl/bit_field/type/rwe_rwl',
36
34
  'rtl/bit_field/type/rws',
37
35
  'rtl/bit_field/type/w0crs_w0src_w1crs_w1src_wcrs_wsrc',
38
36
  'rtl/bit_field/type/w0t_w1t',
@@ -116,7 +116,7 @@ RgGen.define_simple_feature(:bit_field, :sv_rtl_top) do
116
116
 
117
117
  def bit_field_if_connection
118
118
  macro_call(
119
- :rggen_connect_bit_field_if,
119
+ 'rggen_connect_bit_field_if',
120
120
  [
121
121
  register.bit_field_if,
122
122
  bit_field.bit_field_sub_if,
@@ -4,16 +4,16 @@ RgGen.define_list_item_feature(:bit_field, :type, [:rc, :w0c, :w1c, :wc, :woc])
4
4
  sv_rtl do
5
5
  build do
6
6
  input :set, {
7
- name: "i_#{full_name}_set", data_type: :logic, width: width,
7
+ name: "i_#{full_name}_set", width: width,
8
8
  array_size: array_size, array_format: array_port_format
9
9
  }
10
10
  output :value_out, {
11
- name: "o_#{full_name}", data_type: :logic, width: width,
11
+ name: "o_#{full_name}", width: width,
12
12
  array_size: array_size, array_format: array_port_format
13
13
  }
14
14
  if bit_field.reference?
15
15
  output :value_unmasked, {
16
- name: "o_#{full_name}_unmasked", data_type: :logic, width: width,
16
+ name: "o_#{full_name}_unmasked", width: width,
17
17
  array_size: array_size, array_format: array_port_format
18
18
  }
19
19
  end
@@ -5,7 +5,7 @@ RgGen.define_list_item_feature(:bit_field, :type, :ro) do
5
5
  build do
6
6
  unless bit_field.reference?
7
7
  input :value_in, {
8
- name: "i_#{full_name}", data_type: :logic, width: width,
8
+ name: "i_#{full_name}", width: width,
9
9
  array_size: array_size, array_format: array_port_format
10
10
  }
11
11
  end
@@ -4,11 +4,11 @@ RgGen.define_list_item_feature(:bit_field, :type, [:rs, :w0s, :w1s, :ws, :wos])
4
4
  sv_rtl do
5
5
  build do
6
6
  input :clear, {
7
- name: "i_#{full_name}_clear", data_type: :logic, width: width,
7
+ name: "i_#{full_name}_clear", width: width,
8
8
  array_size: array_size, array_format: array_port_format
9
9
  }
10
10
  output :value_out, {
11
- name: "o_#{full_name}", data_type: :logic, width: width,
11
+ name: "o_#{full_name}", width: width,
12
12
  array_size: array_size, array_format: array_port_format
13
13
  }
14
14
  end
@@ -4,7 +4,7 @@ RgGen.define_list_item_feature(:bit_field, :type, [:rw, :w1, :wo, :wo1]) do
4
4
  sv_rtl do
5
5
  build do
6
6
  output :value_out, {
7
- name: "o_#{full_name}", data_type: :logic, width: width,
7
+ name: "o_#{full_name}", width: width,
8
8
  array_size: array_size, array_format: array_port_format
9
9
  }
10
10
  end
@@ -5,12 +5,12 @@ RgGen.define_list_item_feature(:bit_field, :type, :rwc) do
5
5
  build do
6
6
  unless bit_field.reference?
7
7
  input :clear, {
8
- name: "i_#{full_name}_clear", data_type: :logic, width: 1,
8
+ name: "i_#{full_name}_clear", width: 1,
9
9
  array_size: array_size, array_format: array_port_format
10
10
  }
11
11
  end
12
12
  output :value_out, {
13
- name: "o_#{full_name}", data_type: :logic, width: width,
13
+ name: "o_#{full_name}", width: width,
14
14
  array_size: array_size, array_format: array_port_format
15
15
  }
16
16
  end
@@ -1,12 +1,12 @@
1
1
  rggen_bit_field #(
2
2
  .WIDTH (<%= width %>),
3
3
  .INITIAL_VALUE (<%= initial_value %>),
4
- .SW_WRITE_ENABLE_POLARITY (RGGEN_ACTIVE_LOW)
4
+ .SW_WRITE_ENABLE_POLARITY (<%= polarity %>)
5
5
  ) u_bit_field (
6
6
  .i_clk (<%= clock %>),
7
7
  .i_rst_n (<%= reset %>),
8
8
  .bit_field_if (<%= bit_field_if %>),
9
- .i_sw_write_enable (<%= lock_signal %>),
9
+ .i_sw_write_enable (<%= control_signal %>),
10
10
  .i_hw_write_enable ('0),
11
11
  .i_hw_write_data ('0),
12
12
  .i_hw_set ('0),
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ RgGen.define_list_item_feature(:bit_field, :type, [:rwe, :rwl]) do
4
+ sv_rtl do
5
+ build do
6
+ unless bit_field.reference?
7
+ input :control, {
8
+ name: "i_#{full_name}_#{enable_or_lock}", width: 1,
9
+ array_size: array_size, array_format: array_port_format
10
+ }
11
+ end
12
+ output :value_out, {
13
+ name: "o_#{full_name}", width: width,
14
+ array_size: array_size, array_format: array_port_format
15
+ }
16
+ end
17
+
18
+ main_code :bit_field, from_template: true
19
+
20
+ private
21
+
22
+ def enable_or_lock
23
+ { rwe: :enable, rwl: :lock }[bit_field.type]
24
+ end
25
+
26
+ def control_signal
27
+ reference_bit_field || control[loop_variables]
28
+ end
29
+
30
+ def polarity
31
+ { rwe: 'RGGEN_ACTIVE_HIGH', rwl: 'RGGEN_ACTIVE_LOW' }[bit_field.type]
32
+ end
33
+ end
34
+ end
@@ -5,16 +5,16 @@ RgGen.define_list_item_feature(:bit_field, :type, :rws) do
5
5
  build do
6
6
  unless bit_field.reference?
7
7
  input :set, {
8
- name: "i_#{full_name}_set", data_type: :logic, width: 1,
8
+ name: "i_#{full_name}_set", width: 1,
9
9
  array_size: array_size, array_format: array_port_format
10
10
  }
11
11
  end
12
12
  input :value_in, {
13
- name: "i_#{full_name}", data_type: :logic, width: width,
13
+ name: "i_#{full_name}", width: width,
14
14
  array_size: array_size, array_format: array_port_format
15
15
  }
16
16
  output :value_out, {
17
- name: "o_#{full_name}", data_type: :logic, width: width,
17
+ name: "o_#{full_name}", width: width,
18
18
  array_size: array_size, array_format: array_port_format
19
19
  }
20
20
  end
@@ -6,7 +6,7 @@ RgGen.define_list_item_feature(
6
6
  sv_rtl do
7
7
  build do
8
8
  output :value_out, {
9
- name: "o_#{full_name}", data_type: :logic, width: width,
9
+ name: "o_#{full_name}", width: width,
10
10
  array_size: array_size, array_format: array_port_format
11
11
  }
12
12
  end
@@ -4,7 +4,7 @@ RgGen.define_list_item_feature(:bit_field, :type, [:w0t, :w1t]) do
4
4
  sv_rtl do
5
5
  build do
6
6
  output :value_out, {
7
- name: "o_#{full_name}", data_type: :logic, width: width,
7
+ name: "o_#{full_name}", width: width,
8
8
  array_size: array_size, array_format: array_port_format
9
9
  }
10
10
  end
@@ -4,7 +4,7 @@ RgGen.define_list_item_feature(:bit_field, :type, [:w0trg, :w1trg]) do
4
4
  sv_rtl do
5
5
  build do
6
6
  output :trigger, {
7
- name: "o_#{full_name}_trigger", data_type: :logic, width: width,
7
+ name: "o_#{full_name}_trigger", width: width,
8
8
  array_size: array_size, array_format: array_port_format
9
9
  }
10
10
  end
@@ -4,7 +4,7 @@ RgGen.define_list_item_feature(:bit_field, :type, [:wrc, :wrs]) do
4
4
  sv_rtl do
5
5
  build do
6
6
  output :value_out, {
7
- name: "o_#{full_name}", data_type: :logic, width: width,
7
+ name: "o_#{full_name}", width: width,
8
8
  array_size: array_size, array_format: array_port_format
9
9
  }
10
10
  end
@@ -15,8 +15,7 @@ module RgGen
15
15
  end
16
16
 
17
17
  def local_index
18
- index_name = local_index_name
19
- index_name && create_identifier(index_name)
18
+ create_identifier(local_index_name)
20
19
  end
21
20
 
22
21
  def local_indices
@@ -16,10 +16,12 @@ module RgGen
16
16
  InterfaceInstance.new(attributes, &block)
17
17
  end
18
18
 
19
- def create_argument(direction, attributes, &block)
20
- DataObject.new(
21
- :argument, attributes.merge(direction: direction), &block
22
- )
19
+ def create_port(direction, attributes, &block)
20
+ attributes =
21
+ { data_type: 'logic' }
22
+ .merge(attributes)
23
+ .merge(direction: direction)
24
+ DataObject.new(:argument, attributes, &block)
23
25
  end
24
26
 
25
27
  def create_if_port(_, attributes, &block)
@@ -34,8 +36,8 @@ module RgGen
34
36
 
35
37
  define_entity :logic, :create_variable, :variable, -> { component }
36
38
  define_entity :interface, :create_if_instance, :variable, -> { component }
37
- define_entity :input, :create_argument, :port, -> { register_block }
38
- define_entity :output, :create_argument, :port, -> { register_block }
39
+ define_entity :input, :create_port, :port, -> { register_block }
40
+ define_entity :output, :create_port, :port, -> { register_block }
39
41
  define_entity :interface_port, :create_if_port, :port, -> { register_block }
40
42
  define_entity :parameter, :create_parameter, :parameter, -> { register_block }
41
43
  define_entity :localparam, :create_parameter, :parameter, -> { component }
@@ -7,12 +7,11 @@ module RgGen
7
7
  private
8
8
 
9
9
  def partial_sums(operands)
10
- sums =
11
- operands
12
- .chunk(&method(:integer?))
13
- .flat_map(&method(:calc_partial_sum))
14
- .reject { |value| integer?(value) && value.zero? }
15
- sums.empty? && [0] || sums
10
+ operands
11
+ .chunk(&method(:integer?))
12
+ .flat_map(&method(:calc_partial_sum))
13
+ .reject { |value| integer?(value) && value.zero? }
14
+ .tap { |sums| sums.empty? && (sums << 0) }
16
15
  end
17
16
 
18
17
  def calc_partial_sum(kind_ans_values)
@@ -11,36 +11,28 @@ RgGen.define_list_item_feature(:register, :type, :external) do
11
11
  }
12
12
  else
13
13
  output :valid, {
14
- name: "o_#{register.name}_valid",
15
- data_type: :logic, width: 1
14
+ name: "o_#{register.name}_valid", width: 1
16
15
  }
17
16
  output :access, {
18
- name: "o_#{register.name}_access",
19
- data_type: :logic, width: '$bits(rggen_access)'
17
+ name: "o_#{register.name}_access", width: '$bits(rggen_access)'
20
18
  }
21
19
  output :address, {
22
- name: "o_#{register.name}_address",
23
- data_type: :logic, width: address_width
20
+ name: "o_#{register.name}_address", width: address_width
24
21
  }
25
22
  output :write_data, {
26
- name: "o_#{register.name}_data",
27
- data_type: :logic, width: bus_width
23
+ name: "o_#{register.name}_data", width: bus_width
28
24
  }
29
25
  output :strobe, {
30
- name: "o_#{register.name}_strobe",
31
- data_type: :logic, width: byte_width
26
+ name: "o_#{register.name}_strobe", width: byte_width
32
27
  }
33
28
  input :ready, {
34
- name: "i_#{register.name}_ready",
35
- data_type: :logic, width: 1
29
+ name: "i_#{register.name}_ready", width: 1
36
30
  }
37
31
  input :status, {
38
- name: "i_#{register.name}_status",
39
- data_type: :logic, width: 2
32
+ name: "i_#{register.name}_status", width: 2
40
33
  }
41
34
  input :read_data, {
42
- name: "i_#{register.name}_data",
43
- data_type: :logic, width: bus_width
35
+ name: "i_#{register.name}_data", width: bus_width
44
36
  }
45
37
  interface :bus_if, {
46
38
  name: 'bus_if', interface_type: 'rggen_bus_if',
@@ -27,34 +27,34 @@ RgGen.define_list_item_feature(:register_block, :protocol, :apb) do
27
27
  }
28
28
  else
29
29
  input :psel, {
30
- name: 'i_psel', data_type: :logic, width: 1
30
+ name: 'i_psel', width: 1
31
31
  }
32
32
  input :penable, {
33
- name: 'i_penable', data_type: :logic, width: 1
33
+ name: 'i_penable', width: 1
34
34
  }
35
35
  input :paddr, {
36
- name: 'i_paddr', data_type: :logic, width: address_width
36
+ name: 'i_paddr', width: address_width
37
37
  }
38
38
  input :pprot, {
39
- name: 'i_pprot', data_type: :logic, width: 3
39
+ name: 'i_pprot', width: 3
40
40
  }
41
41
  input :pwrite, {
42
- name: 'i_pwrite', data_type: :logic, width: 1
42
+ name: 'i_pwrite', width: 1
43
43
  }
44
44
  input :pstrb, {
45
- name: 'i_pstrb', data_type: :logic, width: byte_width
45
+ name: 'i_pstrb', width: byte_width
46
46
  }
47
47
  input :pwdata, {
48
- name: 'i_pwdata', data_type: :logic, width: bus_width
48
+ name: 'i_pwdata', width: bus_width
49
49
  }
50
50
  output :pready, {
51
- name: 'o_pready', data_type: :logic, width: 1
51
+ name: 'o_pready', width: 1
52
52
  }
53
53
  output :prdata, {
54
- name: 'o_prdata', data_type: :logic, width: bus_width
54
+ name: 'o_prdata', width: bus_width
55
55
  }
56
56
  output :pslverr, {
57
- name: 'o_pslverr', data_type: :logic, width: 1
57
+ name: 'o_pslverr', width: 1
58
58
  }
59
59
  interface :apb_if, {
60
60
  name: 'apb_if', interface_type: 'rggen_apb_if',
@@ -26,73 +26,73 @@ RgGen.define_list_item_feature(:register_block, :protocol, :axi4lite) do
26
26
  }
27
27
  else
28
28
  input :awvalid, {
29
- name: 'i_awvalid', data_type: :logic, width: 1
29
+ name: 'i_awvalid', width: 1
30
30
  }
31
31
  output :awready, {
32
- name: 'o_awready', data_type: :logic, width: 1
32
+ name: 'o_awready', width: 1
33
33
  }
34
34
  input :awid, {
35
- name: 'i_awid', data_type: :logic, width: id_port_width
35
+ name: 'i_awid', width: id_port_width
36
36
  }
37
37
  input :awaddr, {
38
- name: 'i_awaddr', data_type: :logic, width: address_width
38
+ name: 'i_awaddr', width: address_width
39
39
  }
40
40
  input :awprot, {
41
- name: 'i_awprot', data_type: :logic, width: 3
41
+ name: 'i_awprot', width: 3
42
42
  }
43
43
  input :wvalid, {
44
- name: 'i_wvalid', data_type: :logic, width: 1
44
+ name: 'i_wvalid', width: 1
45
45
  }
46
46
  output :wready, {
47
- name: 'o_wready', data_type: :logic, width: 1
47
+ name: 'o_wready', width: 1
48
48
  }
49
49
  input :wdata, {
50
- name: 'i_wdata', data_type: :logic, width: bus_width
50
+ name: 'i_wdata', width: bus_width
51
51
  }
52
52
  input :wstrb, {
53
- name: 'i_wstrb', data_type: :logic, width: byte_width
53
+ name: 'i_wstrb', width: byte_width
54
54
  }
55
55
  output :bvalid, {
56
- name: 'o_bvalid', data_type: :logic, width: 1
56
+ name: 'o_bvalid', width: 1
57
57
  }
58
58
  output :bid, {
59
- name: 'o_bid', data_type: :logic, width: id_port_width
59
+ name: 'o_bid', width: id_port_width
60
60
  }
61
61
  input :bready, {
62
- name: 'i_bready', data_type: :logic, width: 1
62
+ name: 'i_bready', width: 1
63
63
  }
64
64
  output :bresp, {
65
- name: 'o_bresp', data_type: :logic, width: 2
65
+ name: 'o_bresp', width: 2
66
66
  }
67
67
  input :arvalid, {
68
- name: 'i_arvalid', data_type: :logic, width: 1
68
+ name: 'i_arvalid', width: 1
69
69
  }
70
70
  output :arready, {
71
- name: 'o_arready', data_type: :logic, width: 1
71
+ name: 'o_arready', width: 1
72
72
  }
73
73
  input :arid, {
74
- name: 'i_arid', data_type: :logic, width: id_port_width
74
+ name: 'i_arid', width: id_port_width
75
75
  }
76
76
  input :araddr, {
77
- name: 'i_araddr', data_type: :logic, width: address_width
77
+ name: 'i_araddr', width: address_width
78
78
  }
79
79
  input :arprot, {
80
- name: 'i_arprot', data_type: :logic, width: 3
80
+ name: 'i_arprot', width: 3
81
81
  }
82
82
  output :rvalid, {
83
- name: 'o_rvalid', data_type: :logic, width: 1
83
+ name: 'o_rvalid', width: 1
84
84
  }
85
85
  input :rready, {
86
- name: 'i_rready', data_type: :logic, width: 1
86
+ name: 'i_rready', width: 1
87
87
  }
88
88
  output :rid, {
89
- name: 'o_rid', data_type: :logic, width: id_port_width
89
+ name: 'o_rid', width: id_port_width
90
90
  }
91
91
  output :rdata, {
92
- name: 'o_rdata', data_type: :logic, width: bus_width
92
+ name: 'o_rdata', width: bus_width
93
93
  }
94
94
  output :rresp, {
95
- name: 'o_rresp', data_type: :logic, width: 2
95
+ name: 'o_rresp', width: 2
96
96
  }
97
97
  interface :axi4lite_if, {
98
98
  name: 'axi4lite_if', interface_type: 'rggen_axi4lite_if',
@@ -5,12 +5,8 @@ RgGen.define_simple_feature(:register_block, :sv_rtl_top) do
5
5
  export :total_registers
6
6
 
7
7
  build do
8
- input :clock, {
9
- name: 'i_clk', data_type: :logic, width: 1
10
- }
11
- input :reset, {
12
- name: 'i_rst_n', data_type: :logic, width: 1
13
- }
8
+ input :clock, { name: 'i_clk', width: 1 }
9
+ input :reset, { name: 'i_rst_n', width: 1 }
14
10
  interface :register_if, {
15
11
  name: 'register_if', interface_type: 'rggen_register_if',
16
12
  parameter_values: [address_width, bus_width, value_width],
@@ -50,13 +50,10 @@ module RgGen
50
50
  end
51
51
 
52
52
  def index(offset_or_offsets = nil)
53
- operands = index_operands(offset_or_offsets)
54
- partial_indices = partial_sums(operands)
55
- if partial_indices.empty? || partial_indices.all?(&method(:integer?))
56
- partial_indices.sum
57
- else
58
- partial_indices.join('+')
59
- end
53
+ offset_or_offsets
54
+ .yield_self(&method(:index_operands))
55
+ .yield_self(&method(:partial_sums))
56
+ .yield_self(&method(:reduce_indices))
60
57
  end
61
58
 
62
59
  def inside_loop?
@@ -87,12 +84,17 @@ module RgGen
87
84
  ]
88
85
  end
89
86
 
87
+ def reduce_indices(indices)
88
+ if indices.empty? || indices.all?(&method(:integer?))
89
+ indices.sum
90
+ else
91
+ indices.join('+')
92
+ end
93
+ end
94
+
90
95
  def local_register_index(offset)
91
96
  (component.array? || nil) &&
92
- begin
93
- operands = [component.count(false), offset || local_index]
94
- product(operands, true)
95
- end
97
+ product([component.count(false), offset || local_index], true)
96
98
  end
97
99
 
98
100
  def product(operands, need_bracket)
@@ -25,9 +25,10 @@ module RgGen
25
25
  end
26
26
 
27
27
  def offset_address
28
- offsets = [*register_files, register].flat_map(&method(:collect_offsets))
29
- offsets = partial_sums(offsets)
30
- format_offsets(offsets)
28
+ [*register_files, register]
29
+ .flat_map(&method(:collect_offsets))
30
+ .yield_self(&method(:partial_sums))
31
+ .yield_self(&method(:format_offsets))
31
32
  end
32
33
 
33
34
  def collect_offsets(component)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RgGen
4
4
  module SystemVerilog
5
- VERSION = '0.24.0'
5
+ VERSION = '0.25.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rggen-systemverilog
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
- - !ruby/object:Gem::Dependency
14
- name: facets
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '3.0'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: '3.0'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: bundler
29
15
  requirement: !ruby/object:Gem::Requirement
@@ -69,7 +55,7 @@ files:
69
55
  - lib/rggen/systemverilog/common/utility/structure_definition.rb
70
56
  - lib/rggen/systemverilog/ral.rb
71
57
  - lib/rggen/systemverilog/ral/bit_field/type.rb
72
- - lib/rggen/systemverilog/ral/bit_field/type/reserved_rof.rb
58
+ - lib/rggen/systemverilog/ral/bit_field/type/rof.rb
73
59
  - lib/rggen/systemverilog/ral/bit_field/type/rwc_rws.rb
74
60
  - lib/rggen/systemverilog/ral/bit_field/type/rwe_rwl.rb
75
61
  - lib/rggen/systemverilog/ral/bit_field/type/w0trg_w1trg.rb
@@ -91,8 +77,6 @@ files:
91
77
  - lib/rggen/systemverilog/rtl/bit_field/type.rb
92
78
  - lib/rggen/systemverilog/rtl/bit_field/type/rc_w0c_w1c_wc_woc.erb
93
79
  - lib/rggen/systemverilog/rtl/bit_field/type/rc_w0c_w1c_wc_woc.rb
94
- - lib/rggen/systemverilog/rtl/bit_field/type/reserved.erb
95
- - lib/rggen/systemverilog/rtl/bit_field/type/reserved.rb
96
80
  - lib/rggen/systemverilog/rtl/bit_field/type/ro.erb
97
81
  - lib/rggen/systemverilog/rtl/bit_field/type/ro.rb
98
82
  - lib/rggen/systemverilog/rtl/bit_field/type/rof.erb
@@ -103,10 +87,8 @@ files:
103
87
  - lib/rggen/systemverilog/rtl/bit_field/type/rw_w1_wo_wo1.rb
104
88
  - lib/rggen/systemverilog/rtl/bit_field/type/rwc.erb
105
89
  - lib/rggen/systemverilog/rtl/bit_field/type/rwc.rb
106
- - lib/rggen/systemverilog/rtl/bit_field/type/rwe.erb
107
- - lib/rggen/systemverilog/rtl/bit_field/type/rwe.rb
108
- - lib/rggen/systemverilog/rtl/bit_field/type/rwl.erb
109
- - lib/rggen/systemverilog/rtl/bit_field/type/rwl.rb
90
+ - lib/rggen/systemverilog/rtl/bit_field/type/rwe_rwl.erb
91
+ - lib/rggen/systemverilog/rtl/bit_field/type/rwe_rwl.rb
110
92
  - lib/rggen/systemverilog/rtl/bit_field/type/rws.erb
111
93
  - lib/rggen/systemverilog/rtl/bit_field/type/rws.rb
112
94
  - lib/rggen/systemverilog/rtl/bit_field/type/w0crs_w0src_w1crs_w1src_wcrs_wsrc.erb
@@ -158,7 +140,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
158
140
  requirements:
159
141
  - - ">="
160
142
  - !ruby/object:Gem::Version
161
- version: '2.4'
143
+ version: '2.5'
162
144
  required_rubygems_version: !ruby/object:Gem::Requirement
163
145
  requirements:
164
146
  - - ">="
@@ -168,5 +150,5 @@ requirements: []
168
150
  rubygems_version: 3.2.3
169
151
  signing_key:
170
152
  specification_version: 4
171
- summary: rggen-systemverilog-0.24.0
153
+ summary: rggen-systemverilog-0.25.0
172
154
  test_files: []
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RgGen.define_list_item_feature(:bit_field, :type, [:reserved, :rof]) do
4
- sv_ral { access 'RO' }
5
- end
@@ -1,18 +0,0 @@
1
- rggen_bit_field #(
2
- .WIDTH (<%= width %>),
3
- .SW_READ_ACTION (RGGEN_READ_NONE),
4
- .STORAGE (0)
5
- ) u_bit_field (
6
- .i_clk ('0),
7
- .i_rst_n ('0),
8
- .bit_field_if (<%= bit_field_if %>),
9
- .i_sw_write_enable ('0),
10
- .i_hw_write_enable ('0),
11
- .i_hw_write_data ('0),
12
- .i_hw_set ('0),
13
- .i_hw_clear ('0),
14
- .i_value ('0),
15
- .i_mask ('0),
16
- .o_value (),
17
- .o_value_unmasked ()
18
- );
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RgGen.define_list_item_feature(:bit_field, :type, :reserved) do
4
- sv_rtl do
5
- main_code :bit_field, from_template: true
6
- end
7
- end
@@ -1,18 +0,0 @@
1
- rggen_bit_field #(
2
- .WIDTH (<%= width %>),
3
- .INITIAL_VALUE (<%= initial_value %>),
4
- .SW_WRITE_ENABLE_POLARITY (RGGEN_ACTIVE_HIGH)
5
- ) u_bit_field (
6
- .i_clk (<%= clock %>),
7
- .i_rst_n (<%= reset %>),
8
- .bit_field_if (<%= bit_field_if %>),
9
- .i_sw_write_enable (<%= enable_signal %>),
10
- .i_hw_write_enable ('0),
11
- .i_hw_write_data ('0),
12
- .i_hw_set ('0),
13
- .i_hw_clear ('0),
14
- .i_value ('0),
15
- .i_mask ('1),
16
- .o_value (<%= value_out[loop_variables] %>),
17
- .o_value_unmasked ()
18
- );
@@ -1,26 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RgGen.define_list_item_feature(:bit_field, :type, :rwe) do
4
- sv_rtl do
5
- build do
6
- unless bit_field.reference?
7
- input :enable, {
8
- name: "i_#{full_name}_enable", data_type: :logic, width: 1,
9
- array_size: array_size, array_format: array_port_format
10
- }
11
- end
12
- output :value_out, {
13
- name: "o_#{full_name}", data_type: :logic, width: width,
14
- array_size: array_size, array_format: array_port_format
15
- }
16
- end
17
-
18
- main_code :bit_field, from_template: true
19
-
20
- private
21
-
22
- def enable_signal
23
- reference_bit_field || enable[loop_variables]
24
- end
25
- end
26
- end
@@ -1,26 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RgGen.define_list_item_feature(:bit_field, :type, :rwl) do
4
- sv_rtl do
5
- build do
6
- unless bit_field.reference?
7
- input :lock, {
8
- name: "i_#{full_name}_lock", data_type: :logic, width: 1,
9
- array_size: array_size, array_format: array_port_format
10
- }
11
- end
12
- output :value_out, {
13
- name: "o_#{full_name}", data_type: :logic, width: width,
14
- array_size: array_size, array_format: array_port_format
15
- }
16
- end
17
-
18
- main_code :bit_field, from_template: true
19
-
20
- private
21
-
22
- def lock_signal
23
- reference_bit_field || lock[loop_variables]
24
- end
25
- end
26
- end