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 66 |
# 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? show_chips() elsif s.is_a? Hash .update(s) show_chips() else [:chip] = s show_chips() end end |
#delete_all_chips ⇒ Object
Delete all specs
168 169 170 |
# File 'lib/origen/chips.rb', line 168 def delete_all_chips @_chips = nil end |
#delete_all_designs ⇒ Object
182 183 184 |
# File 'lib/origen/chips.rb', line 182 def delete_all_designs @_designs = nil end |
#delete_all_docs ⇒ Object
Delete all doc
178 179 180 |
# File 'lib/origen/chips.rb', line 178 def delete_all_docs @_docs = nil end |
#delete_all_notes ⇒ Object
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, = {}) _designs @_designs[type][revision] = Design_Entry.new(date, type, revision, description, ) 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( = {}) = { 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
106 107 108 109 |
# File 'lib/origen/chips.rb', line 106 def doc(date, type, revision, description, = {}) _docs @_docs[type][revision] = Doc_Entry.new(date, type, revision, description, ) 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( = {}) = { 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
87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/origen/chips.rb', line 87 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
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?( = {}) _chips = { group: nil, family: nil, performance: nil, chip: nil, creating_chip: false }.update() if @_chips.nil? || @_chips == {} false else !!show_chips() 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( = {}) = { 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? nil elsif notes_found.size == 1 notes_found.values.first.values.first else notes_found end end |