origen 0.34.3 → 0.52.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (207) hide show
  1. checksums.yaml +5 -5
  2. data/bin/origen +1 -231
  3. data/config/application.rb +12 -3
  4. data/config/boot.rb +2 -7
  5. data/config/commands.rb +3 -74
  6. data/config/rubocop/easy_disabled.yml +4 -0
  7. data/config/rubocop/easy_enabled.yml +0 -4
  8. data/config/rubocop/strict_disabled.yml +4 -0
  9. data/config/rubocop/strict_enabled.yml +0 -4
  10. data/config/version.rb +2 -3
  11. data/lib/origen.rb +27 -14
  12. data/lib/origen/application.rb +88 -2
  13. data/lib/origen/application/deployer.rb +3 -1
  14. data/lib/origen/application/release.rb +2 -2
  15. data/lib/origen/application/runner.rb +35 -20
  16. data/lib/origen/boot.rb +302 -0
  17. data/lib/origen/boot/api.rb +13 -0
  18. data/lib/origen/boot/app.rb +284 -0
  19. data/lib/origen/code_generators.rb +30 -10
  20. data/lib/origen/code_generators/actions.rb +244 -34
  21. data/lib/origen/code_generators/base.rb +9 -2
  22. data/lib/origen/code_generators/block.rb +203 -0
  23. data/lib/origen/code_generators/block_common.rb +100 -0
  24. data/lib/origen/code_generators/dut.rb +62 -0
  25. data/lib/origen/code_generators/feature.rb +50 -0
  26. data/lib/origen/code_generators/klass.rb +41 -0
  27. data/lib/origen/code_generators/model.rb +60 -0
  28. data/lib/origen/code_generators/module.rb +92 -0
  29. data/lib/origen/commands.rb +30 -13
  30. data/lib/origen/commands/archive.rb +175 -0
  31. data/lib/origen/commands/extract.rb +43 -0
  32. data/lib/origen/commands/generate.rb +1 -0
  33. data/lib/origen/commands/lint.rb +6 -1
  34. data/lib/origen/commands/new.rb +48 -24
  35. data/lib/origen/commands/new_resource.rb +41 -0
  36. data/lib/origen/commands/site.rb +52 -0
  37. data/lib/origen/commands/web.rb +11 -6
  38. data/lib/origen/commands_global.rb +9 -7
  39. data/lib/origen/core_ext/numeric.rb +20 -0
  40. data/lib/{option_parser → origen/core_ext/option_parser}/optparse.rb +0 -0
  41. data/lib/origen/dependencies.rb +0 -0
  42. data/lib/origen/file_handler.rb +18 -6
  43. data/lib/origen/generator.rb +19 -10
  44. data/lib/origen/generator/comparator.rb +2 -1
  45. data/lib/origen/generator/flow.rb +3 -1
  46. data/lib/origen/generator/job.rb +60 -16
  47. data/lib/origen/generator/pattern.rb +132 -72
  48. data/lib/origen/generator/pattern_finder.rb +3 -3
  49. data/lib/origen/generator/pattern_sequence.rb +201 -0
  50. data/lib/origen/generator/pattern_sequencer.rb +99 -0
  51. data/lib/origen/generator/pattern_thread.rb +175 -0
  52. data/lib/origen/loader.rb +381 -0
  53. data/lib/origen/log.rb +250 -108
  54. data/lib/origen/model.rb +22 -1
  55. data/lib/origen/model/exporter.rb +50 -10
  56. data/lib/origen/model_initializer.rb +5 -1
  57. data/lib/origen/operating_systems.rb +4 -0
  58. data/lib/origen/parameters.rb +96 -4
  59. data/lib/origen/parameters/set.rb +4 -3
  60. data/lib/origen/pins.rb +10 -8
  61. data/lib/origen/pins/pin.rb +61 -46
  62. data/lib/origen/ports/port.rb +5 -0
  63. data/lib/origen/registers.rb +5 -0
  64. data/lib/origen/registers/bit.rb +57 -53
  65. data/lib/origen/registers/bit_collection.rb +100 -43
  66. data/lib/origen/registers/msb0_delegator.rb +47 -0
  67. data/lib/origen/registers/reg.rb +114 -99
  68. data/lib/origen/revision_control.rb +1 -1
  69. data/lib/origen/revision_control/git.rb +23 -3
  70. data/lib/origen/site_config.rb +251 -60
  71. data/lib/origen/site_config/config.rb +217 -0
  72. data/lib/origen/sub_blocks.rb +106 -31
  73. data/lib/origen/top_level.rb +11 -0
  74. data/lib/origen/users/user.rb +3 -2
  75. data/lib/origen/utility/mailer.rb +42 -9
  76. data/lib/origen/value/bin_str_val.rb +1 -1
  77. data/lib/origen/value/hex_str_val.rb +1 -1
  78. data/lib/origen/version_string.rb +6 -1
  79. data/lib/tasks/gem.rake +6 -1
  80. data/origen_app_generators/Gemfile +19 -0
  81. data/origen_app_generators/Gemfile.lock +152 -0
  82. data/origen_app_generators/LICENSE +21 -0
  83. data/origen_app_generators/README.md +368 -0
  84. data/{templates/code_generators/rakefile.rb → origen_app_generators/Rakefile} +0 -0
  85. data/origen_app_generators/bin/boot.rb +39 -0
  86. data/origen_app_generators/config/application.rb +153 -0
  87. data/origen_app_generators/config/boot.rb +1 -0
  88. data/origen_app_generators/config/commands.rb +63 -0
  89. data/origen_app_generators/config/shared_commands.rb +177 -0
  90. data/origen_app_generators/config/version.rb +8 -0
  91. data/origen_app_generators/doc/history +223 -0
  92. data/origen_app_generators/lbin/bundle +105 -0
  93. data/origen_app_generators/lbin/byebug +29 -0
  94. data/origen_app_generators/lbin/coderay +29 -0
  95. data/origen_app_generators/lbin/htmldiff +29 -0
  96. data/origen_app_generators/lbin/httparty +29 -0
  97. data/origen_app_generators/lbin/httpclient +29 -0
  98. data/origen_app_generators/lbin/kramdown +29 -0
  99. data/origen_app_generators/lbin/ldiff +29 -0
  100. data/origen_app_generators/lbin/nanoc +29 -0
  101. data/origen_app_generators/lbin/nokogiri +29 -0
  102. data/origen_app_generators/lbin/origen +62 -0
  103. data/origen_app_generators/lbin/pry +29 -0
  104. data/origen_app_generators/lbin/rackup +29 -0
  105. data/origen_app_generators/lbin/rake +29 -0
  106. data/origen_app_generators/lbin/rspec +29 -0
  107. data/origen_app_generators/lbin/rubocop +29 -0
  108. data/origen_app_generators/lbin/ruby-parse +29 -0
  109. data/origen_app_generators/lbin/ruby-rewrite +29 -0
  110. data/origen_app_generators/lbin/thor +29 -0
  111. data/origen_app_generators/lbin/tilt +29 -0
  112. data/origen_app_generators/lbin/yard +29 -0
  113. data/origen_app_generators/lbin/yardoc +29 -0
  114. data/origen_app_generators/lbin/yri +29 -0
  115. data/origen_app_generators/lib/origen_app_generators.rb +125 -0
  116. data/origen_app_generators/lib/origen_app_generators/application.rb +62 -0
  117. data/origen_app_generators/lib/origen_app_generators/base.rb +257 -0
  118. data/origen_app_generators/lib/origen_app_generators/empty_application.rb +15 -0
  119. data/origen_app_generators/lib/origen_app_generators/empty_plugin.rb +15 -0
  120. data/origen_app_generators/lib/origen_app_generators/new.rb +170 -0
  121. data/origen_app_generators/lib/origen_app_generators/new_app_tests.rb +4 -0
  122. data/origen_app_generators/lib/origen_app_generators/origen_infrastructure/app_generator_plugin.rb +107 -0
  123. data/origen_app_generators/lib/origen_app_generators/plugin.rb +55 -0
  124. data/origen_app_generators/lib/origen_app_generators/test_engineering/common.rb +29 -0
  125. data/origen_app_generators/lib/origen_app_generators/test_engineering/stand_alone_application.rb +64 -0
  126. data/origen_app_generators/lib/origen_app_generators/test_engineering/test_block.rb +61 -0
  127. data/origen_app_generators/origen_app_generators.gemspec +33 -0
  128. data/{templates/code_generators → origen_app_generators/spec}/spec_helper.rb +0 -0
  129. data/origen_app_generators/target/debug.rb +8 -0
  130. data/origen_app_generators/target/default.rb +8 -0
  131. data/origen_app_generators/target/production.rb +0 -0
  132. data/origen_app_generators/templates/app_generators/application/.gitignore +37 -0
  133. data/origen_app_generators/templates/app_generators/application/.irbrc +9 -0
  134. data/origen_app_generators/templates/app_generators/application/.rspec +1 -0
  135. data/origen_app_generators/templates/app_generators/application/.travis.yml +11 -0
  136. data/origen_app_generators/templates/app_generators/application/Gemfile +34 -0
  137. data/origen_app_generators/templates/app_generators/application/Rakefile +7 -0
  138. data/origen_app_generators/templates/app_generators/application/app/blocks/top_level.rb +12 -0
  139. data/origen_app_generators/templates/app_generators/application/app/lib/module.rb +6 -0
  140. data/origen_app_generators/templates/app_generators/application/app/templates/web/index.md.erb +19 -0
  141. data/origen_app_generators/templates/app_generators/application/app/templates/web/layouts/_basic.html.erb +13 -0
  142. data/origen_app_generators/templates/app_generators/application/app/templates/web/partials/_navbar.html.erb +20 -0
  143. data/origen_app_generators/templates/app_generators/application/app/templates/web/release_notes.md.erb +5 -0
  144. data/origen_app_generators/templates/app_generators/application/config/application.rb +121 -0
  145. data/origen_app_generators/templates/app_generators/application/config/boot.rb +4 -0
  146. data/origen_app_generators/templates/app_generators/application/config/commands.rb +79 -0
  147. data/origen_app_generators/templates/app_generators/application/config/maillist_dev.txt +4 -0
  148. data/origen_app_generators/templates/app_generators/application/config/maillist_prod.txt +3 -0
  149. data/origen_app_generators/templates/app_generators/application/config/version.rb +8 -0
  150. data/origen_app_generators/templates/app_generators/application/doc/history +0 -0
  151. data/origen_app_generators/templates/app_generators/application/dot_keep +0 -0
  152. data/origen_app_generators/templates/app_generators/application/origen_core_session +2 -0
  153. data/origen_app_generators/templates/app_generators/application/spec/spec_helper.rb +44 -0
  154. data/origen_app_generators/templates/app_generators/application/target/debug.rb +8 -0
  155. data/origen_app_generators/templates/app_generators/application/target/default.rb +1 -0
  156. data/origen_app_generators/templates/app_generators/application/target/production.rb +4 -0
  157. data/origen_app_generators/templates/app_generators/new/generator.rb +102 -0
  158. data/origen_app_generators/templates/app_generators/new/info.md.erb +9 -0
  159. data/origen_app_generators/templates/app_generators/origen_infrastructure/app_generator_plugin/app/lib/application.rb +54 -0
  160. data/origen_app_generators/templates/app_generators/origen_infrastructure/app_generator_plugin/app/lib/base.rb +55 -0
  161. data/origen_app_generators/templates/app_generators/origen_infrastructure/app_generator_plugin/app/lib/module.rb +28 -0
  162. data/origen_app_generators/templates/app_generators/origen_infrastructure/app_generator_plugin/app/lib/plugin.rb +64 -0
  163. data/origen_app_generators/templates/app_generators/origen_infrastructure/app_generator_plugin/config/load_generators.rb +6 -0
  164. data/origen_app_generators/templates/app_generators/plugin/Gemfile +32 -0
  165. data/origen_app_generators/templates/app_generators/plugin/Rakefile +10 -0
  166. data/origen_app_generators/templates/app_generators/plugin/app/templates/web/index.md.erb +37 -0
  167. data/origen_app_generators/templates/app_generators/plugin/app/templates/web/partials/_navbar_external.html.erb +20 -0
  168. data/origen_app_generators/templates/app_generators/plugin/app/templates/web/partials/_navbar_internal.html.erb +20 -0
  169. data/origen_app_generators/templates/app_generators/plugin/config/boot.rb +24 -0
  170. data/origen_app_generators/templates/app_generators/plugin/gemspec.rb +43 -0
  171. data/origen_app_generators/templates/app_generators/test_engineering/environment/j750.rb +1 -0
  172. data/origen_app_generators/templates/app_generators/test_engineering/environment/uflex.rb +1 -0
  173. data/origen_app_generators/templates/app_generators/test_engineering/environment/v93k.rb +1 -0
  174. data/origen_app_generators/templates/app_generators/test_engineering/stand_alone_application/.keep +0 -0
  175. data/origen_app_generators/templates/app_generators/test_engineering/test_block/.keep +0 -0
  176. data/origen_site_config.yml +55 -5
  177. data/templates/code_generators/attributes.rb +20 -0
  178. data/templates/code_generators/class.rb +9 -0
  179. data/templates/code_generators/controller.rb +87 -0
  180. data/templates/code_generators/model.rb +21 -0
  181. data/templates/code_generators/module.rb +4 -0
  182. data/templates/code_generators/parameters.rb +19 -0
  183. data/templates/code_generators/pins.rb +28 -0
  184. data/templates/code_generators/registers.rb +20 -0
  185. data/templates/code_generators/sub_blocks.rb +24 -0
  186. data/templates/code_generators/timesets.rb +24 -0
  187. data/templates/code_generators/version.rb +0 -1
  188. data/templates/git/gitignore.erb +0 -1
  189. data/vendor/lib/models/origen/export1.rb +77 -0
  190. data/vendor/lib/models/origen/export1/block1.rb +13 -0
  191. data/vendor/lib/models/origen/export1/block1/x.rb +36 -0
  192. data/vendor/lib/models/origen/non_origen_meta_data.md +1 -0
  193. metadata +149 -68
  194. data/bin/fix_my_workspace +0 -100
  195. data/lib/c99/ate_interface.rb +0 -77
  196. data/lib/c99/nvm.rb +0 -110
  197. data/lib/c99/target/mock2.rb +0 -1
  198. data/lib/c99/target/subdir/mock3.rb +0 -1
  199. data/lib/origen/code_generators/bundler.rb +0 -17
  200. data/lib/origen/code_generators/gem_setup.rb +0 -49
  201. data/lib/origen/code_generators/rake.rb +0 -13
  202. data/lib/origen/code_generators/rspec.rb +0 -12
  203. data/lib/origen/commands/add.rb +0 -12
  204. data/lib/tasks/private/build.rake +0 -8
  205. data/templates/code_generators/gemfile_app.rb +0 -4
  206. data/templates/code_generators/gemfile_plugin.rb +0 -6
  207. data/templates/code_generators/gemspec.rb +0 -33
@@ -1,6 +1,16 @@
1
1
  module Origen
2
2
  module Model
3
3
  module Exporter
4
+ # Export the model
5
+ #
6
+ # Options defaults:
7
+ # include_pins: true
8
+ # include_registers: true
9
+ # include_sub_blocks: true
10
+ # include_timestamp: true
11
+ # rm_rb_only: nil # delete only .rb files, default is rm -rf * Origen.root/vendor/lib/models/name
12
+ #
13
+ # Use the rm_rb_only option if the export dir is under revision control and the dir contains revision control metadata
4
14
  def export(name, options = {})
5
15
  options = {
6
16
  include_pins: true,
@@ -14,7 +24,13 @@ module Origen
14
24
  file = options[:file_path] || export_path(name, options)
15
25
  dir = options[:dir_path] || export_dir(options)
16
26
  path_to_file = Pathname.new(File.join(dir, file))
17
- FileUtils.rm_rf(path_to_file.sub_ext('').to_s) if File.exist?(path_to_file.sub_ext('').to_s)
27
+ if File.exist?(path_to_file.sub_ext('').to_s)
28
+ if options[:rm_rb_only]
29
+ Dir.glob(path_to_file.sub_ext('').to_s + '/**/*.rb').each { |f| FileUtils.rm_f(f) }
30
+ else
31
+ FileUtils.rm_rf(path_to_file.sub_ext('').to_s)
32
+ end
33
+ end
18
34
  FileUtils.rm_rf(path_to_file.to_s) if File.exist?(path_to_file.to_s)
19
35
  FileUtils.mkdir_p(path_to_file.dirname)
20
36
  File.open(path_to_file, 'w') do |f|
@@ -114,7 +130,7 @@ module Origen
114
130
  attr_end_str = (attr == pin_pkg_meta.keys.last) ? ' }' : ', '
115
131
  case attr_val
116
132
  when String
117
- str << "'#{attr_val}'#{attr_end_str}"
133
+ str << "\"#{attr_val.gsub('"', '\"')}\"#{attr_end_str}"
118
134
  else
119
135
  str << "#{attr_val}#{attr_end_str}"
120
136
  end
@@ -177,6 +193,9 @@ module Origen
177
193
  if (d = pin.direction) != :io
178
194
  line << ", direction: :#{d}"
179
195
  end
196
+ if (t = pin.type)
197
+ line << ", type: :#{t}"
198
+ end
180
199
  pkg_meta = write_pin_packages(pin)
181
200
  line << ", #{pkg_meta}" unless pkg_meta == ''
182
201
  Array(options[:attributes]).each do |attr|
@@ -224,7 +243,7 @@ module Origen
224
243
  indent = ' ' * (options[:indent] || 0)
225
244
  file_path = File.join(Pathname.new(options[:file_path]).sub_ext(''), "#{id}.rb")
226
245
  dir_path = options[:dir_path]
227
- line = indent + "model.sub_block :#{id}, file: '#{file_path}', dir: '#{dir_path}', lazy: true"
246
+ line = indent + "model.sub_block :#{id}, file: '#{file_path}', dir: \"#{dir_path.gsub(Origen.root.to_s, '#{Origen.root!}')}\", lazy: true"
228
247
  unless block.base_address == 0
229
248
  line << ", base_address: #{block.base_address.to_hex}"
230
249
  end
@@ -232,9 +251,9 @@ module Origen
232
251
  if value.is_a?(Symbol)
233
252
  line << ", #{key}: :#{value}"
234
253
  elsif value.is_a?(String)
235
- line << ", #{key}: '#{value}'"
254
+ line << ", #{key}: \"#{value.gsub('"', '\"')}\""
236
255
  else
237
- line << ", #{key}: #{value}"
256
+ line << ", #{key}: #{value}" unless value.nil?
238
257
  end
239
258
  end
240
259
  block.export(id, options.merge(file_path: file_path, dir_path: dir_path))
@@ -247,22 +266,29 @@ module Origen
247
266
  unless reg.description.empty?
248
267
  reg.description.each { |l| lines << indent + "# #{l}" }
249
268
  end
250
- lines << indent + "model.add_reg :#{id}, #{reg.offset.to_hex}, size: #{reg.size} do |reg|"
269
+ lines << indent + "model.add_reg :#{id}, #{reg.offset.to_hex}, size: #{reg.size} #{reg.bit_order == :msb0 ? ', bit_order: :msb0' : ''}#{build_reg_meta(reg)} do |reg|"
251
270
  indent = ' ' * ((options[:indent] || 0) + 2)
252
271
  reg.named_bits.each do |name, bits|
253
272
  unless bits.description.empty?
254
273
  bits.description.each { |l| lines << indent + "# #{l}" }
255
274
  end
275
+ position = reg.bit_order == :msb0 ? (reg.size - bits.position - 1) : bits.position
256
276
  if bits.size == 1
257
- line = indent + "reg.bit #{bits.position}, :#{name}"
277
+ line = indent + "reg.bit #{position}, :#{name}"
258
278
  else
259
- line = indent + "reg.bit #{bits.position + bits.size - 1}..#{bits.position}, :#{name}"
279
+ if reg.bit_order == :msb0
280
+ line = indent + "reg.bit #{position - bits.size + 1}..#{position}, :#{name}"
281
+ else
282
+ line = indent + "reg.bit #{position + bits.size - 1}..#{position}, :#{name}"
283
+ end
260
284
  end
261
285
  unless bits.access == :rw
262
286
  line << ", access: :#{bits.access}"
263
287
  end
264
- unless bits.reset_val == 0
265
- line << ", reset: #{bits.reset_val.to_hex}"
288
+ if bits.reset_val.is_a?(Symbol)
289
+ line << ", reset: :#{bits.reset_val}"
290
+ else
291
+ line << ", reset: #{bits.reset_val.to_hex}" unless bits.reset_val == 0
266
292
  end
267
293
  lines << line
268
294
  end
@@ -270,6 +296,20 @@ module Origen
270
296
  lines << indent + 'end'
271
297
  lines.join("\n")
272
298
  end
299
+
300
+ def build_reg_meta(reg)
301
+ ret_str = ''
302
+ reg.meta.each do |key, value|
303
+ if value.is_a?(Symbol)
304
+ ret_str += ", #{key}: :#{value}"
305
+ elsif value.is_a?(String)
306
+ ret_str += ", #{key}: \"#{value.gsub('"', '\"')}\""
307
+ else
308
+ ret_str += ", #{key}: #{value}" unless value.nil?
309
+ end
310
+ end
311
+ ret_str
312
+ end
273
313
  end
274
314
  end
275
315
  end
@@ -46,7 +46,10 @@ module Origen
46
46
  else
47
47
  x.send(:initialize, *args, &block)
48
48
  end
49
- x.send(:_initialized) if x.respond_to?(:is_an_origen_model?)
49
+ if x.respond_to?(:is_an_origen_model?)
50
+ x.send(:_initialized)
51
+ Origen::Loader.load_block(x)
52
+ end
50
53
  if x.respond_to?(:register_callback_listener)
51
54
  Origen.after_app_loaded do |app|
52
55
  x.register_callback_listener
@@ -55,6 +58,7 @@ module Origen
55
58
  # Do this before wrapping, otherwise the respond to method in the controller will
56
59
  # be looking for the model to be instantiated when it is not fully done yet
57
60
  is_top_level = x.respond_to?(:includes_origen_top_level?)
61
+
58
62
  if x.respond_to?(:wrap_in_controller)
59
63
  x = x.wrap_in_controller
60
64
  end
@@ -22,6 +22,10 @@ module Origen
22
22
  !windows?
23
23
  end
24
24
  end
25
+
26
+ # Blow this cache whenever this file is re-loaded
27
+ @operating_systems = nil
28
+
25
29
  def self.os
26
30
  @operating_systems ||= OperatingSystems.new
27
31
  end
@@ -1,4 +1,5 @@
1
1
  require 'active_support/concern'
2
+ require 'set'
2
3
  module Origen
3
4
  module Parameters
4
5
  extend ActiveSupport::Concern
@@ -8,6 +9,75 @@ module Origen
8
9
 
9
10
  attr_accessor :current
10
11
 
12
+ # @api private
13
+ #
14
+ # Any define_params blocks contained within the given block will be allowed to be re-opened later
15
+ # in the block to override existing parameter settings or to add new ones.
16
+ #
17
+ # This is not allowed normally since already-defined child parameter sets could have referenced the
18
+ # original parameter and they would not reflect the final value after re-opening the parent parameter
19
+ # set.
20
+ #
21
+ # By defining the parameters within this block, Origen will keep track of relationships between parameter
22
+ # sets and any time a parent is changed the definitions of existing children will be re-executed to ensure
23
+ # that they reflect the new values.
24
+ #
25
+ # This is initially intended to support the concept of a app/parameters/application.rb being
26
+ # used to define baseline parameter sets, and then target-specific files can then override them.
27
+ def self.transaction
28
+ start_transaction
29
+ yield
30
+ stop_transaction
31
+ end
32
+
33
+ # @api private
34
+ def self.start_transaction
35
+ @transaction_data = {}
36
+ @transaction_open = true
37
+ @transaction_counter ||= 0
38
+ @transaction_counter += 1
39
+ end
40
+
41
+ # @api private
42
+ def self.stop_transaction
43
+ @transaction_counter -= 1
44
+ if @transaction_counter == 0
45
+ # Now finalize (freeze) all parameter sets we have just defined, this was deferred at define time due
46
+ # to running within a transaction
47
+ @transaction_data.each do |model, parameter_sets|
48
+ parameter_sets.keys.each do |name|
49
+ model._parameter_sets[name].finalize
50
+ end
51
+ end
52
+ @transaction_data = nil
53
+ @transaction_open = false
54
+ end
55
+ end
56
+
57
+ # @api private
58
+ def self.transaction_data
59
+ @transaction_data
60
+ end
61
+
62
+ # @api private
63
+ def self.transaction_open
64
+ @transaction_open
65
+ end
66
+
67
+ # @api private
68
+ def self.transaction_redefine
69
+ @transaction_redefine
70
+ end
71
+
72
+ # @api private
73
+ def self.redefine(model, name)
74
+ @transaction_redefine = true
75
+ model._parameter_sets.delete(name)
76
+ @transaction_data[model][name][:definitions].each { |options, block| model.define_params(name, options, &block) }
77
+ @transaction_data[model][name][:children].each { |model, name| redefine(model, name) }
78
+ @transaction_redefine = false
79
+ end
80
+
11
81
  module ClassMethods
12
82
  def parameters_context(obj = nil)
13
83
  if obj
@@ -25,19 +95,41 @@ module Origen
25
95
  end
26
96
  end
27
97
 
98
+ # @api private
99
+ def define_params_transaction
100
+ Origen::Parameters.transaction_data
101
+ end
102
+
28
103
  def define_params(name, options = {}, &block)
29
- if _parameter_sets[name]
30
- fail 'Parameter sets cannot be re-opened once originally defined!'
104
+ name = name.to_sym
105
+ if _parameter_sets[name] && !Origen::Parameters.transaction_open
106
+ fail "Parameter set '#{name}' cannot be re-opened once originally defined!"
31
107
  else
32
- _parameter_sets[name] = Set.new(top_level: true, owner: self)
108
+ if Origen::Parameters.transaction_open && !Origen::Parameters.transaction_redefine
109
+ define_params_transaction[self] ||= {}
110
+ define_params_transaction[self][name] ||= { children: ::Set[], definitions: [] }
111
+ define_params_transaction[self][name][:definitions] << [options.dup, block]
112
+ redefine_children = define_params_transaction[self][name][:children] if _parameter_sets[name]
113
+ end
114
+ if _parameter_sets[name]
115
+ defaults_already_set = true
116
+ else
117
+ _parameter_sets[name] = Origen::Parameters::Set.new(top_level: true, owner: self)
118
+ end
33
119
  if options[:inherit]
34
120
  kontext = _validate_parameter_set_name(options[:inherit])
35
121
  parent = kontext[:obj]._parameter_sets[kontext[:context]]
36
- _parameter_sets[name].copy_defaults_from(parent)
122
+ if Origen::Parameters.transaction_open && !Origen::Parameters.transaction_redefine
123
+ define_params_transaction[kontext[:obj]][kontext[:context]][:children] << [self, name]
124
+ end
125
+ _parameter_sets[name].copy_defaults_from(parent) unless defaults_already_set
37
126
  _parameter_sets[name].define(parent, &block)
38
127
  else
39
128
  _parameter_sets[name].define(&block)
40
129
  end
130
+ if redefine_children
131
+ redefine_children.each { |model, set_name| Origen::Parameters.redefine(model, set_name) }
132
+ end
41
133
  end
42
134
  end
43
135
  alias_method :define_parameters, :define_params
@@ -21,7 +21,7 @@ module Origen
21
21
  @defining = true
22
22
  yield self, parent
23
23
  @defining = false
24
- finalize
24
+ finalize unless Origen::Parameters.transaction_open
25
25
  end
26
26
 
27
27
  # Returns the current parameter context
@@ -60,10 +60,10 @@ module Origen
60
60
  if args.length != 0
61
61
  super
62
62
  else
63
- val = self[method]
64
- if !val
63
+ if !key?(method)
65
64
  super
66
65
  else
66
+ val = self[method]
67
67
  if val.is_a?(Set)
68
68
  val
69
69
  else
@@ -114,6 +114,7 @@ module Origen
114
114
  end
115
115
 
116
116
  def defining?
117
+ return true if Origen::Parameters.transaction_open
117
118
  if top_level?
118
119
  @defining
119
120
  else
data/lib/origen/pins.rb CHANGED
@@ -229,21 +229,23 @@ module Origen
229
229
 
230
230
  rtl_name = options[:rtl_name]
231
231
  force = options[:force]
232
+ offset = options.delete(:offset) || 0
232
233
  options.delete(:size).times do |i|
233
- options[:name] = "#{id}#{i}".to_sym
234
- options[:rtl_name] = "#{rtl_name}#{i}".to_sym if rtl_name
235
- options[:force] = force[i] if force
234
+ pin_index = offset + i
235
+ options[:name] = "#{id}#{pin_index}".to_sym
236
+ options[:rtl_name] = "#{rtl_name}#{pin_index}".to_sym if rtl_name
237
+ options[:force] = force[pin_index] if force
236
238
 
237
239
  if power_pin
238
- group[i] = PowerPin.new(i, self, options)
240
+ group[i] = PowerPin.new(pin_index, self, options)
239
241
  elsif ground_pin
240
- group[i] = GroundPin.new(i, self, options)
242
+ group[i] = GroundPin.new(pin_index, self, options)
241
243
  elsif virtual_pin
242
- group[i] = VirtualPin.new(i, self, options)
244
+ group[i] = VirtualPin.new(pin_index, self, options)
243
245
  elsif other_pin
244
- group[i] = OtherPin.new(i, self, options)
246
+ group[i] = OtherPin.new(pin_index, self, options)
245
247
  else
246
- group[i] = Pin.new(i, self, options)
248
+ group[i] = Pin.new(pin_index, self, options)
247
249
  end
248
250
  group[i].invalidate_group_cache
249
251
  end
@@ -56,6 +56,14 @@ module Origen
56
56
  attr_accessor :description
57
57
  attr_accessor :notes
58
58
 
59
+ # Returns a hash containing any meta data associated with the current pin state
60
+ #
61
+ # my_pin.read!(1, meta: { position: 10 })
62
+ # my_pin.state_meta # => { position: 10 }
63
+ # my_pin.dont_care
64
+ # my_pin.state_meta # => {}
65
+ attr_reader :state_meta
66
+
59
67
  # Should be instantiated through the HasPins macros
60
68
  def initialize(id, owner, options = {}) # :nodoc:
61
69
  options = {
@@ -89,6 +97,7 @@ module Origen
89
97
  @clock = nil
90
98
  @meta = options[:meta] || {}
91
99
  @dib_meta = options[:dib_meta] || {}
100
+ @state_meta = {}
92
101
  @_saved_state = []
93
102
  @_saved_value = []
94
103
  @_saved_suspend = []
@@ -638,6 +647,11 @@ module Origen
638
647
  @repeat_previous
639
648
  end
640
649
 
650
+ def set_state_with_options(state, options = {})
651
+ @state_meta = options[:meta] || {}
652
+ set_state(state)
653
+ end
654
+
641
655
  def set_state(state)
642
656
  invalidate_vector_cache
643
657
  @repeat_previous = false
@@ -690,76 +704,77 @@ module Origen
690
704
 
691
705
  def state=(value)
692
706
  invalidate_vector_cache
707
+ @state_meta = {}
693
708
  @state = value
694
709
  end
695
710
 
696
711
  # Set the pin to drive a 1 on future cycles
697
- def drive_hi
698
- set_state(:drive)
712
+ def drive_hi(options = {})
713
+ set_state_with_options(:drive, options)
699
714
  set_value(1)
700
715
  end
701
716
  alias_method :write_hi, :drive_hi
702
717
 
703
- def drive_hi!
704
- drive_hi
718
+ def drive_hi!(options = {})
719
+ drive_hi(options)
705
720
  cycle
706
721
  end
707
722
  alias_method :write_hi!, :drive_hi!
708
723
 
709
724
  # Set the pin to drive a high voltage on future cycles (if the tester supports it).
710
725
  # For example on a J750 high-voltage channel the pin state would be set to "2"
711
- def drive_very_hi
712
- set_state(:drive_very_hi)
726
+ def drive_very_hi(options = {})
727
+ set_state_with_options(:drive_very_hi, options)
713
728
  set_value(1)
714
729
  end
715
730
 
716
- def drive_very_hi!
717
- drive_very_hi
731
+ def drive_very_hi!(options = {})
732
+ drive_very_hi(options)
718
733
  cycle
719
734
  end
720
735
 
721
736
  # Set the pin to drive a 0 on future cycles
722
- def drive_lo
723
- set_state(:drive)
737
+ def drive_lo(options = {})
738
+ set_state_with_options(:drive, options)
724
739
  set_value(0)
725
740
  end
726
741
  alias_method :write_lo, :drive_lo
727
742
 
728
- def drive_lo!
729
- drive_lo
743
+ def drive_lo!(options = {})
744
+ drive_lo(options)
730
745
  cycle
731
746
  end
732
747
  alias_method :write_lo!, :drive_lo!
733
748
 
734
- def drive_mem
735
- set_state(:drive_mem)
749
+ def drive_mem(options = {})
750
+ set_state_with_options(:drive_mem, options)
736
751
  end
737
752
 
738
- def drive_mem!
739
- drive_mem
753
+ def drive_mem!(options = {})
754
+ drive_mem(options)
740
755
  cycle
741
756
  end
742
757
 
743
- def expect_mem
744
- set_state(:expect_mem)
758
+ def expect_mem(options = {})
759
+ set_state_with_options(:expect_mem, options)
745
760
  end
746
761
 
747
- def expect_mem!
748
- expect_mem
762
+ def expect_mem!(options = {})
763
+ expect_mem(options)
749
764
  cycle
750
765
  end
751
766
 
752
767
  # Set the pin to expect a 1 on future cycles
753
- def assert_hi(_options = {})
754
- set_state(:compare)
768
+ def assert_hi(options = {})
769
+ set_state_with_options(:compare, options)
755
770
  set_value(1)
756
771
  end
757
772
  alias_method :expect_hi, :assert_hi
758
773
  alias_method :compare_hi, :assert_hi
759
774
  alias_method :read_hi, :assert_hi
760
775
 
761
- def assert_hi!
762
- assert_hi
776
+ def assert_hi!(options = {})
777
+ assert_hi(options)
763
778
  cycle
764
779
  end
765
780
  alias_method :expect_hi!, :assert_hi!
@@ -767,8 +782,8 @@ module Origen
767
782
  alias_method :read_hi!, :assert_hi!
768
783
 
769
784
  # Set the pin to expect a 0 on future cycles
770
- def assert_lo(_options = {})
771
- set_state(:compare)
785
+ def assert_lo(options = {})
786
+ set_state_with_options(:compare, options)
772
787
  set_value(0)
773
788
  # Planning to add the active load logic to the tester instead...
774
789
  # options = { :active => false #if active true means to take tester active load capability into account
@@ -783,8 +798,8 @@ module Origen
783
798
  alias_method :compare_lo, :assert_lo
784
799
  alias_method :read_lo, :assert_lo
785
800
 
786
- def assert_lo!
787
- assert_lo
801
+ def assert_lo!(options = {})
802
+ assert_lo(options)
788
803
  cycle
789
804
  end
790
805
  alias_method :expect_lo!, :assert_lo!
@@ -792,12 +807,12 @@ module Origen
792
807
  alias_method :read_lo!, :assert_lo!
793
808
 
794
809
  # Set the pin to X on future cycles
795
- def dont_care
796
- set_state(:dont_care)
810
+ def dont_care(options = {})
811
+ set_state_with_options(:dont_care, options)
797
812
  end
798
813
 
799
- def dont_care!
800
- dont_care
814
+ def dont_care!(options = {})
815
+ dont_care(options)
801
816
  cycle
802
817
  end
803
818
 
@@ -807,14 +822,14 @@ module Origen
807
822
  # [0,1,1,0].each do |level|
808
823
  # $pin(:d_in).drive(level)
809
824
  # end
810
- def drive(value)
811
- set_state(:drive)
825
+ def drive(value, options = {})
826
+ set_state_with_options(:drive, options)
812
827
  set_value(value)
813
828
  end
814
829
  alias_method :write, :drive
815
830
 
816
- def drive!(value)
817
- drive(value)
831
+ def drive!(value, options = {})
832
+ drive(value, options)
818
833
  cycle
819
834
  end
820
835
  alias_method :write!, :drive!
@@ -825,8 +840,8 @@ module Origen
825
840
  # [0,1,1,0].each do |level|
826
841
  # $pin(:d_in).assert(level)
827
842
  # end
828
- def assert(value, _options = {})
829
- set_state(:compare)
843
+ def assert(value, options = {})
844
+ set_state_with_options(:compare, options)
830
845
  set_value(value)
831
846
  end
832
847
  alias_method :compare, :assert
@@ -841,15 +856,15 @@ module Origen
841
856
  alias_method :expect!, :assert!
842
857
  alias_method :read!, :assert!
843
858
 
844
- def assert_midband
845
- set_state(:compare_midband)
859
+ def assert_midband(options = {})
860
+ set_state_with_options(:compare_midband, options)
846
861
  end
847
862
  alias_method :compare_midband, :assert_midband
848
863
  alias_method :expect_midband, :assert_midband
849
864
  alias_method :read_midband, :assert_midband
850
865
 
851
- def assert_midband!
852
- assert_midband
866
+ def assert_midband!(options = {})
867
+ assert_midband(options)
853
868
  cycle
854
869
  end
855
870
  alias_method :compare_midband!, :assert_midband!
@@ -909,14 +924,14 @@ module Origen
909
924
  end
910
925
 
911
926
  # Mark the (data) from the pin to be captured
912
- def capture
913
- set_state(:capture)
927
+ def capture(options = {})
928
+ set_state_with_options(:capture, options)
914
929
  end
915
930
  alias_method :store, :capture
916
931
 
917
932
  # Mark the (data) from the pin to be captured and trigger a cycle
918
- def capture!
919
- capture
933
+ def capture!(options = {})
934
+ capture(options)
920
935
  cycle
921
936
  end
922
937
  alias_method :store!, :capture!