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.
- checksums.yaml +7 -0
- data/.gitignore +5 -0
- data/History.txt +4 -0
- data/LICENSE +678 -0
- data/README.rdoc +228 -0
- data/Rakefile +46 -0
- data/bin/soc_maker_cli +80 -0
- data/bin/soc_maker_parser +85 -0
- data/core_lib/cores/adv_debug_sys/01_adv_debug_sys.yaml +245 -0
- data/core_lib/cores/or1200_rel2/01_or1200.yaml +208 -0
- data/core_lib/cores/or1200_rel2/02_or1200_files.yaml +421 -0
- data/core_lib/cores/or1200_rel2/03_or1200_sparam.yaml +188 -0
- data/core_lib/cores/or1200_rel2/or1200_defines.v.in +1799 -0
- data/core_lib/cores/ram_wb/ram_wb.yaml +102 -0
- data/core_lib/cores/ram_wb/ram_wb_b3.v.in +259 -0
- data/core_lib/cores/uart16550/01_uart16550.yaml +99 -0
- data/core_lib/cores/uart16550/02_uart16550_files.yaml +70 -0
- data/core_lib/cores/wb_connect/minsoc_tc_top.v +1802 -0
- data/core_lib/cores/wb_connect/wb_connect.yaml +733 -0
- data/core_lib/inc.yaml +13 -0
- data/core_lib/interfaces/clk_rst/clk.yaml +9 -0
- data/core_lib/interfaces/clk_rst/rst.yaml +9 -0
- data/core_lib/interfaces/clk_rst/single.yaml +7 -0
- data/core_lib/interfaces/debug/debug.yaml +32 -0
- data/core_lib/interfaces/jtag/jtag.yaml +13 -0
- data/core_lib/interfaces/jtag/jtag_tap.yaml +22 -0
- data/core_lib/interfaces/power/or_power.yaml +25 -0
- data/core_lib/interfaces/uart/uart.yaml +21 -0
- data/core_lib/interfaces/wishbone/wishbone_ma_b3.yaml +54 -0
- data/core_lib/interfaces/wishbone/wishbone_sl_b3.yaml +51 -0
- data/doc/class_arch.uml +5113 -0
- data/doc/fig/hierarchical.svg +273 -0
- data/examples/or1200_test/or1200_test.cmd +78 -0
- data/examples/or1200_test/or1200_test.rb +136 -0
- data/examples/or1200_test/rtl/or1200_test_top.vhd +274 -0
- data/examples/or1200_test/rtl/s3astarter.ucf +10 -0
- data/examples/or1200_test/rtl/xilinx_internal_jtag.v +438 -0
- data/examples/or1200_test/rtl/xilinx_internal_jtag_options.v +12 -0
- data/examples/or1200_test/sw/README.txt +35 -0
- data/examples/or1200_test/sw/bin2vmem.c +159 -0
- data/examples/or1200_test/sw/board.h +24 -0
- data/examples/or1200_test/sw/compile.sh +18 -0
- data/examples/or1200_test/sw/except.S +152 -0
- data/examples/or1200_test/sw/int.c +79 -0
- data/examples/or1200_test/sw/int.h +14 -0
- data/examples/or1200_test/sw/interconnect.h +17 -0
- data/examples/or1200_test/sw/interrupts.c +14 -0
- data/examples/or1200_test/sw/main.c +16 -0
- data/examples/or1200_test/sw/or1200.h +454 -0
- data/examples/or1200_test/sw/orp.ld +60 -0
- data/examples/or1200_test/sw/reset.S +112 -0
- data/examples/or1200_test/sw/support.c +123 -0
- data/examples/or1200_test/sw/support.h +33 -0
- data/examples/or1200_test/sw/tick.c +30 -0
- data/examples/or1200_test/sw/tick.h +2 -0
- data/examples/or1200_test/sw/uart.c +136 -0
- data/examples/or1200_test/sw/uart.h +126 -0
- data/lib/soc_maker.rb +324 -0
- data/lib/soc_maker/cli.rb +544 -0
- data/lib/soc_maker/conf.rb +310 -0
- data/lib/soc_maker/core_def.rb +579 -0
- data/lib/soc_maker/core_inst.rb +305 -0
- data/lib/soc_maker/err.rb +211 -0
- data/lib/soc_maker/hdl_coder.rb +500 -0
- data/lib/soc_maker/hdl_file.rb +166 -0
- data/lib/soc_maker/hdl_parser.rb +431 -0
- data/lib/soc_maker/ifc_def.rb +193 -0
- data/lib/soc_maker/ifc_port.rb +133 -0
- data/lib/soc_maker/ifc_spc.rb +180 -0
- data/lib/soc_maker/lib.rb +289 -0
- data/lib/soc_maker/lib_inc.rb +109 -0
- data/lib/soc_maker/parameter.rb +149 -0
- data/lib/soc_maker/soc_def.rb +847 -0
- data/lib/soc_maker/sparameter.rb +289 -0
- data/lib/soc_maker/version.rb +8 -0
- data/lib/soc_maker/ypp.rb +130 -0
- data/soc_maker.gemspec +28 -0
- data/spec/cli_cmds1.txt +39 -0
- data/spec/cli_spec.rb +49 -0
- data/spec/conf_spec.rb +44 -0
- data/spec/core_def_spec.rb +503 -0
- data/spec/core_inst_spec.rb +169 -0
- data/spec/hdl_file_spec.rb +154 -0
- data/spec/hdl_parser_spec.rb +201 -0
- data/spec/ifc_def_spec.rb +121 -0
- data/spec/ifc_port_spec.rb +92 -0
- data/spec/ifc_spc_spec.rb +196 -0
- data/spec/lib_inc_spec.rb +99 -0
- data/spec/lib_spec.rb +209 -0
- data/spec/parameter_spec.rb +86 -0
- data/spec/soc_def_spec.rb +611 -0
- data/spec/soc_maker_spec.rb +7 -0
- data/spec/sparameter_spec.rb +182 -0
- data/spec/spec_helper.rb +78 -0
- data/spec/test_soc.yaml +105 -0
- data/spec/test_soc2.yaml +60 -0
- data/spec/test_soc_lib/cores/core_A_rel1/00_core_a.yaml +75 -0
- data/spec/test_soc_lib/cores/core_A_rel1/01_core_a.yaml +57 -0
- data/spec/test_soc_lib/cores/core_A_rel1/core_a.vhd +29 -0
- data/spec/test_soc_lib/cores/core_A_rel1/core_a_pkg.vhd.src +3 -0
- data/spec/test_soc_lib/cores/core_A_rel1/core_a_pkg2.vhd.src +4 -0
- data/spec/test_soc_lib/cores/core_A_rel1/core_a_pkg3.v.src +6 -0
- data/spec/test_soc_lib/cores/core_B_rel1/core_b.vhd +25 -0
- data/spec/test_soc_lib/cores/core_B_rel1/core_b.yaml +36 -0
- data/spec/test_soc_lib/cores/core_C_v1/core_C.vhd +57 -0
- data/spec/test_soc_lib/cores/core_C_v1/core_c.yaml +42 -0
- data/spec/test_soc_lib/cores/soc_A/soc_A.yaml +12 -0
- data/spec/test_soc_lib/cores/soc_maker_include.yaml +6 -0
- data/spec/test_soc_lib/ifcs/core_AB_ifc/bidir_ifc.yaml +19 -0
- data/spec/test_soc_lib/ifcs/core_AB_ifc/core_AB_ifc.yaml +15 -0
- data/spec/test_soc_lib/ifcs/core_AB_ifc/top_ifc.yaml +9 -0
- data/spec/test_soc_lib/soc_maker_include.yaml +4 -0
- data/spec/yaml_examples.rb +367 -0
- data/spec/ypp_spec.rb +156 -0
- data/test/test_soc_maker.rb +0 -0
- metadata +255 -0
@@ -0,0 +1,305 @@
|
|
1
|
+
###############################################################
|
2
|
+
#
|
3
|
+
# File: core_inst.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
|
+
#
|
40
|
+
# This class represents a core instantiation within
|
41
|
+
# a SOC. It contains a parameter-hash #params,
|
42
|
+
# which is used to define, which parameters are set to which values.
|
43
|
+
# The type field is used to identify the SOCMaker::CoreDef
|
44
|
+
# and the field @defn is initialized as reference to
|
45
|
+
# the corresponding CoreDef instance.
|
46
|
+
class CoreInst
|
47
|
+
include ERR
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
# The core-definition of this instance
|
52
|
+
# Please note: this field is initialized by
|
53
|
+
# the method consistence_check
|
54
|
+
attr_accessor :defn
|
55
|
+
|
56
|
+
# The type (core-def. id), as symbol
|
57
|
+
attr_accessor :type
|
58
|
+
|
59
|
+
# (HDL) instance parameters
|
60
|
+
attr_accessor :params
|
61
|
+
|
62
|
+
|
63
|
+
|
64
|
+
#
|
65
|
+
# Constructor:
|
66
|
+
# there is one mandatory attributes +type+ and an optional one +params+.
|
67
|
+
#
|
68
|
+
# +type+:: The id of the core-definition, which is instanciated
|
69
|
+
# +params+:: Instanciation parameters
|
70
|
+
#
|
71
|
+
def initialize( type, params = {} )
|
72
|
+
init_with( 'type' => type,
|
73
|
+
'params' => params )
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
#
|
78
|
+
# Encoder method (to yaml)
|
79
|
+
#
|
80
|
+
# +coder+:: An instance of the Psych::Coder to encode this class to a YAML file
|
81
|
+
#
|
82
|
+
def encode_with( coder )
|
83
|
+
init_error_if !coder.is_a?( Psych::Coder ),
|
84
|
+
'coder is not given as Psych::Coder'
|
85
|
+
coder[ "params" ] = @params
|
86
|
+
coder[ "type" ] = @type.to_s
|
87
|
+
end
|
88
|
+
|
89
|
+
#
|
90
|
+
# Initialization method (from yaml)
|
91
|
+
#
|
92
|
+
# +coder+:: An instance of the Psych::Coder to init this class from a YAML file
|
93
|
+
#
|
94
|
+
#
|
95
|
+
def init_with( coder )
|
96
|
+
init_error_if !( coder.is_a?( Hash ) || coder.is_a?( Psych::Coder ) ),
|
97
|
+
'coder is not given as Hash neither as Psych::Coder'
|
98
|
+
|
99
|
+
init_error_if( !( coder[ 'type' ].is_a?( String ) ||
|
100
|
+
coder[ 'type' ].is_a?( Symbol ) ),
|
101
|
+
"core-type error: must be defined as String or Symbol",
|
102
|
+
field: type )
|
103
|
+
|
104
|
+
@type = coder[ 'type' ].to_sym
|
105
|
+
|
106
|
+
@params = coder[ 'params' ] || {}
|
107
|
+
init_error_if !@params.is_a?( Hash ),
|
108
|
+
'Parameters are not given as hash',
|
109
|
+
field: 'params'
|
110
|
+
|
111
|
+
end
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
|
116
|
+
#
|
117
|
+
# Runs a consistence check and creates an internal
|
118
|
+
# hash, which contains all evaluated ports.
|
119
|
+
# Because the core-definition may contain variable port sizes,
|
120
|
+
# which depend on the instance, these sizes need to be evaluated.
|
121
|
+
# This is also done here and the result is stored in @_ifcs_evaluated.
|
122
|
+
#
|
123
|
+
#
|
124
|
+
def consistence_check
|
125
|
+
|
126
|
+
begin
|
127
|
+
@defn = SOCMaker::lib.get_core( @type )
|
128
|
+
rescue ProcessingError => e
|
129
|
+
consistence_error e.message
|
130
|
+
end
|
131
|
+
|
132
|
+
|
133
|
+
# check, if the instance parameters are in the core definition
|
134
|
+
@params.each do |param_name, value|
|
135
|
+
consistence_error_if(
|
136
|
+
@defn.inst_parameters[ param_name ] == nil,
|
137
|
+
"Parameter not found: " + param_name.to_s,
|
138
|
+
field: 'params',
|
139
|
+
core_type: @defn.name )
|
140
|
+
end
|
141
|
+
|
142
|
+
## auto-complete parameters with default values
|
143
|
+
@defn.inst_parameters.each do |param_name, param|
|
144
|
+
|
145
|
+
# auto-complete to default values
|
146
|
+
@params[ param_name ] ||= param.default
|
147
|
+
end
|
148
|
+
|
149
|
+
@_ifcs_evaluated ||= {}
|
150
|
+
@defn.interfaces.keys.each do |ifc_name|
|
151
|
+
@_ifcs_evaluated[ ifc_name ] = {}
|
152
|
+
@defn.ports( ifc_name.to_s ) do |port_name, port_dir, port_len, default, spc_ref, is_last |
|
153
|
+
if port_len.is_a?( String )
|
154
|
+
param_match = SOCMaker::conf[ :length_regex ].match( port_len )
|
155
|
+
if param_match and @params[ port_len.to_sym ] != nil
|
156
|
+
tmp =@params[ port_len.to_sym ]
|
157
|
+
tmp = tmp.to_i if tmp.is_a?( String )
|
158
|
+
@_ifcs_evaluated[ ifc_name ][ port_name.to_sym ] = { len: tmp, dir: port_dir, default: default, ref: spc_ref }
|
159
|
+
else
|
160
|
+
SOCMaker::logger.error( "Failed to evaluate #{port_len} for port #{port_name}" )
|
161
|
+
end
|
162
|
+
else
|
163
|
+
@_ifcs_evaluated[ ifc_name ][ port_name.to_sym ] = { len: port_len, dir: port_dir, default: default, ref: spc_ref }
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
@defn.consistence_check
|
169
|
+
|
170
|
+
end
|
171
|
+
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
|
178
|
+
#
|
179
|
+
# Iterate over all ports and call the block with
|
180
|
+
# - port-name
|
181
|
+
# - port length
|
182
|
+
# - default value
|
183
|
+
# - is-last value
|
184
|
+
#
|
185
|
+
# If no argument is given, all ports of this instance are processed.
|
186
|
+
# If arguments are given, each argument is supposed to the name of
|
187
|
+
# a interface. All specified interfaces with all ports are processed.
|
188
|
+
#
|
189
|
+
# +args+:: Optional list of interface names
|
190
|
+
#
|
191
|
+
#
|
192
|
+
def ports( *args )
|
193
|
+
|
194
|
+
if args.size == 0
|
195
|
+
ifc_sel = @_ifcs_evaluated
|
196
|
+
else
|
197
|
+
ifc_sel = @_ifcs_evaluated.select{ |k,v| args.include?( k ) }
|
198
|
+
end
|
199
|
+
|
200
|
+
ifc_sel.values.each_with_index do |ifc, i_ifc|
|
201
|
+
ifc.each_with_index do |(port_name, port_def), i_port|
|
202
|
+
yield( port_name.to_s,
|
203
|
+
port_def[ :dir ],
|
204
|
+
port_def[ :len ],
|
205
|
+
port_def[ :default ],
|
206
|
+
port_def[ :ref ],
|
207
|
+
i_port==ifc.size-1 && i_ifc == ifc_sel.size-1 )
|
208
|
+
end
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
#
|
213
|
+
# Iterate over all generics and call the block with
|
214
|
+
# - generic-name
|
215
|
+
# - generic-type
|
216
|
+
# - the value
|
217
|
+
# - is-last information
|
218
|
+
#
|
219
|
+
def generics
|
220
|
+
@defn.generics do |name, type, default_value, is_last|
|
221
|
+
value = @params[ name.to_sym ];
|
222
|
+
value = default_value if value == nil
|
223
|
+
yield( name.to_s, type, value, is_last )
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
227
|
+
|
228
|
+
|
229
|
+
|
230
|
+
|
231
|
+
|
232
|
+
|
233
|
+
#
|
234
|
+
# Returns a port, identified by the interface and port name
|
235
|
+
#
|
236
|
+
# +ifc_name+:: name of the interface
|
237
|
+
# +port_ref+:: name of the port
|
238
|
+
#
|
239
|
+
def port( ifc_name, port_ref )
|
240
|
+
tmp = @defn.interfaces[ ifc_name ].
|
241
|
+
ports.select{ |key,hash| hash.spc_ref == port_ref.to_s }.
|
242
|
+
keys.first
|
243
|
+
return [ tmp.to_s, @_ifcs_evaluated[ ifc_name ][ tmp ] ]
|
244
|
+
end
|
245
|
+
|
246
|
+
#
|
247
|
+
# Returns the length of a port within an interface.
|
248
|
+
# If no instance is given, we know that it is
|
249
|
+
# a toplevel interface.
|
250
|
+
# Otherwise we check for this and we do a recursive call.
|
251
|
+
# If this port is within a interface of a core, we
|
252
|
+
# pass the call to the core-definition of this instance, which
|
253
|
+
# knows all cores.
|
254
|
+
#
|
255
|
+
# +ifc_name+:: name of the interface
|
256
|
+
# +port_ref+:: name of the port
|
257
|
+
# +inst+:: name of the instance (optional), default is nil
|
258
|
+
#
|
259
|
+
def port_length( ifc_name, port_ref, inst = nil )
|
260
|
+
if inst == nil
|
261
|
+
tmp = @defn.interfaces[ ifc_name ].
|
262
|
+
ports.select{ |key,hash| hash.spc_ref == port_ref.to_s }.
|
263
|
+
keys
|
264
|
+
return 0 if tmp.size == 0
|
265
|
+
return @_ifcs_evaluated[ ifc_name ][ tmp.first ][ :len ] if tmp.size == 1
|
266
|
+
# we ensure in SOCMaker::IfcDef that there is only one reference
|
267
|
+
else
|
268
|
+
if inst == @defn.toplevel.to_sym
|
269
|
+
return port_length( ifc_name, port_ref )
|
270
|
+
else
|
271
|
+
return @defn.port_length( ifc_name, port_ref, inst )
|
272
|
+
end
|
273
|
+
end
|
274
|
+
end
|
275
|
+
|
276
|
+
|
277
|
+
#
|
278
|
+
# Returns a string describing this instance
|
279
|
+
#
|
280
|
+
def to_s
|
281
|
+
"type: #{type}\n" +
|
282
|
+
"params: #{params}\n"
|
283
|
+
end
|
284
|
+
|
285
|
+
#
|
286
|
+
# Equality operator
|
287
|
+
#
|
288
|
+
def ==(o)
|
289
|
+
o.class == self.class &&
|
290
|
+
o.type == self.type &&
|
291
|
+
o.params == self.params
|
292
|
+
end
|
293
|
+
|
294
|
+
|
295
|
+
|
296
|
+
# private :core_definition
|
297
|
+
|
298
|
+
|
299
|
+
|
300
|
+
end # CoreInst
|
301
|
+
end # SOCMaker
|
302
|
+
|
303
|
+
|
304
|
+
|
305
|
+
# vim: noai:ts=2:sw=2
|
@@ -0,0 +1,211 @@
|
|
1
|
+
###############################################################
|
2
|
+
#
|
3
|
+
# File: err.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
|
+
# This sub-module contains some error-functionallity,
|
38
|
+
# which is used in different classes via mixins.
|
39
|
+
#
|
40
|
+
module ERR
|
41
|
+
|
42
|
+
#
|
43
|
+
# An error, which is thrown if YAML parsing fails
|
44
|
+
#
|
45
|
+
class YAMLParseError < RuntimeError
|
46
|
+
end
|
47
|
+
|
48
|
+
|
49
|
+
|
50
|
+
#
|
51
|
+
# Processing errors: occur during the the processing
|
52
|
+
# of SoCs.
|
53
|
+
#
|
54
|
+
class ProcessingError < RuntimeError
|
55
|
+
#
|
56
|
+
# Optional error information
|
57
|
+
#
|
58
|
+
attr :optinal
|
59
|
+
#
|
60
|
+
# This constructor saves the message and optional infos and
|
61
|
+
# adds a log entry via SOCMaker::logger.error
|
62
|
+
# +message+:: the error message
|
63
|
+
# +o+:: optional error information
|
64
|
+
#
|
65
|
+
def initialize( message, o={} )
|
66
|
+
super message
|
67
|
+
@optional = o
|
68
|
+
SOCMaker::logger.error( "Processing Error Raised: #{message} #{ "\n\t\t" + o.inspect if o.size > 0}" )
|
69
|
+
end
|
70
|
+
#
|
71
|
+
# Returns a string describing this error
|
72
|
+
#
|
73
|
+
def to_s
|
74
|
+
"#{super} #{ "\n\t\t" + @optional.inspect if @optional.size > 0}"
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
#
|
79
|
+
# Method to raise a processing error
|
80
|
+
# +msg+:: error message
|
81
|
+
# +o+:: optional info
|
82
|
+
#
|
83
|
+
def processing_error( msg, o={} )
|
84
|
+
raise ProcessingError.new( msg, o )
|
85
|
+
end
|
86
|
+
|
87
|
+
# Method to raise a processing error
|
88
|
+
# if the condition is true
|
89
|
+
# +con+:: condition
|
90
|
+
# +msg+:: error message
|
91
|
+
# +o+:: optional info
|
92
|
+
def processing_error_if( res, msg, o={} )
|
93
|
+
if !!(res)
|
94
|
+
processing_error( msg, o )
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
#
|
104
|
+
# Consistence errors: occur during the consistence check
|
105
|
+
# of the classes or in a few methods, where a inconsistence
|
106
|
+
# can be caused by external call.
|
107
|
+
# A cause for this error could be, that a core or interface
|
108
|
+
# doesn't exist in the library. Or a port in of a IfcDef is
|
109
|
+
# not defined in the IfcSpc.
|
110
|
+
#
|
111
|
+
class ConsistenceError < RuntimeError
|
112
|
+
#
|
113
|
+
# Optional error information
|
114
|
+
#
|
115
|
+
attr :optinal
|
116
|
+
#
|
117
|
+
# This constructor saves the message and optional infos and
|
118
|
+
# adds a log entry via SOCMaker::logger.error
|
119
|
+
# +message+:: the error message
|
120
|
+
# +o+:: optional error information
|
121
|
+
#
|
122
|
+
def initialize( message, o={} )
|
123
|
+
super message
|
124
|
+
@optional = o
|
125
|
+
SOCMaker::logger.error( "Consistence Error Raised: #{message} #{ "\n\t\t" + o.inspect if o.size > 0}" )
|
126
|
+
end
|
127
|
+
#
|
128
|
+
# Returns a string describing this error
|
129
|
+
#
|
130
|
+
def to_s
|
131
|
+
"#{super} #{ "\n\t\t" + @optional.inspect if @optional.size > 0}"
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
#
|
136
|
+
# Method to raise a consistence error
|
137
|
+
# +msg+:: error message
|
138
|
+
# +o+:: optional info
|
139
|
+
#
|
140
|
+
def consistence_error( msg, o={} )
|
141
|
+
raise ConsistenceError.new( msg, o )
|
142
|
+
end
|
143
|
+
|
144
|
+
# Method to raise a consistence error
|
145
|
+
# if the condition is true
|
146
|
+
# +con+:: condition
|
147
|
+
# +msg+:: error message
|
148
|
+
# +o+:: optional info
|
149
|
+
def consistence_error_if( con, msg, o={} )
|
150
|
+
if !!(con)
|
151
|
+
consistence_error( msg, o )
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
#
|
158
|
+
# Initialization errors: occur during the initialization
|
159
|
+
# of the classes. A cause for this error could be a wrong structure
|
160
|
+
# of the YAML file, for example wrong data types.
|
161
|
+
#
|
162
|
+
class InitError < RuntimeError
|
163
|
+
#
|
164
|
+
# Optional error information
|
165
|
+
#
|
166
|
+
attr :optinal
|
167
|
+
#
|
168
|
+
# This constructor saves the message and optional infos and
|
169
|
+
# adds a log entry via SOCMaker::logger.error
|
170
|
+
# +message+:: the error message
|
171
|
+
# +o+:: optional error information
|
172
|
+
#
|
173
|
+
def initialize( message, o={} )
|
174
|
+
super message
|
175
|
+
@optional = o
|
176
|
+
if SOCMaker::logger
|
177
|
+
SOCMaker::logger.error( "Initialization Error Raised: #{message} #{ "\n\t\t" + o.inspect if o.size > 0}" )
|
178
|
+
end
|
179
|
+
end
|
180
|
+
#
|
181
|
+
# Returns a string describing this error
|
182
|
+
#
|
183
|
+
def to_s
|
184
|
+
"#{super} #{ "\n\t\t" + @optional.inspect if @optional.size > 0}"
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
#
|
189
|
+
# Method to raise an initialization error
|
190
|
+
# +msg+:: error message
|
191
|
+
# +o+:: optional info
|
192
|
+
#
|
193
|
+
def init_error( msg, o={} )
|
194
|
+
raise InitError.new( msg, o )
|
195
|
+
end
|
196
|
+
|
197
|
+
# Method to raise an initialization error
|
198
|
+
# if the condition is true
|
199
|
+
# +con+:: condition
|
200
|
+
# +msg+:: error message
|
201
|
+
# +o+:: optional info
|
202
|
+
def init_error_if( con, msg, o={} )
|
203
|
+
if !!(con)
|
204
|
+
init_error( msg, o )
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
208
|
+
|
209
|
+
end # module ERR
|
210
|
+
|
211
|
+
end # module SOCMaker
|