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,158 @@
1
+ module Origen
2
+ module Utility
3
+ # Diff provides an easy way to diff the contents of two files while optionally
4
+ # ignoring any differences in file comments.
5
+ #
6
+ # differ = Origen::Utility::Diff.new(:ignore_blank_lines => true, :comment_char => "//")
7
+ #
8
+ # differ.file_a = "#{Origen.root}/my/file1.v"
9
+ # differ.file_b = "#{Origen.root}/my/file2.v"
10
+ #
11
+ # if differ.diffs?
12
+ # puts "You've changed something!"
13
+ # end
14
+ class Diff
15
+ # Full path to File A, this attribute must be set before calling any diff actions
16
+ attr_accessor :file_a
17
+ # Full path to File B, this attribute must be set before calling any diff actions
18
+ attr_accessor :file_b
19
+ # When true the diff will ignore blank lines, or lines that contain only whitespace
20
+ attr_accessor :ignore_blank_lines
21
+ # Set this attribute to the comment char used by the given file and comments will
22
+ # be ignored by the diff.
23
+ # An array of strings can be passed in to mask multiple comment identifiers.
24
+ attr_accessor :comment_char
25
+
26
+ # Create a new diff, attributes can be initialized via the options, or can be
27
+ # set later.
28
+ def initialize(options = {})
29
+ @file_a = options[:file_a]
30
+ @file_b = options[:file_b]
31
+ @ignore_blank_lines = options[:ignore_blank_lines]
32
+ @comment_char = options[:comment_char]
33
+ @suspend_string = options[:suspend_string] # permits suspending diff check based on a string
34
+ @resume_string = options[:resume_string] # permits resuming diff check based on a string
35
+ @suspend_diff = false
36
+ @resume_diff = false
37
+ end
38
+
39
+ # Returns true if there are differences between the two files based on the
40
+ # current configuration
41
+ def diffs?
42
+ initialize_counters
43
+ result = false
44
+ content_a = File.readlines(@file_a)
45
+ content_b = File.readlines(@file_b)
46
+
47
+ changes = false
48
+ lines_remaining = true
49
+
50
+ while lines_remaining
51
+ a = get_next_line_a(content_a) # Get the next vectors
52
+ b = get_next_line_b(content_b)
53
+ if !a && !b # If both patterns finished
54
+ lines_remaining = false
55
+ elsif !a || !b # If only 1 pattern finished
56
+ lines_remaining = false
57
+ changes = true unless @suspend_diff # There are extra vectors in one of the patterns
58
+ elsif a != b # If the vectors don't match
59
+ changes = true unless @suspend_diff
60
+ end
61
+ if @resume_diff # resume checking diffs for subsequent lines
62
+ @suspend_diff = false
63
+ @resume_diff = false
64
+ end
65
+ end
66
+
67
+ changes
68
+ end
69
+
70
+ private
71
+
72
+ def set_suspend_diff(line)
73
+ if line.valid_encoding?
74
+ if @suspend_string && !@suspend_diff
75
+ if line =~ /#{@suspend_string}/
76
+ @suspend_diff = true
77
+ end
78
+ elsif @resume_string && @suspend_diff
79
+ if line =~ /#{@resume_string}/
80
+ @resume_diff = true
81
+ end
82
+ end
83
+ end
84
+ end
85
+
86
+ def get_next_line_b(array)
87
+ @b_ix = next_index(array, @b_ix)
88
+ get_line(array, @b_ix)
89
+ end
90
+
91
+ def get_next_line_a(array)
92
+ @a_ix = next_index(array, @a_ix)
93
+ get_line(array, @a_ix)
94
+ end
95
+
96
+ # Fetches the line from the given array and does some pre-processing
97
+ def get_line(array, ix)
98
+ line = array[ix]
99
+ if line
100
+ set_suspend_diff(line)
101
+ if @comment_char
102
+ # Screen off any inline comments at the end of line
103
+ begin
104
+ [@comment_char].flatten.each do |_char|
105
+ if line =~ /(.*)#{@char}.*/
106
+ return Regexp.last_match[1].strip
107
+ end
108
+ end
109
+ # This rescue is a crude way to guard against non-ASCII files that find
110
+ # their way in here
111
+ rescue
112
+ return line
113
+ end
114
+ else
115
+ line.strip
116
+ end
117
+ end
118
+ end
119
+
120
+ # Find the next line in the given array and return the new index pointer
121
+ def next_index(array, ix = nil)
122
+ ix = ix ? ix + 1 : 0
123
+ matched = false
124
+ while !matched && ix < array.size
125
+ begin
126
+ comment_matched = false
127
+ # Skip comment lines
128
+ if @comment_char
129
+ [@comment_char].flatten.each do |char|
130
+ if array[ix] =~ /^\s*#{char}.*/
131
+ comment_matched = true
132
+ end
133
+ end
134
+ end
135
+ # Skip blank lines
136
+ if comment_matched
137
+ ix += 1
138
+ elsif @ignore_blank_lines && array[ix] =~ /^\s*$/
139
+ ix += 1
140
+ else
141
+ matched = true
142
+ end
143
+ # This rescue is a crude way to guard against non-ASCII files that find
144
+ # there way in here
145
+ rescue
146
+ matched = true
147
+ end
148
+ end
149
+ ix
150
+ end
151
+
152
+ def initialize_counters
153
+ @a_ix = nil
154
+ @b_ix = nil
155
+ end
156
+ end
157
+ end
158
+ end
@@ -0,0 +1,121 @@
1
+ require 'readline'
2
+ module Origen
3
+ module Utility
4
+ module InputCapture
5
+ # Gets text input from the user
6
+ # Supply an optional default value in the event that the user enters nothing
7
+ def get_text(options = {})
8
+ options = { default: false,
9
+ single: false, # Set if only a single line entry is expected
10
+ confirm: false,
11
+ accept: false, # Supply and array of entries you are willing to accept
12
+ case_sensitive: false, # If accept values are supplied they will be treated as case
13
+ # in-sensitive by default
14
+ wrap: true, # Automatically split long lines
15
+ }.merge(options)
16
+ if options[:confirm]
17
+ puts "Type 'yes' or 'no' to confirm or 'quit' to abort."
18
+ elsif options[:accept]
19
+ puts "You can enter: #{options[:accept].map { |v| "'#{v}'" }.join(', ')} or 'quit' to abort."
20
+ # "
21
+ else
22
+ puts options[:single] ? "Enter 'quit' to abort." : "Enter a single '.' to finish, or 'quit' to abort."
23
+ end
24
+ puts '------------------------------------------------------------------------------------------'
25
+ text = ''
26
+ line = ''
27
+ if options[:confirm]
28
+ print "(#{options[:default]}): " if options[:default]
29
+ else
30
+ print "Hit return to accept the default (#{options[:default]}): " if options[:default]
31
+ end
32
+
33
+ while line != '.'
34
+ orig_line = Readline.readline('', false).chomp.rstrip
35
+ line = orig_line.strip
36
+ if (line.empty? || line == '.') && text.empty? && options[:default]
37
+ text = options[:default].to_s
38
+ line = '.'
39
+ elsif line.downcase == 'quit'
40
+ exit 0
41
+ elsif line == '.'
42
+ # Do nothing
43
+ else
44
+ if options[:wrap]
45
+ split_long_line(orig_line) do |short_line|
46
+ text << "#{short_line}\n"
47
+ end
48
+ else
49
+ text << orig_line
50
+ end
51
+ end
52
+ confirm = text.strip.downcase if options[:confirm]
53
+ text = text.strip if options[:single]
54
+ line = '.' if options[:single] || options[:confirm]
55
+ end
56
+ puts ''
57
+
58
+ if options[:confirm]
59
+ if confirm == 'no' || confirm == 'n'
60
+ if options[:confirm] == :return_boolean
61
+ return false
62
+ else
63
+ exit 0
64
+ end
65
+ end
66
+ if confirm == 'yes' || confirm == 'y'
67
+ if options[:confirm] == :return_boolean
68
+ return true
69
+ else
70
+ return
71
+ end
72
+ else
73
+ get_text(options)
74
+ end
75
+
76
+ elsif options[:accept]
77
+ accept = options[:accept].map do |v|
78
+ v = v.to_s
79
+ v = v.downcase unless options[:case_sensitive]
80
+ v
81
+ end
82
+ text = text.downcase unless options[:case_sensitive]
83
+ text = text.strip
84
+ if accept.include?(text)
85
+ text
86
+ else
87
+ get_text(options)
88
+ end
89
+
90
+ else
91
+ text
92
+ end
93
+ end
94
+
95
+ # Splits a long line into short ones, split by the nearest space
96
+ def split_long_line(line)
97
+ if line.length <= 90
98
+ yield line
99
+ else
100
+ until line.empty?
101
+ if line.length <= 90
102
+ yield line
103
+ line = ''
104
+ else
105
+ yield line.slice(0, find_space(line, 90))
106
+ line = line.slice(find_space(line, 90), line.length).strip
107
+ end
108
+ end
109
+ end
110
+ end
111
+
112
+ # Find the space closest to but less than max_position, returns max_position if none
113
+ # can be found
114
+ def find_space(line, max_position)
115
+ x = max_position
116
+ x -= 1 until line[x] == ' ' || x == 0
117
+ x == 0 ? max_position : x
118
+ end
119
+ end
120
+ end
121
+ end
@@ -0,0 +1,143 @@
1
+ require 'net/smtp'
2
+ module Origen
3
+ module Utility
4
+ class Mailer
5
+ include Users
6
+
7
+ # Generic method to send an email, alternatively use one of the
8
+ # pre-defined mail types using the other methods.
9
+ def send_email(options = {})
10
+ options = { server: Origen.site_config.email_server,
11
+ port: Origen.site_config.email_port,
12
+ from: current_user.email,
13
+ from_alias: current_user.name,
14
+ subject: 'Hello',
15
+ body: 'Hello from Origen!',
16
+ to: 'Stephen McGinty <stephen.mcginty@freescale.com>'
17
+ }.merge(options)
18
+
19
+ # Force to an array
20
+ to = options[:to].respond_to?('each') ? options[:to] : [options[:to]]
21
+
22
+ # Convert any user objects to an email
23
+ to = to.map { |obj| obj.respond_to?('email') ? obj.email : obj }
24
+
25
+ to.uniq.each do |addr|
26
+ msg = <<END_OF_MESSAGE
27
+ From: #{options[:from_alias]} <#{options[:from]}>
28
+ To: #{addr}
29
+ Subject: #{options[:subject]}
30
+
31
+ #{options[:body]}
32
+ END_OF_MESSAGE
33
+
34
+ begin
35
+ # Exceptions raised here will be caught by rescue clause
36
+ Net::SMTP.start(options[:server], options[:port]) do |smtp|
37
+ smtp.send_message msg, options[:from], addr
38
+ end
39
+ rescue
40
+ warn "Email not able to be sent to address '#{addr}'"
41
+ end
42
+ end
43
+ end
44
+
45
+ # Call to send a notice
46
+ def send_release_notice(version, release_note, type, selectors, options = {})
47
+ if external?(type)
48
+ header = "A new version of #{config.name} is available:"
49
+ else
50
+ header = "A new development version of #{config.name} is available:"
51
+ end
52
+
53
+ msg = <<-END1
54
+ Hi,
55
+
56
+ #{header}
57
+
58
+ #{version} #{selectors}
59
+
60
+ Release note:
61
+
62
+ --------------------------------------------------------------------------------------
63
+
64
+ #{release_note}
65
+
66
+ --------------------------------------------------------------------------------------
67
+ END1
68
+
69
+ if config.release_instructions
70
+ msg += <<-END2
71
+
72
+ #{config.release_instructions}
73
+
74
+ --------------------------------------------------------------------------------------
75
+ END2
76
+ end
77
+
78
+ msg += <<-END3
79
+
80
+ You are receiving this because you are a member of the #{config.name} Mailing List,
81
+ or a member of the development team.
82
+ END3
83
+
84
+ if external?(type)
85
+ to = app_users + Origen.app.subscribers_prod + Origen.app.subscribers_dev
86
+ if config.release_email_subject
87
+ subject = "[#{Origen.app.namespace}] New Official Release: #{config.release_email_subject}"
88
+ else
89
+ subject = "[#{Origen.app.namespace}] New Official Release"
90
+ end
91
+ else
92
+ to = admins + Origen.app.subscribers_dev
93
+ if config.release_email_subject
94
+ subject = "[#{Origen.app.namespace}] New Development Tag: #{config.release_email_subject}"
95
+ else
96
+ subject = "[#{Origen.app.namespace}] New Development Tag"
97
+ end
98
+ end
99
+
100
+ begin
101
+ send_email({ to: to, subject: subject, body: msg }.merge(options))
102
+ rescue
103
+ warn "Email could not be sent to #{to}"
104
+ end
105
+ end
106
+
107
+ # Send a regression complete notice,
108
+ def send_regression_complete_notice(stats = Origen.app.runner.stats, options = {})
109
+ stats, options = Origen.app.runner.stats, stats if stats.is_a?(Hash)
110
+ options = {
111
+ to: current_user
112
+ }.merge(options)
113
+
114
+ msg = <<-END1
115
+ Hi,
116
+
117
+ The regression results are:
118
+
119
+ #{stats.summary_text}
120
+
121
+ END1
122
+
123
+ subject = "[#{Origen.app.namespace}] Regression - "
124
+ if stats.clean_run?
125
+ subject += 'PASSED'
126
+ else
127
+ subject += 'FAILED'
128
+ end
129
+ send_email({ to: options[:to], subject: subject, body: msg }.merge(options))
130
+ end
131
+
132
+ private
133
+
134
+ def config
135
+ Origen.config
136
+ end
137
+
138
+ def external?(type)
139
+ [:production, :major, :minor, :bugfix].include?(type)
140
+ end
141
+ end
142
+ end
143
+ end
@@ -0,0 +1,205 @@
1
+ module Origen
2
+ module Utility
3
+ # A class to handle the parsing of S-records
4
+ #
5
+ # An S-record file consists of a sequence of specially formatted ASCII character strings. An S-record will
6
+ # be less than or equal to 78 bytes in length.
7
+ # The order of S-records within a file is of no significance and no particular order may be assumed.
8
+ #
9
+ # The general format of an S-record follows:
10
+ #
11
+ # +-------------------//------------------//-----------------------+
12
+ # | type | count | address | data | checksum |
13
+ # +-------------------//------------------//-----------------------+
14
+ #
15
+ # type -- A char[2] field. These characters describe the type of record (S0, S1, S2, S3, S5, S7, S8, or S9).
16
+ # count -- A char[2] field. These characters when paired and interpreted as a hexadecimal value, display
17
+ # the count of remaining character pairs in the record.
18
+ #
19
+ # address -- A char[4,6, or 8] field. These characters grouped and interpreted as a hexadecimal value,
20
+ # display the address at which the data field is to be loaded into memory. The length of the field depends
21
+ # on the number of bytes necessary to hold the address. A 2-byte address uses 4 characters, a 3-byte
22
+ # address uses 6 characters, and a 4-byte address uses 8 characters.
23
+ #
24
+ # data -- A char [0-64] field. These characters when paired and interpreted as hexadecimal values represent
25
+ # the memory loadable data or descriptive information.
26
+ #
27
+ # data -- A char [0-64] field. These characters when paired and interpreted as hexadecimal values represent
28
+ # checksum -- A char[2] field. These characters when paired and interpreted as a hexadecimal value display
29
+ # the least significant byte of the ones complement of the sum of the byte values represented by the pairs
30
+ # of characters making up the count, the address, and the data fields.
31
+ #
32
+ # data -- A char [0-64] field. These characters when paired and interpreted as hexadecimal values represent
33
+ # Each record is terminated with a line feed. If any additional or different record terminator(s) or delay
34
+ # characters are needed during transmission to the target system it is the responsibility of the
35
+ # transmitting program to provide them.
36
+ #
37
+ # data -- A char [0-64] field. These characters when paired and interpreted as hexadecimal values represent
38
+ # S0 Record. The type of record is 'S0' (0x5330). The address field is unused and will be filled with zeros
39
+ # (0x0000). The header information within the data field is divided into the following subfields.
40
+ #
41
+ # * mname is char[20] and is the module name.
42
+ # * ver is char[2] and is the version number.
43
+ # * rev is char[2] and is the revision number.
44
+ # * description is char[0-36] and is a text comment.
45
+ #
46
+ # Each of the subfields is composed of ASCII bytes whose associated characters, when paired, represent one
47
+ # byte hexadecimal values in the case of the version and revision numbers, or represent the hexadecimal
48
+ # values of the ASCII characters comprising the module name and description.
49
+ #
50
+ # S1 Record. The type of record field is 'S1' (0x5331). The address field is intrepreted as a 2-byte
51
+ # address. The data field is composed of memory loadable data.
52
+ #
53
+ # S2 Record. The type of record field is 'S2' (0x5332). The address field is intrepreted as a 3-byte
54
+ # address. The data field is composed of memory loadable data.
55
+ #
56
+ # S3 Record. The type of record field is 'S3' (0x5333). The address field is intrepreted as a 4-byte
57
+ # address. The data field is composed of memory loadable data.
58
+ #
59
+ # S5 Record. The type of record field is 'S5' (0x5335). The address field is intrepreted as a 2-byte value
60
+ # and contains the count of S1, S2, and S3 records previously transmitted. There is no data field.
61
+ #
62
+ # S7 Record. The type of record field is 'S7' (0x5337). The address field contains the starting execution
63
+ # address and is intrepreted as 4-byte address. There is no data field.
64
+ #
65
+ # S8 Record. The type of record field is 'S8' (0x5338). The address field contains the starting execution
66
+ # address and is intrepreted as 3-byte address. There is no data field.
67
+ #
68
+ # S9 Record. The type of record field is 'S9' (0x5339). The address field contains the starting execution
69
+ # address and is intrepreted as 2-byte address. There is no data field.
70
+ #
71
+ # EXAMPLE
72
+ #
73
+ # Shown below is a typical S-record format file.
74
+ #
75
+ # S00600004844521B
76
+ # S1130000285F245F2212226A000424290008237C2A
77
+ # S11300100002000800082629001853812341001813
78
+ # S113002041E900084E42234300182342000824A952
79
+ # S107003000144ED492
80
+ # S5030004F8
81
+ # S9030000FC
82
+ #
83
+ # The file consists of one S0 record, four S1 records, one S5 record and an S9 record.
84
+ #
85
+ # The S0 record is comprised as follows:
86
+ #
87
+ # * S0 S-record type S0, indicating it is a header record.
88
+ # * 06 Hexadecimal 06 (decimal 6), indicating that six character pairs (or ASCII bytes) follow.
89
+ # * 00 00 Four character 2-byte address field, zeroes in this example.
90
+ # * 48 44 52 ASCII H, D, and R - "HDR".
91
+ # * 1B The checksum.
92
+ #
93
+ # The first S1 record is comprised as follows:
94
+ #
95
+ # * S1 S-record type S1, indicating it is a data record to be loaded at a 2-byte address.
96
+ # * 13 Hexadecimal 13 (decimal 19), indicating that nineteen character pairs, representing a 2 byte address,
97
+ # * 16 bytes of binary data, and a 1 byte checksum, follow.
98
+ # * 00 00 Four character 2-byte address field; hexidecimal address 0x0000, where the data which follows is to
99
+ # be loaded.
100
+ # * 28 5F 24 5F 22 12 22 6A 00 04 24 29 00 08 23 7C Sixteen character pairs representing the actual binary
101
+ # data.
102
+ # * 2A The checksum.
103
+ # * The second and third S1 records each contain 0x13 (19) character pairs and are ended with checksums of 13
104
+ # and 52, respectively. The fourth S1 record contains 07 character pairs and has a checksum of 92.
105
+ #
106
+ # The S5 record is comprised as follows:
107
+ #
108
+ # * S5 S-record type S5, indicating it is a count record indicating the number of S1 records
109
+ # * 03 Hexadecimal 03 (decimal 3), indicating that three character pairs follow.
110
+ # * 00 04 Hexadecimal 0004 (decimal 4), indicating that there are four data records previous to this record.
111
+ # * F8 The checksum.
112
+ #
113
+ # The S9 record is comprised as follows:
114
+ #
115
+ # * S9 S-record type S9, indicating it is a termination record.
116
+ # * 03 Hexadecimal 03 (decimal 3), indicating that three character pairs follow.
117
+ # * 00 00 The address field, hexadecimal 0 (decimal 0) indicating the starting execution address.
118
+ # * FC The checksum.
119
+ #
120
+ # --------------------------------------------------------------------------------
121
+ #
122
+ # Instructor Notes
123
+ #
124
+ # There isn't any evidence that Motorola ever has made use of the header information within the data field
125
+ # of the S0 record, as described above. This must have been used by some third party vendors.
126
+ # This is the only place that a 78-byte limit on total record length or 64-byte limit on data length is
127
+ # documented. These values shouldn't be trusted for the general case.
128
+ # The count field can have values in the range of 0x3 (2 bytes of address + 1 byte checksum = 3, a not
129
+ # very useful record) to 0xff; this is the count of remaining character pairs, including checksum.
130
+ # If you write code to convert S-Records, you should always assume that a record can be as long as 514
131
+ # (decimal) characters in length (255 * 2 = 510, plus 4 characters for the type and count fields), plus
132
+ # any terminating character(s). That is, in establishing an input buffer in C, you would declare it to be
133
+ # an array of 515 chars, thus leaving room for the terminating null character.
134
+ class SRecord
135
+ # Supply a path to the S-record file, this should be a relative path from the top
136
+ # level of your project workspace (Origen.root)
137
+ def initialize(file)
138
+ @file = file
139
+ end
140
+
141
+ # Parses the S-record and returns either an array of address and data values like this:
142
+ # * \[addr, data, addr, data, addr, data\]
143
+ # Or if a block is supplied it will pass back a single address and a single data value
144
+ # in turn.
145
+ # ==== Options
146
+ # * :data_width_in_bytes - By default the returned data items will be 1 byte wide, set
147
+ # this option to have it parsed and passed back in N byte wide packets
148
+ # ==== Example
149
+ # srec = SRecord.new("srecs/test_atd.abs.S19")
150
+ # $top.write_addr_data(srec.parse) # Let write_addr_data handle the processing
151
+ # # As above but pass the data to the top block in 16-bit packets
152
+ # $top.write_addr_data(srec.parse(:data_width_in_bytes => 2))
153
+ #
154
+ # # Handle the processing from here...
155
+ # srec.parse do |addr,data|
156
+ # $top.write(addr, data)
157
+ # end
158
+ def parse(options = {})
159
+ addr_data = extract_addr_data(options)
160
+ if block_given?
161
+ addr_data.each_slice(2) do |pair|
162
+ yield pair[0], pair[1]
163
+ end
164
+ else
165
+ addr_data
166
+ end
167
+ end
168
+
169
+ private
170
+
171
+ # Returns an array containing all address/data from the given s-record
172
+ # No address manipulation is performed, that is left to the caller to apply
173
+ # any scrambling as required by the target system
174
+ def extract_addr_data(options = {}) # :nodoc:
175
+ options = { data_width_in_bytes: 1
176
+ }.merge(options)
177
+
178
+ result = []
179
+ File.readlines(Origen.file_handler.clean_path_to(@file)).each do |line|
180
+ # Only if the line is an s-record with data...
181
+ if line =~ /^S([1-3])/
182
+ type = Regexp.last_match[1].to_i(16) # S-record type, 1-3
183
+ # Set the matcher to capture x number of bytes dependent on the s-rec type
184
+ addr_matcher = '\w\w' * (1 + type)
185
+ line.strip =~ /^S\d\w\w(#{addr_matcher})(\w*)\w\w$/ # $1 = address, $2 = data
186
+ addr = Regexp.last_match[1].to_i(16)
187
+ data = Regexp.last_match[2]
188
+ data_matcher = '\w\w' * options[:data_width_in_bytes]
189
+ data.scan(/#{data_matcher}/).each do |data_packet|
190
+ result << addr
191
+ result << data_packet.to_i(16)
192
+ addr += options[:data_width_in_bytes]
193
+ end
194
+ # If a partial word is left over
195
+ if (remainder = data.length % (2 * options[:data_width_in_bytes])) > 0
196
+ result << addr
197
+ result << data[data.length - remainder..data.length].to_i(16)
198
+ end
199
+ end
200
+ end
201
+ result
202
+ end
203
+ end
204
+ end
205
+ end
@@ -0,0 +1,30 @@
1
+ module Origen
2
+ module Utility
3
+ # Collection of methods related to time and dates
4
+ module TimeAndDate
5
+ # Returns the current time in this format:
6
+ # 05-Jun-2010 10:05AM
7
+ def time_now(options = {})
8
+ options = { underscore: false,
9
+ format: :human,
10
+ include_time: true
11
+ }.merge(options)
12
+
13
+ # Nice description of time format options
14
+ # http://wesgarrison.us/2006/03/12/ruby-strftime-options-for-date-formatting/
15
+
16
+ if options[:format] == :human
17
+ Time.now.strftime('%d-%b-%Y %H:%M%p')
18
+ elsif options[:format] == :universal
19
+ time = options[:underscore] ? Time.now.strftime('_%H_%M') : Time.now.strftime('%H%M')
20
+ date = options[:underscore] ? Time.now.strftime('%Y_%m_%d') : Time.now.strftime('%Y%m%d')
21
+ options[:include_time] ? date + time : date
22
+ elsif options[:format] == :timestamp
23
+ Time.now.strftime('%Y%m%d%H%M%S')
24
+ else
25
+ fail 'Unknown date format requested!'
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,12 @@
1
+ module Origen
2
+ module Utility
3
+ autoload :DesignSync, 'origen/utility/design_sync'
4
+ autoload :Diff, 'origen/utility/diff'
5
+ autoload :Mailer, 'origen/utility/mailer'
6
+ autoload :SRecord, 'origen/utility/s_record'
7
+ autoload :CSV, 'origen/utility/csv_data'
8
+ autoload :TimeAndDate, 'origen/utility/time_and_date'
9
+ autoload :InputCapture, 'origen/utility/input_capture'
10
+ autoload :BlockArgs, 'origen/utility/block_args'
11
+ end
12
+ end