Module: Origen::Chips

Defined in:
lib/origen/chips.rb,
lib/origen/chips/chip.rb,
lib/origen/chips/note.rb,
lib/origen/chips/doc_entry.rb,
lib/origen/chips/design_entry.rb

Defined Under Namespace

Classes: Chip, ChipArray, Design_Entry, Doc_Entry, RSS_Note, SpecTableAttr

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

#_chips=(value) ⇒ Object

Sets the attribute _chips

Parameters:

  • value

    the value to set the attribute _chips to.



8
9
10
# File 'lib/origen/chips.rb', line 8

def _chips=(value)
  @_chips = value
end

#_designs=(value) ⇒ Object

Sets the attribute _designs

Parameters:

  • value

    the value to set the attribute _designs to.



8
9
10
# File 'lib/origen/chips.rb', line 8

def _designs=(value)
  @_designs = value
end

#_docs=(value) ⇒ Object

Sets the attribute _docs

Parameters:

  • value

    the value to set the attribute _docs to.



8
9
10
# File 'lib/origen/chips.rb', line 8

def _docs=(value)
  @_docs = value
end

#_notes=(value) ⇒ Object

Sets the attribute _notes

Parameters:

  • value

    the value to set the attribute _notes to.



8
9
10
# File 'lib/origen/chips.rb', line 8

def _notes=(value)
  @_notes = value
end

Instance Method Details

#chip(name, description, selector = {}, options = {}, &block) ⇒ Object

Define and instantiate a Spec object



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/origen/chips.rb', line 51

def chip(name, description, selector = {}, options = {}, &block)
  # return chips(name, group) unless block_given?
  _chips
  name = name_audit(name)
  group = selector[:group]
  family = selector[:family]
  performance = selector[:performance]
  previous_parts = selector[:previous_parts]
  power = selector[:power]
  chip_holder = Chip.new(name, description, previous_parts, power, options)
  if has_chip?(name, group: group, family: family, performance: performance, creating_chip: true)
    fail "Chip already exists for chip: #{name}, group: #{group}, family: #{family} for object #{self}"
  end

  @_chips[group][family][performance][name] = chip_holder
end

#chips(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



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

def chips(s = nil, options = {})
  options = {
    group:       nil,
    family:      nil,
    performance: nil,
    part:        nil,
    chip:        nil
  }.update(options || {})
  _chips
  if s.nil?
    show_chips(options)
  elsif s.is_a? Hash
    options.update(s)
    show_chips(options)
  else
    options[:chip] = s
    show_chips(options)
  end
end

#delete_all_chipsObject

Delete all specs



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

def delete_all_chips
  @_chips = nil
end

#delete_all_designsObject



182
183
184
# File 'lib/origen/chips.rb', line 182

def delete_all_designs
  @_designs = nil
end

#delete_all_docsObject

Delete all doc



178
179
180
# File 'lib/origen/chips.rb', line 178

def delete_all_docs
  @_docs = nil
end

#delete_all_notesObject

Delete all notes



173
174
175
# File 'lib/origen/chips.rb', line 173

def delete_all_notes
  @_notes = nil
end

#design(date, type, revision, description, options = {}) ⇒ Object



111
112
113
114
# File 'lib/origen/chips.rb', line 111

def design(date, type, revision, description, options = {})
  _designs
  @_designs[type][revision] = Design_Entry.new(date, type, revision, description, options)
end

#designs(options = {}) ⇒ Object



153
154
155
156
157
158
159
160
161
162
163
164
165
# File 'lib/origen/chips.rb', line 153

def designs(options = {})
  options = {
    type: nil,
    rev:  nil
  }.update(options)
  designs_to_be_shown = []
  filter_hash(_designs, options[:type]).each do |type, hash|
    filter_hash(hash, options[:rev]).each do |revision, hash_|
      designs_to_be_shown << hash_
    end
  end
  designs_to_be_shown
end

#doc(date, type, revision, description, options = {}) ⇒ Object



106
107
108
109
# File 'lib/origen/chips.rb', line 106

def doc(date, type, revision, description, options = {})
  _docs
  @_docs[type][revision] = Doc_Entry.new(date, type, revision, description, options)
end

#docs(options = {}) ⇒ Object



139
140
141
142
143
144
145
146
147
148
149
150
151
# File 'lib/origen/chips.rb', line 139

def docs(options = {})
  options = {
    type: nil,
    rev:  nil
  }.update(options)
  docs_to_be_shown = []
  filter_hash(_docs, options[:type]).each do |type, hash|
    filter_hash(hash, options[:rev]).each do |revision, hash_|
      docs_to_be_shown << hash_
    end
  end
  docs_to_be_shown
end

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

Check if the current IP has a spec

Returns:

  • (Boolean)


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

def has_chip?(s, options = {})
  _chips
  options = {
    group:         nil,
    family:        nil,
    performance:   nil,
    chip:          nil,
    creating_spec: false
  }.update(options)
  options[:chip] = s
  !!show_chips(options)
end

#has_chips?(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)


70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/origen/chips.rb', line 70

def has_chips?(options = {})
  _chips
  options = {
    group:         nil,
    family:        nil,
    performance:   nil,
    chip:          nil,
    creating_chip: false
  }.update(options)
  if @_chips.nil? || @_chips == {}
    false
  else
    !!show_chips(options)
  end
end

#note(id, type, feature) ⇒ Object

Define and instantiate a Note object



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

def note(id, type, feature)
  _notes
  @_notes[id][type] = RSS_Note.new(id, type, feature)
end

#notes(options = {}) ⇒ Object

Returns a Note object from the notes hash



117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# File 'lib/origen/chips.rb', line 117

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