Module: Origen::Specs

Includes:
Checkers
Included in:
PowerDomains::PowerDomain
Defined in:
lib/origen/specs.rb,
lib/origen/specs/note.rb,
lib/origen/specs/spec.rb,
lib/origen/specs/exhibit.rb,
lib/origen/specs/checkers.rb,
lib/origen/specs/override.rb,
lib/origen/specs/mode_select.rb,
lib/origen/specs/doc_resource.rb,
lib/origen/specs/power_supply.rb,
lib/origen/specs/creation_info.rb,
lib/origen/specs/documentation.rb,
lib/origen/specs/spec_features.rb,
lib/origen/specs/version_history.rb

Defined Under Namespace

Modules: Checkers Classes: Creation_Info, Doc_Resource, Documentation, Exhibit, Mode_Select, Note, Override, Power_Supply, Spec, SpecArray, SpecTableAttr, Spec_Features, Version_History

Constant Summary collapse

SPEC_TYPES =

Added :impedance and :power to the spec types

[:dc, :ac, :temperature, :supply, :impedance, :power]
NOTE_TYPES =
[:spec, :doc, :mode, :feature, :sighting]
FEATURE_TYPES =
[:intro, :feature, :subfeature]

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Checkers

#evaluate_limit, #get_mode, #limits_ok?, #name_audit

Instance Attribute Details

#_creation_info=(value) ⇒ Object

Sets the attribute _creation_info

Parameters:

  • value

    the value to set the attribute _creation_info to.



17
18
19
# File 'lib/origen/specs.rb', line 17

def _creation_info=(value)
  @_creation_info = value
end

#_doc_resources=(value) ⇒ Object

Sets the attribute _doc_resources

Parameters:

  • value

    the value to set the attribute _doc_resources to.



17
18
19
# File 'lib/origen/specs.rb', line 17

def _doc_resources=(value)
  @_doc_resources = value
end

#_documentation=(value) ⇒ Object

Sets the attribute _documentation

Parameters:

  • value

    the value to set the attribute _documentation to.



17
18
19
# File 'lib/origen/specs.rb', line 17

def _documentation=(value)
  @_documentation = value
end

#_exhibits=(value) ⇒ Object

Sets the attribute _exhibits

Parameters:

  • value

    the value to set the attribute _exhibits to.



17
18
19
# File 'lib/origen/specs.rb', line 17

def _exhibits=(value)
  @_exhibits = value
end

#_mode_selects=(value) ⇒ Object

Sets the attribute _mode_selects

Parameters:

  • value

    the value to set the attribute _mode_selects to.



17
18
19
# File 'lib/origen/specs.rb', line 17

def _mode_selects=(value)
  @_mode_selects = value
end

#_notes=(value) ⇒ Object

Sets the attribute _notes

Parameters:

  • value

    the value to set the attribute _notes to.



17
18
19
# File 'lib/origen/specs.rb', line 17

def _notes=(value)
  @_notes = value
end

#_overrides=(value) ⇒ Object

Sets the attribute _overrides

Parameters:

  • value

    the value to set the attribute _overrides to.



17
18
19
# File 'lib/origen/specs.rb', line 17

def _overrides=(value)
  @_overrides = value
end

#_power_supplies=(value) ⇒ Object

Sets the attribute _power_supplies

Parameters:

  • value

    the value to set the attribute _power_supplies to.



17
18
19
# File 'lib/origen/specs.rb', line 17

def _power_supplies=(value)
  @_power_supplies = value
end

#_spec_features=(value) ⇒ Object

Sets the attribute _spec_features

Parameters:

  • value

    the value to set the attribute _spec_features to.



17
18
19
# File 'lib/origen/specs.rb', line 17

def _spec_features=(value)
  @_spec_features = value
end

#_specs=(value) ⇒ Object

Sets the attribute _specs

Parameters:

  • value

    the value to set the attribute _specs to.



17
18
19
# File 'lib/origen/specs.rb', line 17

def _specs=(value)
  @_specs = value
end

#_version_history=(value) ⇒ Object

Sets the attribute _version_history

Parameters:

  • value

    the value to set the attribute _version_history to.



17
18
19
# File 'lib/origen/specs.rb', line 17

def _version_history=(value)
  @_version_history = value
end

#descriptionObject

Detailed description for the ip block



20
21
22
# File 'lib/origen/specs.rb', line 20

def description
  @description
end

Instance Method Details

#creation_info(author, date, version, src_info = {}, tool_info = {}) ⇒ Object



213
214
215
216
# File 'lib/origen/specs.rb', line 213

def creation_info(author, date, version, src_info = {}, tool_info = {})
  # Create a new Information Information.  Should only be one.
  @_creation_info = Creation_Info.new(author, date, version, src_info, tool_info)
end

#delete_all_doc_resourcesObject



516
517
518
# File 'lib/origen/specs.rb', line 516

def delete_all_doc_resources
  @_doc_resources = nil
end

#delete_all_documentationObject



544
545
546
# File 'lib/origen/specs.rb', line 544

def delete_all_documentation
  @_documentation = nil
end

#delete_all_exhibitsObject

Delete all exhibits



512
513
514
# File 'lib/origen/specs.rb', line 512

def delete_all_exhibits
  @_exhibits = nil
end

#delete_all_mode_selectsObject



532
533
534
# File 'lib/origen/specs.rb', line 532

def delete_all_mode_selects
  @_mode_selects = nil
end

#delete_all_notesObject

Delete all notes



507
508
509
# File 'lib/origen/specs.rb', line 507

def delete_all_notes
  @_notes = nil
end

#delete_all_overridesObject



520
521
522
# File 'lib/origen/specs.rb', line 520

def delete_all_overrides
  @_overrides = nil
end

#delete_all_power_suppliesObject



524
525
526
# File 'lib/origen/specs.rb', line 524

def delete_all_power_supplies
  @_power_supplies = nil
end

#delete_all_specsObject

Delete all specs



502
503
504
# File 'lib/origen/specs.rb', line 502

def delete_all_specs
  @_specs = nil
end

#delete_all_version_historyObject



528
529
530
# File 'lib/origen/specs.rb', line 528

def delete_all_version_history
  @_version_history = nil
end

#delete_creation_infoObject



536
537
538
# File 'lib/origen/specs.rb', line 536

def delete_creation_info
  @_creation_info = nil
end

#delete_spec_featuresObject



540
541
542
# File 'lib/origen/specs.rb', line 540

def delete_spec_features
  @_spec_features = nil
end

#doc_resource(selector = {}, table_title = {}, text = {}, options = {}) ⇒ Object



166
167
168
169
170
171
172
173
174
175
# File 'lib/origen/specs.rb', line 166

def doc_resource(selector = {}, table_title = {}, text = {}, options = {})
  # Welguisz:  No idea why this is here, but keeping it here because it follows other blocks
  _doc_resources
  mode = selector[:mode]
  type = selector[:type]
  sub_type = selector[:sub_type]
  audience = selector[:audience]
  # Create a new Document Resource and place it in the Doc Resources 4-D Hash
  @_doc_resources[mode][type][sub_type][audience] = Doc_Resource.new(selector, table_title, text, options)
end

#doc_resources(options = {}) ⇒ Object



306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
# File 'lib/origen/specs.rb', line 306

def doc_resources(options = {})
  options = {
    mode:     nil,
    type:     nil,
    sub_type: nil,
    audience: nil
  }.update(options)
  return nil if @_doc_resources.nil?
  return nil if @_doc_resources.empty?
  dr_found = Hash.new do |h, k|
    h[k] = Hash.new do |hh, kk|
      hh[kk] = Hash.new do |hhh, kkk|
        hhh[kkk] = {}
      end
    end
  end
  filter_hash(@_doc_resources, options[:mode]).each do |_mode, hash|
    filter_hash(hash, options[:type]).each do |_type, hash_|
      filter_hash(hash_, options[:sub_type]).each do |_sub_type, hash__|
        filter_hash(hash__, options[:audience]).each do |_audience, spec|
          dr_found[_mode][_type][_sub_type][_audience] = spec
        end
      end
    end
  end
  if dr_found.empty?
    return nil
  else
    return dr_found
  end
end

#documentation(header_info, selection, applicable_devices, link) ⇒ Object

Adds a new documentation notion to the block



137
138
139
140
141
# File 'lib/origen/specs.rb', line 137

def documentation(header_info, selection, applicable_devices, link)
  _documentation
  # Create a new documenation and place it in the 5-D hash
  @_documentation[header_info[:section]][header_info[:subsection]][selection[:interface]][selection[:type]][selection[:sub_type]][selection[:mode]][selection[:audience]] = Documentation.new(header_info, selection, applicable_devices, link)
end

#documentations(options = {}) ⇒ Object



338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
# File 'lib/origen/specs.rb', line 338

def documentations(options = {})
  options = {
    section:    nil,
    subsection: nil,
    interface:  nil,
    mode:       nil,
    type:       nil,
    sub_type:   nil,
    audience:   nil
  }.update(options)
  return nil if @_documentation.nil?
  return nil if @_documentation.empty?
  doc_found = Hash.new do |h, k|
    h[k] = Hash.new do |hh, kk|
      hh[kk] = Hash.new do |hhh, kkk|
        hhh[kkk] = Hash.new do |hhhh, kkkk|
          hhhh[kkkk] = Hash.new do |hhhhh, kkkkk|
            hhhhh[kkkkk] = Hash.new do |hhhhhh, kkkkkk|
              hhhhhh[kkkkkk] = {}
            end
          end
        end
      end
    end
  end
  filter_hash(@_documentation, options[:section]).each do |_section, hash|
    filter_hash(hash, options[:subsection]).each do |_subsection, hash_|
      filter_hash(hash_, options[:interface]).each do |_interface, hash__|
        filter_hash(hash__, options[:type]).each do |_type, hash___|
          filter_hash(hash___, options[:sub_type]).each do |_sub_type, hash____|
            filter_hash(hash____, options[:mode]).each do |_mode, hash_____|
              filter_hash(hash_____, options[:audience]).each do |_audience, doc|
                doc_found[_section][_subsection][_interface][_type][_sub_type][_mode][_audience] = doc
              end
            end
          end
        end
      end
    end
  end
  if doc_found.empty?
    return nil
  else
    return doc_found
  end
end

#exhibit(id, type, overrides = {}, options = {}) ⇒ Object



159
160
161
162
163
164
# File 'lib/origen/specs.rb', line 159

def exhibit(id, type, overrides = {}, options = {})
  # Welguisz:  No idea why this is here, but keeping it here because it follows other blocks
  _exhibits
  # Create a new Exhibit and place it in the exhibits 3-D Hash
  @_exhibits[options[:block_id]][id][type] = Exhibit.new(id, type, overrides, options)
end

#exhibits(options = {}) ⇒ Object



279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
# File 'lib/origen/specs.rb', line 279

def exhibits(options = {})
  options = {
    block: nil,
    id:    nil,
    type:  nil
  }.update(options)
  return nil if @_exhibits.nil?
  return nil if @_exhibits.empty?
  ex_found = Hash.new do |h, k|
    h[k] = Hash.new do |hh, kk|
      hh[kk] = {}
    end
  end
  filter_hash(@_exhibits, options[:block]).each do |_block, hash|
    filter_hash(hash, options[:id]).each do |_id, hash_|
      filter_hash(hash_, options[:type]).each do |_type, exh|
        ex_found[_block][_id][_type] = exh
      end
    end
  end
  if ex_found.empty?
    return nil
  else
    return ex_found
  end
end

#get_creation_infoObject



218
219
220
# File 'lib/origen/specs.rb', line 218

def get_creation_info
  @_creation_info
end

#get_modesObject

Returns the modes for this block



117
118
119
# File 'lib/origen/specs.rb', line 117

def get_modes
  @_modes
end

#has_spec?(s, options = {}) ⇒ Boolean

Check if the current IP has a spec

Returns:

  • (Boolean)


122
123
124
125
126
127
128
129
130
131
132
133
134
# File 'lib/origen/specs.rb', line 122

def has_spec?(s, options = {})
  _specs
  options = {
    type:          nil,
    sub_type:      nil,
    mode:          current_mode.nil? ? nil : current_mode.name,
    spec:          nil,
    symbol:        false,
    creating_spec: false
  }.update(options)
  options[:spec] = s
  !!show_specs(options)
end

#has_specs?(options = {}) ⇒ Boolean

Returns Boolean based on whether the calling object has any defined specs If the mode option is selected then the search is narrowed

Returns:

  • (Boolean)


99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/origen/specs.rb', line 99

def has_specs?(options = {})
  _specs
  options = {
    type:          nil,
    sub_type:      nil,
    mode:          current_mode.nil? ? nil : current_mode.name,
    spec:          nil,
    symbol:        false,
    creating_spec: false
  }.update(options)
  if @_specs.nil? || @_specs == {}
    return false
  else
    return !!show_specs(options)
  end
end

#infoObject



497
498
499
# File 'lib/origen/specs.rb', line 497

def info
  @_creation_info
end

#mode_select(block_information, mode_usage, power_information) ⇒ Object



204
205
206
207
208
209
210
211
# File 'lib/origen/specs.rb', line 204

def mode_select(block_information, mode_usage, power_information)
  # Welguisz:  No idea why this is here, but keeping it here because it follows other blocks
  _mode_selects
  # See if the mode will be used.  If so, create a new Mode Select and place it in mode_selects 2-D Hash
  if block_information[:usage]
    @_mode_selects[block_information[:name]][mode_usage[:mode]] = Mode_Select.new(block_information, mode_usage, power_information)
  end
end

#mode_selects(options = {}) ⇒ Object



422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
# File 'lib/origen/specs.rb', line 422

def mode_selects(options = {})
  options = {
    block: nil,
    mode:  nil
  }.update(options)
  return nil if @_mode_selects.nil?
  return nil if @_mode_selects.empty?
  modes_found = Hash.new do|h, k|
    h[k] = {}
  end
  filter_hash(@_mode_selects, options[:block]).each do |block, hash|
    filter_hash(hash, options[:mode]).each do |mode, sel|
      modes_found[block][mode] = sel
    end
  end
  if modes_found.empty?
    return nil
  else
    return modes_found
  end
end

#note(id, type, options = {}) ⇒ Object

Define and instantiate a Note object



152
153
154
155
156
157
# File 'lib/origen/specs.rb', line 152

def note(id, type, options = {})
  # Welguisz:  No idea why this is here, but keeping it here because it follows other blocks
  _notes
  # Create a new note and place it in the notes 2-D Hash
  @_notes[id][type] = Note.new(id, type, options)
end

#notes(options = {}) ⇒ Object

Returns a Note object from the notes hash



223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
# File 'lib/origen/specs.rb', line 223

def notes(options = {})
  # Create a default 2 item hash and update if options is supplied
  options = {
    id:   nil,
    type: nil
  }.update(options)
  return nil if @_notes.nil?
  return nil if @_notes.empty?
  # Empty 2-D Hash to be used for notes found based on id and type
  notes_found = Hash.new do |h, k|
    # h is the id portion of the hash
    # k is the type portion of the hash
    h[k] = {}
  end
  # Filter @notes based off of the id
  filter_hash(@_notes, options[:id]).each do |id, hash|
    # Filter hash based off of the type
    filter_hash(hash, options[:type]).each do |type, note|
      # Store the note into note_found
      notes_found[id][type] = note
    end
  end
  if notes_found.empty?
    return nil
  elsif notes_found.size == 1
    notes_found.values.first.values.first
  else
    return notes_found
  end
end

#override(block_options = {}, find_spec = {}, values = {}, options = {}) ⇒ Object



185
186
187
188
189
190
191
192
193
194
195
# File 'lib/origen/specs.rb', line 185

def override(block_options = {}, find_spec = {}, values = {}, options = {})
  # Welguisz:  No idea why this is here, but keeping it here because it follows other blocks
  _overrides
  block = block_options[:block]
  spec_ref = find_spec[:spec_id]
  mode_ref = find_spec[:mode_ref]
  sub_type = find_spec[:sub_type]
  audience = find_spec[:audience]
  # Create a new Override and place it in the overrides 5-D Hash
  @_overrides[block][spec_ref][mode_ref][sub_type][audience] = Override.new(block_options, find_spec, values, options)
end

#overrides(options = {}) ⇒ Object



385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
# File 'lib/origen/specs.rb', line 385

def overrides(options = {})
  options = {
    block:    nil,
    spec_ref: nil,
    mode_ref: nil,
    sub_type: nil,
    audience: nil
  }.update(options)
  return nil if @_overrides.nil?
  return nil if @_overrides.empty?
  overrides_found = Hash.new do |h, k|
    h[k] = Hash.new do |hh, kk|
      hh[kk] = Hash.new do |hhh, kkk|
        hhh[kkk] = Hash.new do |hhhh, kkkk|
          hhhh[kkkk] = {}
        end
      end
    end
  end
  filter_hash(@_overrides, options[:block]).each do |_block, hash|
    filter_hash(hash, options[:spec_ref]).each do |_spec_ref, hash_|
      filter_hash(hash_, options[:mode_ref]).each do |_mode_ref, hash__|
        filter_hash(hash__, options[:sub_type]).each do |_sub_type, hash___|
          filter_hash(hash___, options[:audience]).each do |_audience, override|
            overrides_found[_block][_spec_ref][_mode_ref][_sub_type][_audience] = override
          end
        end
      end
    end
  end
  if overrides_found.empty?
    return nil
  else
    return overrides_found
  end
end

#power_supplies(options = {}) ⇒ Object



444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
# File 'lib/origen/specs.rb', line 444

def power_supplies(options = {})
  options = {
    gen: nil,
    act: nil
  }.update(options)
  ps_found = Hash.new do|h, k|
    h[k] = {}
  end
  return nil if @_power_supplies.nil?
  return nil if @_power_supplies.empty?
  filter_hash(@_power_supplies, options[:gen]).each do |gen, hash|
    filter_hash(hash, options[:act]).each do |act, sel|
      ps_found[gen][act] = sel
    end
  end
  if ps_found.empty?
    return nil
  else
    return ps_found
  end
end

#power_supply(gen, act) ⇒ Object



197
198
199
200
201
202
# File 'lib/origen/specs.rb', line 197

def power_supply(gen, act)
  # Welguisz:  No idea why this is here, but keeping it here because it follows other blocks
  _power_supplies
  # Create a new Power Supply and place it in the power supplies 2-D Hash
  @_power_supplies[gen][act] = Power_Supply.new(gen, act)
end

#spec(name, type = nil, mode = nil, &block) ⇒ Object

Define and instantiate a Spec object



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/origen/specs.rb', line 69

def spec(name, type = nil, mode = nil, &block)
  return specs(name, type) unless block_given?
  fail 'A type argument is required when defining a spec!' unless type
  _specs
  name = name_audit(name)
  fail 'Specification names must be of SPEC_TYPES Symbol or String and cannot start with a number' if name.nil?
  fail "Spec type must be one of #{SPEC_TYPES.join(', ')}" unless SPEC_TYPES.include? type
  type = type
  mode = get_mode if mode.nil?
  owner_name = ''
  if self.respond_to?(:name) && send(:name)
    owner_name = self.name.to_s.downcase.to_sym
  elsif self == Origen.top_level
    owner_name = self.class.to_s.split('::').last.downcase.to_sym
  else
    owner_name = self.class.to_s.split('::').last.downcase.to_sym
  end
  spec_placeholder = Spec
                     .new(name, type, mode, owner_name, &block)
  # Check if the spec already exists
  if has_spec?(name, type: type, mode: mode, sub_type: spec_placeholder.sub_type, creating_spec: true)
    # Spec already exists.  Go ahead flag error and drop processing.
    # This is a fatal error.
    fail "Spec already exists for name: #{name}, type: #{type}, mode: #{mode} for object #{self}"
  end
  @_specs[name][mode][type][spec_placeholder.sub_type] = spec_placeholder
end

#spec_feature(id, attrs, device, text, internal_comment) ⇒ Object

Adds a new feature to the block



144
145
146
147
148
149
# File 'lib/origen/specs.rb', line 144

def spec_feature(id, attrs, device, text, internal_comment)
  # Welguisz:  No idea why this is here, but keeping it here because it follows other blocks
  _spec_features
  # Create a new feature and place it in the features 2-D Hash
  @_spec_features[id][device] = Spec_Features.new(id, attrs, device, text, internal_comment)
end

#spec_features(options = {}) ⇒ Object



254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
# File 'lib/origen/specs.rb', line 254

def spec_features(options = {})
  options = {
    id:     nil,
    device: nil
  }.update(options)
  return @_spec_features if options[:id].nil? && options[:device].nil?
  return nil if @_spec_features.nil?
  return nil if @_spec_features.empty?
  features_found = Hash.new do |h, k|
    h[k] = {}
  end
  filter_hash(@_spec_features, options[:id]).each do |id, hash|
    filter_hash(hash, options[:device]).each do |device, feat|
      features_found[id][device] = feat
    end
  end
  if features_found.empty?
    return nil
  elsif features_found.size == 1
    features_found.values.first.values.first
  else
    return features_found
  end
end

#specs(s = nil, options = {}) ⇒ Object

Returns a hash of hash containing all specs/modes If no spec is specified then all specs are returned via inspect If a spec is specified, a spec object will be returned if found in the current mode. If a mode option is passed and no spec is passed it will filter the specs inspect display by the mode and visa-versa



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/origen/specs.rb', line 45

def specs(s = nil, options = {})
  options = {
    type:          nil,
    sub_type:      nil,
    mode:          current_mode.nil? ? nil : current_mode.name,
    spec:          nil,
    symbol:        false,
    creating_spec: false
  }.update(options || {})
  _specs
  if s.nil?
    return show_specs(options)
  elsif s.is_a? Hash
    # no spec was passed but some option was passed
    options.update(s)
    return show_specs(options)
  else
    # a spec was passed
    options[:spec] = s
    return show_specs(options)
  end
end

#version_histories(options = {}) ⇒ Object



466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
# File 'lib/origen/specs.rb', line 466

def version_histories(options = {})
  options = {
    date:   nil,
    author: nil,
    label:  nil
  }.update(options)
  vh_found = Hash.new do |h, k|
    h[k] = Hash.new do |hh, kk|
      hh[kk] = {}
    end
  end
  return nil if @_version_history.nil?
  return nil if @_version_history.empty?
  filter_hash(@_version_history, options[:date]).each do |date, hash|
    filter_hash(hash, options[:author]).each do |author, hash1|
      filter_hash(hash1, options[:label]).each do |label, ver|
        vh_found[date][author][label] = ver
      end
    end
  end
  if vh_found.empty?
    return nil
  else
    return vh_found
  end
end

#version_history(date, author, changes, label = nil, mark_external_internal = nil) ⇒ Object



177
178
179
180
181
182
183
# File 'lib/origen/specs.rb', line 177

def version_history(date, author, changes, label = nil, mark_external_internal = nil)
  # Welguisz:  No idea why this is here, but keeping it here because it follows other blocks
  _version_history
  # Create a new Version History and place it in the version history 2-D Hash
  tmp_ver_history = Version_History.new(date, author, changes, label, mark_external_internal)
  @_version_history[date][author][label] = tmp_ver_history
end

#versionsObject



493
494
495
# File 'lib/origen/specs.rb', line 493

def versions
  @_version_history
end