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,4 +1,5 @@
1
1
  require 'json'
2
+ require 'origen/registers/msb0_delegator'
2
3
  module Origen
3
4
  module Registers
4
5
  # The register class can be used to represent not only h/ware resgisters,
@@ -68,13 +69,14 @@ module Origen
68
69
  @name = name
69
70
  @init_as_writable = options.delete(:init_as_writable)
70
71
  @define_file = options.delete(:define_file)
72
+ @from_placeholder = options.delete(:from_placeholder) || false
71
73
  REG_LEVEL_ATTRIBUTES.each do |attribute, _meta|
72
- if options[attribute[1..-1].to_sym]
74
+ if @from_placeholder
75
+ instance_variable_set("@#{attribute[1..-1]}", options.delete(attribute))
76
+ else
73
77
  # If register creation is coming directly from Reg.new, instead of Placeholder,
74
78
  # it may not have attributes with '_' prefix
75
79
  instance_variable_set("@#{attribute[1..-1]}", options.delete(attribute[1..-1].to_sym))
76
- else
77
- instance_variable_set("@#{attribute[1..-1]}", options.delete(attribute))
78
80
  end
79
81
  end
80
82
  @description_from_api = {}
@@ -90,7 +92,20 @@ module Origen
90
92
  @bits << Bit.new(self, n, writable: @init_as_writable, undefined: true)
91
93
  end
92
94
 
95
+ # Internally re-map msb0 register descriptions as lsb0
96
+ options.each_value { |bit_desc| bit_desc[:pos] = @size - bit_desc[:pos] - bit_desc[:bits] } if bit_order == :msb0
97
+
93
98
  add_bits_from_options(options)
99
+
100
+ @msb0_delegator = Msb0Delegator.new(self, @bits)
101
+ end
102
+
103
+ def with_msb0
104
+ @msb0_delegator
105
+ end
106
+
107
+ def with_lsb0
108
+ self
94
109
  end
95
110
 
96
111
  # Returns the bit order attribute of the register (either :msb0 or :lsb0). If
@@ -133,6 +148,18 @@ module Origen
133
148
  end
134
149
 
135
150
  def inspect(options = {})
151
+ wbo = options[:with_bit_order] || :lsb0
152
+ domsb0 = wbo == :msb0
153
+ dolsb0 = !domsb0
154
+ if wbo != bit_order
155
+ Origen.log.warn "Register displayed with #{wbo} numbering, but defined with #{bit_order} numbering"
156
+ Origen.log.warn 'Access (and display) this register with explicit numbering like this:'
157
+ Origen.log.warn ''
158
+ Origen.log.warn " reg(:#{name}).with_msb0 # bit numbering scheme is msb0"
159
+ Origen.log.warn " reg(:#{name}).with_lsb0 # bit numbering scheme is lsb0 (default)"
160
+ Origen.log.warn " reg(:#{name}) # bit numbering scheme is lsb0 (default)"
161
+ end
162
+
136
163
  # This fancy_output option is passed in via option hash
137
164
  # Even better, the output could auto-detect 7-bit vs 8-bit terminal output and adjust the parameter, but that's for another day
138
165
  fancy_output = options[:fancy_output].nil? ? true : options[:fancy_output]
@@ -172,14 +199,10 @@ module Origen
172
199
  bit_width = 13
173
200
  desc = ["\n0x%X - :#{name}" % address]
174
201
  r = size % 8
175
- if r == 0 || (size > 8 && bit_order == :msb0)
202
+ if r == 0 # || (size > 8 && domsb0)
176
203
  desc << (' ' + corner_double_up_left + ((horiz_double_line * bit_width + horiz_double_tee_down) * 8)).chop + corner_double_up_right
177
204
  else
178
- if bit_order == :lsb0
179
- desc << (' ' + (' ' * (bit_width + 1) * (8 - r)) + corner_double_up_left + ((horiz_double_line * bit_width + horiz_double_tee_down) * r)).chop + corner_double_up_right
180
- else
181
- desc << (' ' + corner_double_up_left + ((horiz_double_line * bit_width + horiz_double_tee_down) * r)).chop + corner_double_up_right
182
- end
205
+ desc << (' ' + (' ' * (bit_width + 1) * (8 - r)) + corner_double_up_left + ((horiz_double_line * bit_width + horiz_double_tee_down) * r)).chop + corner_double_up_right
183
206
  end
184
207
 
185
208
  # "<#{self.class}: #{self.name}>"
@@ -187,32 +210,22 @@ module Origen
187
210
  num_bytes.times do |byte_index|
188
211
  # Need to add support for little endian regs here?
189
212
  byte_number = num_bytes - byte_index
190
- if bit_order == :lsb0
191
- max_bit = (byte_number * 8) - 1
192
- min_bit = max_bit - 8 + 1
193
- else
194
- min_bit = (byte_index * 8)
195
- max_bit = min_bit + 7
196
- end
213
+ max_bit = (byte_number * 8) - 1
214
+ min_bit = max_bit - 8 + 1
197
215
 
198
216
  # BIT INDEX ROW
199
217
  line = ' '
200
218
  line_complete = false
201
219
  8.times do |i|
202
- if bit_order == :lsb0
203
- bit_num = (byte_number * 8) - i - 1
204
- else
205
- bit_num = (byte_index * 8) + i
206
- end
220
+ bit_num = (byte_number * 8) - i - 1
207
221
  if bit_num > size - 1
208
- if bit_order == :msb0 && bit_num == size
209
- line += vert_single_line
210
- line_complete = true
222
+ line << ' ' + ''.center(bit_width) unless line_complete
223
+ else
224
+ if dolsb0
225
+ line << vert_single_line + "#{bit_num}".center(bit_width)
211
226
  else
212
- line << ' ' + ''.center(bit_width) unless line_complete
227
+ line << vert_single_line + "#{size - bit_num - 1}".center(bit_width)
213
228
  end
214
- else
215
- line << vert_single_line + "#{bit_num}".center(bit_width)
216
229
  end
217
230
  end
218
231
  line += vert_single_line unless line_complete
@@ -224,11 +237,9 @@ module Origen
224
237
  line_complete = false
225
238
  named_bits include_spacers: true do |name, bit, bitcounter|
226
239
  if _bit_in_range?(bit, max_bit, min_bit)
227
- if bit_order == :lsb0
228
- if max_bit > (size - 1) && !first_done
229
- (max_bit - (size - 1)).times do
230
- line << ' ' * (bit_width + 1)
231
- end
240
+ if max_bit > (size - 1) && !first_done
241
+ (max_bit - (size - 1)).times do
242
+ line << ' ' * (bit_width + 1)
232
243
  end
233
244
  end
234
245
 
@@ -236,17 +247,13 @@ module Origen
236
247
 
237
248
  if name
238
249
  if bitcounter.nil?
239
- if bit_order == :lsb0
240
- bit_name = "#{name}[#{_max_bit_in_range(bit, max_bit, min_bit)}:#{_min_bit_in_range(bit, max_bit, min_bit)}]"
241
- else
242
- bit_name = "#{name}[#{_min_bit_in_range(bit, max_bit, min_bit)}:#{_max_bit_in_range(bit, max_bit, min_bit)}]"
243
- end
250
+ bit_name = "#{name}[#{_max_bit_in_range(bit, max_bit, min_bit, options)}:#{_min_bit_in_range(bit, max_bit, min_bit, options)}]"
244
251
  bit_span = _num_bits_in_range(bit, max_bit, min_bit)
245
252
 
246
253
  else
247
- upper = _max_bit_in_range(bit, max_bit, min_bit) + bitcounter - bit.size
248
- lower = _min_bit_in_range(bit, max_bit, min_bit) + bitcounter - bit.size
249
- if bit_order == :lsb0
254
+ upper = _max_bit_in_range(bit, max_bit, min_bit, options) + bitcounter - bit.size
255
+ lower = _min_bit_in_range(bit, max_bit, min_bit, options) + bitcounter - bit.size
256
+ if dolsb0
250
257
  bit_name = "#{name}[#{upper}:#{lower}]"
251
258
  else
252
259
  bit_name = "#{name}[#{upper}:#{lower}]"
@@ -292,11 +299,9 @@ module Origen
292
299
  first_done = false
293
300
  named_bits include_spacers: true do |name, bit, _bitcounter|
294
301
  if _bit_in_range?(bit, max_bit, min_bit)
295
- if bit_order == :lsb0
296
- if max_bit > (size - 1) && !first_done
297
- (max_bit - (size - 1)).times do
298
- line << ' ' * (bit_width + 1)
299
- end
302
+ if max_bit > (size - 1) && !first_done
303
+ (max_bit - (size - 1)).times do
304
+ line << ' ' * (bit_width + 1)
300
305
  end
301
306
  end
302
307
 
@@ -347,12 +352,8 @@ module Origen
347
352
 
348
353
  if size >= 8
349
354
  r = size % 8
350
- if byte_index == 0 && r != 0 && bit_order == :lsb0
355
+ if byte_index == 0 && r != 0
351
356
  desc << (' ' + corner_double_up_left + ((horiz_double_line * bit_width + horiz_double_tee_down) * (8 - r)).chop + horiz_double_cross + (horiz_single_line * (bit_width + 1) * r)).chop + vert_single_tee_left
352
- elsif (byte_index == num_bytes - 1) && r != 0 && bit_order == :msb0
353
- desc << (' ' + corner_single_down_left + ((horiz_single_line * bit_width + horiz_single_tee_up) * r)).chop + corner_single_down_right
354
- elsif (byte_index == num_bytes - 2) && r != 0 && bit_order == :msb0
355
- desc << ' ' + vert_single_tee_right + ((horiz_single_line * bit_width + horiz_single_cross) * r) + ((horiz_single_line * bit_width + horiz_single_tee_up) * (8 - r)).chop + corner_single_down_right
356
357
  else
357
358
  if byte_index == num_bytes - 1
358
359
  desc << (' ' + corner_single_down_left + ((horiz_single_line * bit_width + horiz_single_tee_up) * 8)).chop + corner_single_down_right
@@ -361,11 +362,7 @@ module Origen
361
362
  end
362
363
  end
363
364
  else
364
- if bit_order == :lsb0
365
- desc << (' ' + (' ' * (bit_width + 1) * (8 - size)) + corner_single_down_left + ((horiz_single_line * bit_width + horiz_single_tee_up) * size)).chop + corner_single_down_right
366
- else
367
- desc << (' ' + corner_single_down_left + ((horiz_single_line * bit_width + horiz_single_tee_up) * size)).chop + corner_single_down_right
368
- end
365
+ desc << (' ' + (' ' * (bit_width + 1) * (8 - size)) + corner_single_down_left + ((horiz_single_line * bit_width + horiz_single_tee_up) * size)).chop + corner_single_down_right
369
366
  end
370
367
  end
371
368
  desc.join("\n")
@@ -583,24 +580,13 @@ module Origen
583
580
  @lookup.each { |_k, v| split_bits = true if v.is_a? Array }
584
581
 
585
582
  if split_bits == false
586
- if bit_order == :lsb0
587
- current_pos = size
588
- else
589
- current_pos = 0
590
- end
583
+ current_pos = size
584
+
591
585
  # Sort by position
592
- @lookup.sort_by { |_name, details| bit_order == :lsb0 ? -details[:pos] : details[:pos] }.each do |name, details|
593
- if bit_order == :lsb0
594
- pos = details[:bits] + details[:pos]
595
- else
596
- pos = details[:pos]
597
- end
586
+ @lookup.sort_by { |_name, details| -details[:pos] }.each do |name, details|
587
+ pos = details[:bits] + details[:pos]
598
588
  if options[:include_spacers] && (pos != current_pos)
599
- if bit_order == :lsb0
600
- collection = BitCollection.dummy(self, nil, size: current_pos - pos, pos: pos)
601
- else
602
- collection = BitCollection.dummy(self, nil, size: pos - current_pos, pos: current_pos)
603
- end
589
+ collection = BitCollection.dummy(self, nil, size: current_pos - pos, pos: pos)
604
590
  unless collection.size == 0
605
591
  if block_given?
606
592
  yield nil, collection
@@ -620,19 +606,10 @@ module Origen
620
606
  result << [name, collection]
621
607
  end
622
608
  end
623
- if bit_order == :lsb0
624
- current_pos = details[:pos]
625
- else
626
- current_pos = details[:bits] + details[:pos]
627
- end
609
+ current_pos = details[:pos]
628
610
  end
629
- if options[:include_spacers] && ((bit_order == :lsb0 && current_pos != 0) ||
630
- bit_order == :msb0 && current_pos != size)
631
- if bit_order == :lsb0
632
- collection = BitCollection.dummy(self, nil, size: current_pos, pos: 0)
633
- else
634
- collection = BitCollection.dummy(self, nil, size: size - current_pos, pos: current_pos)
635
- end
611
+ if options[:include_spacers] && (current_pos != 0)
612
+ collection = BitCollection.dummy(self, nil, size: current_pos, pos: 0)
636
613
  unless collection.size == 0
637
614
  if block_given?
638
615
  yield nil, collection
@@ -819,7 +796,13 @@ module Origen
819
796
  object = writer
820
797
  (Origen.top_level || owner).write_register_missing!(self) unless object
821
798
  end
822
- object.send(operation, self, options)
799
+ if tester && tester.respond_to?(operation)
800
+ tester.send(operation, self, options) do
801
+ object.send(operation, self, options)
802
+ end
803
+ else
804
+ object.send(operation, self, options)
805
+ end
823
806
  self
824
807
  end
825
808
 
@@ -1060,10 +1043,12 @@ module Origen
1060
1043
  alias_method :delete_bits, :delete_bit
1061
1044
 
1062
1045
  # @api private
1063
- def expand_range(range)
1046
+ def expand_range(range, wbo = :lsb0)
1064
1047
  if range.first > range.last
1065
1048
  range = Range.new(range.last, range.first)
1066
1049
  end
1050
+ range = range.to_a
1051
+ range.reverse! if wbo == :msb0
1067
1052
  range.each do |i|
1068
1053
  yield i
1069
1054
  end
@@ -1085,13 +1070,22 @@ module Origen
1085
1070
  # reg(:control).bit(1) # => Returns a BitCollection containing status bit
1086
1071
  # reg(:control).bit(1,2) # => Returns a BitCollection containing both status bits
1087
1072
  def bit(*args)
1073
+ # allow msb0 bit numbering if requested
1074
+ wbo = :lsb0
1075
+ if args.last.is_a?(Hash)
1076
+ wbo = args.last.delete(:with_bit_order) || :lsb0
1077
+ args.pop if args.last.size == 0
1078
+ end
1079
+
1088
1080
  multi_bit_names = false
1089
1081
  # return get_bits_with_constraint(nil,:default) if args.size == 0
1090
1082
  constraint = extract_feature_params(args)
1091
1083
  if constraint.nil?
1092
1084
  constraint = :default
1093
1085
  end
1094
- collection = BitCollection.new(self, :unknown)
1086
+
1087
+ collection = BitCollection.new(self, :unknown, [], with_bit_order: wbo)
1088
+
1095
1089
  if args.size == 0
1096
1090
  collection.add_name(name)
1097
1091
  @bits.each do |bit|
@@ -1100,13 +1094,14 @@ module Origen
1100
1094
  else
1101
1095
  args.flatten!
1102
1096
  args.sort!
1097
+ args.reverse! if wbo == :msb0
1103
1098
  args.each do |arg_item|
1104
1099
  if arg_item.is_a?(Integer)
1105
- b = get_bits_with_constraint(arg_item, constraint)
1100
+ b = get_bits_with_constraint(arg_item, constraint, with_bit_order: wbo)
1106
1101
  collection << b if b
1107
1102
  elsif arg_item.is_a?(Range)
1108
- expand_range(arg_item) do |bit_number|
1109
- collection << get_bits_with_constraint(bit_number, constraint)
1103
+ expand_range(arg_item, wbo) do |bit_number|
1104
+ collection << get_bits_with_constraint(bit_number, constraint, with_bit_order: wbo)
1110
1105
  end
1111
1106
  else
1112
1107
  multi_bit_names = args.size > 1
@@ -1139,14 +1134,21 @@ module Origen
1139
1134
  else
1140
1135
  if multi_bit_names
1141
1136
  collection.sort_by!(&:position)
1137
+ wbo == :msb0 ? collection.with_msb0 : collection.with_lsb0
1142
1138
  end
1143
- collection
1139
+ wbo == :msb0 ? collection.with_msb0 : collection.with_lsb0
1144
1140
  end
1145
1141
  end
1146
1142
  alias_method :bits, :bit
1147
1143
  alias_method :[], :bit
1148
1144
 
1149
- def get_bits_with_constraint(number, params)
1145
+ def get_bits_with_constraint(number, params, options = {})
1146
+ options = { with_bit_order: :lsb0 }.merge(options)
1147
+ # remap to lsb0 number to grab correct bit
1148
+ if options[:with_bit_order] == :msb0
1149
+ number = size - number - 1
1150
+ end
1151
+
1150
1152
  return nil unless @bits[number]
1151
1153
  if (params == :default || !params) && @bits[number].enabled?
1152
1154
  @bits[number]
@@ -1267,23 +1269,28 @@ module Origen
1267
1269
 
1268
1270
  # All other Reg methods are delegated to BitCollection
1269
1271
  def method_missing(method, *args, &block) # :nodoc:
1272
+ wbo = :lsb0
1273
+ if args.last.is_a?(Hash)
1274
+ wbo = args.last[:with_bit_order] if args.last.key?(:with_bit_order)
1275
+ end
1276
+
1270
1277
  if method.to_sym == :to_ary || method.to_sym == :to_hash
1271
1278
  nil
1272
1279
  elsif meta_data_method?(method)
1273
1280
  extract_meta_data(method, *args)
1274
1281
  else
1275
1282
  if BitCollection.instance_methods.include?(method)
1276
- to_bit_collection.send(method, *args, &block)
1283
+ to_bit_collection(with_bit_order: wbo).send(method, *args, &block)
1277
1284
  elsif has_bits?(method)
1278
- bits(method)
1285
+ bits(method, with_bit_order: wbo)
1279
1286
  else
1280
1287
  super
1281
1288
  end
1282
1289
  end
1283
1290
  end
1284
1291
 
1285
- def to_bit_collection
1286
- BitCollection.new(self, name, @bits)
1292
+ def to_bit_collection(options = {})
1293
+ BitCollection.new(self, name, @bits, options)
1287
1294
  end
1288
1295
 
1289
1296
  # Recognize that Reg responds to all BitCollection methods methods based on
@@ -1554,14 +1561,22 @@ module Origen
1554
1561
  end
1555
1562
  end
1556
1563
 
1557
- def _max_bit_in_range(bits, max, _min)
1564
+ def _max_bit_in_range(bits, max, _min, options = { with_bit_order: false })
1558
1565
  upper = bits.position + bits.size - 1
1559
- [upper, max].min - bits.position
1566
+ if options[:with_bit_order] == :msb0
1567
+ bits.size - ([upper, max].min - bits.position) - 1
1568
+ else
1569
+ [upper, max].min - bits.position
1570
+ end
1560
1571
  end
1561
1572
 
1562
- def _min_bit_in_range(bits, _max, min)
1573
+ def _min_bit_in_range(bits, _max, min, options = { with_bit_order: false })
1563
1574
  lower = bits.position
1564
- [lower, min].max - bits.position
1575
+ if options[:with_bit_order] == :msb0
1576
+ bits.size - ([lower, min].max - lower) - 1
1577
+ else
1578
+ [lower, min].max - bits.position
1579
+ end
1565
1580
  end
1566
1581
 
1567
1582
  # Returns true if some portion of the given bits falls
@@ -8,7 +8,7 @@ module Origen
8
8
 
9
9
  IGNORE_DIRS = %w(
10
10
  .ws .lsf log output web coverage .ref .yardoc .collection .bin
11
- .session .bundle .tpc pkg tmp lbin .git
11
+ .session .bundle .tpc pkg tmp .git
12
12
  )
13
13
 
14
14
  IGNORE_FILES = %w(
@@ -11,6 +11,25 @@ module Origen
11
11
  nil
12
12
  end
13
13
 
14
+ # Returns the Git version number from the current runtime environment (as a string)
15
+ def self.version
16
+ @version ||= begin
17
+ version = nil
18
+ git('--version', verbose: false).each do |line|
19
+ if line =~ /git version (\d+(\.\d+)+)/
20
+ version = Regexp.last_match(1)
21
+ break
22
+ end
23
+ end
24
+ if version
25
+ version
26
+ else
27
+ Origen.log.warning 'Failed to determine the current Git version, proceeding by assuming version 2.0.0'
28
+ '2.0.0'
29
+ end
30
+ end
31
+ end
32
+
14
33
  def build(options = {})
15
34
  if Dir["#{local}/*"].empty? || options[:force]
16
35
  FileUtils.rm_rf(local.to_s)
@@ -129,7 +148,8 @@ module Origen
129
148
  # Returns true if the current user can checkin to the given repo (means has permission
130
149
  # to push in Git terms)
131
150
  def can_checkin?
132
- git('push --dry-run', verbose: false)
151
+ # dry run attempting to create a new remote branch named OrigenWritePermissionsTest
152
+ git('push --dry-run origin origin:refs/heads/OrigenWritePermissionsTest', verbose: false)
133
153
  true
134
154
  rescue
135
155
  false
@@ -262,7 +282,7 @@ module Origen
262
282
  end
263
283
  File.exist?("#{local}/.git") &&
264
284
  git('remote -v', verbose: false).any? { |r| r =~ /#{remote_without_protocol_and_user}/ || r =~ /#{remote_without_protocol_and_user.to_s.gsub(':', "\/")}/ } &&
265
- !git('status', verbose: false).any? { |l| l =~ /^#? ?Initial commit$/ }
285
+ !git('status', verbose: false).any? { |l| l =~ /^#? ?(Initial commit|No commits yet)$/ }
266
286
  end
267
287
 
268
288
  # Delete everything in the given directory, or the whole repo
@@ -330,7 +350,7 @@ module Origen
330
350
  Origen.log.debug "Initializing Git workspace at #{local}"
331
351
  git 'init'
332
352
  git 'remote remove origin', verbose: false, check_errors: false
333
- git "remote add origin #{remote}"
353
+ git "remote add origin #{remote}", check_errors: false
334
354
  end
335
355
  end
336
356