Module: Origen::Specs

Includes:
Checkers
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/version_history.rb

Defined Under Namespace

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

Constant Summary collapse

SPEC_TYPES =
[:dc, :ac, :temperature, :supply]
NOTE_TYPES =
[:spec, :doc, :mode, :feature, :sighting]

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.



15
16
17
# File 'lib/origen/specs.rb', line 15

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.



15
16
17
# File 'lib/origen/specs.rb', line 15

def _doc_resources=(value)
  @_doc_resources = value
end

#_exhibits=(value) ⇒ Object

Sets the attribute _exhibits

Parameters:

  • value

    the value to set the attribute _exhibits to.



15
16
17
# File 'lib/origen/specs.rb', line 15

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.



15
16
17
# File 'lib/origen/specs.rb', line 15

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.



15
16
17
# File 'lib/origen/specs.rb', line 15

def _notes=(value)
  @_notes = value
end

#_overrides=(value) ⇒ Object

Sets the attribute _overrides

Parameters:

  • value

    the value to set the attribute _overrides to.



15
16
17
# File 'lib/origen/specs.rb', line 15

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.



15
16
17
# File 'lib/origen/specs.rb', line 15

def _power_supplies=(value)
  @_power_supplies = value
end

#_specs=(value) ⇒ Object

Sets the attribute _specs

Parameters:

  • value

    the value to set the attribute _specs to.



15
16
17
# File 'lib/origen/specs.rb', line 15

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.



15
16
17
# File 'lib/origen/specs.rb', line 15

def _version_history=(value)
  @_version_history = value
end

Instance Method Details

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



168
169
170
# File 'lib/origen/specs.rb', line 168

def creation_info(author, date, version, src_info = {}, tool_info = {})
  @_creation_info = Creation_Info.new(author, date, version, src_info, tool_info)
end

#delete_all_doc_resourcesObject



323
324
325
# File 'lib/origen/specs.rb', line 323

def delete_all_doc_resources
  @_doc_resources = nil
end

#delete_all_exhibitsObject

Delete all exhibits



319
320
321
# File 'lib/origen/specs.rb', line 319

def delete_all_exhibits
  @_exhibits = nil
end

#delete_all_mode_selectsObject



339
340
341
# File 'lib/origen/specs.rb', line 339

def delete_all_mode_selects
  @_mode_selects = nil
end

#delete_all_notesObject

Delete all notes



314
315
316
# File 'lib/origen/specs.rb', line 314

def delete_all_notes
  @_notes = nil
end

#delete_all_overridesObject



327
328
329
# File 'lib/origen/specs.rb', line 327

def delete_all_overrides
  @_overrides = nil
end

#delete_all_power_suppliesObject



331
332
333
# File 'lib/origen/specs.rb', line 331

def delete_all_power_supplies
  @_power_supplies = nil
end

#delete_all_specsObject

Delete all specs



309
310
311
# File 'lib/origen/specs.rb', line 309

def delete_all_specs
  @_specs = nil
end

#delete_all_version_historyObject



335
336
337
# File 'lib/origen/specs.rb', line 335

def delete_all_version_history
  @_version_history = nil
end

#delete_creation_infoObject



343
344
345
# File 'lib/origen/specs.rb', line 343

def delete_creation_info
  @_creation_info = nil
end

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



131
132
133
134
135
136
137
138
# File 'lib/origen/specs.rb', line 131

def doc_resource(selector = {}, table_title = {}, text = {}, options = {})
  _doc_resources
  mode = selector[:mode]
  type = selector[:type]
  sub_type = selector[:sub_type]
  audience = selector[:audience]
  @_doc_resources[mode][type][sub_type][audience] = Doc_Resource.new(selector, table_title, text, options)
end

#doc_resources(options = {}) ⇒ Object



213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
# File 'lib/origen/specs.rb', line 213

def doc_resources(options = {})
  options = {
    mode:                      nil,
    type:                      nil,
    sub_type:                  nil,
    audience:                  nil,
    doc_resources_to_be_shown: []
  }.update(options)
  doc_resources_to_be_shown = options[:doc_resources_to_be_shown]
  filter_hash(_doc_resources, options[:mode]).each do |_doc_resource, 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|
          doc_resources_to_be_shown << spec
        end
      end
    end
  end
end

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



126
127
128
129
# File 'lib/origen/specs.rb', line 126

def exhibit(id, type, options = {})
  _exhibits
  @_exhibits[options[:block_id]][id][type] = Exhibit.new(id, type, options)
end

#exhibits(options = {}) ⇒ Object



195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
# File 'lib/origen/specs.rb', line 195

def exhibits(options = {})
  options = {
    block:                nil,
    id:                   nil,
    type:                 nil,
    exhibits_to_be_shown: []
  }.update(options)
  exhibits_to_be_shown = options[:exhibits_to_be_shown]
  filter_hash(_exhibits, options[:block]).each do |_exhibit, hash|
    filter_hash(hash, options[:id]).each do |id, hash_|
      filter_hash(hash_, options[:type]).each do |type, hash__|
        exhibits_to_be_shown << hash__
      end
    end
  end
  exhibits_to_be_shown
end

#get_modesObject



102
103
104
# File 'lib/origen/specs.rb', line 102

def get_modes
  @_modes
end

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

Check if the current IP has a spec

Returns:

  • (Boolean)


107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/origen/specs.rb', line 107

def has_spec?(s, options = {})
  _specs
  options = {
    type:          nil,
    sub_type:      nil,
    mode:          current_mode.nil? ? nil : current_mode.name,
    spec:          nil,
    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)


86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/origen/specs.rb', line 86

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

#infoObject



304
305
306
# File 'lib/origen/specs.rb', line 304

def info
  @_creation_info
end

#mode_select(blk, use, mode_ref, support, loc) ⇒ Object



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

def mode_select(blk, use, mode_ref, support, loc)
  _mode_selects
  if use
    @_mode_selects[blk][mode_ref] = Mode_Select.new(blk, use, mode_ref, support, loc)
  end
end

#mode_selects(options = {}) ⇒ Object



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

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

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

Define and instantiate a Note object



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

def note(id, type, options = {})
  _notes
  @_notes[id][type] = Note.new(id, type, options)
end

#notes(options = {}) ⇒ Object

Returns a Note object from the notes hash



173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
# File 'lib/origen/specs.rb', line 173

def notes(options = {})
  options = {
    id:   nil,
    type: nil
  }.update(options)
  notes_found = Hash.new do |h, k|
    h[k] = {}
  end
  _notes.filter(options[:id]).each do |id, hash|
    hash.filter(options[:type]).each do |type, note|
      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



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

def override(block_options = {}, find_spec = {}, values = {}, options = {})
  _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]
  @_overrides[block][spec_ref][mode_ref][sub_type][audience] = Override.new(block_options, find_spec, values, options)
end

#overrides(options = {}) ⇒ Object



233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
# File 'lib/origen/specs.rb', line 233

def overrides(options = {})
  options = {
    block:     nil,
    spec_ref:  nil,
    mode_ref:  nil,
    sub_type:  nil,
    audience:  nil,
    overrides: []
  }.update(options)
  overrides = options[:overrides]
  filter_hash(_overrides, options[:block]).each do |_override, 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 << override
          end
        end
      end
    end
  end
end

#power_supplies(options = {}) ⇒ Object



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

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

#power_supply(gen, act) ⇒ Object



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

def power_supply(gen, act)
  _power_supplies
  @_power_supplies[gen][act] = Power_Supply.new(gen, act)
end

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

Define and instantiate a Spec object



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/origen/specs.rb', line 58

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)
    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

#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



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/origen/specs.rb', line 37

def specs(s = nil, options = {})
  options = {
    type:          nil,
    sub_type:      nil,
    mode:          current_mode.nil? ? nil : current_mode.name,
    spec:          nil,
    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_history(date, author, changes) ⇒ Object



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

def version_history(date, author, changes)
  _version_history
  tmp_ver_history = Version_History.new(date, author, changes)
  @_version_history[date][author] = tmp_ver_history
end

#versionsObject



300
301
302
# File 'lib/origen/specs.rb', line 300

def versions
  @_version_history
end