rggen-duh 0.1.0 → 0.2.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: 21a4dfe93b28bd15f58cd41f23054983596906407d7cfc47aad862f9afb0b4d8
4
- data.tar.gz: 437207982100076e8212b3a1964730e47a8039b3d719e99f9c0def53e73d5f72
3
+ metadata.gz: d22b0dc17bcbcc805b0a645107a78aa4d80554f11112d0690e37cde1c4a6dcd7
4
+ data.tar.gz: 8638fefb8ae9f698b836c431c959ad2e36dacba4a77a61dc6364976d00909853
5
5
  SHA512:
6
- metadata.gz: 1bbd7db3d1de636f659ef919442aa56ce449538cc6106c8398b363ef00f1547f251ca4a9d98bf49f9631970a88a8e2be3f39691dc890525331a04e62f92626ff
7
- data.tar.gz: 4aec9aaa0688094934b3ed20bae857540e228916f560f86640d471dcb549b4022d07791262b07b38fc444f647bdacecd14aa05e940a0f552c43dc3c6b8f7132b
6
+ metadata.gz: 14588567b6340bbf8bcc9ce223d320d171ecc13c20f9b85f18bca3054fca27a5e4ef1b9ecb166dd8d39b61abe933445e33936ff9b49ee05a9ae900b32d342865
7
+ data.tar.gz: b98bdef9b548c0bfaf359f22e02c22c19e4e5c01792ecd8290def85392ba1a84ac14e3a8bd85ec167ce2fe3a3f21480a4bb58eeda41fc4478f6bc993c3a2e11e
data/README.md CHANGED
@@ -34,6 +34,44 @@ $ export RGGEN_PLUGINS=${RGGEN_PLUGINS}:rggen-duh
34
34
  $ rggen your_duh.json5
35
35
  ```
36
36
 
37
+ ## Supported Bit Field Types
38
+
39
+ Following table describes which RgGen bit field types are supported by DUH format and corresponeded DUH properties.
40
+
41
+ | RgGen bit field type | Support? | access | modifiedWriteValue | readAction | reserved |
42
+ |:---------------------|:---------|:---------------|:-------------------|:--------------|:---------|
43
+ | rw | yes | read-write | not specified | not specified | no |
44
+ | ro | yes | read-only | don't care | not specified | no |
45
+ | rof | no | | | | no |
46
+ | wo | yes | write-only | not specified | don't care | no |
47
+ | wrc | yes | read-write | not specified | clear | no |
48
+ | wrs | yes | read-write | not specified | set | no |
49
+ | rc | yes | read-only | don't care | clear | no |
50
+ | w0c | yes | read-write | zeroToClear | not specified | no |
51
+ | w1c | yes | read-write | oneToClear | not specified | no |
52
+ | wc | yes | read-write | clear | not specified | no |
53
+ | woc | yes | write-only | clear | don't care | no |
54
+ | rs | yes | read-only | don't care | set | no |
55
+ | w0s | yes | read-write | zeroToSet | not specified | no |
56
+ | w1s | yes | read-write | oneToSet | not specified | no |
57
+ | ws | yes | read-write | set | not specified | no |
58
+ | wos | yes | write-only | set | don't care | no |
59
+ | rwc | no | | | | |
60
+ | rwe | no | | | | |
61
+ | rwl | no | | | | |
62
+ | rws | no | | | | |
63
+ | w0crs | yes | read-write | zeroToClear | set | no |
64
+ | w1crs | yes | read-write | oneToClear | set | no |
65
+ | wcrs | yes | read-write | clear | set | no |
66
+ | w0src | yes | read-write | zeroToSet | clear | no |
67
+ | w1src | yes | read-write | oneToSet | clear | no |
68
+ | wsrc | yes | read-write | set | clear | no |
69
+ | w0trg | no | | | | |
70
+ | w1trg | no | | | | |
71
+ | w1 | yes | read-writeOnce | not specified | not specified | no |
72
+ | wo1 | yes | writeOnce | not specified | don't care | no |
73
+ | reserved | yes | don't care | don't care | don't care | yes |
74
+
37
75
  ## Contact
38
76
 
39
77
  Feedbacks, bug reports, questions and etc. are wellcome! You can post them by using following ways:
@@ -5,7 +5,7 @@ require 'rb_json5'
5
5
  require 'json_refs'
6
6
  require 'json_schemer'
7
7
  require_relative 'duh/version'
8
- require_relative 'duh/validation_failed'
8
+ require_relative 'duh/exceptions'
9
9
  require_relative 'duh/schema'
10
10
  require_relative 'duh/loader'
11
11
 
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RgGen
4
+ module DUH
5
+ class ParseError < RgGen::Core::LoadError
6
+ def initialize(message, file_name, reason)
7
+ super(message, file_name, reason)
8
+ end
9
+ end
10
+
11
+ class ValidationError < RgGen::Core::LoadError
12
+ def initialize(message, file_name, errors)
13
+ error_info = errors.map(&JSONSchemer::Errors.method(:pretty)).join("\n")
14
+ super(message, file_name, error_info)
15
+ end
16
+ end
17
+ end
18
+ end
@@ -16,6 +16,14 @@ RgGen.define_value_extractor(:register_map, :duh, :bit_field, :type) do
16
16
  wo: {
17
17
  access: 'write-only', modified_write_value: 'default', reserved: false
18
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
+ },
19
27
  rc: {
20
28
  access: 'read-only', read_action: 'clear', reserved: false
21
29
  },
@@ -27,6 +35,13 @@ RgGen.define_value_extractor(:register_map, :duh, :bit_field, :type) do
27
35
  access: 'read-write', modified_write_value: 'oneToClear',
28
36
  read_action: 'default', reserved: false
29
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
+ },
30
45
  rs: {
31
46
  access: 'read-only', read_action: 'set', reserved: false
32
47
  },
@@ -38,6 +53,13 @@ RgGen.define_value_extractor(:register_map, :duh, :bit_field, :type) do
38
53
  access: 'read-write', modified_write_value: 'oneToSet',
39
54
  read_action: 'default', reserved: false
40
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
+ },
41
63
  w0t: {
42
64
  access: 'read-write', modified_write_value: 'zeroToToggle',
43
65
  read_action: 'default', reserved: false
@@ -54,6 +76,10 @@ RgGen.define_value_extractor(:register_map, :duh, :bit_field, :type) do
54
76
  access: 'read-write', modified_write_value: 'oneToClear',
55
77
  read_action: 'set', reserved: false
56
78
  },
79
+ wcrs: {
80
+ access: 'read-write', modified_write_value: 'clear',
81
+ read_action: 'set', reserved: false
82
+ },
57
83
  w0src: {
58
84
  access: 'read-write', modified_write_value: 'zeroToSet',
59
85
  read_action: 'clear', reserved: false
@@ -62,6 +88,10 @@ RgGen.define_value_extractor(:register_map, :duh, :bit_field, :type) do
62
88
  access: 'read-write', modified_write_value: 'oneToSet',
63
89
  read_action: 'clear', reserved: false
64
90
  },
91
+ wsrc: {
92
+ access: 'read-write', modified_write_value: 'set',
93
+ read_action: 'clear', reserved: false
94
+ },
65
95
  w1: {
66
96
  access: 'read-writeOnce', modified_write_value: 'default',
67
97
  read_action: 'default', reserved: false
@@ -12,18 +12,26 @@ module RgGen
12
12
  private
13
13
 
14
14
  def read_file(file_name)
15
- duh = JsonRefs.call(RbJSON5.load_file(file_name))
15
+ duh = load_json5(file_name)
16
16
  validation? && validate(duh, file_name)
17
17
  duh
18
18
  end
19
19
 
20
+ def load_json5(file_name)
21
+ JsonRefs.dereference(RbJSON5.load_file(file_name))
22
+ rescue RbJSON5::ParseError => e
23
+ reason = e.parse_failure_cause.ascii_tree.strip
24
+ raise ParseError.new(e.message, file_name, reason)
25
+ end
26
+
20
27
  def validation?
21
28
  !@disable_validation
22
29
  end
23
30
 
24
31
  def validate(duh, file_name)
25
32
  errors = Schema.validate(duh)
26
- errors.empty? || (raise ValidationFailed.new(file_name, errors))
33
+ errors.empty? ||
34
+ (raise ValidationError.new('input DUH file is invalid', file_name, errors))
27
35
  end
28
36
 
29
37
  SUB_LAYERS = {
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RgGen
4
4
  module DUH
5
- VERSION = '0.1.0'
5
+ VERSION = '0.2.0'
6
6
  end
7
7
  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.1.0
4
+ version: 0.2.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-17 00:00:00.000000000 Z
11
+ date: 2020-08-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json_refs
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 0.1.3
19
+ version: 0.1.4
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 0.1.3
26
+ version: 0.1.4
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: json_schemer
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: 0.2.0
47
+ version: 0.3.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: 0.2.0
54
+ version: 0.3.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: bundler
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -80,15 +80,15 @@ files:
80
80
  - lib/rggen/duh/duh-schema/LICENSE
81
81
  - lib/rggen/duh/duh-schema/README.md
82
82
  - lib/rggen/duh/duh-schema/schema.json
83
+ - lib/rggen/duh/exceptions.rb
83
84
  - lib/rggen/duh/extractor/bit_assignment.rb
84
85
  - lib/rggen/duh/extractor/simple_extractors.rb
85
86
  - lib/rggen/duh/extractor/type.rb
86
87
  - lib/rggen/duh/loader.rb
87
88
  - lib/rggen/duh/schema.rb
88
89
  - lib/rggen/duh/setup.rb
89
- - lib/rggen/duh/validation_failed.rb
90
90
  - lib/rggen/duh/version.rb
91
- homepage: https://github.com/rggen/rggen-dut
91
+ homepage: https://github.com/rggen/rggen-duh
92
92
  licenses:
93
93
  - MIT
94
94
  metadata:
@@ -114,5 +114,5 @@ requirements: []
114
114
  rubygems_version: 3.1.2
115
115
  signing_key:
116
116
  specification_version: 4
117
- summary: rggen-dut-0.1.0
117
+ summary: rggen-dut-0.2.0
118
118
  test_files: []
@@ -1,21 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module RgGen
4
- module DUH
5
- class ValidationFailed < RgGen::Core::LoadError
6
- def initialize(file_name, errors)
7
- super("input DUH file is invalid: #{file_name}")
8
- @errors = errors
9
- end
10
-
11
- attr_reader :errors
12
-
13
- def to_s
14
- [
15
- super,
16
- *errors.map { |error| " - #{JSONSchemer::Errors.pretty(error)}" }
17
- ].join("\n")
18
- end
19
- end
20
- end
21
- end