rggen-systemverilog 0.28.0 → 0.29.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: 60c25d990cd209fcfe988002dee2325f1ec8d319295f9014cfe59715b87d44e7
4
- data.tar.gz: db8957f134063c33fdd6efbfe3596e5871ac6f166359bb4f7b013f883ab9f3bd
3
+ metadata.gz: 7e5fc548cd3c93e80580efc9d2027ce309b9a6e8900078f3f5bf8bb157357e53
4
+ data.tar.gz: 4fb5af7f5ad76f4938406a553fe425767e2fc363ce79b79b07213fd292535efb
5
5
  SHA512:
6
- metadata.gz: 759a5c90f3311b34f016b4fbade25d14785349f9ae88e1244596baa9b44abb80453eb3609ad2534d0b9d78a390aa8f39c747257c0a9ababa209b669cbb52b331
7
- data.tar.gz: d0923aa115d8251966cad5ee14846b6037d1187e5c889ff288af6c0a26b132dcd7823916dd8d7214317dccbc849f85482fc1b2d947b6cf465cc218d8d704fef2
6
+ metadata.gz: 34cc65c49e1510303e8ca8ed7d16b941bfd331d66188602ecdf41a61cc9b1b0a627f56d33c3ba6b44b0c2e56ca1c44a896893ad3d82070a72b5cfb913e5a28b5
7
+ data.tar.gz: 55600c8bf365ffbbc2d8cc6b020e6cb13c33ebb91f49253d53cef0c5a7a5df86d639a61cc0a1eb2aa5d2a36d86530236e837735721da55def694c2a1c19c9d74
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2019-2022 Taichi Ishitani
3
+ Copyright (c) 2019-2023 Taichi Ishitani
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -35,7 +35,7 @@ Feedbacks, bug reports, questions and etc. are wellcome! You can post them by us
35
35
 
36
36
  ## Copyright & License
37
37
 
38
- Copyright © 2019-2022 Taichi Ishitani. RgGen::SystemVerilog is licensed under the [MIT License](https://opensource.org/licenses/MIT), see [LICENSE](LICENSE) for futher details.
38
+ Copyright © 2019-2023 Taichi Ishitani. RgGen::SystemVerilog is licensed under the [MIT License](https://opensource.org/licenses/MIT), see [LICENSE](LICENSE) for futher details.
39
39
 
40
40
  ## Code of Conduct
41
41
 
@@ -8,6 +8,7 @@ module RgGen
8
8
  define_attribute :name
9
9
  define_attribute :package_imports
10
10
  define_attribute :include_files
11
+ define_attribute :parameters
11
12
 
12
13
  def package_imports(packages)
13
14
  @package_imports ||= []
@@ -36,21 +37,28 @@ module RgGen
36
37
  def pre_body_code(code)
37
38
  package_import_declaration(code)
38
39
  file_include_directives(code)
40
+ parameter_declarations(code)
39
41
  end
40
42
 
41
43
  def package_import_declaration(code)
42
44
  declarations =
43
- Array(@package_imports)
44
- .map { |package| ['import', space, package, '::*'] }
45
- add_declarations_to_body(code, declarations)
45
+ @package_imports
46
+ &.map { |package| ['import', space, package, '::*'] }
47
+ declarations &&
48
+ add_declarations_to_body(code, declarations)
46
49
  end
47
50
 
48
51
  def file_include_directives(code)
49
- Array(@include_files).each do |file|
52
+ @include_files&.each do |file|
50
53
  code << ['`include', space, string(file), nl]
51
54
  end
52
55
  end
53
56
 
57
+ def parameter_declarations(code)
58
+ parameters &&
59
+ add_declarations_to_body(code, parameters)
60
+ end
61
+
54
62
  def footer_code
55
63
  'endpackage'
56
64
  end
@@ -7,6 +7,7 @@ require_relative 'rtl/register_index'
7
7
  require_relative 'rtl/register_type'
8
8
  require_relative 'rtl/indirect_index'
9
9
  require_relative 'rtl/bit_field_index'
10
+ require_relative 'rtl_package/feature'
10
11
 
11
12
  RgGen.setup_plugin :'rggen-sv-rtl' do |plugin|
12
13
  plugin.version RgGen::SystemVerilog::VERSION
@@ -50,4 +51,17 @@ RgGen.setup_plugin :'rggen-sv-rtl' do |plugin|
50
51
  'rtl/bit_field/type/wo_wo1_wotrg',
51
52
  'rtl/bit_field/type/wrc_wrs'
52
53
  ]
54
+
55
+ plugin.register_component :sv_rtl_package do
56
+ component RgGen::SystemVerilog::Common::Component,
57
+ RgGen::SystemVerilog::Common::ComponentFactory
58
+ feature RgGen::SystemVerilog::RTLPackage::Feature,
59
+ RgGen::SystemVerilog::Common::FeatureFactory
60
+ end
61
+
62
+ plugin.files [
63
+ 'rtl_package/bit_field/sv_rtl_package',
64
+ 'rtl_package/register/sv_rtl_package',
65
+ 'rtl_package/register_block/sv_rtl_package'
66
+ ]
53
67
  end
@@ -0,0 +1,65 @@
1
+ # frozen_string_literal: true
2
+
3
+ RgGen.define_simple_feature(:bit_field, :sv_rtl_package) do
4
+ sv_rtl_package do
5
+ build do
6
+ localparam :__width, {
7
+ name: "#{full_name}_bit_width",
8
+ data_type: :int, default: bit_field.width
9
+ }
10
+ localparam :__mask, {
11
+ name: "#{full_name}_bit_mask",
12
+ data_type: :bit, width: bit_field.width, default: mask_value
13
+ }
14
+ define_offset_localparam
15
+ define_label_localparams
16
+ end
17
+
18
+ private
19
+
20
+ def mask_value
21
+ hex((1 << bit_field.width) - 1, bit_field.width)
22
+ end
23
+
24
+ def define_offset_localparam
25
+ if bit_field.sequential?
26
+ define_sequential_offset_localparam
27
+ else
28
+ define_single_offset_localparam
29
+ end
30
+ end
31
+
32
+ def define_sequential_offset_localparam
33
+ size = bit_field.sequence_size
34
+ localparam :__offset, {
35
+ name: "#{full_name}_bit_offset",
36
+ data_type: :int, array_size: [size], default: offset_value(size)
37
+ }
38
+ end
39
+
40
+ def offset_value(size)
41
+ array(Array.new(size, &bit_field.method(:lsb)))
42
+ end
43
+
44
+ def define_single_offset_localparam
45
+ localparam :__offset, {
46
+ name: "#{full_name}_bit_offset",
47
+ data_type: :int, default: bit_field.lsb
48
+ }
49
+ end
50
+
51
+ def define_label_localparams
52
+ bit_field.labels
53
+ .each { |label| define_label_localparam(label) }
54
+ end
55
+
56
+ def define_label_localparam(label)
57
+ identifier = "label_#{label.name}".downcase.to_sym
58
+ value = hex(label.value, bit_field.width)
59
+ localparam identifier, {
60
+ name: "#{full_name}_#{label.name}",
61
+ data_type: :bit, width: bit_field.width, default: value
62
+ }
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RgGen
4
+ module SystemVerilog
5
+ module RTLPackage
6
+ class Feature < Common::Feature
7
+ private
8
+
9
+ def full_name(separator = '_')
10
+ component.full_name(separator)
11
+ end
12
+
13
+ def create_parameter(parameter_type, attributes, &block)
14
+ attributes =
15
+ attributes.merge(
16
+ parameter_type: parameter_type, array_format: :unpacked,
17
+ name: attributes[:name].upcase
18
+ )
19
+ DataObject.new(
20
+ :parameter, attributes, &block
21
+ )
22
+ end
23
+
24
+ define_entity :localparam, :create_parameter, :parameter, -> { register_block }
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,83 @@
1
+ # frozen_string_literal: true
2
+
3
+ RgGen.define_simple_feature(:register, :sv_rtl_package) do
4
+ sv_rtl_package do
5
+ build do
6
+ localparam :__byte_width, {
7
+ name: "#{full_name}_byte_width",
8
+ data_type: :int, default: register.byte_width
9
+ }
10
+ localparam :__byte_size, {
11
+ name: "#{full_name}_byte_size",
12
+ data_type: :int, default: register.byte_size(hierarchical: true)
13
+ }
14
+ define_array_size_localparam
15
+ define_offset_localparams
16
+ end
17
+
18
+ private
19
+
20
+ def define_array_size_localparam
21
+ return unless array?
22
+
23
+ list = array_size_list
24
+ localparam :__array_size, {
25
+ name: "#{full_name}_array_size",
26
+ data_type: :int, array_size: [list.size], default: array(list)
27
+ }
28
+ end
29
+
30
+ def define_offset_localparams
31
+ if array?
32
+ define_array_offset_localparams
33
+ else
34
+ define_single_offset_localparam
35
+ end
36
+ end
37
+
38
+ def define_array_offset_localparams
39
+ width = register_block.local_address_width
40
+ size_list = array_size_list
41
+ value_list = group_address_list(address_list, size_list).first
42
+ localparam :__offset, {
43
+ name: "#{full_name}_byte_offset",
44
+ data_type: :bit, width: width, array_size: size_list, default: value_list
45
+ }
46
+ end
47
+
48
+ def address_list
49
+ register
50
+ .expanded_offset_addresses
51
+ .map { |address| hex(address, register_block.local_address_width) }
52
+ end
53
+
54
+ def group_address_list(address_list, size_list)
55
+ list =
56
+ if size_list.size > 1
57
+ group_address_list(address_list, size_list[1..])
58
+ else
59
+ address_list
60
+ end
61
+ list
62
+ .each_slice(size_list.first)
63
+ .map(&method(:array))
64
+ end
65
+
66
+ def define_single_offset_localparam
67
+ width = register_block.local_address_width
68
+ value = address_list.first
69
+ localparam :__offset, {
70
+ name: "#{full_name}_byte_offset",
71
+ data_type: :bit, width: width, default: value
72
+ }
73
+ end
74
+
75
+ def array?
76
+ register.array?(hierarchical: true)
77
+ end
78
+
79
+ def array_size_list
80
+ register.array_size(hierarchical: true)
81
+ end
82
+ end
83
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ RgGen.define_simple_feature(:register_block, :sv_rtl_package) do
4
+ sv_rtl_package do
5
+ write_file '<%= package_name %>.sv' do |file|
6
+ file.body { sv_rtl_package_definition }
7
+ end
8
+
9
+ private
10
+
11
+ def sv_rtl_package_definition
12
+ package_definition(package_name) do |package|
13
+ package.parameters parameters
14
+ end
15
+ end
16
+
17
+ def package_name
18
+ "#{register_block.name}_rtl_pkg"
19
+ end
20
+
21
+ def parameters
22
+ register_block.declarations[:parameter]
23
+ end
24
+ end
25
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RgGen
4
4
  module SystemVerilog
5
- VERSION = '0.28.0'
5
+ VERSION = '0.29.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rggen-systemverilog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.28.0
4
+ version: 0.29.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: 2022-10-10 00:00:00.000000000 Z
11
+ date: 2023-01-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -135,6 +135,10 @@ files:
135
135
  - lib/rggen/systemverilog/rtl/register_file/sv_rtl_top.rb
136
136
  - lib/rggen/systemverilog/rtl/register_index.rb
137
137
  - lib/rggen/systemverilog/rtl/register_type.rb
138
+ - lib/rggen/systemverilog/rtl_package/bit_field/sv_rtl_package.rb
139
+ - lib/rggen/systemverilog/rtl_package/feature.rb
140
+ - lib/rggen/systemverilog/rtl_package/register/sv_rtl_package.rb
141
+ - lib/rggen/systemverilog/rtl_package/register_block/sv_rtl_package.rb
138
142
  - lib/rggen/systemverilog/version.rb
139
143
  homepage: https://github.com/rggen/rggen-systemverilog
140
144
  licenses:
@@ -153,15 +157,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
153
157
  requirements:
154
158
  - - ">="
155
159
  - !ruby/object:Gem::Version
156
- version: '2.6'
160
+ version: '2.7'
157
161
  required_rubygems_version: !ruby/object:Gem::Requirement
158
162
  requirements:
159
163
  - - ">="
160
164
  - !ruby/object:Gem::Version
161
165
  version: '0'
162
166
  requirements: []
163
- rubygems_version: 3.3.7
167
+ rubygems_version: 3.4.1
164
168
  signing_key:
165
169
  specification_version: 4
166
- summary: rggen-systemverilog-0.28.0
170
+ summary: rggen-systemverilog-0.29.0
167
171
  test_files: []