Module: Origen::Specs

Defined in:
lib/origen/specs.rb,
lib/origen/specs/note.rb,
lib/origen/specs/spec.rb,
lib/origen/specs/exhibit.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

Classes: Creation_Info, Doc_Resource, Exhibit, Mode_Select, Note, Override, Power_Supply, Spec, 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

Instance Attribute Details

#_creation_info=(value) ⇒ Object

Sets the attribute _creation_info



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

def _creation_info=(value)
  @_creation_info = value
end

#_doc_resources=(value) ⇒ Object

Sets the attribute _doc_resources



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

def _doc_resources=(value)
  @_doc_resources = value
end

#_exhibits=(value) ⇒ Object

Sets the attribute _exhibits



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

def _exhibits=(value)
  @_exhibits = value
end

#_mode_selects=(value) ⇒ Object

Sets the attribute _mode_selects



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

def _mode_selects=(value)
  @_mode_selects = value
end

#_notes=(value) ⇒ Object

Sets the attribute _notes



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

def _notes=(value)
  @_notes = value
end

#_overrides=(value) ⇒ Object

Sets the attribute _overrides



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

def _overrides=(value)
  @_overrides = value
end

#_power_supplies=(value) ⇒ Object

Sets the attribute _power_supplies



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

def _power_supplies=(value)
  @_power_supplies = value
end

#_specs=(value) ⇒ Object

Sets the attribute _specs



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

def _specs=(value)
  @_specs = value
end

#_version_history=(value) ⇒ Object

Sets the attribute _version_history



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

def _version_history=(value)
  @_version_history = value
end

Instance Method Details

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



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

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

#delete_all_doc_resourcesObject



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

def delete_all_doc_resources
  @_doc_resources = nil
end

#delete_all_exhibitsObject

Delete all exhibits



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

def delete_all_exhibits
  @_exhibits = nil
end

#delete_all_mode_selectsObject



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

def delete_all_mode_selects
  @_mode_selects = nil
end

#delete_all_notesObject

Delete all notes



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

def delete_all_notes
  @_notes = nil
end

#delete_all_overridesObject



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

def delete_all_overrides
  @_overrides = nil
end

#delete_all_power_suppliesObject



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

def delete_all_power_supplies
  @_power_supplies = nil
end

#delete_all_specsObject

Delete all specs



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

def delete_all_specs
  @_specs = nil
end

#delete_all_version_historyObject



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

def delete_all_version_history
  @_version_history = nil
end

#delete_creation_infoObject



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

def delete_creation_info
  @_creation_info = nil
end

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



123
124
125
126
127
128
129
130
# File 'lib/origen/specs.rb', line 123

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



204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
# File 'lib/origen/specs.rb', line 204

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



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

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

#exhibits(options = {}) ⇒ Object



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

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
end

#get_modesObject



93
94
95
# File 'lib/origen/specs.rb', line 93

def get_modes
  @_modes
end

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

Check if the current IP has a spec



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

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



76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/origen/specs.rb', line 76

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

#infoObject



295
296
297
# File 'lib/origen/specs.rb', line 295

def info
  @_creation_info
end

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



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

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



247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
# File 'lib/origen/specs.rb', line 247

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



113
114
115
116
# File 'lib/origen/specs.rb', line 113

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



165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
# File 'lib/origen/specs.rb', line 165

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



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

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



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

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



269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
# File 'lib/origen/specs.rb', line 269

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



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

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

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

Define and instantiate a Spec object



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/origen/specs.rb', line 50

def spec(name, type, mode = nil, &block)
  _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



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/origen/specs.rb', line 28

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



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

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



291
292
293
# File 'lib/origen/specs.rb', line 291

def versions
  @_version_history
end