origen 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (336) hide show
  1. checksums.yaml +4 -4
  2. data/bin/ctags +0 -0
  3. data/bin/origen +165 -1
  4. data/bin/rgen +2 -0
  5. data/config/application.rb +141 -0
  6. data/config/commands.rb +72 -0
  7. data/config/development.rb +7 -0
  8. data/config/environment.rb +0 -0
  9. data/config/rgen.policy +7 -0
  10. data/config/rubocop/easy.yml +620 -0
  11. data/config/rubocop/easy_disabled.yml +271 -0
  12. data/config/rubocop/easy_enabled.yml +731 -0
  13. data/config/rubocop/strict.yml +620 -0
  14. data/config/rubocop/strict_disabled.yml +247 -0
  15. data/config/rubocop/strict_enabled.yml +755 -0
  16. data/config/users.rb +20 -0
  17. data/config/version.rb +1 -1
  18. data/helpers/url.rb +68 -0
  19. data/lib/c99/doc_interface.rb +56 -0
  20. data/lib/c99/j750_interface.rb +85 -0
  21. data/lib/c99/nvm.rb +89 -0
  22. data/lib/c99/target/mock2.rb +1 -0
  23. data/lib/c99/target/subdir/mock3.rb +1 -0
  24. data/lib/option_parser/optparse.rb +12 -0
  25. data/lib/origen/acronyms.rb +60 -0
  26. data/lib/origen/application/command_dispatcher.rb +12 -0
  27. data/lib/origen/application/configuration.rb +206 -0
  28. data/lib/origen/application/configuration_manager.rb +78 -0
  29. data/lib/origen/application/deployer.rb +367 -0
  30. data/lib/origen/application/environment.rb +186 -0
  31. data/lib/origen/application/lsf.rb +145 -0
  32. data/lib/origen/application/lsf_manager.rb +657 -0
  33. data/lib/origen/application/plugins_manager.rb +280 -0
  34. data/lib/origen/application/release.rb +359 -0
  35. data/lib/origen/application/runner.rb +246 -0
  36. data/lib/origen/application/statistics.rb +191 -0
  37. data/lib/origen/application/target.rb +374 -0
  38. data/lib/origen/application/version_tracker.rb +59 -0
  39. data/lib/origen/application/workspace_manager.rb +151 -0
  40. data/lib/origen/application.rb +746 -0
  41. data/lib/origen/bugs/bug.rb +36 -0
  42. data/lib/origen/bugs.rb +45 -0
  43. data/lib/origen/callbacks.rb +35 -0
  44. data/lib/origen/chip_mode.rb +118 -0
  45. data/lib/origen/chip_package.rb +461 -0
  46. data/lib/origen/client.rb +87 -0
  47. data/lib/origen/code_generators/actions.rb +258 -0
  48. data/lib/origen/code_generators/base.rb +57 -0
  49. data/lib/origen/code_generators/bundler.rb +17 -0
  50. data/lib/origen/code_generators/gem_setup.rb +49 -0
  51. data/lib/origen/code_generators/rake.rb +13 -0
  52. data/lib/origen/code_generators/rspec.rb +12 -0
  53. data/lib/origen/code_generators/semver.rb +39 -0
  54. data/lib/origen/code_generators/timever.rb +37 -0
  55. data/lib/origen/code_generators.rb +111 -0
  56. data/lib/origen/commands/add.rb +12 -0
  57. data/lib/origen/commands/compile.rb +62 -0
  58. data/lib/origen/commands/ctags.rb +9 -0
  59. data/lib/origen/commands/dispatch.rb +22 -0
  60. data/lib/origen/commands/environment.rb +11 -0
  61. data/lib/origen/commands/fetch.rb +63 -0
  62. data/lib/origen/commands/generate.rb +130 -0
  63. data/lib/origen/commands/interactive.rb +73 -0
  64. data/lib/origen/commands/lint.rb +82 -0
  65. data/lib/origen/commands/lsf.rb +93 -0
  66. data/lib/origen/commands/merge.rb +55 -0
  67. data/lib/origen/commands/modifications.rb +12 -0
  68. data/lib/origen/commands/new.rb +113 -0
  69. data/lib/origen/commands/plugin.rb +105 -0
  70. data/lib/origen/commands/program.rb +70 -0
  71. data/lib/origen/commands/rc.rb +442 -0
  72. data/lib/origen/commands/save.rb +56 -0
  73. data/lib/origen/commands/target.rb +27 -0
  74. data/lib/origen/commands/time.rb +127 -0
  75. data/lib/origen/commands/version.rb +17 -0
  76. data/lib/origen/commands/web.rb +221 -0
  77. data/lib/origen/commands.rb +272 -0
  78. data/lib/origen/commands_global.rb +76 -0
  79. data/lib/origen/controller.rb +94 -0
  80. data/lib/origen/core_ext/array.rb +23 -0
  81. data/lib/origen/core_ext/bignum.rb +36 -0
  82. data/lib/origen/core_ext/enumerable.rb +76 -0
  83. data/lib/origen/core_ext/fixnum.rb +46 -0
  84. data/lib/origen/core_ext/hash.rb +52 -0
  85. data/lib/origen/core_ext/module.rb +14 -0
  86. data/lib/origen/core_ext/numeric.rb +126 -0
  87. data/lib/origen/core_ext/object.rb +13 -0
  88. data/lib/origen/core_ext/range.rb +7 -0
  89. data/lib/origen/core_ext/string.rb +124 -0
  90. data/lib/origen/core_ext.rb +10 -0
  91. data/lib/origen/database/key_value_store.rb +111 -0
  92. data/lib/origen/database/key_value_stores.rb +108 -0
  93. data/lib/origen/database.rb +6 -0
  94. data/lib/origen/encodings.rb +102 -0
  95. data/lib/origen/features/feature.rb +22 -0
  96. data/lib/origen/features.rb +104 -0
  97. data/lib/origen/file_handler.rb +429 -0
  98. data/lib/origen/generator/comparator.rb +56 -0
  99. data/lib/origen/generator/compiler.rb +277 -0
  100. data/lib/origen/generator/flow.rb +49 -0
  101. data/lib/origen/generator/job.rb +131 -0
  102. data/lib/origen/generator/pattern.rb +356 -0
  103. data/lib/origen/generator/pattern_finder.rb +155 -0
  104. data/lib/origen/generator/pattern_iterator.rb +55 -0
  105. data/lib/origen/generator/renderer.rb +113 -0
  106. data/lib/origen/generator/resources.rb +40 -0
  107. data/lib/origen/generator/stage.rb +89 -0
  108. data/lib/origen/generator.rb +85 -0
  109. data/lib/origen/global_methods.rb +205 -0
  110. data/lib/origen/import_manager.rb +596 -0
  111. data/lib/origen/location/base.rb +116 -0
  112. data/lib/origen/location/map.rb +83 -0
  113. data/lib/origen/location.rb +6 -0
  114. data/lib/origen/log.rb +217 -0
  115. data/lib/origen/logger_methods.rb +56 -0
  116. data/lib/origen/mode.rb +61 -0
  117. data/lib/origen/model.rb +267 -0
  118. data/lib/origen/model_initializer.rb +45 -0
  119. data/lib/origen/nvm/block_array.rb +72 -0
  120. data/lib/origen/nvm.rb +6 -0
  121. data/lib/origen/parameters/live.rb +22 -0
  122. data/lib/origen/parameters/missing.rb +28 -0
  123. data/lib/origen/parameters/set.rb +144 -0
  124. data/lib/origen/parameters.rb +107 -0
  125. data/lib/origen/pdm.rb +218 -0
  126. data/lib/origen/pins/function_proxy.rb +36 -0
  127. data/lib/origen/pins/ground_pin.rb +6 -0
  128. data/lib/origen/pins/pin.rb +860 -0
  129. data/lib/origen/pins/pin_bank.rb +349 -0
  130. data/lib/origen/pins/pin_clock.rb +124 -0
  131. data/lib/origen/pins/pin_collection.rb +492 -0
  132. data/lib/origen/pins/pin_common.rb +206 -0
  133. data/lib/origen/pins/port.rb +268 -0
  134. data/lib/origen/pins/power_pin.rb +30 -0
  135. data/lib/origen/pins.rb +696 -0
  136. data/lib/origen/registers/bit.rb +562 -0
  137. data/lib/origen/registers/bit_collection.rb +787 -0
  138. data/lib/origen/registers/container.rb +288 -0
  139. data/lib/origen/registers/domain.rb +16 -0
  140. data/lib/origen/registers/reg.rb +1406 -0
  141. data/lib/origen/registers/reg_collection.rb +24 -0
  142. data/lib/origen/registers.rb +652 -0
  143. data/lib/origen/regression_manager.rb +251 -0
  144. data/lib/origen/remote_manager.rb +340 -0
  145. data/lib/origen/revision_control/base.rb +257 -0
  146. data/lib/origen/revision_control/design_sync.rb +276 -0
  147. data/lib/origen/revision_control/git.rb +243 -0
  148. data/lib/origen/revision_control/subversion.rb +6 -0
  149. data/lib/origen/revision_control.rb +44 -0
  150. data/lib/origen/ruby_version_check.rb +131 -0
  151. data/lib/origen/site_config.rb +61 -0
  152. data/lib/origen/specs/checkers.rb +103 -0
  153. data/lib/origen/specs/creation_info.rb +17 -0
  154. data/lib/origen/specs/doc_resource.rb +91 -0
  155. data/lib/origen/specs/exhibit.rb +17 -0
  156. data/lib/origen/specs/mode_select.rb +16 -0
  157. data/lib/origen/specs/note.rb +17 -0
  158. data/lib/origen/specs/override.rb +21 -0
  159. data/lib/origen/specs/power_supply.rb +13 -0
  160. data/lib/origen/specs/spec.rb +226 -0
  161. data/lib/origen/specs/version_history.rb +14 -0
  162. data/lib/origen/specs.rb +552 -0
  163. data/lib/origen/sub_blocks.rb +298 -0
  164. data/lib/origen/tester/api.rb +277 -0
  165. data/lib/origen/tester/bdm/bdm.rb +25 -0
  166. data/lib/origen/tester/command_based_tester.rb +46 -0
  167. data/lib/origen/tester/doc/doc.rb +226 -0
  168. data/lib/origen/tester/doc/generator/flow.rb +71 -0
  169. data/lib/origen/tester/doc/generator/flow_line.rb +203 -0
  170. data/lib/origen/tester/doc/generator/test.rb +68 -0
  171. data/lib/origen/tester/doc/generator/test_group.rb +66 -0
  172. data/lib/origen/tester/doc/generator/tests.rb +47 -0
  173. data/lib/origen/tester/doc/generator.rb +126 -0
  174. data/lib/origen/tester/doc/model.rb +162 -0
  175. data/lib/origen/tester/generator/flow_control_api.rb +606 -0
  176. data/lib/origen/tester/generator/identity_map.rb +25 -0
  177. data/lib/origen/tester/generator/placeholder.rb +13 -0
  178. data/lib/origen/tester/generator/test_numberer.rb +25 -0
  179. data/lib/origen/tester/generator.rb +271 -0
  180. data/lib/origen/tester/interface.rb +154 -0
  181. data/lib/origen/tester/j750/files.rb +45 -0
  182. data/lib/origen/tester/j750/generator/flow.rb +123 -0
  183. data/lib/origen/tester/j750/generator/flow_line.rb +288 -0
  184. data/lib/origen/tester/j750/generator/patgroup.rb +111 -0
  185. data/lib/origen/tester/j750/generator/patgroups.rb +41 -0
  186. data/lib/origen/tester/j750/generator/patset.rb +111 -0
  187. data/lib/origen/tester/j750/generator/patsets.rb +41 -0
  188. data/lib/origen/tester/j750/generator/templates/flow.txt.erb +9 -0
  189. data/lib/origen/tester/j750/generator/templates/instances.txt.erb +16 -0
  190. data/lib/origen/tester/j750/generator/templates/patgroups.txt.erb +8 -0
  191. data/lib/origen/tester/j750/generator/templates/patsets.txt.erb +10 -0
  192. data/lib/origen/tester/j750/generator/test_instance.rb +846 -0
  193. data/lib/origen/tester/j750/generator/test_instance_group.rb +60 -0
  194. data/lib/origen/tester/j750/generator/test_instances.rb +182 -0
  195. data/lib/origen/tester/j750/generator.rb +203 -0
  196. data/lib/origen/tester/j750/j750.rb +845 -0
  197. data/lib/origen/tester/j750/j750_hpt.rb +35 -0
  198. data/lib/origen/tester/j750/parser/ac_spec.rb +11 -0
  199. data/lib/origen/tester/j750/parser/ac_specs.rb +0 -0
  200. data/lib/origen/tester/j750/parser/dc_spec.rb +36 -0
  201. data/lib/origen/tester/j750/parser/dc_specs.rb +50 -0
  202. data/lib/origen/tester/j750/parser/descriptions.rb +340 -0
  203. data/lib/origen/tester/j750/parser/flow.rb +111 -0
  204. data/lib/origen/tester/j750/parser/flow_line.rb +207 -0
  205. data/lib/origen/tester/j750/parser/flows.rb +23 -0
  206. data/lib/origen/tester/j750/parser/pattern_set.rb +94 -0
  207. data/lib/origen/tester/j750/parser/pattern_sets.rb +33 -0
  208. data/lib/origen/tester/j750/parser/test_instance.rb +322 -0
  209. data/lib/origen/tester/j750/parser/test_instances.rb +26 -0
  210. data/lib/origen/tester/j750/parser/timeset.rb +15 -0
  211. data/lib/origen/tester/j750/parser/timesets.rb +0 -0
  212. data/lib/origen/tester/j750/parser.rb +104 -0
  213. data/lib/origen/tester/jlink/jlink.rb +33 -0
  214. data/lib/origen/tester/parser/description_lookup.rb +64 -0
  215. data/lib/origen/tester/parser/searchable_array.rb +32 -0
  216. data/lib/origen/tester/parser/searchable_hash.rb +32 -0
  217. data/lib/origen/tester/parser.rb +24 -0
  218. data/lib/origen/tester/time.rb +338 -0
  219. data/lib/origen/tester/timing.rb +253 -0
  220. data/lib/origen/tester/ultraflex/files.rb +45 -0
  221. data/lib/origen/tester/ultraflex/generator/flow.rb +119 -0
  222. data/lib/origen/tester/ultraflex/generator/flow_line.rb +269 -0
  223. data/lib/origen/tester/ultraflex/generator/patgroup.rb +111 -0
  224. data/lib/origen/tester/ultraflex/generator/patgroups.rb +41 -0
  225. data/lib/origen/tester/ultraflex/generator/patset.rb +111 -0
  226. data/lib/origen/tester/ultraflex/generator/patsets.rb +41 -0
  227. data/lib/origen/tester/ultraflex/generator/templates/flow.txt.erb +9 -0
  228. data/lib/origen/tester/ultraflex/generator/templates/instances.txt.erb +16 -0
  229. data/lib/origen/tester/ultraflex/generator/templates/patgroups.txt.erb +8 -0
  230. data/lib/origen/tester/ultraflex/generator/templates/patsets.txt.erb +10 -0
  231. data/lib/origen/tester/ultraflex/generator/test_instance.rb +622 -0
  232. data/lib/origen/tester/ultraflex/generator/test_instance_group.rb +60 -0
  233. data/lib/origen/tester/ultraflex/generator/test_instances.rb +174 -0
  234. data/lib/origen/tester/ultraflex/generator.rb +200 -0
  235. data/lib/origen/tester/ultraflex/parser/ac_spec.rb +11 -0
  236. data/lib/origen/tester/ultraflex/parser/ac_specs.rb +0 -0
  237. data/lib/origen/tester/ultraflex/parser/dc_spec.rb +36 -0
  238. data/lib/origen/tester/ultraflex/parser/dc_specs.rb +50 -0
  239. data/lib/origen/tester/ultraflex/parser/descriptions.rb +342 -0
  240. data/lib/origen/tester/ultraflex/parser/flow.rb +111 -0
  241. data/lib/origen/tester/ultraflex/parser/flow_line.rb +207 -0
  242. data/lib/origen/tester/ultraflex/parser/flows.rb +23 -0
  243. data/lib/origen/tester/ultraflex/parser/pattern_set.rb +94 -0
  244. data/lib/origen/tester/ultraflex/parser/pattern_sets.rb +33 -0
  245. data/lib/origen/tester/ultraflex/parser/test_instance.rb +262 -0
  246. data/lib/origen/tester/ultraflex/parser/test_instances.rb +26 -0
  247. data/lib/origen/tester/ultraflex/parser/timeset.rb +15 -0
  248. data/lib/origen/tester/ultraflex/parser/timesets.rb +0 -0
  249. data/lib/origen/tester/ultraflex/parser.rb +104 -0
  250. data/lib/origen/tester/ultraflex/ultraflex.rb +759 -0
  251. data/lib/origen/tester/v93k/generator/flow.rb +63 -0
  252. data/lib/origen/tester/v93k/generator/flow_node/print.rb +10 -0
  253. data/lib/origen/tester/v93k/generator/flow_node.rb +17 -0
  254. data/lib/origen/tester/v93k/generator/pattern.rb +16 -0
  255. data/lib/origen/tester/v93k/generator/pattern_master.rb +54 -0
  256. data/lib/origen/tester/v93k/generator/templates/_test_method.txt.erb +6 -0
  257. data/lib/origen/tester/v93k/generator/templates/_test_suite.txt.erb +11 -0
  258. data/lib/origen/tester/v93k/generator/templates/template.flow.erb +121 -0
  259. data/lib/origen/tester/v93k/generator/templates/template.pmfl.erb +9 -0
  260. data/lib/origen/tester/v93k/generator/test_function.rb +103 -0
  261. data/lib/origen/tester/v93k/generator/test_functions.rb +79 -0
  262. data/lib/origen/tester/v93k/generator/test_method.rb +46 -0
  263. data/lib/origen/tester/v93k/generator/test_methods.rb +75 -0
  264. data/lib/origen/tester/v93k/generator/test_suite.rb +54 -0
  265. data/lib/origen/tester/v93k/generator/test_suites.rb +65 -0
  266. data/lib/origen/tester/v93k/generator.rb +80 -0
  267. data/lib/origen/tester/v93k/v93k.rb +420 -0
  268. data/lib/origen/tester/vector.rb +86 -0
  269. data/lib/origen/tester/vector_generator.rb +633 -0
  270. data/lib/origen/tester/vector_pipeline.rb +150 -0
  271. data/lib/origen/tester.rb +56 -0
  272. data/lib/origen/top_level.rb +134 -0
  273. data/lib/origen/users/ldap.rb +65 -0
  274. data/lib/origen/users/user.rb +149 -0
  275. data/lib/origen/users.rb +30 -0
  276. data/lib/origen/utility/block_args.rb +93 -0
  277. data/lib/origen/utility/csv_data.rb +110 -0
  278. data/lib/origen/utility/design_sync.rb +494 -0
  279. data/lib/origen/utility/diff.rb +158 -0
  280. data/lib/origen/utility/input_capture.rb +121 -0
  281. data/lib/origen/utility/mailer.rb +143 -0
  282. data/lib/origen/utility/s_record.rb +205 -0
  283. data/lib/origen/utility/time_and_date.rb +30 -0
  284. data/lib/origen/utility.rb +12 -0
  285. data/lib/origen/version_checker.rb +117 -0
  286. data/lib/origen/version_string.rb +356 -0
  287. data/lib/origen.rb +648 -0
  288. data/lib/tasks/gem.rake +27 -22
  289. data/origen_site_config.yml +36 -0
  290. data/source_setup +17 -0
  291. data/spec/format/rgen_formatter.rb +14 -0
  292. data/templates/api_doc/README.txt.erb +24 -0
  293. data/templates/code_generators/gemfile_app.rb +4 -0
  294. data/templates/code_generators/gemfile_plugin.rb +6 -0
  295. data/templates/code_generators/gemspec.rb +33 -0
  296. data/templates/code_generators/rakefile.rb +10 -0
  297. data/templates/code_generators/spec_helper.rb +49 -0
  298. data/templates/code_generators/version.rb +8 -0
  299. data/templates/code_generators/version_time.rb +3 -0
  300. data/templates/git/gitignore.erb +33 -0
  301. data/templates/j750/_vt_flow.txt.erb +8 -0
  302. data/templates/j750/_vt_instances.txt.erb +4 -0
  303. data/templates/j750/program_sheet.txt.erb +9 -0
  304. data/templates/nanoc/Rules +74 -0
  305. data/templates/nanoc/config.yaml +77 -0
  306. data/templates/nanoc/content/favicon.ico +0 -0
  307. data/templates/nanoc/layouts/bootstrap.html.erb +63 -0
  308. data/templates/nanoc/layouts/bootstrap3.html.erb +71 -0
  309. data/templates/nanoc/layouts/freescale.html.erb +79 -0
  310. data/templates/nanoc/lib/bootstrap_filter.rb +49 -0
  311. data/templates/nanoc/lib/codeblocks_filter.rb +41 -0
  312. data/templates/nanoc/lib/default.rb +2 -0
  313. data/templates/nanoc/lib/gzip_filter.rb +16 -0
  314. data/templates/nanoc/lib/haml_code_filter.rb +41 -0
  315. data/templates/nanoc/lib/helpers.rb +1 -0
  316. data/templates/nanoc/lib/search_filter.rb +62 -0
  317. data/templates/nanoc_dynamic/content/search.js.erb +92 -0
  318. data/templates/shared/web/_logo.html +10 -0
  319. data/templates/test/_inline_sub.txt.erb +2 -0
  320. data/templates/test/environment.txt.erb +1 -0
  321. data/templates/test/inline.txt.erb +11 -0
  322. data/templates/test/inspections.txt.erb +19 -0
  323. data/templates/test/set1/_sub1.txt.erb +12 -0
  324. data/templates/test/set1/_sub4.txt.erb +1 -0
  325. data/templates/test/set1/_sub5.txt.erb +1 -0
  326. data/templates/test/set1/main.txt.erb +53 -0
  327. data/templates/test/set1/sub_dir/_sub2.txt.erb +20 -0
  328. data/templates/test/set1/sub_dir/_sub3.txt.erb +12 -0
  329. data/templates/test/set1/sub_dir/main2.txt.erb +4 -0
  330. data/templates/test/set2/template_with_no_erb_1.txt +9 -0
  331. data/templates/test/set2/template_with_no_erb_2.txt +9 -0
  332. data/templates/test/set3/_layout.html.erb +4 -0
  333. data/templates/test/set3/content.html.erb +6 -0
  334. data/templates/time/filter.rb.erb +15 -0
  335. data/templates/time/rules.rb.erb +45 -0
  336. metadata +639 -5
@@ -0,0 +1,24 @@
1
+ module Origen
2
+ module Registers
3
+ # This is a regular Ruby hash that is used to store collections of Reg objects, it has additional
4
+ # methods added to allow interaction with the contained registers.
5
+ # All Ruby hash methods are also available - http://www.ruby-doc.org/core/classes/Hash.html
6
+ class RegCollection < Hash
7
+ # Returns the object that owns the registers
8
+ attr_reader :owner
9
+
10
+ def initialize(owner, _options = {})
11
+ @owner = owner
12
+ end
13
+
14
+ def inspect
15
+ map { |k, _v| k }.inspect
16
+ end
17
+
18
+ # Display all regs visually in a console session
19
+ def show
20
+ puts map { |_k, v| v }.inspect
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,652 @@
1
+ module Origen
2
+ # Origen provides a powerful register class which you are encouraged to use when
3
+ # you wish to interact with a silicon register (or RAM location).
4
+ # By interacting with the register on silicon through the register API your
5
+ # pattern will automatically track silicon state, so you can set and forget
6
+ # bits in the patgen the same as you would do with a physical register.
7
+ # Include this module to add registers to your block, then use the macros described
8
+ # below to instantiate register objects
9
+ # include Origen::Registers
10
+ module Registers
11
+ extend ActiveSupport::Concern
12
+
13
+ autoload :Container, 'origen/registers/container'
14
+ autoload :Reg, 'origen/registers/reg'
15
+ autoload :Bit, 'origen/registers/bit'
16
+ autoload :BitCollection, 'origen/registers/bit_collection'
17
+ autoload :RegCollection, 'origen/registers/reg_collection'
18
+ autoload :Domain, 'origen/registers/domain'
19
+
20
+ included do
21
+ include Origen::ModelInitializer
22
+ include Origen::SubBlocks
23
+ include Origen::Callbacks # Required for global register reset
24
+
25
+ attr_accessor :owner
26
+ attr_accessor :name
27
+ end
28
+
29
+ def method_missing(method, *args, &block) # :nodoc:
30
+ if _registers.key?(method)
31
+ reg(method)
32
+ else
33
+ super
34
+ end
35
+ end
36
+
37
+ def respond_to?(sym) # :nodoc:
38
+ _registers.key?(sym) || super(sym)
39
+ end
40
+
41
+ def delete_registers
42
+ @_registers = nil
43
+ end
44
+
45
+ # Class methods of this module
46
+ class << self
47
+ @@reg_metadata = {}
48
+ @@bit_metadata = {}
49
+
50
+ # @api private
51
+ # Returns a lookup table containing all custom register metadata
52
+ # defined by objects in an application
53
+ def reg_metadata
54
+ @@reg_metadata ||= {}
55
+ end
56
+
57
+ # @api private
58
+ # Returns a lookup table containing all custom bit metadata
59
+ # defined by objects in an application
60
+ def bit_metadata
61
+ @@bit_metadata ||= {}
62
+ end
63
+
64
+ # Can be called to add app specific meta data to all registers
65
+ def default_reg_metadata
66
+ Origen::Registers.reg_metadata[:global] ||= {}
67
+ if block_given?
68
+ collector = Collector.new
69
+ yield collector
70
+ Origen::Registers.reg_metadata[:global].merge!(collector.store)
71
+ end
72
+ Origen::Registers.reg_metadata[:global]
73
+ end
74
+
75
+ # An alias for default_reg_metadata
76
+ def default_reg_meta_data(*args, &block)
77
+ default_reg_metadata(*args, &block)
78
+ end
79
+
80
+ # Can be called to add app specific meta data to all bits
81
+ def default_bit_metadata
82
+ Origen::Registers.bit_metadata[:global] ||= {}
83
+ if block_given?
84
+ collector = Collector.new
85
+ yield collector
86
+ Origen::Registers.bit_metadata[:global].merge!(collector.store)
87
+ end
88
+ Origen::Registers.bit_metadata[:global]
89
+ end
90
+
91
+ # An alias for default_bit_metadata
92
+ def default_bit_meta_data(*args, &block)
93
+ default_bit_metadata(*args, &block)
94
+ end
95
+ end
96
+
97
+ # All register objects are stored here, but they should be accessed
98
+ # via the _reg method to ensure that feature scoping is applied
99
+ #
100
+ # @api private
101
+ def _registers
102
+ @_registers ||= RegCollection.new(self)
103
+ end
104
+
105
+ # Instantiating registers can be quite expensive, this object is a placeholder
106
+ # for a register and will transform into one automatically when it is required to
107
+ # (i.e. whenever a register method is called on it).
108
+ class Placeholder
109
+ attr_reader :name, :owner, :attributes, :feature
110
+ alias_method :id, :name
111
+
112
+ def initialize(owner, name, attributes)
113
+ @owner = owner
114
+ @name = name
115
+ @attributes = attributes
116
+ @feature = attributes[:feature] if attributes.key?(:feature)
117
+ end
118
+
119
+ # Make this appear like a reg to any application code
120
+ def is_a?(klass)
121
+ klass == Origen::Registers::Reg ||
122
+ klass == self.class
123
+ end
124
+
125
+ # Returns true if the register is enabled by a feature of owner.
126
+ def enabled?
127
+ if feature
128
+ value = false
129
+ current_owner = self
130
+ if feature.class == Array
131
+ feature.each do |f|
132
+ current_owner = self
133
+ loop do
134
+ if current_owner.respond_to?(:owner)
135
+ current_owner = current_owner.owner
136
+ if current_owner.respond_to?(:has_feature?)
137
+ if current_owner.has_feature?(f)
138
+ value = true
139
+ break
140
+ end
141
+ end
142
+ else # if current owner does not have a owner
143
+ value = false
144
+ break
145
+ end
146
+ end # loop end
147
+ unless value
148
+ if Origen.top_level && \
149
+ Origen.top_level.respond_to?(:has_feature?) && \
150
+ Origen.top_level.has_feature?(f)
151
+ value = true
152
+ unless value
153
+ break
154
+ end
155
+ end
156
+ end
157
+ unless value
158
+ break # break if feature not found and return false
159
+ end
160
+ end # iterated through all features in array
161
+ return value
162
+ else # if feature.class != Array
163
+ loop do
164
+ if current_owner.respond_to?(:owner)
165
+ current_owner = current_owner.owner
166
+ if current_owner.respond_to?(:has_feature?)
167
+ if current_owner.has_feature?(feature)
168
+ value = true
169
+ break
170
+ end
171
+ end
172
+ else # if current owner does not have a owner
173
+ value = false
174
+ break
175
+ end
176
+ end # loop end
177
+ unless value
178
+ if Origen.top_level && \
179
+ Origen.top_level.respond_to?(:has_feature?) && \
180
+ Origen.top_level.has_feature?(feature)
181
+ value = true
182
+ end
183
+ end
184
+ return value
185
+ end
186
+ else
187
+ return true
188
+ end
189
+ end
190
+
191
+ # Returns true if the register is constrained by the given/any feature
192
+ def enabled_by_feature?(name = nil)
193
+ if !name
194
+ !!feature
195
+ else
196
+ if feature.class == Array
197
+ feature.each do |f|
198
+ if f == name
199
+ return true
200
+ end
201
+ end
202
+ return false
203
+ else
204
+ return feature == name
205
+ end
206
+ end
207
+ end
208
+ alias_method :has_feature_constraint?, :enabled_by_feature?
209
+
210
+ # Make it look like a reg in the console to avoid confusion
211
+ def inspect
212
+ materialize.inspect
213
+ end
214
+
215
+ # Don't need to act on reset, an un-materialized reg is by default already reset
216
+ def reset
217
+ end
218
+
219
+ def freeze
220
+ materialize.freeze
221
+ end
222
+
223
+ def method_missing(method, *args, &block)
224
+ materialize.send(method, *args, &block)
225
+ end
226
+
227
+ def respond_to?(method)
228
+ materialize.respond_to?(method)
229
+ end
230
+
231
+ def materialize
232
+ owner.instantiate_reg(name, attributes)
233
+ end
234
+
235
+ def clone
236
+ materialize.clone
237
+ end
238
+
239
+ def dup
240
+ materialize.dup
241
+ end
242
+
243
+ def contains_bits?
244
+ true
245
+ end
246
+ end
247
+
248
+ class Collector
249
+ attr_reader :store
250
+
251
+ def initialize
252
+ @store = {}
253
+ end
254
+
255
+ def method_missing(method, *args, &_block)
256
+ @store[method.to_s.sub('=', '').to_sym] = args.first
257
+ end
258
+ end
259
+
260
+ # Returns true if the given object is one of the recognized Origen
261
+ # bit containers (bit collection, reg or container).
262
+ def contains_bits?(obj)
263
+ obj.respond_to?(:contains_bits?) && obj.contains_bits?
264
+ end
265
+
266
+ # Returns true if the given object is an Origen bit
267
+ def is_a_bit?(obj)
268
+ obj.is_a?(Origen::Registers::Bit)
269
+ end
270
+
271
+ # Add a register.
272
+ # When adding a register you must supply a name, an address, size in bits, and bit definitions,
273
+ # any bits that are not declared will be filled with dummy bit objects that are
274
+ # not writable and will read back as 0.
275
+ #
276
+ # @example
277
+ # Name Address Size Bit Definitions
278
+ # add_reg :control, 0x00, 16 :mode => { :pos => 8, :bits => 8 },
279
+ # # Leaving out bits does 1 by default
280
+ # :launch => { :pos => 6 },
281
+ # # The default reset state is 0, specify an alternative..
282
+ # :status => { :pos => 4, :bits => 2, :res => 0b11 },
283
+ # :fail => { :pos => 2 },
284
+ # :done => { :pos => 0 }
285
+ #
286
+ # Can be called on any object to add a register to it
287
+ def add_reg(id, address, size = nil, bit_info = {}, &_block)
288
+ size, bit_info = nil, size if size.is_a?(Hash)
289
+ size ||= bit_info.delete(:size) || 32
290
+ description = bit_info.delete(:description)
291
+
292
+ local_vars = {}
293
+
294
+ Reg::REG_LEVEL_ATTRIBUTES.each do |attribute, meta|
295
+ aliases = [attribute]
296
+ aliases += meta[:aliases] if meta[:aliases]
297
+ aliases.each { |_a| local_vars[attribute] = bit_info.delete(attribute) if bit_info.key?(attribute) }
298
+ end
299
+
300
+ local_vars[:reset] ||= :memory if local_vars[:memory]
301
+ @min_reg_address ||= address
302
+ @max_reg_address ||= address
303
+ @min_reg_address = address if address < @min_reg_address
304
+ if address > @max_reg_address
305
+ @max_address_reg_size = size
306
+ @max_reg_address = address
307
+ end
308
+ @reg_define_file ||= define_file(caller[0])
309
+
310
+ if block_given?
311
+ @new_reg_attrs = { meta: bit_info }
312
+ yield self
313
+ bit_info = @new_reg_attrs
314
+ end
315
+ if _registers[id] && Origen.config.strict_errors
316
+ puts ''
317
+ puts "Add register error, you have already added a register named #{id} to #{self.class}"
318
+ puts ''
319
+ fail 'Duplicate register error!'
320
+ else
321
+ attributes = {
322
+ define_file: @reg_define_file,
323
+ address: address,
324
+ size: size,
325
+ bit_info: bit_info,
326
+ description: description
327
+ }
328
+ Reg::REG_LEVEL_ATTRIBUTES.each do |attribute, _meta|
329
+ attributes[attribute] = local_vars[attribute]
330
+ end
331
+ _registers[id] = Placeholder.new(self, id, attributes)
332
+ end
333
+ @reg_define_file = nil
334
+ end
335
+
336
+ # Delete an existing register
337
+ def del_reg(id)
338
+ _registers.delete(id)
339
+ end
340
+
341
+ # @api private
342
+ def define_file(file)
343
+ if Origen.running_on_windows?
344
+ fields = file.split(':')
345
+ "#{fields[0]}:#{fields[1]}"
346
+ else
347
+ file.split(':').first
348
+ end
349
+ end
350
+
351
+ # Called within an add_reg block to define bits
352
+ def bit(index, name, attrs = {})
353
+ if index.is_a?(Range)
354
+ msb = index.first
355
+ lsb = index.last
356
+ msb, lsb = lsb, msb if lsb > msb
357
+ pos = lsb
358
+ bits = (msb - lsb).abs + 1
359
+ elsif index.is_a?(Numeric)
360
+ pos = index
361
+ bits = 1
362
+ else
363
+ fail 'No valid index supplied when defining a register bit!'
364
+ end
365
+
366
+ # Traynor, this could be more elegant
367
+ # its just a dirty way to make the value of the
368
+ # key in @new_reg_atts hash array (ie name) tie to
369
+ # a value that is an array of hashes describing
370
+ # data for each scrambled bit
371
+ attrs = attrs.merge(pos: pos, bits: bits)
372
+ temparray = []
373
+ if @new_reg_attrs[name].nil?
374
+ @new_reg_attrs[name] = attrs
375
+ else
376
+ if @new_reg_attrs[name].is_a? Hash
377
+ temparray = temparray.push(@new_reg_attrs[name])
378
+ else
379
+ temparray = @new_reg_attrs[name]
380
+ end
381
+ temparray = temparray.push(attrs)
382
+ # added the sort so that the order the registers bits is described is not important
383
+ @new_reg_attrs[name] = temparray.sort { |a, b| b[:pos] <=> a[:pos] }
384
+
385
+ end
386
+ end
387
+
388
+ alias_method :bits, :bit
389
+
390
+ # Can be called to add app specific meta data that is isolated to all registers
391
+ # defined within a given class
392
+ def default_reg_metadata
393
+ Origen::Registers.reg_metadata[self.class] ||= {}
394
+ if block_given?
395
+ collector = Collector.new
396
+ yield collector
397
+ Origen::Registers.reg_metadata[self.class].merge!(collector.store)
398
+ end
399
+ Origen::Registers.reg_metadata[self.class]
400
+ end
401
+ alias_method :default_reg_meta_data, :default_reg_metadata
402
+
403
+ def default_bit_metadata
404
+ Origen::Registers.bit_metadata[self.class] ||= {}
405
+ if block_given?
406
+ collector = Collector.new
407
+ yield collector
408
+ Origen::Registers.bit_metadata[self.class].merge!(collector.store)
409
+ end
410
+ Origen::Registers.bit_metadata[self.class]
411
+ end
412
+ alias_method :default_bit_meta_data, :default_bit_metadata
413
+
414
+ # @api private
415
+ def instantiate_reg(id, attrs)
416
+ return _registers[id] unless _registers[id].is_a?(Origen::Registers::Placeholder)
417
+ attributes = {
418
+ define_file: attrs[:define_file],
419
+ description: attrs[:description]
420
+ }
421
+ Reg::REG_LEVEL_ATTRIBUTES.each do |attribute, _meta|
422
+ attributes[attribute] = attrs[attribute]
423
+ end
424
+ _registers[id] = Reg.new(self, attrs[:address], attrs[:size], id,
425
+ attrs[:bit_info].merge(attributes))
426
+ end
427
+
428
+ def add_reg32(id, address, args = {}, &block)
429
+ @reg_define_file = define_file(caller[0])
430
+ add_reg(id, address, 32, args, &block)
431
+ end
432
+
433
+ # Returns the lowest address of all registers that have been added
434
+ def min_reg_address
435
+ @min_reg_address || 0
436
+ end
437
+
438
+ # Returns the highest address of all registers that have been added
439
+ def max_reg_address
440
+ @max_reg_address || 0
441
+ end
442
+
443
+ # Returns the size (in bits) of the register with the highest address,
444
+ # can be useful in combination with max_reg_address to work out the
445
+ # range of addresses containing registers
446
+ def max_address_reg_size
447
+ @max_address_reg_size
448
+ end
449
+
450
+ # Resets all registers
451
+ def reset_registers
452
+ regs.each { |_name, reg| reg.reset }
453
+ end
454
+
455
+ # Returns true if the object contains a register matching the given name
456
+ def has_reg?(name, params = {})
457
+ params = {
458
+ test_for_true_false: true
459
+ }.update(params)
460
+ if params.key?(:enabled_features) || params.key?(:enabled_feature)
461
+ return !!get_registers(params).include?(name)
462
+ else
463
+ params[:enabled_features] = :default
464
+ return !!get_registers(params).include?(name)
465
+ end
466
+ end
467
+ alias_method :has_reg, :has_reg?
468
+
469
+ # Returns the register object matching the given name, or a hash of all registers,
470
+ # associated with a feature,if no name is specified.
471
+ #
472
+ # Can also be used to define a new register if a block is supplied in which case
473
+ # it is equivalent to calling add_reg with a block.
474
+ def reg(*args, &block)
475
+ if block_given?
476
+ @reg_define_file = define_file(caller[0])
477
+ add_reg(*args, &block)
478
+ else
479
+ # Example use cases:
480
+ # reg(:reg2)
481
+ # reg(:name => :reg2)
482
+ if !args.empty? && args.size == 1 && (args[0].class != Hash || (args[0].key?(:name) && args[0].size == 1))
483
+ if args[0].class == Hash
484
+ name = args[0][:name]
485
+ else name = args.first
486
+ end
487
+ if has_reg(name)
488
+ return _registers[name]
489
+ else
490
+ if Origen.config.strict_errors
491
+ puts ''
492
+ if regs.empty?
493
+ puts "#{self.class} does not have a register named #{name} or it is not enabled."
494
+ else
495
+ puts "#{self.class} does not have a register named #{name} or it is not enabled."
496
+ puts 'You may need to add it. This could also be a typo, these are the valid register names:'
497
+ puts regs.keys
498
+ end
499
+ puts ''
500
+ fail 'Missing register error!'
501
+ end
502
+ end
503
+ # Example use cases:
504
+ # reg(:enabled_features => :all)
505
+ # reg(:name => :reg2, enabled_features => :all)
506
+ # reg(:name => :reg2, enabled_features => :fac)
507
+ elsif !args.empty? && args.size == 1 && args[0].class == Hash
508
+ params = args[0]
509
+
510
+ # Example use case:
511
+ # reg(:name => :reg2, :enabled_features => :all)
512
+ if (params.key?(:enabled_features) || params.key?(:enabled_feature)) && params.key?(:name)
513
+ name = params[:name]
514
+ if has_reg(name, params)
515
+ _registers[name]
516
+ else
517
+ reg_missing_error(params)
518
+ end
519
+ # Example use case:
520
+ # reg(:enabled_features =>[:fac, fac2])
521
+ elsif params.size == 1 && params.key?(:enabled_features)
522
+ return get_registers(enabled_features: params[:enabled_features])
523
+ end
524
+
525
+ # Example use case:
526
+ # reg(:reg2, :enabled_features => :all)
527
+ # reg(:reg2, :enabled_features => :default)
528
+ # reg(:reg2, :enabled_features => :fac)
529
+ elsif !args.empty? && args.size == 2
530
+ name = args[0]
531
+ params = args[1]
532
+ name, params = params, name if name.class == Hash
533
+ if has_reg(name, params)
534
+ _registers[name]
535
+ else
536
+ reg_missing_error(params)
537
+ end
538
+ elsif args.empty?
539
+ if _registers.empty?
540
+ return _registers
541
+ else
542
+ return get_registers(enabled_features: :default)
543
+ end
544
+ else
545
+ if Origen.config.strict_errors
546
+ fail 'Invalid call to reg method or invalid arguments specified'
547
+ end
548
+ end
549
+ end
550
+ end
551
+ alias_method :regs, :reg
552
+
553
+ private
554
+
555
+ def reg_missing_error(params)
556
+ if Origen.config.strict_errors
557
+ puts ''
558
+ temp = regs(params)
559
+ if temp.empty?
560
+ puts "#{self.class} does not have a register named #{name} within the supplied feature scope, you need to add it."
561
+ else
562
+ puts "#{self.class} does not have a register named #{name} within the supplied feature scope, you may need to add it."
563
+ puts 'This could also be a typo, these are the valid register names:'
564
+ puts temp.keys
565
+ end
566
+ puts ''
567
+ fail 'Missing register error!'
568
+ end
569
+ end
570
+
571
+ def extract_enabled_features(options)
572
+ options[:enabled_features] || options[:enabled_feature]
573
+ end
574
+
575
+ def get_registers(params)
576
+ params = {
577
+ test_for_true_false: false
578
+ }.update(params)
579
+ regs_to_return = RegCollection.new(self)
580
+ req_features = extract_enabled_features(params)
581
+ if req_features == :all
582
+ regs_to_return = _registers
583
+ elsif req_features == :none
584
+ _registers.each do |k, v|
585
+ regs_to_return[k] = v unless v.has_feature_constraint?
586
+ end
587
+ elsif req_features == :default
588
+ _registers.each do |k, v|
589
+ regs_to_return[k] = v if v.enabled?
590
+ end
591
+ elsif req_features.class == Array
592
+ req_features.each do |req_feat|
593
+ _registers.each do |k, v|
594
+ regs_to_return[k] = v if v.enabled_by_feature?(req_feat) || !v.has_feature_constraint?
595
+ end
596
+ end
597
+ else
598
+ _registers.each do |k, v|
599
+ regs_to_return[k] = v if v.enabled_by_feature?(req_features) || !v.has_feature_constraint?
600
+ end
601
+ end
602
+ if regs_to_return.empty?
603
+ unless params[:test_for_true_false]
604
+ puts 'No register found with the specified feature or the register is disabled!'
605
+ fail 'Missing register error!'
606
+ end
607
+ end
608
+ regs_to_return
609
+ end
610
+
611
+ public
612
+
613
+ # Creates a dummy register. Equivalent to Reg.dummy except the reg owner is assigned
614
+ # as the caller rather than Reg. Use this if you need to call read! or write! on the
615
+ # dummy register object.
616
+ def dummy_reg(size = 16)
617
+ Reg.new(self, 0, size, :dummy, init_as_writable: true)
618
+ end
619
+
620
+ def write_register_missing!(reg)
621
+ puts ''
622
+ puts ''
623
+ puts <<-EOT
624
+ You have made a request to write register: #{reg.name}, however the #{self.class}
625
+ class does not know how to do this yet. You must implement a write_register
626
+ method in the #{self.class} like this:
627
+
628
+ def write_register(reg, options={})
629
+ <logic to handle the writing of the reg object here>
630
+ end
631
+ EOT
632
+ puts ''
633
+ exit 1
634
+ end
635
+
636
+ def read_register_missing!(reg)
637
+ puts ''
638
+ puts ''
639
+ puts <<-EOT
640
+ You have made a request to read register: #{reg.name}, however the #{self.class}
641
+ class does not know how to do this yet. You must implement a read_register
642
+ method in the #{self.class} like this:
643
+
644
+ def read_register(reg, options={})
645
+ <logic to handle reading the reg object here>
646
+ end
647
+ EOT
648
+ puts ''
649
+ exit 1
650
+ end
651
+ end
652
+ end