soc_maker 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +5 -0
  3. data/History.txt +4 -0
  4. data/LICENSE +678 -0
  5. data/README.rdoc +228 -0
  6. data/Rakefile +46 -0
  7. data/bin/soc_maker_cli +80 -0
  8. data/bin/soc_maker_parser +85 -0
  9. data/core_lib/cores/adv_debug_sys/01_adv_debug_sys.yaml +245 -0
  10. data/core_lib/cores/or1200_rel2/01_or1200.yaml +208 -0
  11. data/core_lib/cores/or1200_rel2/02_or1200_files.yaml +421 -0
  12. data/core_lib/cores/or1200_rel2/03_or1200_sparam.yaml +188 -0
  13. data/core_lib/cores/or1200_rel2/or1200_defines.v.in +1799 -0
  14. data/core_lib/cores/ram_wb/ram_wb.yaml +102 -0
  15. data/core_lib/cores/ram_wb/ram_wb_b3.v.in +259 -0
  16. data/core_lib/cores/uart16550/01_uart16550.yaml +99 -0
  17. data/core_lib/cores/uart16550/02_uart16550_files.yaml +70 -0
  18. data/core_lib/cores/wb_connect/minsoc_tc_top.v +1802 -0
  19. data/core_lib/cores/wb_connect/wb_connect.yaml +733 -0
  20. data/core_lib/inc.yaml +13 -0
  21. data/core_lib/interfaces/clk_rst/clk.yaml +9 -0
  22. data/core_lib/interfaces/clk_rst/rst.yaml +9 -0
  23. data/core_lib/interfaces/clk_rst/single.yaml +7 -0
  24. data/core_lib/interfaces/debug/debug.yaml +32 -0
  25. data/core_lib/interfaces/jtag/jtag.yaml +13 -0
  26. data/core_lib/interfaces/jtag/jtag_tap.yaml +22 -0
  27. data/core_lib/interfaces/power/or_power.yaml +25 -0
  28. data/core_lib/interfaces/uart/uart.yaml +21 -0
  29. data/core_lib/interfaces/wishbone/wishbone_ma_b3.yaml +54 -0
  30. data/core_lib/interfaces/wishbone/wishbone_sl_b3.yaml +51 -0
  31. data/doc/class_arch.uml +5113 -0
  32. data/doc/fig/hierarchical.svg +273 -0
  33. data/examples/or1200_test/or1200_test.cmd +78 -0
  34. data/examples/or1200_test/or1200_test.rb +136 -0
  35. data/examples/or1200_test/rtl/or1200_test_top.vhd +274 -0
  36. data/examples/or1200_test/rtl/s3astarter.ucf +10 -0
  37. data/examples/or1200_test/rtl/xilinx_internal_jtag.v +438 -0
  38. data/examples/or1200_test/rtl/xilinx_internal_jtag_options.v +12 -0
  39. data/examples/or1200_test/sw/README.txt +35 -0
  40. data/examples/or1200_test/sw/bin2vmem.c +159 -0
  41. data/examples/or1200_test/sw/board.h +24 -0
  42. data/examples/or1200_test/sw/compile.sh +18 -0
  43. data/examples/or1200_test/sw/except.S +152 -0
  44. data/examples/or1200_test/sw/int.c +79 -0
  45. data/examples/or1200_test/sw/int.h +14 -0
  46. data/examples/or1200_test/sw/interconnect.h +17 -0
  47. data/examples/or1200_test/sw/interrupts.c +14 -0
  48. data/examples/or1200_test/sw/main.c +16 -0
  49. data/examples/or1200_test/sw/or1200.h +454 -0
  50. data/examples/or1200_test/sw/orp.ld +60 -0
  51. data/examples/or1200_test/sw/reset.S +112 -0
  52. data/examples/or1200_test/sw/support.c +123 -0
  53. data/examples/or1200_test/sw/support.h +33 -0
  54. data/examples/or1200_test/sw/tick.c +30 -0
  55. data/examples/or1200_test/sw/tick.h +2 -0
  56. data/examples/or1200_test/sw/uart.c +136 -0
  57. data/examples/or1200_test/sw/uart.h +126 -0
  58. data/lib/soc_maker.rb +324 -0
  59. data/lib/soc_maker/cli.rb +544 -0
  60. data/lib/soc_maker/conf.rb +310 -0
  61. data/lib/soc_maker/core_def.rb +579 -0
  62. data/lib/soc_maker/core_inst.rb +305 -0
  63. data/lib/soc_maker/err.rb +211 -0
  64. data/lib/soc_maker/hdl_coder.rb +500 -0
  65. data/lib/soc_maker/hdl_file.rb +166 -0
  66. data/lib/soc_maker/hdl_parser.rb +431 -0
  67. data/lib/soc_maker/ifc_def.rb +193 -0
  68. data/lib/soc_maker/ifc_port.rb +133 -0
  69. data/lib/soc_maker/ifc_spc.rb +180 -0
  70. data/lib/soc_maker/lib.rb +289 -0
  71. data/lib/soc_maker/lib_inc.rb +109 -0
  72. data/lib/soc_maker/parameter.rb +149 -0
  73. data/lib/soc_maker/soc_def.rb +847 -0
  74. data/lib/soc_maker/sparameter.rb +289 -0
  75. data/lib/soc_maker/version.rb +8 -0
  76. data/lib/soc_maker/ypp.rb +130 -0
  77. data/soc_maker.gemspec +28 -0
  78. data/spec/cli_cmds1.txt +39 -0
  79. data/spec/cli_spec.rb +49 -0
  80. data/spec/conf_spec.rb +44 -0
  81. data/spec/core_def_spec.rb +503 -0
  82. data/spec/core_inst_spec.rb +169 -0
  83. data/spec/hdl_file_spec.rb +154 -0
  84. data/spec/hdl_parser_spec.rb +201 -0
  85. data/spec/ifc_def_spec.rb +121 -0
  86. data/spec/ifc_port_spec.rb +92 -0
  87. data/spec/ifc_spc_spec.rb +196 -0
  88. data/spec/lib_inc_spec.rb +99 -0
  89. data/spec/lib_spec.rb +209 -0
  90. data/spec/parameter_spec.rb +86 -0
  91. data/spec/soc_def_spec.rb +611 -0
  92. data/spec/soc_maker_spec.rb +7 -0
  93. data/spec/sparameter_spec.rb +182 -0
  94. data/spec/spec_helper.rb +78 -0
  95. data/spec/test_soc.yaml +105 -0
  96. data/spec/test_soc2.yaml +60 -0
  97. data/spec/test_soc_lib/cores/core_A_rel1/00_core_a.yaml +75 -0
  98. data/spec/test_soc_lib/cores/core_A_rel1/01_core_a.yaml +57 -0
  99. data/spec/test_soc_lib/cores/core_A_rel1/core_a.vhd +29 -0
  100. data/spec/test_soc_lib/cores/core_A_rel1/core_a_pkg.vhd.src +3 -0
  101. data/spec/test_soc_lib/cores/core_A_rel1/core_a_pkg2.vhd.src +4 -0
  102. data/spec/test_soc_lib/cores/core_A_rel1/core_a_pkg3.v.src +6 -0
  103. data/spec/test_soc_lib/cores/core_B_rel1/core_b.vhd +25 -0
  104. data/spec/test_soc_lib/cores/core_B_rel1/core_b.yaml +36 -0
  105. data/spec/test_soc_lib/cores/core_C_v1/core_C.vhd +57 -0
  106. data/spec/test_soc_lib/cores/core_C_v1/core_c.yaml +42 -0
  107. data/spec/test_soc_lib/cores/soc_A/soc_A.yaml +12 -0
  108. data/spec/test_soc_lib/cores/soc_maker_include.yaml +6 -0
  109. data/spec/test_soc_lib/ifcs/core_AB_ifc/bidir_ifc.yaml +19 -0
  110. data/spec/test_soc_lib/ifcs/core_AB_ifc/core_AB_ifc.yaml +15 -0
  111. data/spec/test_soc_lib/ifcs/core_AB_ifc/top_ifc.yaml +9 -0
  112. data/spec/test_soc_lib/soc_maker_include.yaml +4 -0
  113. data/spec/yaml_examples.rb +367 -0
  114. data/spec/ypp_spec.rb +156 -0
  115. data/test/test_soc_maker.rb +0 -0
  116. metadata +255 -0
@@ -0,0 +1,289 @@
1
+ ###############################################################
2
+ #
3
+ # File: spc_lib.rb
4
+ #
5
+ # Author: Christian Hättich
6
+ #
7
+ # Project: System-On-Chip Maker
8
+ #
9
+ # Target: Linux / Windows / Mac
10
+ #
11
+ # Language: ruby
12
+ #
13
+ #
14
+ ###############################################################
15
+ #
16
+ #
17
+ # Copyright (C) 2014 Christian Hättich - feddischson [ at ] opencores.org
18
+ #
19
+ # This program is free software: you can redistribute it and/or modify
20
+ # it under the terms of the GNU General Public License as published by
21
+ # the Free Software Foundation, either version 3 of the License, or
22
+ # (at your option) any later version.
23
+ #
24
+ # This program is distributed in the hope that it will be useful,
25
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
26
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27
+ # GNU General Public License for more details.
28
+ #
29
+ # You should have received a copy of the GNU General Public License
30
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
31
+ #
32
+ #
33
+ ###############################################################
34
+
35
+ module SOCMaker
36
+
37
+ #
38
+ # This class represents the IP core library, which holds all
39
+ # - cores (core-definitions and SoC definitions)
40
+ # - interfaces (interface-specifications)
41
+ #
42
+ # The cores are stored in #cores_lib and the interfaces in
43
+ # #ifc_lib. Furthermore, a #path_lut is used to remmeber,
44
+ # which folder-path has been processed. This is necessary to avoid
45
+ # circular search during loading.
46
+ #
47
+ class Lib
48
+ include ERR
49
+
50
+ #
51
+ # The constructor creates two empty hashes #cores_lib and
52
+ # #ifc_lib, and an empty list #path_lut.
53
+ #
54
+ def initialize
55
+
56
+ # will store all cores
57
+ @cores_lib = {}
58
+
59
+ # will store all interfaces
60
+ @ifc_lib = {}
61
+
62
+ # we remember paths, which we've already processed
63
+ @path_lut = []
64
+
65
+ end
66
+
67
+
68
+ #
69
+ # This method clears all three attributes of this class.
70
+ #
71
+ def clear
72
+ @cores_lib.clear
73
+ @ifc_lib.clear
74
+ @path_lut.clear
75
+ end
76
+
77
+
78
+ #
79
+ # Method to refresh / load the core library:
80
+ # it useses the global configuration entry cores_search_path,
81
+ # which defines, where to search for inc_fname (defined in SOCMaker::Conf) files.
82
+ #
83
+ # Before start searching, clear is called to clear the library.
84
+ #
85
+ # For each directory, we call process_include. The method process_include
86
+ # takes care of proessing everything else recursively.
87
+ #
88
+ #
89
+ # +paths+:: eiter a single path (as String) or multiple paths (as Array of strings)
90
+ #
91
+ def refresh( paths = nil )
92
+
93
+
94
+ paths = [ paths ] if paths.is_a?( String )
95
+
96
+
97
+ SOCMaker::logger.info "START REFRESHING CORE LIBRARY"
98
+
99
+ # clear the libs
100
+ clear
101
+
102
+ # use argument if given, otherwise config paths
103
+ paths ||= SOCMaker::conf[ :cores_search_path ]
104
+
105
+
106
+ paths.each do |dir|
107
+ process_include dir
108
+ end
109
+ SOCMaker::logger.info "DONE REFRESHING CORE LIBRARY"
110
+
111
+ end
112
+
113
+
114
+
115
+ #
116
+ # This method processes a directory, which needs to be included
117
+ # into the search:
118
+ # It uses the method get_all_yaml_in_str to read all *.yaml
119
+ # files and processes each yaml-object.
120
+ # If there is a SOCMaker::LibInc object, all entries of this
121
+ # object are further processed with this method
122
+ # (recursively, see add_include).
123
+ #
124
+ # +dir+:: the directory path, which is processed
125
+ #
126
+ def process_include( dir )
127
+
128
+ #
129
+ # this prevents the revursive call
130
+ # from an infinite call
131
+ #
132
+ folder_sym = File.expand_path( dir ).to_sym
133
+ init_error_if @path_lut.include?( folder_sym ),
134
+ "double-include: infinite resursive search?"
135
+ @path_lut << folder_sym
136
+
137
+ # get all yaml files in the directory
138
+ SOCMaker::logger.info "search for include in: " + dir
139
+
140
+
141
+ SOCMaker::from_s( get_all_yaml_in_str( dir ) ) do |o|
142
+ o.src_dir = dir
143
+ case o
144
+ when SOCMaker::LibInc
145
+ add_include( o, dir )
146
+ when SOCMaker::SOCDef
147
+ add_core( o )
148
+ when SOCMaker::CoreDef
149
+ add_core( o )
150
+ when SOCMaker::IfcSpc
151
+ add_ifc( o )
152
+ else
153
+ raise SOCMaker::ERR::InitError.new( "Can't load object", object: o )
154
+ end
155
+ end
156
+
157
+ end
158
+
159
+
160
+ #
161
+ # Search for all *.yaml files and concatenate them.
162
+ #
163
+ # +result+:: the resulting string
164
+ #
165
+ def get_all_yaml_in_str( dir )
166
+ yaml_str = ""
167
+ Dir[ File.join( dir, "*.yaml" ) ].sort.each do |yaml_file|
168
+ SOCMaker::logger.info "reading:" + yaml_file
169
+ yaml_str << File.read( yaml_file )
170
+ end
171
+ return yaml_str
172
+ end
173
+
174
+
175
+
176
+ # gets an SOCMaker::LibInc object and iterates
177
+ # over all folders.
178
+ # Note: this is moved from process_include to this extra function
179
+ # to support test capability
180
+ def add_include( soc_inc_object, dir )
181
+ soc_inc_object.dirs.each { |d| process_include( File.expand_path( File.join( dir, d ) ) ) }
182
+ end
183
+
184
+
185
+ #
186
+ # Method to add an IP-Core object (SOCMaker::CoreDef) to this library
187
+ #
188
+ def add_core( core )
189
+ # save core
190
+ @cores_lib[ core.id ] = core
191
+
192
+ SOCMaker::logger.info "loaded #{core.name}, id: #{core.id}"
193
+ end
194
+
195
+ #
196
+ # Method to access IP-Core objects (SOCMaker::CoreDef) of this library
197
+ #
198
+ def get_core( id )
199
+ tmp = @cores_lib[ id ]
200
+ processing_error "Core with id '#{id}' does not exist" if !tmp
201
+ return tmp
202
+ end
203
+
204
+ #
205
+ # Method to remove IP-Core objects (SOCMaker::CoreDef) from this library
206
+ #
207
+ def rm_core( arg )
208
+
209
+ if arg.is_a?( Symbol )
210
+ processing_error "Core with id '#{arg}' does not exist" if !@cores_lib[ arg ]
211
+ @cores_lib.delete( arg )
212
+
213
+ elsif arg.is_a?( SOCMaker::CoreDef )
214
+ processing_error "Core with id '#{arg.id}' does not exist" if !@cores_lib[ arg.id ]
215
+ @cores_lib.delete( arg.id )
216
+
217
+ else
218
+ raise SOCMaker::ERR::ProcessingError.new( "", "Can't remove core" )
219
+ end
220
+ end
221
+
222
+
223
+
224
+
225
+ #
226
+ # Method to add an IP-Core interface (SOCMaker::IfcSpc) to this library
227
+ #
228
+ def add_ifc( ifc )
229
+ @ifc_lib[ ifc.id ] = ifc
230
+ end
231
+
232
+ #
233
+ # Method to access an IP-Core interface (SOCMaker::IfcSpc) of this library
234
+ #
235
+ def get_ifc( id )
236
+ tmp = @ifc_lib[ id ]
237
+ processing_error "Interface with id '#{id}' does not exist" if !tmp
238
+ return tmp
239
+ end
240
+
241
+ #
242
+ # Method to remove an IP-Core interface (SOCMaker::IfcSpc) from this library
243
+ #
244
+ def rm_ifc( arg )
245
+
246
+ if arg.is_a?( Symbol )
247
+ processing_error "Interface with id '#{arg}' does not exist" if !@ifc_lib[ arg ]
248
+ @ifc_lib.delete( arg )
249
+
250
+ elsif arg.is_a?( SOCMaker::IfcSpc )
251
+ processing_error "Interface with id '#{arg.id}' does not exist" if !@ifc_lib[ arg.id ]
252
+ @ifc_lib.delete( arg.id )
253
+
254
+ else
255
+ raise SOCMaker::ERR::ProcessingError.new( "", "Can't remove interface" )
256
+ end
257
+
258
+ end
259
+
260
+ #
261
+ # Function to represent this library as string:
262
+ # A list of IP-cores and interfaces is returned as string
263
+ #
264
+ def to_s
265
+ "IP-Core - lib: \n" +
266
+ @cores_lib.keys.to_s +
267
+ "\n\nIP-Interfaces - lib: \n" +
268
+ @ifc_lib.keys.to_s
269
+ end
270
+
271
+
272
+ #
273
+ # Iterates over all cores and yields the block with the id (as string)
274
+ # and the core.
275
+ #
276
+ def cores
277
+ @cores_lib.each do |id,core|
278
+ yield( id.to_s, core )
279
+ end
280
+ end
281
+
282
+
283
+ private :add_include, :get_all_yaml_in_str
284
+
285
+ end #class Lib
286
+ end #Module SOCMaker
287
+
288
+ #
289
+ # vim: noai:ts=2:sw=2
@@ -0,0 +1,109 @@
1
+ ###############################################################
2
+ #
3
+ # File: lib_inc.rb
4
+ #
5
+ # Author: Christian Hättich
6
+ #
7
+ # Project: System-On-Chip Maker
8
+ #
9
+ # Target: Linux / Windows / Mac
10
+ #
11
+ # Language: ruby
12
+ #
13
+ #
14
+ ###############################################################
15
+ #
16
+ #
17
+ # Copyright (C) 2014 Christian Hättich - feddischson [ at ] opencores.org
18
+ #
19
+ # This program is free software: you can redistribute it and/or modify
20
+ # it under the terms of the GNU General Public License as published by
21
+ # the Free Software Foundation, either version 3 of the License, or
22
+ # (at your option) any later version.
23
+ #
24
+ # This program is distributed in the hope that it will be useful,
25
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
26
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27
+ # GNU General Public License for more details.
28
+ #
29
+ # You should have received a copy of the GNU General Public License
30
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
31
+ #
32
+ #
33
+ ###############################################################
34
+ module SOCMaker
35
+
36
+
37
+ #
38
+ # A small class, which represents a library-include information.
39
+ # The included directories are stored in @dirs
40
+ #
41
+ #
42
+ #
43
+ class LibInc
44
+ include ERR
45
+ include YAML_EXT
46
+
47
+ # the included directories
48
+ attr_accessor :dirs
49
+
50
+ #
51
+ # This constructor does nothing special. The directories can be passed
52
+ # via optional arguments
53
+ #
54
+ def initialize( opts = {} )
55
+ init_with( opts )
56
+ end
57
+
58
+ #
59
+ # Encoder method (to yaml)
60
+ #
61
+ # +coder+:: An instance of the Psych::Coder to encode this class to a YAML file
62
+ #
63
+ def encode_with( coder )
64
+ init_error_if !coder.is_a?( Psych::Coder ),
65
+ 'coder is not given as Psych::Coder'
66
+ %w[ dirs ].
67
+ each { |v| coder[ v ] = instance_variable_get "@#{v}" }
68
+ end
69
+
70
+ #
71
+ # Initialization method (from yaml)
72
+ #
73
+ # +coder+:: An instance of the Psych::Coder to init this class from a YAML file
74
+ #
75
+ #
76
+ def init_with( coder )
77
+ init_error_if !( coder.is_a?( Hash ) || coder.is_a?( Psych::Coder ) ),
78
+ 'coder is not given as Hash neither as Psych::Coder'
79
+
80
+ init_error 'no dirs are given' if coder[ 'dirs' ] == nil
81
+ @dirs = coder[ 'dirs' ]
82
+
83
+ init_error 'dirs must be of type array' if !@dirs.is_a?( Array )
84
+ init_error 'there must be at least one dir-entry' if @dirs.size == 0
85
+
86
+
87
+ @dirs.each do |f|
88
+ init_error "The dir must be defined as string",
89
+ field: 'dirs' if !f.is_a?( String )
90
+
91
+ init_error "The path string has zero length",
92
+ field: 'dirs' if f.size == 0
93
+ end
94
+ end
95
+
96
+
97
+ #
98
+ # Equality operator
99
+ #
100
+ def ==(o)
101
+ o.class == self.class && o.dirs == self.dirs
102
+ end
103
+
104
+ end
105
+ end
106
+
107
+ # vim: noai:ts=2:sw=2
108
+
109
+
@@ -0,0 +1,149 @@
1
+ ###############################################################
2
+ #
3
+ # File: parameter.rb
4
+ #
5
+ # Author: Christian Hättich
6
+ #
7
+ # Project: System-On-Chip Maker
8
+ #
9
+ # Target: Linux / Windows / Mac
10
+ #
11
+ # Language: ruby
12
+ #
13
+ #
14
+ ###############################################################
15
+ #
16
+ #
17
+ # Copyright (C) 2014 Christian Hättich - feddischson [ at ] opencores.org
18
+ #
19
+ # This program is free software: you can redistribute it and/or modify
20
+ # it under the terms of the GNU General Public License as published by
21
+ # the Free Software Foundation, either version 3 of the License, or
22
+ # (at your option) any later version.
23
+ #
24
+ # This program is distributed in the hope that it will be useful,
25
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
26
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27
+ # GNU General Public License for more details.
28
+ #
29
+ # You should have received a copy of the GNU General Public License
30
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
31
+ #
32
+ #
33
+ ###############################################################
34
+
35
+
36
+ module SOCMaker
37
+ #
38
+ #
39
+ # A small classes, used to group information
40
+ # and to verify, auto-correct and auto-complete
41
+ # this information:
42
+ # This class represents an instance parameter for
43
+ # a core with the following values:
44
+ # - type (mandatory)
45
+ # - default
46
+ # - min
47
+ # - max
48
+ # - visible
49
+ # - editable
50
+ # - description
51
+ # Most of the fields are reserved for future implementations.
52
+ #
53
+ class Parameter
54
+ include ERR
55
+
56
+ # type of the parameter
57
+ attr_accessor :type
58
+
59
+ # default value
60
+ attr_accessor :default
61
+
62
+ # min value
63
+ attr_accessor :min
64
+
65
+ # max value
66
+ attr_accessor :max
67
+
68
+ # visibility
69
+ attr_accessor :visible
70
+
71
+ # editable flag
72
+ attr_accessor :editable
73
+
74
+ # description
75
+ attr_accessor :description
76
+
77
+ # choice: if type == 'enum', choice must be an array of choices
78
+ attr_accessor :choice
79
+
80
+ #
81
+ # This constructor expects only the type as mandatory parameter,
82
+ # everything else can be passed as optional parameter.
83
+ #
84
+ def initialize( type, optional = {} )
85
+ init_with( { 'type' => type }.merge( optional ) )
86
+ end
87
+
88
+ #
89
+ # Encoder method (to yaml)
90
+ #
91
+ # +coder+:: An instance of the Psych::Coder to encode this class to a YAML file
92
+ #
93
+ def encode_with( coder )
94
+ init_error_if !coder.is_a?( Psych::Coder ),
95
+ 'coder is not given as Psych::Coder'
96
+ %w[ type default min max
97
+ visible editable description ].
98
+ each { |v| coder[ v ] = instance_variable_get "@#{v}" }
99
+ end
100
+
101
+ #
102
+ # Initialization method (from yaml)
103
+ #
104
+ # +coder+:: An instance of the Psych::Coder to init this class from a YAML file
105
+ #
106
+ #
107
+ def init_with( coder )
108
+ init_error_if !( coder.is_a?( Hash ) || coder.is_a?( Psych::Coder ) ),
109
+ 'coder is not given as Hash neither as Psych::Coder'
110
+
111
+ init_error 'no parameter type specified',
112
+ field: "type" if coder[ 'type' ] == nil
113
+
114
+ @type = coder[ 'type' ]
115
+ init_error "Parameter type is not defined with string",
116
+ field: "parameter" if !@type.is_a?( String )
117
+
118
+ init_error "Parameter type string has zero length",
119
+ field: "parameter" if @type.size == 0
120
+
121
+ @default = coder[ 'default' ] || 0
122
+ @min = coder[ 'min' ] || 0
123
+ @max = coder[ 'max' ] || 0
124
+ @visible = coder[ 'visible' ] || true
125
+ @editable = coder[ 'editable' ] || false
126
+ @description = coder[ 'description' ] || ''
127
+ @choice = coder[ 'choice' ] || []
128
+ end
129
+
130
+
131
+ #
132
+ # Equality operator
133
+ #
134
+ def ==(o)
135
+ o.class == self.class &&
136
+ o.type == self.type &&
137
+ o.default == self.default &&
138
+ o.min == self.min &&
139
+ o.max == self.max &&
140
+ o.visible == self.visible &&
141
+ o.editable == self.editable &&
142
+ o.description == self.description &&
143
+ o.choice == self.choice
144
+ end
145
+
146
+
147
+ end
148
+ end
149
+