rggen-duh 0.2.0 → 0.5.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: d22b0dc17bcbcc805b0a645107a78aa4d80554f11112d0690e37cde1c4a6dcd7
4
- data.tar.gz: 8638fefb8ae9f698b836c431c959ad2e36dacba4a77a61dc6364976d00909853
3
+ metadata.gz: 6b5ce08e269e78df704f19710e47175c0767d0c09f0f9d97b8fef2365dd3d7b9
4
+ data.tar.gz: 80800a7f97dc36786d61ed1773e71fc1ce7f618506584bf8194f40c4b779820a
5
5
  SHA512:
6
- metadata.gz: 14588567b6340bbf8bcc9ce223d320d171ecc13c20f9b85f18bca3054fca27a5e4ef1b9ecb166dd8d39b61abe933445e33936ff9b49ee05a9ae900b32d342865
7
- data.tar.gz: b98bdef9b548c0bfaf359f22e02c22c19e4e5c01792ecd8290def85392ba1a84ac14e3a8bd85ec167ce2fe3a3f21480a4bb58eeda41fc4478f6bc993c3a2e11e
6
+ metadata.gz: 91021bac959ff0d798cb32e08b9bc43d366b0e6b7b1e0348087eee61db022c49b74e2550ad731861cd33e894786e0f528ca95dadecd766418448aaa98c0d998e
7
+ data.tar.gz: 3bbde57d20911503ad739f5bd2d8ffba5c61f1e599383725cb6f1ae7e102358401f17bc917f79e09eaa2eb18f2122457f4d0a08fe9480db73e324110762802c3
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2020 Taichi Ishitani
3
+ Copyright (c) 2020-2022 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
@@ -4,7 +4,6 @@
4
4
  [![codecov](https://codecov.io/gh/rggen/rggen-duh/branch/master/graph/badge.svg)](https://codecov.io/gh/rggen/rggen-duh)
5
5
  [![Gitter](https://badges.gitter.im/rggen/rggen.svg)](https://gitter.im/rggen/rggen?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
6
6
 
7
-
8
7
  # RgGen::DUH
9
8
 
10
9
  RgGen::DUH adds ability to load register map documents written in [DUH](https://github.com/sifive/duh) format.
@@ -41,9 +40,14 @@ Following table describes which RgGen bit field types are supported by DUH forma
41
40
  | RgGen bit field type | Support? | access | modifiedWriteValue | readAction | reserved |
42
41
  |:---------------------|:---------|:---------------|:-------------------|:--------------|:---------|
43
42
  | rw | yes | read-write | not specified | not specified | no |
43
+ | rwtrg | no | | | | |
44
44
  | ro | yes | read-only | don't care | not specified | no |
45
- | rof | no | | | | no |
45
+ | rotrg | no | | | | |
46
+ | rowo | no | | | | |
47
+ | rowotrg | no | | | | |
48
+ | rof | no | | | | |
46
49
  | wo | yes | write-only | not specified | don't care | no |
50
+ | wotrg | no | | | | |
47
51
  | wrc | yes | read-write | not specified | clear | no |
48
52
  | wrs | yes | read-write | not specified | set | no |
49
53
  | rc | yes | read-only | don't care | clear | no |
@@ -83,7 +87,7 @@ Feedbacks, bug reports, questions and etc. are wellcome! You can post them by us
83
87
 
84
88
  ## Copyright & License
85
89
 
86
- Copyright © 2020 Taichi Ishitani. RgGen::DUH is licensed under the [MIT License](https://opensource.org/licenses/MIT), see [LICENSE](LICENSE) for futher details.
90
+ Copyright © 2020-2022 Taichi Ishitani. RgGen::DUH is licensed under the [MIT License](https://opensource.org/licenses/MIT), see [LICENSE](LICENSE) for futher details.
87
91
 
88
92
  ## Notice
89
93
 
@@ -92,4 +96,4 @@ See [lib/rggen/duh/duh-schema/README.md](lib/rggen/duh/duh-schema/README.md) for
92
96
 
93
97
  ## Code of Conduct
94
98
 
95
- Everyone interacting in the Rggen::Duh project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/rggen/rggen-duh/blob/master/CODE_OF_CONDUCT.md).
99
+ Everyone interacting in the RgGen::Duh project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/rggen/rggen-duh/blob/master/CODE_OF_CONDUCT.md).
@@ -3,9 +3,6 @@
3
3
  module RgGen
4
4
  module DUH
5
5
  class ParseError < RgGen::Core::LoadError
6
- def initialize(message, file_name, reason)
7
- super(message, file_name, reason)
8
- end
9
6
  end
10
7
 
11
8
  class ValidationError < RgGen::Core::LoadError
@@ -5,107 +5,109 @@ RgGen.define_value_extractor(:register_map, :duh, :bit_field, :type) do
5
5
 
6
6
  private
7
7
 
8
- TYPE_MAP = {
9
- rw: {
10
- access: 'read-write', modified_write_value: 'default',
11
- read_action: 'default', reserved: false
12
- },
13
- ro: {
14
- access: 'read-only', read_action: 'default', reserved: false
15
- },
16
- wo: {
17
- access: 'write-only', modified_write_value: 'default', reserved: false
18
- },
19
- wrc: {
20
- access: 'read-write', modified_write_value: 'default',
21
- read_action: 'clear', reserved: false
22
- },
23
- wrs: {
24
- access: 'read-write', modified_write_value: 'default',
25
- read_action: 'set', reserved: false
26
- },
27
- rc: {
28
- access: 'read-only', read_action: 'clear', reserved: false
29
- },
30
- w0c: {
31
- access: 'read-write', modified_write_value: 'zeroToClear',
32
- read_action: 'default', reserved: false
33
- },
34
- w1c: {
35
- access: 'read-write', modified_write_value: 'oneToClear',
36
- read_action: 'default', reserved: false
37
- },
38
- wc: {
39
- access: 'read-write', modified_write_value: 'clear',
40
- read_action: 'default', reserved: false
41
- },
42
- woc: {
43
- access: 'write-only', modified_write_value: 'clear', reserved: false
44
- },
45
- rs: {
46
- access: 'read-only', read_action: 'set', reserved: false
47
- },
48
- w0s: {
49
- access: 'read-write', modified_write_value: 'zeroToSet',
50
- read_action: 'default', reserved: false
51
- },
52
- w1s: {
53
- access: 'read-write', modified_write_value: 'oneToSet',
54
- read_action: 'default', reserved: false
55
- },
56
- ws: {
57
- access: 'read-write', modified_write_value: 'set',
58
- read_action: 'default', reserved: false
59
- },
60
- wos: {
61
- access: 'write-only', modified_write_value: 'set', reserved: false
62
- },
63
- w0t: {
64
- access: 'read-write', modified_write_value: 'zeroToToggle',
65
- read_action: 'default', reserved: false
66
- },
67
- w1t: {
68
- access: 'read-write', modified_write_value: 'oneToToggle',
69
- read_action: 'default', reserved: false
70
- },
71
- w0crs: {
72
- access: 'read-write', modified_write_value: 'zeroToClear',
73
- read_action: 'set', reserved: false
74
- },
75
- w1crs: {
76
- access: 'read-write', modified_write_value: 'oneToClear',
77
- read_action: 'set', reserved: false
78
- },
79
- wcrs: {
80
- access: 'read-write', modified_write_value: 'clear',
81
- read_action: 'set', reserved: false
82
- },
83
- w0src: {
84
- access: 'read-write', modified_write_value: 'zeroToSet',
85
- read_action: 'clear', reserved: false
86
- },
87
- w1src: {
88
- access: 'read-write', modified_write_value: 'oneToSet',
89
- read_action: 'clear', reserved: false
90
- },
91
- wsrc: {
92
- access: 'read-write', modified_write_value: 'set',
93
- read_action: 'clear', reserved: false
94
- },
95
- w1: {
96
- access: 'read-writeOnce', modified_write_value: 'default',
97
- read_action: 'default', reserved: false
98
- },
99
- wo1: {
100
- access: 'writeOnce', modified_write_value: 'default', reserved: false
101
- },
102
- reserved: {
103
- reserved: true
104
- }
105
- }.freeze
106
-
107
8
  def find_type(duh)
108
- TYPE_MAP.find { |_, properties| match_properties?(duh, properties) }&.first
9
+ type_map.find { |_, properties| match_properties?(duh, properties) }&.first
10
+ end
11
+
12
+ def type_map
13
+ @type_map ||= {
14
+ rw: {
15
+ access: 'read-write', modified_write_value: 'default',
16
+ read_action: 'default', reserved: false
17
+ },
18
+ ro: {
19
+ access: 'read-only', read_action: 'default', reserved: false
20
+ },
21
+ wo: {
22
+ access: 'write-only', modified_write_value: 'default', reserved: false
23
+ },
24
+ wrc: {
25
+ access: 'read-write', modified_write_value: 'default',
26
+ read_action: 'clear', reserved: false
27
+ },
28
+ wrs: {
29
+ access: 'read-write', modified_write_value: 'default',
30
+ read_action: 'set', reserved: false
31
+ },
32
+ rc: {
33
+ access: 'read-only', read_action: 'clear', reserved: false
34
+ },
35
+ w0c: {
36
+ access: 'read-write', modified_write_value: 'zeroToClear',
37
+ read_action: 'default', reserved: false
38
+ },
39
+ w1c: {
40
+ access: 'read-write', modified_write_value: 'oneToClear',
41
+ read_action: 'default', reserved: false
42
+ },
43
+ wc: {
44
+ access: 'read-write', modified_write_value: 'clear',
45
+ read_action: 'default', reserved: false
46
+ },
47
+ woc: {
48
+ access: 'write-only', modified_write_value: 'clear', reserved: false
49
+ },
50
+ rs: {
51
+ access: 'read-only', read_action: 'set', reserved: false
52
+ },
53
+ w0s: {
54
+ access: 'read-write', modified_write_value: 'zeroToSet',
55
+ read_action: 'default', reserved: false
56
+ },
57
+ w1s: {
58
+ access: 'read-write', modified_write_value: 'oneToSet',
59
+ read_action: 'default', reserved: false
60
+ },
61
+ ws: {
62
+ access: 'read-write', modified_write_value: 'set',
63
+ read_action: 'default', reserved: false
64
+ },
65
+ wos: {
66
+ access: 'write-only', modified_write_value: 'set', reserved: false
67
+ },
68
+ w0t: {
69
+ access: 'read-write', modified_write_value: 'zeroToToggle',
70
+ read_action: 'default', reserved: false
71
+ },
72
+ w1t: {
73
+ access: 'read-write', modified_write_value: 'oneToToggle',
74
+ read_action: 'default', reserved: false
75
+ },
76
+ w0crs: {
77
+ access: 'read-write', modified_write_value: 'zeroToClear',
78
+ read_action: 'set', reserved: false
79
+ },
80
+ w1crs: {
81
+ access: 'read-write', modified_write_value: 'oneToClear',
82
+ read_action: 'set', reserved: false
83
+ },
84
+ wcrs: {
85
+ access: 'read-write', modified_write_value: 'clear',
86
+ read_action: 'set', reserved: false
87
+ },
88
+ w0src: {
89
+ access: 'read-write', modified_write_value: 'zeroToSet',
90
+ read_action: 'clear', reserved: false
91
+ },
92
+ w1src: {
93
+ access: 'read-write', modified_write_value: 'oneToSet',
94
+ read_action: 'clear', reserved: false
95
+ },
96
+ wsrc: {
97
+ access: 'read-write', modified_write_value: 'set',
98
+ read_action: 'clear', reserved: false
99
+ },
100
+ w1: {
101
+ access: 'read-writeOnce', modified_write_value: 'default',
102
+ read_action: 'default', reserved: false
103
+ },
104
+ wo1: {
105
+ access: 'writeOnce', modified_write_value: 'default', reserved: false
106
+ },
107
+ reserved: {
108
+ reserved: true
109
+ }
110
+ }.freeze
109
111
  end
110
112
 
111
113
  def match_properties?(duh, properties)
@@ -42,9 +42,14 @@ module RgGen
42
42
  }.freeze
43
43
 
44
44
  def format_sub_layer_data(read_data, layer, _file)
45
- SUB_LAYERS[layer]&.each_with_object({}) do |sub_layer, sub_layer_data|
46
- data = __send__("collect_#{sub_layer}_data", read_data)
47
- data && (sub_layer_data[sub_layer] = data)
45
+ SUB_LAYERS[layer]&.each_with_object([]) do |sub_layer, sub_layer_data|
46
+ data =
47
+ if layer == :root
48
+ collect_register_block_data(read_data)
49
+ else
50
+ collect_sub_layer_data(read_data, sub_layer)
51
+ end
52
+ data && sub_layer_data.concat([sub_layer].product(data))
48
53
  end
49
54
  end
50
55
 
@@ -61,21 +66,15 @@ module RgGen
61
66
  &.compact
62
67
  end
63
68
 
64
- def collect_register_file_data(read_data)
65
- read_data['registerFiles']&.map do |data|
66
- add_parent_and_layer_properties(data, read_data, :register_file)
67
- end
68
- end
69
-
70
- def collect_register_data(read_data)
71
- read_data['registers']&.map do |data|
72
- add_parent_and_layer_properties(data, read_data, :register)
73
- end
74
- end
69
+ KEY_MAP = {
70
+ register_file: 'registerFiles',
71
+ register: 'registers',
72
+ bit_field: 'fields'
73
+ }.freeze
75
74
 
76
- def collect_bit_field_data(read_data)
77
- read_data['fields']&.map do |data|
78
- add_parent_and_layer_properties(data, read_data, :bit_field)
75
+ def collect_sub_layer_data(read_data, sub_layer)
76
+ read_data[KEY_MAP[sub_layer]]&.map do |data|
77
+ add_parent_and_layer_properties(data, read_data, sub_layer)
79
78
  end
80
79
  end
81
80
 
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'rggen/duh'
4
- RgGen.setup RgGen::DUH
4
+ RgGen.register_plugin RgGen::DUH
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RgGen
4
4
  module DUH
5
- VERSION = '0.2.0'
5
+ VERSION = '0.5.0'
6
6
  end
7
7
  end
data/lib/rggen/duh.rb CHANGED
@@ -11,25 +11,15 @@ require_relative 'duh/loader'
11
11
 
12
12
  module RgGen
13
13
  module DUH
14
- PLUGIN_NAME = :'rggen-duh'
14
+ extend Core::Plugin
15
15
 
16
- EXTRACTORS = [
17
- 'duh/extractor/bit_assignment',
18
- 'duh/extractor/simple_extractors',
19
- 'duh/extractor/type'
20
- ].freeze
21
-
22
- def self.register_loader(builder)
23
- builder.register_loader(:register_map, :duh, Loader)
24
- end
25
-
26
- def self.load_extractors
27
- EXTRACTORS.each { |file| require_relative(file) }
28
- end
29
-
30
- def self.default_setup(builder)
31
- register_loader(builder)
32
- load_extractors
16
+ setup_plugin :'rggen-duh' do |plugin|
17
+ plugin.register_loader :register_map, :duh, Loader
18
+ plugin.files [
19
+ 'duh/extractor/bit_assignment',
20
+ 'duh/extractor/simple_extractors',
21
+ 'duh/extractor/type'
22
+ ]
33
23
  end
34
24
  end
35
25
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rggen-duh
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.5.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: 2020-08-25 00:00:00.000000000 Z
11
+ date: 2022-03-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json_refs
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 0.2.12
33
+ version: 0.2.17
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: 0.2.12
40
+ version: 0.2.17
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rb_json5
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -94,6 +94,7 @@ licenses:
94
94
  metadata:
95
95
  bug_tracker_uri: https://github.com/rggen/rggen-duh/issues
96
96
  mailing_list_uri: https://groups.google.com/d/forum/rggen
97
+ rubygems_mfa_required: 'true'
97
98
  source_code_uri: https://github.com/rggen/rggen-duh
98
99
  wiki_uri: https://github.com/rggen/rggen/wiki
99
100
  post_install_message:
@@ -104,15 +105,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
104
105
  requirements:
105
106
  - - ">="
106
107
  - !ruby/object:Gem::Version
107
- version: '2.5'
108
+ version: '2.6'
108
109
  required_rubygems_version: !ruby/object:Gem::Requirement
109
110
  requirements:
110
111
  - - ">="
111
112
  - !ruby/object:Gem::Version
112
113
  version: '0'
113
114
  requirements: []
114
- rubygems_version: 3.1.2
115
+ rubygems_version: 3.3.3
115
116
  signing_key:
116
117
  specification_version: 4
117
- summary: rggen-dut-0.2.0
118
+ summary: rggen-dut-0.5.0
118
119
  test_files: []