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
-
#_chips ⇒ Object
writeonly
Sets the attribute _chips.
-
#_designs ⇒ Object
writeonly
Sets the attribute _designs.
-
#_docs ⇒ Object
writeonly
Sets the attribute _docs.
-
#_notes ⇒ Object
writeonly
Sets the attribute _notes.
Instance Method Summary collapse
-
#chip(name, description, selector = {}, options = {}, &block) ⇒ Object
Define and instantiate a Spec object.
-
#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.
-
#delete_all_chips ⇒ Object
Delete all specs.
- #delete_all_designs ⇒ Object
-
#delete_all_docs ⇒ Object
Delete all doc.
-
#delete_all_notes ⇒ Object
Delete all notes.
- #design(date, type, revision, description, options = {}) ⇒ Object
- #designs(options = {}) ⇒ Object
- #doc(date, type, revision, description, options = {}) ⇒ Object
- #docs(options = {}) ⇒ Object
-
#has_chip?(s, options = {}) ⇒ Boolean
Check if the current IP has a spec.
-
#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.
-
#note(id, type, feature) ⇒ Object
Define and instantiate a Note object.
-
#notes(options = {}) ⇒ Object
Returns a Note object from the notes hash.
Instance Attribute Details
#_chips=(value) ⇒ Object
Sets the attribute _chips
8 9 10 |
# File 'lib/origen/chips.rb', line 8 def _chips=(value) @_chips = value end |
#_designs=(value) ⇒ Object
Sets the attribute _designs
8 9 10 |
# File 'lib/origen/chips.rb', line 8 def _designs=(value) @_designs = value end |
#_docs=(value) ⇒ Object
Sets the attribute _docs
8 9 10 |
# File 'lib/origen/chips.rb', line 8 def _docs=(value) @_docs = value end |
#_notes=(value) ⇒ Object
Sets the attribute _notes
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 |
# File 'lib/origen/chips.rb', line 51 def chip(name, description, selector = {}, = {}, &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, ) 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, = {}) = { group: nil, family: nil, performance: nil, part: nil, chip: nil }.update( || {}) _chips if s.nil? return show_chips() elsif s.is_a? Hash .update(s) return show_chips() else [:chip] = s return show_chips() end end |
#delete_all_chips ⇒ Object
Delete all specs
167 168 169 |
# File 'lib/origen/chips.rb', line 167 def delete_all_chips @_chips = nil end |
#delete_all_designs ⇒ Object
181 182 183 |
# File 'lib/origen/chips.rb', line 181 def delete_all_designs @_designs = nil end |
#delete_all_docs ⇒ Object
Delete all doc
177 178 179 |
# File 'lib/origen/chips.rb', line 177 def delete_all_docs @_docs = nil end |
#delete_all_notes ⇒ Object
Delete all notes
172 173 174 |
# File 'lib/origen/chips.rb', line 172 def delete_all_notes @_notes = nil end |
#design(date, type, revision, description, options = {}) ⇒ Object
110 111 112 113 |
# File 'lib/origen/chips.rb', line 110 def design(date, type, revision, description, = {}) _designs @_designs[type][revision] = Design_Entry.new(date, type, revision, description, ) end |
#designs(options = {}) ⇒ Object
152 153 154 155 156 157 158 159 160 161 162 163 164 |
# File 'lib/origen/chips.rb', line 152 def designs( = {}) = { type: nil, rev: nil }.update() designs_to_be_shown = [] filter_hash(_designs, [:type]).each do |type, hash| filter_hash(hash, [:rev]).each do |revision, hash_| designs_to_be_shown << hash_ end end designs_to_be_shown end |
#doc(date, type, revision, description, options = {}) ⇒ Object
105 106 107 108 |
# File 'lib/origen/chips.rb', line 105 def doc(date, type, revision, description, = {}) _docs @_docs[type][revision] = Doc_Entry.new(date, type, revision, description, ) end |
#docs(options = {}) ⇒ Object
138 139 140 141 142 143 144 145 146 147 148 149 150 |
# File 'lib/origen/chips.rb', line 138 def docs( = {}) = { type: nil, rev: nil }.update() docs_to_be_shown = [] filter_hash(_docs, [:type]).each do |type, hash| filter_hash(hash, [: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
86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/origen/chips.rb', line 86 def has_chip?(s, = {}) _chips = { group: nil, family: nil, performance: nil, chip: nil, creating_spec: false }.update() [:chip] = s !!show_chips() 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
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/origen/chips.rb', line 69 def has_chips?( = {}) _chips = { group: nil, family: nil, performance: nil, chip: nil, creating_chip: false }.update() if @_chips.nil? || @_chips == {} return false else return !!show_chips() end end |
#note(id, type, feature) ⇒ Object
Define and instantiate a Note object
100 101 102 103 |
# File 'lib/origen/chips.rb', line 100 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
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/origen/chips.rb', line 116 def notes( = {}) = { id: nil, type: nil }.update() notes_found = Hash.new do |h, k| h[k] = {} end _notes.filter([:id]).each do |id, hash| hash.filter([: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 |