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
@@ -68,6 +68,11 @@ module Origen
68
68
  end
69
69
  end
70
70
 
71
+ # Prevent infinite loop if a child bit collection checks bit_order
72
+ def bit_order
73
+ parent.bit_order
74
+ end
75
+
71
76
  def drive(value = nil, options = {})
72
77
  value, options = nil, value if value.is_a?(Hash)
73
78
  if options[:index]
@@ -140,6 +140,11 @@ module Origen
140
140
  @name = name
141
141
  @attributes = attributes
142
142
  @feature = attributes[:_feature] if attributes.key?(:_feature)
143
+
144
+ # Give reg.new a way to tell if coming from Placeholder
145
+ if attributes[:bit_info].is_a? Hash
146
+ attributes[:bit_info][:from_placeholder] = true
147
+ end
143
148
  end
144
149
 
145
150
  # Make this appear like a reg to any application code
@@ -5,35 +5,41 @@ module Origen
5
5
  # The :access property of registers or bits can be set to any of the following
6
6
  # key values. Implemented refers to whether the behaviour is accurately modelled
7
7
  # by the Origen register model or not.
8
+ #
9
+ # :base is used in CrossOrigen to set the IP-XACT access type on export.
10
+ #
11
+ # :read and :write are used in CrossOrigen for IP-XACT export to cover 'readAction'
12
+ # and 'modifiedWriteValue' attributes in the IEEE 1685-2009 schema - they do not affect
13
+ # Origen Core functionality (yet?).
8
14
  ACCESS_CODES = {
9
- ro: { implemented: false, description: 'Read-Only' },
10
- rw: { implemented: true, description: 'Read-Write' },
11
- rc: { implemented: false, description: 'Read-only, Clear-on-read' },
12
- rs: { implemented: false, description: "Set-on-read (all bits become '1' on read)" },
13
- wrc: { implemented: false, description: 'Writable, clear-on-read' },
14
- wrs: { implemented: false, description: 'Writable, Sets-on-read' },
15
- wc: { implemented: false, description: 'Clear-on-write' },
16
- ws: { implemented: false, description: 'Set-on-write' },
17
- wsrc: { implemented: false, description: 'Set-on-write, clear-on-read' },
18
- wcrs: { implemented: false, description: 'Clear-on-write, set-on-read' },
19
- w1c: { implemented: false, description: "Write '1' to clear bits" },
20
- w1s: { implemented: false, description: "Write '1' to set bits" },
21
- w1t: { implemented: false, description: "Write '1' to toggle bits" },
22
- w0c: { implemented: false, description: "Write '0' to clear bits" },
23
- w0s: { implemented: false, description: "Write '0' to set bits" },
24
- w0t: { implemented: false, description: "Write '0' to toggle bits" },
25
- w1src: { implemented: false, description: "Write '1' to set and clear-on-read" },
26
- w1crs: { implemented: false, description: "Write '1' to clear and set-on-read" },
27
- w0src: { implemented: false, description: "Write '0' to set and clear-on-read" },
28
- w0crs: { implemented: false, description: "Write '0' to clear and set-on-read" },
29
- wo: { implemented: false, description: 'Write-only' },
30
- woc: { implemented: false, description: "When written sets the field to '0'. Read undeterministic" },
31
- worz: { implemented: false, description: 'Write-only, Reads zero' },
32
- wos: { implemented: false, description: "When written sets all bits to '1'. Read undeterministic" },
33
- w1: { implemented: false, description: 'Write-once. Next time onwards, write is ignored. Read returns the value' },
34
- wo1: { implemented: false, description: 'Write-once. Next time onwards, write is ignored. Read is undeterministic' },
35
- dc: { implemented: false, description: 'RW but no check' },
36
- rowz: { implemented: false, description: 'Read-only, value is cleared on read' }
15
+ ro: { implemented: false, base: 'read-only', write: nil, read: nil, writable: false, readable: true, w1c: false, set_only: false, clr_only: false, description: 'Read-Only' },
16
+ rw: { implemented: true, base: 'read-write', write: nil, read: nil, writable: true, readable: true, w1c: false, set_only: false, clr_only: false, description: 'Read-Write' },
17
+ rc: { implemented: false, base: 'read-only', write: nil, read: 'clear', writable: false, readable: true, w1c: false, set_only: false, clr_only: false, description: 'Read-only, Clear-on-read' },
18
+ rs: { implemented: false, base: 'read-only', write: nil, read: 'set', writable: false, readable: true, w1c: false, set_only: false, clr_only: false, description: "Set-on-read (all bits become '1' on read)" },
19
+ wrc: { implemented: false, base: 'read-write', write: nil, read: 'clear', writable: true, readable: true, w1c: false, set_only: false, clr_only: false, description: 'Writable, clear-on-read' },
20
+ wrs: { implemented: false, base: 'read-write', write: nil, read: 'set', writable: true, readable: true, w1c: false, set_only: false, clr_only: false, description: 'Writable, Sets-on-read' },
21
+ wc: { implemented: false, base: 'read-write', write: 'clear', read: nil, writable: true, readable: true, w1c: false, set_only: false, clr_only: true, description: 'Clear-on-write' },
22
+ ws: { implemented: false, base: 'read-write', write: 'set', read: nil, writable: true, readable: true, w1c: false, set_only: true, clr_only: false, description: 'Set-on-write' },
23
+ wsrc: { implemented: false, base: 'read-write', write: 'set', read: 'clear', writable: true, readable: true, w1c: false, set_only: false, clr_only: false, description: 'Set-on-write, clear-on-read' },
24
+ wcrs: { implemented: false, base: 'read-write', write: 'clear', read: 'set', writable: true, readable: true, w1c: false, set_only: false, clr_only: false, description: 'Clear-on-write, set-on-read' },
25
+ w1c: { implemented: false, base: 'read-write', write: 'oneToClear', read: nil, writable: true, readable: true, w1c: true, set_only: false, clr_only: false, description: "Write '1' to clear bits" },
26
+ w1s: { implemented: false, base: 'read-write', write: 'oneToSet', read: nil, writable: true, readable: true, w1c: false, set_only: false, clr_only: false, description: "Write '1' to set bits" },
27
+ w1t: { implemented: false, base: 'read-write', write: 'oneToToggle', read: nil, writable: true, readable: true, w1c: false, set_only: false, clr_only: false, description: "Write '1' to toggle bits" },
28
+ w0c: { implemented: false, base: 'read-write', write: 'zeroToClear', read: nil, writable: true, readable: true, w1c: false, set_only: false, clr_only: false, description: "Write '0' to clear bits" },
29
+ w0s: { implemented: false, base: 'read-write', write: 'zeroToSet', read: nil, writable: true, readable: true, w1c: false, set_only: false, clr_only: false, description: "Write '0' to set bits" },
30
+ w0t: { implemented: false, base: 'read-write', write: 'zeroToToggle', read: nil, writable: true, readable: true, w1c: false, set_only: false, clr_only: false, description: "Write '0' to toggle bits" },
31
+ w1src: { implemented: false, base: 'read-write', write: 'oneToSet', read: 'clear', writable: true, readable: true, w1c: false, set_only: false, clr_only: false, description: "Write '1' to set and clear-on-read" },
32
+ w1crs: { implemented: false, base: 'read-write', write: 'oneToClear', read: 'set', writable: true, readable: true, w1c: true, set_only: false, clr_only: false, description: "Write '1' to clear and set-on-read" },
33
+ w0src: { implemented: false, base: 'read-write', write: 'zeroToSet', read: 'clear', writable: true, readable: true, w1c: false, set_only: false, clr_only: false, description: "Write '0' to set and clear-on-read" },
34
+ w0crs: { implemented: false, base: 'read-write', write: 'zeroToClear', read: 'set', writable: true, readable: true, w1c: false, set_only: false, clr_only: false, description: "Write '0' to clear and set-on-read" },
35
+ wo: { implemented: false, base: 'write-only', write: nil, read: nil, writable: true, readable: false, w1c: false, set_only: false, clr_only: false, description: 'Write-only' },
36
+ woc: { implemented: false, base: 'write-only', write: 'clear', read: nil, writable: true, readable: false, w1c: false, set_only: false, clr_only: true, description: "When written sets the field to '0'. Read undeterministic" },
37
+ worz: { implemented: false, base: 'write-only', write: nil, read: nil, writable: true, readable: false, w1c: false, set_only: false, clr_only: false, description: 'Write-only, Reads zero' },
38
+ wos: { implemented: false, base: 'write-only', write: 'set', read: nil, writable: true, readable: false, w1c: false, set_only: true, clr_only: false, description: "When written sets all bits to '1'. Read undeterministic" },
39
+ w1: { implemented: false, base: 'read-writeOnce', write: nil, read: nil, writable: true, readable: true, w1c: false, set_only: false, clr_only: false, description: 'Write-once. Next time onwards, write is ignored. Read returns the value' },
40
+ wo1: { implemented: false, base: 'writeOnce', write: nil, read: nil, writable: true, readable: false, w1c: false, set_only: false, clr_only: false, description: 'Write-once. Next time onwards, write is ignored. Read is undeterministic' },
41
+ dc: { implemented: false, base: 'read-write', write: nil, read: nil, writable: true, readable: true, w1c: false, set_only: false, clr_only: false, description: 'RW but no check' },
42
+ rowz: { implemented: false, base: 'read-only', write: nil, read: 'clear', writable: false, readable: true, w1c: false, set_only: false, clr_only: false, description: 'Read-only, value is cleared on read' }
37
43
  }
38
44
 
39
45
  # Returns the Reg object that owns the bit
@@ -72,6 +78,10 @@ module Origen
72
78
  attr_writer :clr_only
73
79
  # Allow modify of set_only flag, bit can only be set (made 1)
74
80
  attr_writer :set_only
81
+ # Returns read_action - whether anything happens to the bit when read
82
+ attr_reader :read_action
83
+ # Returns mod_write_value - what write value modification occurs when written
84
+ attr_reader :mod_write_value
75
85
  # Returns true if bit depends on initial state of NVM in some way
76
86
  attr_reader :nvm_dep
77
87
  # Returns true if bit is critical to starting an important operation (like a state machine)
@@ -84,6 +94,11 @@ module Origen
84
94
  # Returns the access method for the given bit (a symbol), see the ACCESS_CODES constant for
85
95
  # the possible values this can have and their meaning
86
96
  attr_accessor :access
97
+ # Returns the basic access string for a given access method. Possible values: read-write, read-only,
98
+ # write-only, writeOnce, read-writeOnce. Used primarily by CrossOrigen IP-XACT import/export.
99
+ attr_reader :base_access
100
+ # Can be set to indicate that the current state of the bit is unknown, e.g. after reading X from a simulation
101
+ attr_accessor :unknown
87
102
 
88
103
  def initialize(owner, position, options = {}) # rubocop:disable MethodLength
89
104
  options = {
@@ -161,6 +176,10 @@ module Origen
161
176
  @meta = (default_bit_metadata).merge(options)
162
177
  end
163
178
 
179
+ def access_codes
180
+ ACCESS_CODES
181
+ end
182
+
164
183
  def set_access(value)
165
184
  unless ACCESS_CODES.keys.include?(value)
166
185
  puts 'Invalid access code, must be one of these:'
@@ -172,30 +191,15 @@ module Origen
172
191
  end
173
192
  @access = value
174
193
 
175
- # Set readable & writable based on access
176
- if @access == :ro
177
- @readable = true
178
- @writable = false
179
- elsif @access == :wo || @access == :worz
180
- @writable = true
181
- @readable = false
182
- elsif @access == :w1c
183
- @w1c = true
184
- @writable = true
185
- @readable = true # Is this always valid?
186
- elsif @access == :wc
187
- @clr_only = true
188
- @writable = true
189
- @readable = true # Is this always valid?
190
- elsif @access == :ws
191
- @set_only = true
192
- @writable = true
193
- @readable = true # Is this always valid?
194
- # Catch all for now until the behavior of this class is based around @access
195
- else
196
- @writable = true
197
- @readable = true
198
- end
194
+ # Set access attributes by pulling key-value pairs from ACCESS_CODES[<access>]
195
+ @readable = ACCESS_CODES[@access][:readable]
196
+ @writable = ACCESS_CODES[@access][:writable]
197
+ @w1c = ACCESS_CODES[@access][:w1c]
198
+ @set_only = ACCESS_CODES[@access][:set_only]
199
+ @clr_only = ACCESS_CODES[@access][:clr_only]
200
+ @base_access = ACCESS_CODES[@access][:base]
201
+ @read_action = ACCESS_CODES[@access][:read]
202
+ @mod_write_value = ACCESS_CODES[@access][:write]
199
203
  end
200
204
 
201
205
  # Set @access based on @readable and @writable
@@ -288,7 +292,7 @@ module Origen
288
292
  # unknown in cases where the reset value is undefined or determined by a memory location
289
293
  # and where the bit has not been written or read to a specific value yet.
290
294
  def has_known_value?
291
- !@reset_val.is_a?(Symbol) || @updated_post_reset
295
+ !@unknown && (!@reset_val.is_a?(Symbol) || @updated_post_reset)
292
296
  end
293
297
 
294
298
  # Set the data value of the bit to the given value (1 or 0)
@@ -15,16 +15,18 @@ module Origen
15
15
  DONT_CARE_CHAR = 'X'
16
16
  OVERLAY_CHAR = 'V'
17
17
  STORE_CHAR = 'S'
18
+ UNKNOWN_CHAR = '?'
18
19
 
19
20
  attr_accessor :name
20
21
  alias_method :id, :name
21
22
 
22
- def initialize(reg, name, data = []) # :nodoc:
23
+ def initialize(reg, name, data = [], options = {}) # :nodoc:
23
24
  if reg.respond_to?(:has_bits_enabled_by_feature?) && reg.has_parameter_bound_bits?
24
25
  reg.update_bound_bits unless reg.updating_bound_bits?
25
26
  end
26
27
  @reg = reg
27
28
  @name = name
29
+ @with_bit_order = options[:with_bit_order] || :lsb0
28
30
  [data].flatten.each { |item| self << item }
29
31
  end
30
32
 
@@ -33,6 +35,31 @@ module Origen
33
35
  parent.bit_order
34
36
  end
35
37
 
38
+ # Returns the bit numbering order to use when interpreting indeces
39
+ def with_bit_order
40
+ @with_bit_order
41
+ end
42
+
43
+ # Allow bit number interpreting to be explicitly set to msb0
44
+ def with_msb0
45
+ @with_bit_order = :msb0
46
+ self
47
+ end
48
+
49
+ # Allow bit number interpreting to be explicitly set to lsb0
50
+ def with_lsb0
51
+ if block_given?
52
+ # run just the code block with lsb0 numbering (for internal methods)
53
+ saved_wbo = @with_bit_order
54
+ @with_bit_order = :lsb0
55
+ yield
56
+ @with_bit_order = saved_wbo
57
+ else
58
+ @with_bit_order = :lsb0
59
+ self
60
+ end
61
+ end
62
+
36
63
  def terminal?
37
64
  true
38
65
  end
@@ -41,6 +68,24 @@ module Origen
41
68
  parent.bind(name, live_parameter)
42
69
  end
43
70
 
71
+ # Access bits by index
72
+ #
73
+ # **Note** This method behaves differently depending on the setting of @with_bit_order
74
+ #
75
+ # If @with_bit_order == :lsb0 (default) index 0 refers to the lsb of the bit collection
76
+ # If @with_bit_order == :msb0 index 0 refers to the msb of the bit collection
77
+ #
78
+ # ==== Example
79
+ # dut.reg(:some_reg).bits(:some_field).with_msb0[0..1] # returns 2 most significant bits
80
+ # dut.reg(:some_reg).bits(:some_field)[0..1] # returns 2 least significant bits
81
+ #
82
+ # **Note** Internal methods should call this method using a with_lsb0 block around the code
83
+ # or alternatively use the shift_out methods
84
+ # ==== Example
85
+ # with_lsb0 do
86
+ # saved_bit = [index]
87
+ # [index] = some_new_bit_or_operation
88
+ # end
44
89
  def [](*indexes)
45
90
  return self if indexes.empty?
46
91
  b = BitCollection.new(parent, name)
@@ -52,7 +97,8 @@ module Origen
52
97
  if b.size == 1
53
98
  b.first
54
99
  else
55
- b
100
+ # maintain downstream bit numbering setting
101
+ @with_bit_order == :msb0 ? b.with_msb0 : b
56
102
  end
57
103
  end
58
104
  alias_method :bits, :[]
@@ -174,16 +220,18 @@ module Origen
174
220
  puts
175
221
  fail 'Mismatched size for bit collection copy'
176
222
  end
177
- size.times do |i|
178
- source_bit = reg.bit[i]
179
- if source_bit
180
- self[i].overlay(source_bit.overlay_str) if source_bit.has_overlay?
181
- self[i].write(source_bit.data)
182
-
183
- self[i].read if source_bit.is_to_be_read?
184
- self[i].store if source_bit.is_to_be_stored?
223
+ # safely handle collections with differing with_bit_order settings
224
+ with_lsb0 do
225
+ reg.shift_out_with_index do |source_bit, i|
226
+ if source_bit
227
+ self[i].overlay(source_bit.overlay_str) if source_bit.has_overlay?
228
+ self[i].write(source_bit.data)
229
+
230
+ self[i].read if source_bit.is_to_be_read?
231
+ self[i].store if source_bit.is_to_be_stored?
232
+ end
185
233
  end
186
- end
234
+ end # of with_lsb0
187
235
  else
188
236
  write(reg)
189
237
  clear_flags
@@ -331,8 +379,10 @@ module Origen
331
379
  end
332
380
  value = value.data if value.respond_to?('data')
333
381
 
334
- size.times do |i|
335
- self[i].write(value[i], options)
382
+ with_lsb0 do
383
+ size.times do |i|
384
+ self[i].write(value[i], options)
385
+ end
336
386
  end
337
387
  self
338
388
  end
@@ -340,6 +390,11 @@ module Origen
340
390
  alias_method :value=, :write
341
391
  alias_method :val=, :write
342
392
 
393
+ # Sets the unknown attribute on all contained bits
394
+ def unknown=(val)
395
+ each { |bit| bit.unknown = val }
396
+ end
397
+
343
398
  # Will tag all bits for read and if a data value is supplied it
344
399
  # will update the expected data for when the read is performed.
345
400
  def read(value = nil, options = {}) # :nodoc:
@@ -402,38 +457,26 @@ module Origen
402
457
  # bist_shift(bit)
403
458
  # end
404
459
  def shift_out_left
405
- if bit_order == :msb0
406
- each { |bit| yield bit }
407
- else
408
- reverse_each { |bit| yield bit }
409
- end
460
+ # This is functionally equivalent to reverse_shift_out
461
+ reverse_each { |bit| yield bit }
410
462
  end
411
463
 
412
464
  # Same as Reg#shift_out_left but includes the index counter
413
465
  def shift_out_left_with_index
414
- if bit_order == :msb0
415
- each.with_index { |bit, i| yield bit, i }
416
- else
417
- reverse_each.with_index { |bit, i| yield bit, i }
418
- end
466
+ # This is functionally equivalent to reverse_shift_out_with_index
467
+ reverse_each.with_index { |bit, i| yield bit, i }
419
468
  end
420
469
 
421
- # Same as Reg#shift_out_left but starts from the MSB
470
+ # Same as Reg#shift_out_left but starts from the LSB
422
471
  def shift_out_right
423
- if bit_order == :msb0
424
- reverse_each { |bit| yield bit }
425
- else
426
- each { |bit| yield bit }
427
- end
472
+ # This is functionally equivalent to shift_out, actually sends LSB first
473
+ each { |bit| yield bit }
428
474
  end
429
475
 
430
476
  # Same as Reg#shift_out_right but includes the index counter
431
477
  def shift_out_right_with_index
432
- if bit_order == :msb0
433
- reverse_each.with_index { |bit, i| yield bit, i }
434
- else
435
- each_with_index { |bit, i| yield bit, i }
436
- end
478
+ # This is functionally equivalent to shift_out_with_index
479
+ each_with_index { |bit, i| yield bit, i }
437
480
  end
438
481
 
439
482
  # Yields each bit in the register, LSB first.
@@ -865,7 +908,11 @@ module Origen
865
908
  if bit.has_overlay? && options[:mark_overlays]
866
909
  str += OVERLAY_CHAR
867
910
  else
868
- str += bit.data.to_s
911
+ if bit.has_known_value?
912
+ str += bit.data.to_s
913
+ else
914
+ str += UNKNOWN_CHAR
915
+ end
869
916
  end
870
917
  else
871
918
  str += DONT_CARE_CHAR
@@ -876,13 +923,17 @@ module Origen
876
923
  if bit.has_overlay? && options[:mark_overlays]
877
924
  str += OVERLAY_CHAR
878
925
  else
879
- str += bit.data.to_s
926
+ if bit.has_known_value?
927
+ str += bit.data.to_s
928
+ else
929
+ str += UNKNOWN_CHAR
930
+ end
880
931
  end
881
932
  end
882
933
  else
883
934
  fail "Unknown operation (#{operation}), must be :read or :write"
884
935
  end
885
- make_hex_like(str, size / 4)
936
+ make_hex_like(str, (size / 4.0).ceil)
886
937
  end
887
938
 
888
939
  # Shifts the data in the collection left by one place. The data held
@@ -935,11 +986,11 @@ module Origen
935
986
 
936
987
  # Converts a binary-like representation of a data value into a hex-like version.
937
988
  # e.g. input => 010S0011SSSS0110 (where S, X or V represent store, don't care or overlay)
938
- # output => (010s)3S6 (i.e. nibbles that are not all of the same type are expanded)
989
+ # output => [010s]3S6 (i.e. nibbles that are not all of the same type are expanded)
939
990
  def make_hex_like(regval, size_in_nibbles)
940
991
  outstr = ''
941
- regex = '^'
942
- size_in_nibbles.times { regex += '(....)' }
992
+ regex = '^(.?.?.?.)'
993
+ (size_in_nibbles - 1).times { regex += '(....)' }
943
994
  regex += '$'
944
995
  Regexp.new(regex) =~ regval
945
996
 
@@ -950,13 +1001,13 @@ module Origen
950
1001
 
951
1002
  nibbles.each_with_index do |nibble, i|
952
1003
  # If contains any special chars...
953
- if nibble =~ /[#{DONT_CARE_CHAR}#{STORE_CHAR}#{OVERLAY_CHAR}]/
1004
+ if nibble =~ /[#{UNKNOWN_CHAR}#{DONT_CARE_CHAR}#{STORE_CHAR}#{OVERLAY_CHAR}]/
954
1005
  # If all the same...
955
1006
  if nibble[0] == nibble[1] && nibble[1] == nibble[2] && nibble[2] == nibble[3]
956
1007
  outstr += nibble[0, 1] # .to_s
957
1008
  # Otherwise present this nibble in 'binary' format
958
1009
  else
959
- outstr += "(#{nibble.downcase})"
1010
+ outstr += "[#{nibble.downcase}]"
960
1011
  end
961
1012
  # Otherwise if all 1s and 0s...
962
1013
  else
@@ -985,7 +1036,13 @@ module Origen
985
1036
  ixs << index
986
1037
  end
987
1038
  end
988
- ixs.flatten.sort
1039
+ ixs.flatten!
1040
+ # ixs.sort!
1041
+ # convert msb0 numbering (if provided) to lsb0 numbering to get the correct bits
1042
+ if @with_bit_order == :msb0
1043
+ ixs.each_index { |i| ixs[i] = size - ixs[i] - 1 }
1044
+ end
1045
+ ixs.sort
989
1046
  end
990
1047
  end
991
1048
  end
@@ -0,0 +1,47 @@
1
+ module Origen
2
+ module Registers
3
+ require 'delegate'
4
+
5
+ # Thin wrapper around register objects to modify bit number interpretation
6
+ #
7
+ # This is provided as a convenience to make user code more readable
8
+ class Msb0Delegator < ::Delegator
9
+ def initialize(reg_object, bits)
10
+ @reg_object = reg_object
11
+ @bits = bits
12
+ end
13
+
14
+ def __getobj__
15
+ @reg_object
16
+ end
17
+
18
+ def __object__
19
+ @reg_object
20
+ end
21
+
22
+ def __setobj__(obj)
23
+ @reg_object = obj
24
+ end
25
+
26
+ def inspect(options = {})
27
+ options[:with_bit_order] = :msb0
28
+ @reg_object.inspect(options)
29
+ end
30
+
31
+ def method_missing(method, *args, &block)
32
+ if args.last.is_a?(Hash)
33
+ args.last[:with_bit_order] = :msb0
34
+ else
35
+ args << { with_bit_order: :msb0 }
36
+ end
37
+ @reg_object.method_missing(method, *args, &block)
38
+ end
39
+
40
+ def bit(*args)
41
+ @reg_object.bit(args, with_bit_order: :msb0)
42
+ end
43
+ alias_method :bits, :bit
44
+ alias_method :[], :bit
45
+ end
46
+ end
47
+ end