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



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

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



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

def delete_all_doc_resources
  @_doc_resources = nil
end

#delete_all_documentationObject



556
557
558
# File 'lib/origen/specs.rb', line 556

def delete_all_documentation
  @_documentation = nil
end

#delete_all_exhibitsObject

Delete all exhibits



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

def delete_all_exhibits
  @_exhibits = nil
end

#delete_all_mode_selectsObject



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

def delete_all_mode_selects
  @_mode_selects = nil
end

#delete_all_notesObject

Delete all notes



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

def delete_all_notes
  @_notes = nil
end

#delete_all_overridesObject



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

def delete_all_overrides
  @_overrides = nil
end

#delete_all_power_suppliesObject



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

def delete_all_power_supplies
  @_power_supplies = nil
end

#delete_all_specsObject

Delete all specs



514
515
516
# File 'lib/origen/specs.rb', line 514

def delete_all_specs
  @_specs = nil
end

#delete_all_version_historyObject



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

def delete_all_version_history
  @_version_history = nil
end

#delete_creation_infoObject



548
549
550
# File 'lib/origen/specs.rb', line 548

def delete_creation_info
  @_creation_info = nil
end

#delete_spec_featuresObject



552
553
554
# File 'lib/origen/specs.rb', line 552

def delete_spec_features
  @_spec_features = nil
end

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



169
170
171
172
173
174
175
176
177
178
# File 'lib/origen/specs.rb', line 169

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



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
337
338
339
340
341
342
343
# File 'lib/origen/specs.rb', line 312

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?
    nil
  else
    dr_found
  end
end

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

Adds a new documentation notion to the block



140
141
142
143
144
# File 'lib/origen/specs.rb', line 140

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



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
384
385
386
387
388
389
390
391
# File 'lib/origen/specs.rb', line 345

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?
    nil
  else
    doc_found
  end
end

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



162
163
164
165
166
167
# File 'lib/origen/specs.rb', line 162

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



284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
# File 'lib/origen/specs.rb', line 284

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?
    nil
  else
    ex_found
  end
end

#get_creation_infoObject



221
222
223
# File 'lib/origen/specs.rb', line 221

def get_creation_info
  @_creation_info
end

#get_modesObject

Returns the modes for this block



120
121
122
# File 'lib/origen/specs.rb', line 120

def get_modes
  @_modes
end

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

Check if the current IP has a spec

Returns:

  • (Boolean)


125
126
127
128
129
130
131
132
133
134
135
136
137
# File 'lib/origen/specs.rb', line 125

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)


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

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 == {}
    false
  else
    !!show_specs(options)
  end
end

#infoObject



509
510
511
# File 'lib/origen/specs.rb', line 509

def info
  @_creation_info
end

#mode_select(block_information, mode_usage, power_information) ⇒ Object



207
208
209
210
211
212
213
214
# File 'lib/origen/specs.rb', line 207

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



431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
# File 'lib/origen/specs.rb', line 431

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?
    nil
  else
    modes_found
  end
end

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

Define and instantiate a Note object



155
156
157
158
159
160
# File 'lib/origen/specs.rb', line 155

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



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
253
254
255
256
# File 'lib/origen/specs.rb', line 226

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?
    nil
  elsif notes_found.size == 1
    notes_found.values.first.values.first
  else
    notes_found
  end
end

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



188
189
190
191
192
193
194
195
196
197
198
# File 'lib/origen/specs.rb', line 188

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



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
421
422
423
424
425
426
427
428
429
# File 'lib/origen/specs.rb', line 393

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?
    nil
  else
    overrides_found
  end
end

#power_supplies(options = {}) ⇒ Object



454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
# File 'lib/origen/specs.rb', line 454

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?
    nil
  else
    ps_found
  end
end

#power_supply(gen, act) ⇒ Object



200
201
202
203
204
205
# File 'lib/origen/specs.rb', line 200

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
96
97
98
# 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 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



147
148
149
150
151
152
# File 'lib/origen/specs.rb', line 147

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



258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
# File 'lib/origen/specs.rb', line 258

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?
    nil
  elsif features_found.size == 1
    features_found.values.first.values.first
  else
    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?
    show_specs(options)
  elsif s.is_a? Hash
    # no spec was passed but some option was passed
    options.update(s)
    show_specs(options)
  else
    # a spec was passed
    options[:spec] = s
    show_specs(options)
  end
end

#version_histories(options = {}) ⇒ Object



477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
# File 'lib/origen/specs.rb', line 477

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?
    nil
  else
    vh_found
  end
end

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



180
181
182
183
184
185
186
# File 'lib/origen/specs.rb', line 180

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



505
506
507
# File 'lib/origen/specs.rb', line 505

def versions
  @_version_history
end