origen 0.2.2 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 25b15e270740c0844ea3310d0b8b7dba5ea4e449
4
- data.tar.gz: e1c78978a03c9f992ab549db6e53bc02364b4b4e
3
+ metadata.gz: 64c45eb89cc8ad305b8cf99ada8741d36a745c1b
4
+ data.tar.gz: 343beb79e30953b72ea3f048a7676e065538817d
5
5
  SHA512:
6
- metadata.gz: ec73502e12c6e34fd2b15f5c32e9464d1b1a4e1397040af6858516c3f14343fa9b2e8f7d93be8fc041d30819ce19bce47911e0ed1017ccd43481d425960eb5b1
7
- data.tar.gz: 6edf23f23cbfac8c770408d45478343e81ae7399d7387525a20ce3380786805da3403b27f92e04ddc663cc13061444ee6f2335d6f2b613eca082ea1d8afa33cc
6
+ metadata.gz: 25d2cd159aa19e7c50b4cb8982aa4b7fd777da7e312545ec12917bc6a642afafc0a549368d8265bca7934a52b36899f5f865a67556e6a748c783166e8780105f
7
+ data.tar.gz: f599582cd7e4048a7d2169365cb783d129f342027a866e46e260c90e9d19ababbdc9f8b19cad64b81c1c9399c6e8a93933e0675c750741a015a5380a88916633
data/bin/origen CHANGED
@@ -9,6 +9,10 @@ end
9
9
 
10
10
  ORIGEN_MIN_GCC_VERSION = "4.6.3"
11
11
 
12
+ # Keep a note of the pwd at the time when Origen was first loaded, this is initially used
13
+ # by the site_config lookup.
14
+ $_origen_invocation_pwd ||= Pathname.pwd
15
+
12
16
  load File.expand_path('../../lib/origen/operating_systems.rb', __FILE__)
13
17
  load File.expand_path('../../lib/origen/site_config.rb', __FILE__)
14
18
 
@@ -184,17 +188,30 @@ else
184
188
  require "origen"
185
189
  end
186
190
 
187
- # If this script has been invoked from within an Origen application then open
188
- # up all commands, if not then only allow the command to create a new Origen
189
- # application.
190
- # Note that the Origen core workspace is now a fully fledged Origen application in
191
- # its own right.
192
191
  begin
192
+ # If this script has been invoked from within an Origen application then open
193
+ # up all commands, if not then only allow the command to create a new Origen
194
+ # application.
193
195
  if origen_root
194
196
  require "origen/commands"
195
197
  else
196
198
  require "origen/commands_global"
197
199
  end
200
+ rescue Exception => e
201
+ unless e.is_a?(SystemExit) && e.status == 0
202
+ puts
203
+ puts e.message
204
+ if Origen.app_loaded?
205
+ # Only print out the application stack trace by default, if verbose logging is
206
+ # enabled then output the full thing
207
+ e.backtrace.each do |line|
208
+ path = Pathname.new(line)
209
+ puts line if !path.absolute? || Origen.log.level == :verbose
210
+ end
211
+ else
212
+ puts e.backtrace
213
+ end
214
+ end
198
215
  ensure
199
216
  if Origen.app_loaded?
200
217
  Origen.app.listeners_for(:on_origen_shutdown).each do |listener|
File without changes
data/config/version.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  module Origen
2
2
  MAJOR = 0
3
3
  MINOR = 2
4
- BUGFIX = 2
4
+ BUGFIX = 3
5
5
  DEV = nil
6
6
 
7
7
  VERSION = [MAJOR, MINOR, BUGFIX].join(".") + (DEV ? ".pre#{DEV}" : '')
data/lib/origen.rb CHANGED
@@ -1,5 +1,8 @@
1
1
  require 'English'
2
2
  require 'pathname'
3
+ # Keep a note of the pwd at the time when Origen was first loaded, this is initially used
4
+ # by the site_config lookup.
5
+ $_origen_invocation_pwd ||= Pathname.pwd
3
6
  require 'fileutils'
4
7
  require 'origen/site_config'
5
8
  require 'origen/operating_systems'
@@ -46,6 +49,7 @@ module Origen
46
49
  autoload :CodeGenerators, 'origen/code_generators'
47
50
  autoload :Encodings, 'origen/encodings'
48
51
  autoload :Log, 'origen/log'
52
+ autoload :Chips, 'origen/chips'
49
53
 
50
54
  APP_CONFIG = File.join('config', 'application.rb')
51
55
 
@@ -435,6 +439,8 @@ module Origen
435
439
  Origen.import_manager.require!
436
440
  Origen.remote_manager.require!
437
441
  end
442
+ boot = File.join(root, 'config', 'boot.rb')
443
+ require boot if File.exist?(boot)
438
444
  env = File.join(root, 'config', 'environment.rb')
439
445
  require env if File.exist?(env)
440
446
  dev = File.join(root, 'config', 'development.rb')
@@ -587,8 +593,6 @@ module Origen
587
593
  # Returns the current top-level (DUT) object if one has been defined (by
588
594
  # instantiating an object that includes Origen::TopLevel).
589
595
  def top_level
590
- # TODO: This is called a lot and should probably be cached and expired
591
- # on before_target_load
592
596
  application.top_level
593
597
  end
594
598
 
@@ -95,7 +95,11 @@ module Origen
95
95
  RakeLoader.new.load_tasks
96
96
  end
97
97
 
98
- # Returns
98
+ # Returns a revision controller instance (e.g. Origen::RevisionControl::Git) which has
99
+ # been configured to point to the local workspace and the remote repository
100
+ # as defined by Origen.app.config.rc_url. If the revision control URL has not been
101
+ # defined, or it does not resolve to a recognized revision control system, then this
102
+ # method will return nil.
99
103
  def revision_controller
100
104
  if current?
101
105
  if config.rc_url
@@ -109,8 +113,7 @@ module Origen
109
113
  local: root,
110
114
  remote: config.rc_url
111
115
  )
112
- else
113
- fail "The revision control type could not be worked out from the value config.rc_url: #{config.rc_url}"
116
+
114
117
  end
115
118
  else
116
119
  @revision_controller ||= RevisionControl::DesignSync.new(
@@ -207,7 +210,10 @@ module Origen
207
210
 
208
211
  # Returns the current top-level object (the DUT)
209
212
  def top_level
210
- toplevel_listeners.first
213
+ @top_level ||= begin
214
+ t = toplevel_listeners.first
215
+ t.controller ? t.controller : t if t
216
+ end
211
217
  end
212
218
 
213
219
  def listeners_for(*args)
@@ -219,7 +225,7 @@ module Origen
219
225
  }.merge(options)
220
226
  listeners = callback_listeners
221
227
  if Origen.top_level
222
- listeners -= [Origen.top_level]
228
+ listeners -= [Origen.top_level.model]
223
229
  if options[:top_level]
224
230
  if options[:top_level] == :last
225
231
  listeners = listeners + [Origen.top_level]
@@ -228,7 +234,13 @@ module Origen
228
234
  end
229
235
  end
230
236
  end
231
- listeners = listeners.select { |l| l.respond_to?(callback) }
237
+ listeners = listeners.select { |l| l.respond_to?(callback) }.map do |l|
238
+ if l.try(:is_an_origen_model?)
239
+ l.respond_to_directly?(callback) ? l : l.controller
240
+ else
241
+ l
242
+ end
243
+ end
232
244
  if max && listeners.size > max
233
245
  fail "You can only define a #{callback} callback #{max > 1 ? (max.to_s + 'times') : 'once'}, however you have declared it #{listeners.size} times for instances of: #{listeners.map(&:class)}"
234
246
  end
@@ -636,7 +648,11 @@ module Origen
636
648
  Origen.target.set_signature(@target_load_options)
637
649
  $dut = nil
638
650
  load environment.file if environment.file
639
- load target.file!
651
+ if target.proc
652
+ target.proc.call
653
+ else
654
+ load target.file!
655
+ end
640
656
  ensure
641
657
  $_target_options = nil
642
658
  end
@@ -712,6 +728,7 @@ module Origen
712
728
  end
713
729
 
714
730
  def clear_dynamic_resources(type = :transient)
731
+ @top_level = nil
715
732
  if type == :transient
716
733
  @transient_resources = nil
717
734
  else
@@ -16,6 +16,12 @@ module Origen
16
16
  SAVE_FILE = "#{DIR}/.default" # :nodoc:
17
17
  DEFAULT_FILE = "#{DIR}/default.rb" # :nodoc:
18
18
 
19
+ # Not a clean unload, but allows objects to be re-instantiated for testing
20
+ # @api private
21
+ def unload!
22
+ Origen.app.unload_target!
23
+ end
24
+
19
25
  # Implement a target loop based on the supplied options.
20
26
  # The options can contain the keys :target or :targets or neither.
21
27
  #
@@ -159,7 +165,18 @@ module Origen
159
165
  # attribute of the application.
160
166
  #
161
167
  # Calling this method does not affect the default target setting in the workspace.
168
+ #
169
+ # The target can also be set to a proc to be called instead, this is really
170
+ # intended to be used for testing purposes:
171
+ # Origen.target.temporary = -> { $dut = SomeLocalClass.new }
162
172
  def temporary=(name)
173
+ if name.is_a?(Proc)
174
+ self.file = nil
175
+ @proc = name
176
+ return
177
+ else
178
+ @proc = nil
179
+ end
163
180
  tgts = resolve_mapping(name)
164
181
  targets = tgts.is_a?(Array) ? tgts : find(tgts)
165
182
  if targets.size == 0
@@ -189,6 +206,10 @@ module Origen
189
206
  alias_method :switch, :temporary=
190
207
  alias_method :switch_to, :temporary=
191
208
 
209
+ def proc
210
+ @proc
211
+ end
212
+
192
213
  # Returns a signature for the current target, can be used to track target
193
214
  # changes in cases where the name is not unique - i.e. when using a
194
215
  # configurable target
@@ -0,0 +1,281 @@
1
+ module Origen
2
+ module Chips
3
+ autoload :Chip, 'origen/chips/chip.rb'
4
+ autoload :Design_Entry, 'origen/chips/design_entry.rb'
5
+ autoload :Doc_Entry, 'origen/chips/doc_entry.rb'
6
+ autoload :RSS_Note, 'origen/chips/note.rb'
7
+
8
+ attr_accessor :_chips, :_designs, :_docs, :_notes
9
+
10
+ SPEC_TYPES = [:dc, :ac, :temperature, :supply]
11
+
12
+ NOTE_TYPES = [:spec, :doc, :mode, :feature, :sighting]
13
+
14
+ SpecTableAttr = Struct.new(:table_text, :show, :padding)
15
+
16
+ # A regular Array but print specs to the console via their ID for brevity and
17
+ # consistency with other APIs (e.g. $dut.regs # => [:reg1, :reg2])
18
+ class ChipArray < Array
19
+ def inspect
20
+ map(&:name).inspect
21
+ end
22
+ end
23
+
24
+ # Returns a hash of hash containing all specs/modes
25
+ # If no spec is specified then all specs are returned via inspect
26
+ # If a spec is specified, a spec object will be returned if found
27
+ # in the current mode. If a mode option is passed and no spec
28
+ # is passed it will filter the specs inspect display by the mode
29
+ # and visa-versa
30
+ def chips(s = nil, options = {})
31
+ options = {
32
+ group: nil,
33
+ family: nil,
34
+ performance: nil,
35
+ part: nil,
36
+ chip: nil
37
+ }.update(options || {})
38
+ _chips
39
+ if s.nil?
40
+ return show_chips(options)
41
+ elsif s.is_a? Hash
42
+ options.update(s)
43
+ return show_chips(options)
44
+ else
45
+ options[:chip] = s
46
+ return show_chips(options)
47
+ end
48
+ end
49
+
50
+ # Define and instantiate a Spec object
51
+ def chip(name, description, selector = {}, options = {}, &block)
52
+ # return chips(name, group) unless block_given?
53
+ _chips
54
+ name = name_audit(name)
55
+ group = selector[:group]
56
+ family = selector[:family]
57
+ performance = selector[:performance]
58
+ previous_parts = selector[:previous_parts]
59
+ power = selector[:power]
60
+ chip_holder = Chip.new(name, description, previous_parts, power, options)
61
+ if has_chip?(name, group: group, family: family, performance: performance, creating_chip: true)
62
+ fail "Chip already exists for chip: #{name}, group: #{group}, family: #{family} for object #{self}"
63
+ end
64
+ @_chips[group][family][performance][name] = chip_holder
65
+ end
66
+
67
+ # Returns Boolean based on whether the calling object has any defined specs
68
+ # If the mode option is selected then the search is narrowed
69
+ def has_chips?(options = {})
70
+ _chips
71
+ options = {
72
+ group: nil,
73
+ family: nil,
74
+ performance: nil,
75
+ chip: nil,
76
+ creating_chip: false
77
+ }.update(options)
78
+ if @_chips.nil? || @_chips == {}
79
+ return false
80
+ else
81
+ return !!show_chips(options)
82
+ end
83
+ end
84
+
85
+ # Check if the current IP has a spec
86
+ def has_chip?(s, options = {})
87
+ _chips
88
+ options = {
89
+ group: nil,
90
+ family: nil,
91
+ performance: nil,
92
+ chip: nil,
93
+ creating_spec: false
94
+ }.update(options)
95
+ options[:chip] = s
96
+ !!show_chips(options)
97
+ end
98
+
99
+ # Define and instantiate a Note object
100
+ def note(id, type, feature)
101
+ _notes
102
+ @_notes[id][type] = RSS_Note.new(id, type, feature)
103
+ end
104
+
105
+ def doc(date, type, revision, description, options = {})
106
+ _docs
107
+ @_docs[type][revision] = Doc_Entry.new(date, type, revision, description, options)
108
+ end
109
+
110
+ def design(date, type, revision, description, options = {})
111
+ _designs
112
+ @_designs[type][revision] = Design_Entry.new(date, type, revision, description, options)
113
+ end
114
+
115
+ # Returns a Note object from the notes hash
116
+ def notes(options = {})
117
+ options = {
118
+ id: nil,
119
+ type: nil
120
+ }.update(options)
121
+ notes_found = Hash.new do |h, k|
122
+ h[k] = {}
123
+ end
124
+ _notes.filter(options[:id]).each do |id, hash|
125
+ hash.filter(options[:type]).each do |type, note|
126
+ notes_found[id][type] = note
127
+ end
128
+ end
129
+ if notes_found.empty?
130
+ return nil
131
+ elsif notes_found.size == 1
132
+ notes_found.values.first.values.first
133
+ else
134
+ return notes_found
135
+ end
136
+ end
137
+
138
+ def docs(options = {})
139
+ options = {
140
+ type: nil,
141
+ rev: nil
142
+ }.update(options)
143
+ docs_to_be_shown = []
144
+ filter_hash(_docs, options[:type]).each do |type, hash|
145
+ filter_hash(hash, options[:rev]).each do |revision, hash_|
146
+ docs_to_be_shown << hash_
147
+ end
148
+ end
149
+ docs_to_be_shown
150
+ end
151
+
152
+ def designs(options = {})
153
+ options = {
154
+ type: nil,
155
+ rev: nil
156
+ }.update(options)
157
+ designs_to_be_shown = []
158
+ filter_hash(_designs, options[:type]).each do |type, hash|
159
+ filter_hash(hash, options[:rev]).each do |revision, hash_|
160
+ designs_to_be_shown << hash_
161
+ end
162
+ end
163
+ designs_to_be_shown
164
+ end
165
+
166
+ # Delete all specs
167
+ def delete_all_chips
168
+ @_chips = nil
169
+ end
170
+
171
+ # Delete all notes
172
+ def delete_all_notes
173
+ @_notes = nil
174
+ end
175
+
176
+ # Delete all doc
177
+ def delete_all_docs
178
+ @_docs = nil
179
+ end
180
+
181
+ def delete_all_designs
182
+ @_designs = nil
183
+ end
184
+
185
+ private
186
+
187
+ def _chips
188
+ # 4D hash with group, family, and performance
189
+ @_chips ||= Hash.new do |h, k|
190
+ h[k] = Hash.new do |hh, kk|
191
+ hh[kk] = Hash.new do |hhh, kkk|
192
+ hhh[kkk] = {}
193
+ end
194
+ end
195
+ end
196
+ end
197
+
198
+ # Two-dimensional hash with note id and type as the keys
199
+ def _notes
200
+ @_notes ||= Hash.new do |h, k|
201
+ h[k] = {}
202
+ end
203
+ end
204
+
205
+ # Document Type and Revision Number :: 2-D Hash
206
+ def _docs
207
+ @_docs ||= Hash.new do |h, k|
208
+ h[k] = {}
209
+ end
210
+ end
211
+
212
+ # Document Type and Revision Number :: 2-D Hash
213
+ def _designs
214
+ @_designs ||= Hash.new do |h, k|
215
+ h[k] = {}
216
+ end
217
+ end
218
+
219
+ # Return a hash based on the filter provided
220
+ def filter_hash(hash, filter)
221
+ fail 'Hash argument is not a Hash!' unless hash.is_a? Hash
222
+ filtered_hash = {}
223
+ select_logic = case filter
224
+ when String then 'k[Regexp.new(filter)]'
225
+ when (Fixnum || Integer || Float || Numeric) then "k[Regexp.new('#{filter}')]"
226
+ when Regexp then 'k[filter]'
227
+ when Symbol then
228
+ 'k == filter'
229
+ when NilClass then true # Return all specs if a filter is set to nil (i.e. user doesn't care about this filter)
230
+ else true
231
+ end
232
+ # rubocop:disable UnusedBlockArgument
233
+ filtered_hash = hash.select do |k, v|
234
+ [TrueClass, FalseClass].include?(select_logic.class) ? select_logic : eval(select_logic)
235
+ end
236
+ filtered_hash
237
+ end
238
+
239
+ # Filters the 4D hash to find specs for all user visible API
240
+ def show_chips(options = {})
241
+ options = {
242
+ group: nil,
243
+ family: nil,
244
+ performance: nil,
245
+ part: nil,
246
+ chips_to_be_shown: ChipArray.new,
247
+ creating_chip: false
248
+ }.update(options)
249
+ chips_to_be_shown = options[:chips_to_be_shown]
250
+ filter_hash(_chips, options[:group]).each do |_group, hash|
251
+ filter_hash(hash, options[:family]).each do |_family, hash_|
252
+ filter_hash(hash_, options[:performance]).each do |_performance, hash__|
253
+ filter_hash(hash__, options[:part]).each do |_part, chip|
254
+ chips_to_be_shown << chip
255
+ end
256
+ end
257
+ end
258
+ end
259
+ # If no specs were found must check the possibility another search
260
+ # should be started with mode set to :local or :global
261
+ if chips_to_be_shown.empty?
262
+ # Don't want to re-call this method if the callee is trying to create a spec and just wants to know
263
+ # if there is a spec with the exact same options
264
+ if options[:creating_chip] == false
265
+ # Doesn't make sense to recall the method however if the mode is already set to :global or :local
266
+ options[:chips_to_be_shown] = chips_to_be_shown
267
+ Origen.log.debug "re-calling show_chips with options #{options}"
268
+ return show_chips(options)
269
+ end
270
+ Origen.log.debug "Returning no chips for options #{options}"
271
+ return nil
272
+ elsif chips_to_be_shown.size == 1
273
+ Origen.log.debug "returning one spec #{chips_to_be_shown.first.part_name}"
274
+ return chips_to_be_shown.first
275
+ else
276
+ Origen.log.debug "returning an array of specs during initial search: #{chips_to_be_shown}"
277
+ return chips_to_be_shown
278
+ end
279
+ end
280
+ end
281
+ end
@@ -0,0 +1,167 @@
1
+ module Origen
2
+ module Chips
3
+ class Chip
4
+ # Part Name for the SoC, usually this will be the ID
5
+ attr_accessor :part_name
6
+
7
+ # Description for the Part, will be used as part of the RSS feed
8
+ attr_accessor :description
9
+
10
+ # Previous Roadmap Parts. This will allow for a backwards viewable list so that
11
+ # previous parts can have an upgrade path
12
+ attr_accessor :previous_parts
13
+
14
+ # Power Number
15
+ attr_accessor :power
16
+
17
+ # L2 Ram Size
18
+ attr_accessor :l2_ram
19
+
20
+ # L3 Ram Size
21
+ attr_accessor :l3_ram
22
+
23
+ # Package for the Part
24
+ attr_accessor :package_type
25
+
26
+ # Speed for the Cores
27
+ attr_accessor :core_speed
28
+
29
+ attr_accessor :_designs, :_docs, :_notes
30
+
31
+ def initialize(part_name, description, previous_parts, power, options = {})
32
+ @part_name = part_name
33
+ @description = description
34
+ @previous_parts = previous_parts
35
+ @power = power
36
+ @l2_ram = options[:l2_ram]
37
+ @l3_ram = options[:l3_ram]
38
+ @package_type = options[:package_type]
39
+ @core_speed = options[:core_speed]
40
+ end
41
+
42
+ # Define and instantiate a Note object
43
+ def note(id, type, feature)
44
+ _notes
45
+ @_notes[id][type] = RSS_Note.new(id, type, feature)
46
+ end
47
+
48
+ def doc(date, type, revision, description, options = {})
49
+ _docs
50
+ @_docs[type][revision] = Doc_Entry.new(date, type, revision, description, options)
51
+ end
52
+
53
+ def design(date, type, revision, description, options = {})
54
+ _designs
55
+ @_designs[type][revision] = Design_Entry.new(date, type, revision, description, options)
56
+ end
57
+
58
+ # Returns a Note object from the notes hash
59
+ def notes(options = {})
60
+ options = {
61
+ id: nil,
62
+ type: nil
63
+ }.update(options)
64
+ notes_found = Hash.new do |h, k|
65
+ h[k] = {}
66
+ end
67
+ _notes.filter(options[:id]).each do |id, hash|
68
+ hash.filter(options[:type]).each do |type, note|
69
+ notes_found[id][type] = note
70
+ end
71
+ end
72
+ if notes_found.empty?
73
+ return nil
74
+ elsif notes_found.size == 1
75
+ notes_found.values.first.values.first
76
+ else
77
+ return notes_found
78
+ end
79
+ end
80
+
81
+ def docs(options = {})
82
+ options = {
83
+ type: nil,
84
+ rev: nil
85
+ }.update(options)
86
+ docs_to_be_shown = []
87
+ filter_hash(_docs, options[:type]).each do |type, hash|
88
+ filter_hash(hash, options[:rev]).each do |revision, hash_|
89
+ docs_to_be_shown << hash_
90
+ end
91
+ end
92
+ docs_to_be_shown
93
+ end
94
+
95
+ def designs(options = {})
96
+ options = {
97
+ type: nil,
98
+ rev: nil
99
+ }.update(options)
100
+ designs_to_be_shown = []
101
+ filter_hash(_designs, options[:type]).each do |type, hash|
102
+ filter_hash(hash, options[:rev]).each do |revision, hash_|
103
+ designs_to_be_shown << hash_
104
+ end
105
+ end
106
+ designs_to_be_shown
107
+ end
108
+
109
+ # Delete all notes
110
+ def delete_all_notes
111
+ @_notes = nil
112
+ end
113
+
114
+ # Delete all doc
115
+ def delete_all_docs
116
+ @_docs = nil
117
+ end
118
+
119
+ def delete_all_designs
120
+ @_designs = nil
121
+ end
122
+
123
+ private
124
+
125
+ # Two-dimensional hash with note id and type as the keys
126
+ def _notes
127
+ @_notes ||= Hash.new do |h, k|
128
+ h[k] = {}
129
+ end
130
+ end
131
+
132
+ # Document Type and Revision Number :: 2-D Hash
133
+ def _docs
134
+ @_docs ||= Hash.new do |h, k|
135
+ h[k] = {}
136
+ end
137
+ end
138
+
139
+ # Document Type and Revision Number :: 2-D Hash
140
+ def _designs
141
+ @_designs ||= Hash.new do |h, k|
142
+ h[k] = {}
143
+ end
144
+ end
145
+
146
+ # Return a hash based on the filter provided
147
+ def filter_hash(hash, filter)
148
+ fail 'Hash argument is not a Hash!' unless hash.is_a? Hash
149
+ filtered_hash = {}
150
+ select_logic = case filter
151
+ when String then 'k[Regexp.new(filter)]'
152
+ when (Fixnum || Integer || Float || Numeric) then "k[Regexp.new('#{filter}')]"
153
+ when Regexp then 'k[filter]'
154
+ when Symbol then
155
+ 'k == filter'
156
+ when NilClass then true # Return all specs if a filter is set to nil (i.e. user doesn't care about this filter)
157
+ else true
158
+ end
159
+ # rubocop:disable UnusedBlockArgument
160
+ filtered_hash = hash.select do |k, v|
161
+ [TrueClass, FalseClass].include?(select_logic.class) ? select_logic : eval(select_logic)
162
+ end
163
+ filtered_hash
164
+ end
165
+ end
166
+ end
167
+ end
@@ -0,0 +1,36 @@
1
+ module Origen
2
+ module Chips
3
+ class Design_Entry
4
+ # date that the document was released
5
+ attr_accessor :date
6
+
7
+ # document type, e.g. Reference Manual, One Pager, Data Sheet
8
+ attr_accessor :type
9
+
10
+ # revision
11
+ attr_accessor :revision
12
+
13
+ # nda
14
+ attr_accessor :nda
15
+
16
+ # released status
17
+ attr_accessor :release
18
+
19
+ # location
20
+ attr_accessor :location
21
+
22
+ # description of the item
23
+ attr_accessor :description
24
+
25
+ def initialize(date, type, revision, description, options = {})
26
+ @date = date
27
+ @type = type
28
+ @revision = revision
29
+ @description = description
30
+ @nda = options[:nda]
31
+ @release = options[:release]
32
+ @location = options[:location]
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,36 @@
1
+ module Origen
2
+ module Chips
3
+ class Doc_Entry
4
+ # date that the document was released
5
+ attr_accessor :date
6
+
7
+ # document type, e.g. Reference Manual, One Pager, Data Sheet
8
+ attr_accessor :type
9
+
10
+ # revision
11
+ attr_accessor :revision
12
+
13
+ # nda
14
+ attr_accessor :nda
15
+
16
+ # released status
17
+ attr_accessor :release
18
+
19
+ # location
20
+ attr_accessor :location
21
+
22
+ # description
23
+ attr_accessor :description
24
+
25
+ def initialize(date, type, revision, description, options = {})
26
+ @date = date
27
+ @type = type
28
+ @revision = revision
29
+ @description = description
30
+ @nda = options[:nda]
31
+ @release = options[:release]
32
+ @location = options[:location]
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,14 @@
1
+ module Origen
2
+ module Chips
3
+ # This class is used to store spec note information used to document IP
4
+ class RSS_Note
5
+ attr_accessor :id, :type, :feature
6
+
7
+ def initialize(id, type, feature)
8
+ @id = id
9
+ @type = type
10
+ @feature = feature
11
+ end
12
+ end
13
+ end
14
+ end
@@ -53,6 +53,7 @@ module Origen
53
53
  end
54
54
  end
55
55
 
56
+ # Returns the controller's model
56
57
  def model
57
58
  @model ||= begin
58
59
  if self.class.path_to_model
@@ -61,12 +62,22 @@ module Origen
61
62
  end
62
63
  end
63
64
 
65
+ # Means that when dealing with a controller/model pair, you can
66
+ # always call obj.model and obj.controller to get the one you want,
67
+ # regardless of the one you currently have.
68
+ def controller
69
+ self
70
+ end
71
+
64
72
  def respond_to?(*args)
65
- if model
66
- super(*args) || model.respond_to?(*args)
67
- else
68
- super(*args)
69
- end
73
+ super || !!(!@respond_directly && model && model.respond_to_directly?(*args))
74
+ end
75
+
76
+ def respond_to_directly?(*args)
77
+ @respond_directly = true
78
+ result = respond_to?(*args)
79
+ @respond_directly = false
80
+ result
70
81
  end
71
82
 
72
83
  # Used to proxy all method and attribute requests not implemented on the controller
@@ -120,9 +120,7 @@ module Origen
120
120
  Origen.app.stats.failed_patterns += 1
121
121
  end
122
122
  else
123
- puts e.message
124
- puts e.backtrace
125
- exit 1
123
+ raise
126
124
  end
127
125
  end
128
126
  end
@@ -224,28 +224,30 @@ module Origen
224
224
  c2 '*' * 75
225
225
  c2 'ENVIRONMENT:'
226
226
  c2 ' Application'
227
- if Origen.app.rc.git?
228
- c2 " Source: #{Origen.config.rc_url}"
229
- else
230
- c2 " Vault: #{Origen.config.vault}"
227
+ if Origen.app.rc
228
+ if Origen.app.rc.git?
229
+ c2 " Source: #{Origen.config.rc_url}"
230
+ else
231
+ c2 " Vault: #{Origen.config.vault}"
232
+ end
231
233
  end
232
234
  c2 " Version: #{Origen.app.version}"
233
235
  c2 " Workspace: #{Origen.root}"
234
- if Origen.app.rc.git?
236
+ if Origen.app.rc && Origen.app.rc.git?
235
237
  begin
236
- status = "#{Origen.app.rc.current_branch}(#{Origen.app.rc.current_commit})"
237
- status += ' (+local edits)' unless Origen.app.rc.local_modifications.empty?
238
+ @branch ||= Origen.app.rc.current_branch
239
+ @commit ||= Origen.app.rc.current_commit
240
+ status = "#{@branch}(#{@commit})"
241
+ @pattern_local_mods = !Origen.app.rc.local_modifications.empty? unless @pattern_local_mods_fetched
242
+ @pattern_local_mods_fetched = true
243
+ status += ' (+local edits)' if @pattern_local_mods
238
244
  c2 " Branch: #{status}"
239
245
  rescue
240
246
  # No problem, we did our best
241
247
  end
242
248
  end
243
249
  c2 ' Origen'
244
- if Origen.app.rc.git?
245
- c2 ' Source: https://github.com/Origen-SDK/origen'
246
- else
247
- c2 " Vault: #{Origen.config.vault}"
248
- end
250
+ c2 ' Source: https://github.com/Origen-SDK/origen'
249
251
  c2 " Version: #{Origen.version}"
250
252
  c2 " Workspace: #{Origen.top}"
251
253
  unless Origen.plugins.empty?
data/lib/origen/model.rb CHANGED
@@ -27,6 +27,17 @@ module Origen
27
27
  end
28
28
  end
29
29
 
30
+ def is_an_origen_model?
31
+ true
32
+ end
33
+
34
+ # Means that when dealing with a controller/model pair, you can
35
+ # always call obj.model and obj.controller to get the one you want,
36
+ # regardless of the one you currently have.
37
+ def model
38
+ self
39
+ end
40
+
30
41
  def log
31
42
  Origen.log
32
43
  end
@@ -81,8 +92,7 @@ module Origen
81
92
  def _resolve_controller_class
82
93
  klass = self.class
83
94
  while klass != Object
84
- model_class = klass.to_s.split('::').last
85
- controller_class = "#{model_class}Controller"
95
+ controller_class = "#{klass}Controller"
86
96
  if eval("defined? #{controller_class}")
87
97
  return eval(controller_class)
88
98
  elsif eval("defined? ::#{controller_class}")
@@ -248,6 +258,17 @@ module Origen
248
258
  end
249
259
  end
250
260
 
261
+ def respond_to?(*args)
262
+ super || !!(!@respond_directly && controller && controller.respond_to_directly?(*args))
263
+ end
264
+
265
+ def respond_to_directly?(*args)
266
+ @respond_directly = true
267
+ result = respond_to?(*args)
268
+ @respond_directly = false
269
+ result
270
+ end
271
+
251
272
  private
252
273
 
253
274
  def _modes
@@ -39,7 +39,12 @@ module Origen
39
39
 
40
40
  def configs
41
41
  @configs ||= begin
42
- path = Pathname.pwd
42
+ # This global is set when Origen is first required, it generally means that what is considered
43
+ # to be the pwd for the purposes of looking for a site_config file is the place from where the
44
+ # user invoked Origen. Otherwise if the running app switches the PWD it can lead to confusing
45
+ # behavior - this was a particular problem when testing the new app generator which switches the
46
+ # pwd to /tmp to build the new app
47
+ path = $_origen_invocation_pwd
43
48
  configs = []
44
49
  # Add any site_configs from where we are currently running from, i.e. the application
45
50
  # directory area
data/lib/origen/specs.rb CHANGED
@@ -207,6 +207,7 @@ module Origen
207
207
  end
208
208
  end
209
209
  end
210
+ exhibits_to_be_shown
210
211
  end
211
212
 
212
213
  def doc_resources(options = {})
@@ -2,7 +2,7 @@ module Origen
2
2
  module Specs
3
3
  # This class is used to store spec note information used to document IP
4
4
  class Note
5
- attr_accessor :id, :type, :mode, :audience, :text, :markup
5
+ attr_accessor :id, :type, :mode, :audience, :text, :markup, :internal_comment
6
6
 
7
7
  def initialize(id, type, options = {})
8
8
  @id = id
@@ -11,6 +11,7 @@ module Origen
11
11
  @audience = options[:audience]
12
12
  @text = options[:text]
13
13
  @markup = options[:markup]
14
+ @internal_comment = options[:internal_comment]
14
15
  end
15
16
  end
16
17
  end
@@ -11,6 +11,13 @@ module Origen
11
11
  # address API, but will accept any of these
12
12
  @reg_base_address = options.delete(:reg_base_address) || options.delete(:reg_base_address) ||
13
13
  options.delete(:base_address) || options.delete(:base) || 0
14
+ if options[:_instance]
15
+ if @reg_base_address.is_a?(Array)
16
+ @reg_base_address = @reg_base_address[options[:_instance]]
17
+ elsif options[:base_address_step]
18
+ @reg_base_address = @reg_base_address + (options[:_instance] * options[:base_address_step])
19
+ end
20
+ end
14
21
  @domain_names = [options.delete(:domain) || options.delete(:domains)].flatten.compact
15
22
  @domain_specified = !@domain_names.empty?
16
23
  @path = options.delete(:path)
@@ -187,8 +194,12 @@ module Origen
187
194
  include Path
188
195
 
189
196
  # Returns a hash containing all immediate children of the given sub-block
190
- def sub_blocks
191
- @sub_blocks ||= {}.with_indifferent_access
197
+ def sub_blocks(*args)
198
+ if args.empty?
199
+ @sub_blocks ||= {}.with_indifferent_access
200
+ else
201
+ sub_block(*args)
202
+ end
192
203
  end
193
204
  alias_method :children, :sub_blocks
194
205
 
@@ -223,46 +234,64 @@ module Origen
223
234
  end
224
235
 
225
236
  def sub_block(name, options = {})
226
- class_name = options.delete(:class_name)
227
- if class_name
228
- begin
229
- klass = eval("::#{namespace}::#{class_name}")
230
- rescue
237
+ if i = options.delete(:instances)
238
+ a = []
239
+ options[:_instance] = i
240
+ i.times do |j|
241
+ o = options.dup
242
+ o[:_instance] = j
243
+ a << sub_block("#{name}#{j}", o)
244
+ end
245
+ define_singleton_method "#{name}s" do
246
+ a
247
+ end
248
+ a
249
+ else
250
+ class_name = options.delete(:class_name)
251
+ if class_name
231
252
  begin
232
- klass = eval(class_name)
253
+ klass = eval("::#{namespace}::#{class_name}")
233
254
  rescue
234
255
  begin
235
- klass = eval("#{self.class}::#{class_name}")
256
+ klass = eval(class_name)
236
257
  rescue
237
- puts "Could not find class: #{class_name}"
238
- raise 'Unknown sub block class!'
258
+ begin
259
+ klass = eval("#{self.class}::#{class_name}")
260
+ rescue
261
+ puts "Could not find class: #{class_name}"
262
+ raise 'Unknown sub block class!'
263
+ end
239
264
  end
240
265
  end
266
+ else
267
+ klass = Origen::SubBlock
241
268
  end
242
- else
243
- klass = Origen::SubBlock
244
- end
245
- unless klass.respond_to?(:includes_origen_model)
246
- puts 'Any class which is to be instantiated as a sub_block must include Origen::Model,'
247
- puts "add this to #{klass}:"
248
- puts ''
249
- puts ' include Origen::Model'
250
- puts ''
251
- fail 'Sub block does not include Origen::Model!'
252
- end
253
- block = klass.new(options.merge(parent: self))
254
- block.name = name
255
- sub_blocks[name] = block
256
- if respond_to?(name)
257
- # puts "Tried to create a sub-block named #{name} in #{self.class}, but it already has a method with this name!"
258
- # puts "To avoid confusion rename one of them and try again!"
259
- # raise "Non-unique sub-block name!"
260
- else
261
- define_singleton_method name do
262
- sub_blocks[name]
269
+ unless klass.respond_to?(:includes_origen_model)
270
+ puts 'Any class which is to be instantiated as a sub_block must include Origen::Model,'
271
+ puts "add this to #{klass}:"
272
+ puts ''
273
+ puts ' include Origen::Model'
274
+ puts ''
275
+ fail 'Sub block does not include Origen::Model!'
276
+ end
277
+ block = klass.new(options.merge(parent: self))
278
+ block.name = name
279
+ if sub_blocks[name]
280
+ fail "You have already defined a sub-block named #{name} within class #{self.class}"
281
+ else
282
+ sub_blocks[name] = block
283
+ if respond_to?(name)
284
+ # puts "Tried to create a sub-block named #{name} in #{self.class}, but it already has a method with this name!"
285
+ # puts "To avoid confusion rename one of them and try again!"
286
+ # raise "Non-unique sub-block name!"
287
+ else
288
+ define_singleton_method name do
289
+ sub_blocks[name]
290
+ end
291
+ end
263
292
  end
293
+ block
264
294
  end
265
- block
266
295
  end
267
296
 
268
297
  def namespace
data/lib/origen/users.rb CHANGED
@@ -8,9 +8,10 @@ module Origen
8
8
  # Had to do some shenanigans here due to Origen.root not being available
9
9
  # when this file is included, only load the users from the app once a user
10
10
  # method is first called
11
- return @app_users if @app_users
12
- require File.join(Origen.root, 'config', 'users')
13
- @app_users = users
11
+ # return @app_users if @app_users
12
+ # require File.join(Origen.root, 'config', 'users')
13
+ # @app_users = users
14
+ []
14
15
  end
15
16
 
16
17
  # Returns a user object representing the current user, will return a default
@@ -66,7 +66,7 @@ module Origen
66
66
  end
67
67
 
68
68
  def name
69
- @name || name_from_rc || @id
69
+ @name ||= name_from_rc || @id
70
70
  end
71
71
 
72
72
  def name_from_rc
@@ -74,7 +74,7 @@ module Origen
74
74
  end
75
75
 
76
76
  def email
77
- @email || email_from_rc || begin
77
+ @email ||= email_from_rc || begin
78
78
  if Origen.site_config.email_domain
79
79
  "#{id}@#{Origen.site_config.email_domain}"
80
80
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: origen
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen McGinty
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-06 00:00:00.000000000 Z
11
+ date: 2015-08-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -390,17 +390,14 @@ extra_rdoc_files: []
390
390
  files:
391
391
  - bin/origen
392
392
  - config/application.rb
393
+ - config/boot.rb
393
394
  - config/commands.rb
394
- - config/development.rb
395
- - config/environment.rb
396
- - config/rgen.policy
397
395
  - config/rubocop/easy.yml
398
396
  - config/rubocop/easy_disabled.yml
399
397
  - config/rubocop/easy_enabled.yml
400
398
  - config/rubocop/strict.yml
401
399
  - config/rubocop/strict_disabled.yml
402
400
  - config/rubocop/strict_enabled.yml
403
- - config/users.rb
404
401
  - config/version.rb
405
402
  - helpers/url.rb
406
403
  - lib/c99/doc_interface.rb
@@ -431,6 +428,11 @@ files:
431
428
  - lib/origen/callbacks.rb
432
429
  - lib/origen/chip_mode.rb
433
430
  - lib/origen/chip_package.rb
431
+ - lib/origen/chips.rb
432
+ - lib/origen/chips/chip.rb
433
+ - lib/origen/chips/design_entry.rb
434
+ - lib/origen/chips/doc_entry.rb
435
+ - lib/origen/chips/note.rb
434
436
  - lib/origen/client.rb
435
437
  - lib/origen/code_generators.rb
436
438
  - lib/origen/code_generators/actions.rb
@@ -720,7 +722,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
720
722
  version: 1.8.11
721
723
  requirements: []
722
724
  rubyforge_project:
723
- rubygems_version: 2.2.2
725
+ rubygems_version: 2.4.5
724
726
  signing_key:
725
727
  specification_version: 4
726
728
  summary: A Semiconductor Developer's Kit
File without changes
data/config/rgen.policy DELETED
@@ -1,7 +0,0 @@
1
- fs-ruby-/2.1.5-p273
2
- ds-designsync-/v6r2013x
3
- fs-pi-/2012.3.3
4
- gcc-/4.7.3
5
- libxml2-/2.9.0
6
- TWW-pkgconfig-/0.25
7
- OSS-git-/2.3.2
data/config/users.rb DELETED
@@ -1,20 +0,0 @@
1
- # This file defines the users associated with your project, it is basically the
2
- # mailing list for release notes.
3
- # This module must define a method named "users" which returns an array of user
4
- # objects.
5
- # You can split your users into "admin" and "user" groups, the main difference
6
- # between the two is that admin users will get all tag emails, users will get
7
- # emails on external/official releases only.
8
- # Users are also prohibited from running the tag_project script, but this is
9
- # really just to prevent a casual user from executing it inadvertently and it is
10
- # not intended to be a serious security gate.
11
- module Origen
12
- module Users
13
- def users
14
- @users ||= [
15
- # Admins
16
- User.new('Stephen McGinty', 'stephen.f.mcginty@gmail.com', :admin),
17
- ]
18
- end
19
- end
20
- end