origen 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/ctags +0 -0
- data/bin/origen +165 -1
- data/bin/rgen +2 -0
- data/config/application.rb +141 -0
- data/config/commands.rb +72 -0
- data/config/development.rb +7 -0
- data/config/environment.rb +0 -0
- data/config/rgen.policy +7 -0
- data/config/rubocop/easy.yml +620 -0
- data/config/rubocop/easy_disabled.yml +271 -0
- data/config/rubocop/easy_enabled.yml +731 -0
- data/config/rubocop/strict.yml +620 -0
- data/config/rubocop/strict_disabled.yml +247 -0
- data/config/rubocop/strict_enabled.yml +755 -0
- data/config/users.rb +20 -0
- data/config/version.rb +1 -1
- data/helpers/url.rb +68 -0
- data/lib/c99/doc_interface.rb +56 -0
- data/lib/c99/j750_interface.rb +85 -0
- data/lib/c99/nvm.rb +89 -0
- data/lib/c99/target/mock2.rb +1 -0
- data/lib/c99/target/subdir/mock3.rb +1 -0
- data/lib/option_parser/optparse.rb +12 -0
- data/lib/origen/acronyms.rb +60 -0
- data/lib/origen/application/command_dispatcher.rb +12 -0
- data/lib/origen/application/configuration.rb +206 -0
- data/lib/origen/application/configuration_manager.rb +78 -0
- data/lib/origen/application/deployer.rb +367 -0
- data/lib/origen/application/environment.rb +186 -0
- data/lib/origen/application/lsf.rb +145 -0
- data/lib/origen/application/lsf_manager.rb +657 -0
- data/lib/origen/application/plugins_manager.rb +280 -0
- data/lib/origen/application/release.rb +359 -0
- data/lib/origen/application/runner.rb +246 -0
- data/lib/origen/application/statistics.rb +191 -0
- data/lib/origen/application/target.rb +374 -0
- data/lib/origen/application/version_tracker.rb +59 -0
- data/lib/origen/application/workspace_manager.rb +151 -0
- data/lib/origen/application.rb +746 -0
- data/lib/origen/bugs/bug.rb +36 -0
- data/lib/origen/bugs.rb +45 -0
- data/lib/origen/callbacks.rb +35 -0
- data/lib/origen/chip_mode.rb +118 -0
- data/lib/origen/chip_package.rb +461 -0
- data/lib/origen/client.rb +87 -0
- data/lib/origen/code_generators/actions.rb +258 -0
- data/lib/origen/code_generators/base.rb +57 -0
- data/lib/origen/code_generators/bundler.rb +17 -0
- data/lib/origen/code_generators/gem_setup.rb +49 -0
- data/lib/origen/code_generators/rake.rb +13 -0
- data/lib/origen/code_generators/rspec.rb +12 -0
- data/lib/origen/code_generators/semver.rb +39 -0
- data/lib/origen/code_generators/timever.rb +37 -0
- data/lib/origen/code_generators.rb +111 -0
- data/lib/origen/commands/add.rb +12 -0
- data/lib/origen/commands/compile.rb +62 -0
- data/lib/origen/commands/ctags.rb +9 -0
- data/lib/origen/commands/dispatch.rb +22 -0
- data/lib/origen/commands/environment.rb +11 -0
- data/lib/origen/commands/fetch.rb +63 -0
- data/lib/origen/commands/generate.rb +130 -0
- data/lib/origen/commands/interactive.rb +73 -0
- data/lib/origen/commands/lint.rb +82 -0
- data/lib/origen/commands/lsf.rb +93 -0
- data/lib/origen/commands/merge.rb +55 -0
- data/lib/origen/commands/modifications.rb +12 -0
- data/lib/origen/commands/new.rb +113 -0
- data/lib/origen/commands/plugin.rb +105 -0
- data/lib/origen/commands/program.rb +70 -0
- data/lib/origen/commands/rc.rb +442 -0
- data/lib/origen/commands/save.rb +56 -0
- data/lib/origen/commands/target.rb +27 -0
- data/lib/origen/commands/time.rb +127 -0
- data/lib/origen/commands/version.rb +17 -0
- data/lib/origen/commands/web.rb +221 -0
- data/lib/origen/commands.rb +272 -0
- data/lib/origen/commands_global.rb +76 -0
- data/lib/origen/controller.rb +94 -0
- data/lib/origen/core_ext/array.rb +23 -0
- data/lib/origen/core_ext/bignum.rb +36 -0
- data/lib/origen/core_ext/enumerable.rb +76 -0
- data/lib/origen/core_ext/fixnum.rb +46 -0
- data/lib/origen/core_ext/hash.rb +52 -0
- data/lib/origen/core_ext/module.rb +14 -0
- data/lib/origen/core_ext/numeric.rb +126 -0
- data/lib/origen/core_ext/object.rb +13 -0
- data/lib/origen/core_ext/range.rb +7 -0
- data/lib/origen/core_ext/string.rb +124 -0
- data/lib/origen/core_ext.rb +10 -0
- data/lib/origen/database/key_value_store.rb +111 -0
- data/lib/origen/database/key_value_stores.rb +108 -0
- data/lib/origen/database.rb +6 -0
- data/lib/origen/encodings.rb +102 -0
- data/lib/origen/features/feature.rb +22 -0
- data/lib/origen/features.rb +104 -0
- data/lib/origen/file_handler.rb +429 -0
- data/lib/origen/generator/comparator.rb +56 -0
- data/lib/origen/generator/compiler.rb +277 -0
- data/lib/origen/generator/flow.rb +49 -0
- data/lib/origen/generator/job.rb +131 -0
- data/lib/origen/generator/pattern.rb +356 -0
- data/lib/origen/generator/pattern_finder.rb +155 -0
- data/lib/origen/generator/pattern_iterator.rb +55 -0
- data/lib/origen/generator/renderer.rb +113 -0
- data/lib/origen/generator/resources.rb +40 -0
- data/lib/origen/generator/stage.rb +89 -0
- data/lib/origen/generator.rb +85 -0
- data/lib/origen/global_methods.rb +205 -0
- data/lib/origen/import_manager.rb +596 -0
- data/lib/origen/location/base.rb +116 -0
- data/lib/origen/location/map.rb +83 -0
- data/lib/origen/location.rb +6 -0
- data/lib/origen/log.rb +217 -0
- data/lib/origen/logger_methods.rb +56 -0
- data/lib/origen/mode.rb +61 -0
- data/lib/origen/model.rb +267 -0
- data/lib/origen/model_initializer.rb +45 -0
- data/lib/origen/nvm/block_array.rb +72 -0
- data/lib/origen/nvm.rb +6 -0
- data/lib/origen/parameters/live.rb +22 -0
- data/lib/origen/parameters/missing.rb +28 -0
- data/lib/origen/parameters/set.rb +144 -0
- data/lib/origen/parameters.rb +107 -0
- data/lib/origen/pdm.rb +218 -0
- data/lib/origen/pins/function_proxy.rb +36 -0
- data/lib/origen/pins/ground_pin.rb +6 -0
- data/lib/origen/pins/pin.rb +860 -0
- data/lib/origen/pins/pin_bank.rb +349 -0
- data/lib/origen/pins/pin_clock.rb +124 -0
- data/lib/origen/pins/pin_collection.rb +492 -0
- data/lib/origen/pins/pin_common.rb +206 -0
- data/lib/origen/pins/port.rb +268 -0
- data/lib/origen/pins/power_pin.rb +30 -0
- data/lib/origen/pins.rb +696 -0
- data/lib/origen/registers/bit.rb +562 -0
- data/lib/origen/registers/bit_collection.rb +787 -0
- data/lib/origen/registers/container.rb +288 -0
- data/lib/origen/registers/domain.rb +16 -0
- data/lib/origen/registers/reg.rb +1406 -0
- data/lib/origen/registers/reg_collection.rb +24 -0
- data/lib/origen/registers.rb +652 -0
- data/lib/origen/regression_manager.rb +251 -0
- data/lib/origen/remote_manager.rb +340 -0
- data/lib/origen/revision_control/base.rb +257 -0
- data/lib/origen/revision_control/design_sync.rb +276 -0
- data/lib/origen/revision_control/git.rb +243 -0
- data/lib/origen/revision_control/subversion.rb +6 -0
- data/lib/origen/revision_control.rb +44 -0
- data/lib/origen/ruby_version_check.rb +131 -0
- data/lib/origen/site_config.rb +61 -0
- data/lib/origen/specs/checkers.rb +103 -0
- data/lib/origen/specs/creation_info.rb +17 -0
- data/lib/origen/specs/doc_resource.rb +91 -0
- data/lib/origen/specs/exhibit.rb +17 -0
- data/lib/origen/specs/mode_select.rb +16 -0
- data/lib/origen/specs/note.rb +17 -0
- data/lib/origen/specs/override.rb +21 -0
- data/lib/origen/specs/power_supply.rb +13 -0
- data/lib/origen/specs/spec.rb +226 -0
- data/lib/origen/specs/version_history.rb +14 -0
- data/lib/origen/specs.rb +552 -0
- data/lib/origen/sub_blocks.rb +298 -0
- data/lib/origen/tester/api.rb +277 -0
- data/lib/origen/tester/bdm/bdm.rb +25 -0
- data/lib/origen/tester/command_based_tester.rb +46 -0
- data/lib/origen/tester/doc/doc.rb +226 -0
- data/lib/origen/tester/doc/generator/flow.rb +71 -0
- data/lib/origen/tester/doc/generator/flow_line.rb +203 -0
- data/lib/origen/tester/doc/generator/test.rb +68 -0
- data/lib/origen/tester/doc/generator/test_group.rb +66 -0
- data/lib/origen/tester/doc/generator/tests.rb +47 -0
- data/lib/origen/tester/doc/generator.rb +126 -0
- data/lib/origen/tester/doc/model.rb +162 -0
- data/lib/origen/tester/generator/flow_control_api.rb +606 -0
- data/lib/origen/tester/generator/identity_map.rb +25 -0
- data/lib/origen/tester/generator/placeholder.rb +13 -0
- data/lib/origen/tester/generator/test_numberer.rb +25 -0
- data/lib/origen/tester/generator.rb +271 -0
- data/lib/origen/tester/interface.rb +154 -0
- data/lib/origen/tester/j750/files.rb +45 -0
- data/lib/origen/tester/j750/generator/flow.rb +123 -0
- data/lib/origen/tester/j750/generator/flow_line.rb +288 -0
- data/lib/origen/tester/j750/generator/patgroup.rb +111 -0
- data/lib/origen/tester/j750/generator/patgroups.rb +41 -0
- data/lib/origen/tester/j750/generator/patset.rb +111 -0
- data/lib/origen/tester/j750/generator/patsets.rb +41 -0
- data/lib/origen/tester/j750/generator/templates/flow.txt.erb +9 -0
- data/lib/origen/tester/j750/generator/templates/instances.txt.erb +16 -0
- data/lib/origen/tester/j750/generator/templates/patgroups.txt.erb +8 -0
- data/lib/origen/tester/j750/generator/templates/patsets.txt.erb +10 -0
- data/lib/origen/tester/j750/generator/test_instance.rb +846 -0
- data/lib/origen/tester/j750/generator/test_instance_group.rb +60 -0
- data/lib/origen/tester/j750/generator/test_instances.rb +182 -0
- data/lib/origen/tester/j750/generator.rb +203 -0
- data/lib/origen/tester/j750/j750.rb +845 -0
- data/lib/origen/tester/j750/j750_hpt.rb +35 -0
- data/lib/origen/tester/j750/parser/ac_spec.rb +11 -0
- data/lib/origen/tester/j750/parser/ac_specs.rb +0 -0
- data/lib/origen/tester/j750/parser/dc_spec.rb +36 -0
- data/lib/origen/tester/j750/parser/dc_specs.rb +50 -0
- data/lib/origen/tester/j750/parser/descriptions.rb +340 -0
- data/lib/origen/tester/j750/parser/flow.rb +111 -0
- data/lib/origen/tester/j750/parser/flow_line.rb +207 -0
- data/lib/origen/tester/j750/parser/flows.rb +23 -0
- data/lib/origen/tester/j750/parser/pattern_set.rb +94 -0
- data/lib/origen/tester/j750/parser/pattern_sets.rb +33 -0
- data/lib/origen/tester/j750/parser/test_instance.rb +322 -0
- data/lib/origen/tester/j750/parser/test_instances.rb +26 -0
- data/lib/origen/tester/j750/parser/timeset.rb +15 -0
- data/lib/origen/tester/j750/parser/timesets.rb +0 -0
- data/lib/origen/tester/j750/parser.rb +104 -0
- data/lib/origen/tester/jlink/jlink.rb +33 -0
- data/lib/origen/tester/parser/description_lookup.rb +64 -0
- data/lib/origen/tester/parser/searchable_array.rb +32 -0
- data/lib/origen/tester/parser/searchable_hash.rb +32 -0
- data/lib/origen/tester/parser.rb +24 -0
- data/lib/origen/tester/time.rb +338 -0
- data/lib/origen/tester/timing.rb +253 -0
- data/lib/origen/tester/ultraflex/files.rb +45 -0
- data/lib/origen/tester/ultraflex/generator/flow.rb +119 -0
- data/lib/origen/tester/ultraflex/generator/flow_line.rb +269 -0
- data/lib/origen/tester/ultraflex/generator/patgroup.rb +111 -0
- data/lib/origen/tester/ultraflex/generator/patgroups.rb +41 -0
- data/lib/origen/tester/ultraflex/generator/patset.rb +111 -0
- data/lib/origen/tester/ultraflex/generator/patsets.rb +41 -0
- data/lib/origen/tester/ultraflex/generator/templates/flow.txt.erb +9 -0
- data/lib/origen/tester/ultraflex/generator/templates/instances.txt.erb +16 -0
- data/lib/origen/tester/ultraflex/generator/templates/patgroups.txt.erb +8 -0
- data/lib/origen/tester/ultraflex/generator/templates/patsets.txt.erb +10 -0
- data/lib/origen/tester/ultraflex/generator/test_instance.rb +622 -0
- data/lib/origen/tester/ultraflex/generator/test_instance_group.rb +60 -0
- data/lib/origen/tester/ultraflex/generator/test_instances.rb +174 -0
- data/lib/origen/tester/ultraflex/generator.rb +200 -0
- data/lib/origen/tester/ultraflex/parser/ac_spec.rb +11 -0
- data/lib/origen/tester/ultraflex/parser/ac_specs.rb +0 -0
- data/lib/origen/tester/ultraflex/parser/dc_spec.rb +36 -0
- data/lib/origen/tester/ultraflex/parser/dc_specs.rb +50 -0
- data/lib/origen/tester/ultraflex/parser/descriptions.rb +342 -0
- data/lib/origen/tester/ultraflex/parser/flow.rb +111 -0
- data/lib/origen/tester/ultraflex/parser/flow_line.rb +207 -0
- data/lib/origen/tester/ultraflex/parser/flows.rb +23 -0
- data/lib/origen/tester/ultraflex/parser/pattern_set.rb +94 -0
- data/lib/origen/tester/ultraflex/parser/pattern_sets.rb +33 -0
- data/lib/origen/tester/ultraflex/parser/test_instance.rb +262 -0
- data/lib/origen/tester/ultraflex/parser/test_instances.rb +26 -0
- data/lib/origen/tester/ultraflex/parser/timeset.rb +15 -0
- data/lib/origen/tester/ultraflex/parser/timesets.rb +0 -0
- data/lib/origen/tester/ultraflex/parser.rb +104 -0
- data/lib/origen/tester/ultraflex/ultraflex.rb +759 -0
- data/lib/origen/tester/v93k/generator/flow.rb +63 -0
- data/lib/origen/tester/v93k/generator/flow_node/print.rb +10 -0
- data/lib/origen/tester/v93k/generator/flow_node.rb +17 -0
- data/lib/origen/tester/v93k/generator/pattern.rb +16 -0
- data/lib/origen/tester/v93k/generator/pattern_master.rb +54 -0
- data/lib/origen/tester/v93k/generator/templates/_test_method.txt.erb +6 -0
- data/lib/origen/tester/v93k/generator/templates/_test_suite.txt.erb +11 -0
- data/lib/origen/tester/v93k/generator/templates/template.flow.erb +121 -0
- data/lib/origen/tester/v93k/generator/templates/template.pmfl.erb +9 -0
- data/lib/origen/tester/v93k/generator/test_function.rb +103 -0
- data/lib/origen/tester/v93k/generator/test_functions.rb +79 -0
- data/lib/origen/tester/v93k/generator/test_method.rb +46 -0
- data/lib/origen/tester/v93k/generator/test_methods.rb +75 -0
- data/lib/origen/tester/v93k/generator/test_suite.rb +54 -0
- data/lib/origen/tester/v93k/generator/test_suites.rb +65 -0
- data/lib/origen/tester/v93k/generator.rb +80 -0
- data/lib/origen/tester/v93k/v93k.rb +420 -0
- data/lib/origen/tester/vector.rb +86 -0
- data/lib/origen/tester/vector_generator.rb +633 -0
- data/lib/origen/tester/vector_pipeline.rb +150 -0
- data/lib/origen/tester.rb +56 -0
- data/lib/origen/top_level.rb +134 -0
- data/lib/origen/users/ldap.rb +65 -0
- data/lib/origen/users/user.rb +149 -0
- data/lib/origen/users.rb +30 -0
- data/lib/origen/utility/block_args.rb +93 -0
- data/lib/origen/utility/csv_data.rb +110 -0
- data/lib/origen/utility/design_sync.rb +494 -0
- data/lib/origen/utility/diff.rb +158 -0
- data/lib/origen/utility/input_capture.rb +121 -0
- data/lib/origen/utility/mailer.rb +143 -0
- data/lib/origen/utility/s_record.rb +205 -0
- data/lib/origen/utility/time_and_date.rb +30 -0
- data/lib/origen/utility.rb +12 -0
- data/lib/origen/version_checker.rb +117 -0
- data/lib/origen/version_string.rb +356 -0
- data/lib/origen.rb +648 -0
- data/lib/tasks/gem.rake +27 -22
- data/origen_site_config.yml +36 -0
- data/source_setup +17 -0
- data/spec/format/rgen_formatter.rb +14 -0
- data/templates/api_doc/README.txt.erb +24 -0
- data/templates/code_generators/gemfile_app.rb +4 -0
- data/templates/code_generators/gemfile_plugin.rb +6 -0
- data/templates/code_generators/gemspec.rb +33 -0
- data/templates/code_generators/rakefile.rb +10 -0
- data/templates/code_generators/spec_helper.rb +49 -0
- data/templates/code_generators/version.rb +8 -0
- data/templates/code_generators/version_time.rb +3 -0
- data/templates/git/gitignore.erb +33 -0
- data/templates/j750/_vt_flow.txt.erb +8 -0
- data/templates/j750/_vt_instances.txt.erb +4 -0
- data/templates/j750/program_sheet.txt.erb +9 -0
- data/templates/nanoc/Rules +74 -0
- data/templates/nanoc/config.yaml +77 -0
- data/templates/nanoc/content/favicon.ico +0 -0
- data/templates/nanoc/layouts/bootstrap.html.erb +63 -0
- data/templates/nanoc/layouts/bootstrap3.html.erb +71 -0
- data/templates/nanoc/layouts/freescale.html.erb +79 -0
- data/templates/nanoc/lib/bootstrap_filter.rb +49 -0
- data/templates/nanoc/lib/codeblocks_filter.rb +41 -0
- data/templates/nanoc/lib/default.rb +2 -0
- data/templates/nanoc/lib/gzip_filter.rb +16 -0
- data/templates/nanoc/lib/haml_code_filter.rb +41 -0
- data/templates/nanoc/lib/helpers.rb +1 -0
- data/templates/nanoc/lib/search_filter.rb +62 -0
- data/templates/nanoc_dynamic/content/search.js.erb +92 -0
- data/templates/shared/web/_logo.html +10 -0
- data/templates/test/_inline_sub.txt.erb +2 -0
- data/templates/test/environment.txt.erb +1 -0
- data/templates/test/inline.txt.erb +11 -0
- data/templates/test/inspections.txt.erb +19 -0
- data/templates/test/set1/_sub1.txt.erb +12 -0
- data/templates/test/set1/_sub4.txt.erb +1 -0
- data/templates/test/set1/_sub5.txt.erb +1 -0
- data/templates/test/set1/main.txt.erb +53 -0
- data/templates/test/set1/sub_dir/_sub2.txt.erb +20 -0
- data/templates/test/set1/sub_dir/_sub3.txt.erb +12 -0
- data/templates/test/set1/sub_dir/main2.txt.erb +4 -0
- data/templates/test/set2/template_with_no_erb_1.txt +9 -0
- data/templates/test/set2/template_with_no_erb_2.txt +9 -0
- data/templates/test/set3/_layout.html.erb +4 -0
- data/templates/test/set3/content.html.erb +6 -0
- data/templates/time/filter.rb.erb +15 -0
- data/templates/time/rules.rb.erb +45 -0
- metadata +639 -5
@@ -0,0 +1,83 @@
|
|
1
|
+
require 'active_support/concern'
|
2
|
+
module Origen
|
3
|
+
module Location
|
4
|
+
module Map
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
|
7
|
+
module ClassMethods
|
8
|
+
def define_locations(defaults = {})
|
9
|
+
@x = @x ? (@x + 1) : 0 # Provides a unique ID for each define_locations block
|
10
|
+
default_attributes[@x] = defaults
|
11
|
+
@defining = true
|
12
|
+
yield
|
13
|
+
@defining = false
|
14
|
+
end
|
15
|
+
|
16
|
+
def constructor(&block)
|
17
|
+
if defining?
|
18
|
+
constructors[@x] = block
|
19
|
+
else
|
20
|
+
constructors[:default] = block
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def default_constructor(attributes, defaults)
|
25
|
+
Origen::Location::Base.new(defaults.merge(attributes))
|
26
|
+
end
|
27
|
+
|
28
|
+
def definitions
|
29
|
+
@definitions ||= {}
|
30
|
+
end
|
31
|
+
|
32
|
+
def constructors
|
33
|
+
@constructors ||= {}
|
34
|
+
end
|
35
|
+
|
36
|
+
def default_attributes
|
37
|
+
@default_attributes ||= {}
|
38
|
+
end
|
39
|
+
|
40
|
+
def defining?
|
41
|
+
@defining
|
42
|
+
end
|
43
|
+
|
44
|
+
# A hash of constructed location objects, i.e. an entry will be cached here the first time a location
|
45
|
+
# is referenced outside of its initial definition, after that it will be served directly from here.
|
46
|
+
def constructed
|
47
|
+
@constructed ||= {}
|
48
|
+
end
|
49
|
+
|
50
|
+
# Provides accessors for all named locations, for example:
|
51
|
+
#
|
52
|
+
# $dut.nvm.fmu.ifr_map.probe1_pass
|
53
|
+
def method_missing(method, *args, &block)
|
54
|
+
if defining?
|
55
|
+
if definitions[method]
|
56
|
+
warning "Redefinition of map location: #{method}"
|
57
|
+
end
|
58
|
+
definitions[method] = { attributes: args.first, x: @x }
|
59
|
+
else
|
60
|
+
super
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def method_missing(method, *args, &block)
|
66
|
+
klass = self.class
|
67
|
+
klass.constructed[method] || begin
|
68
|
+
definition = klass.definitions[method]
|
69
|
+
if definition
|
70
|
+
defaults = klass.default_attributes[definition[:x]] || {}
|
71
|
+
constructor = klass.constructors[definition[:x]] || klass.constructors[:default]
|
72
|
+
if constructor
|
73
|
+
instance = constructor.call(definition[:attributes], defaults)
|
74
|
+
else
|
75
|
+
instance = klass.default_constructor(definition[:attributes], defaults)
|
76
|
+
end
|
77
|
+
klass.constructed[method] = instance
|
78
|
+
end
|
79
|
+
end || super
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
data/lib/origen/log.rb
ADDED
@@ -0,0 +1,217 @@
|
|
1
|
+
module Origen
|
2
|
+
# An instance of this class is instantiated as Origen.log and provides the following API
|
3
|
+
#
|
4
|
+
# @example
|
5
|
+
# log.error "Blah" # Error message, always shown
|
6
|
+
# log.debug "Blah" # Debug message, only shown when in verbose mode
|
7
|
+
# log.info "Blah" # Info message, always shown
|
8
|
+
# log.warn "Blah" # Warning message, always shown
|
9
|
+
# log.deprecate "Blah" # Deprecate message, always shown
|
10
|
+
class Log
|
11
|
+
require 'colored'
|
12
|
+
require 'log4r'
|
13
|
+
require 'log4r/outputter/fileoutputter'
|
14
|
+
|
15
|
+
LEVELS = [:normal, :verbose, :silent]
|
16
|
+
|
17
|
+
def initialize
|
18
|
+
@log_time_0 = @t0 = Time.new
|
19
|
+
self.level = :normal
|
20
|
+
end
|
21
|
+
|
22
|
+
def console_only?
|
23
|
+
self.class.console_only? || !Origen.app
|
24
|
+
end
|
25
|
+
|
26
|
+
# Anything executed within the given block will log to the console only
|
27
|
+
#
|
28
|
+
# @example
|
29
|
+
#
|
30
|
+
# Origen::Log.console_only do
|
31
|
+
# Origen.log.info "This will not appear in the log file!"
|
32
|
+
# end
|
33
|
+
def self.console_only
|
34
|
+
@console_only = true
|
35
|
+
yield
|
36
|
+
@console_only = false
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.console_only=(val)
|
40
|
+
@console_only = val
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.console_only?
|
44
|
+
@console_only
|
45
|
+
end
|
46
|
+
|
47
|
+
# Set the logger level, for valid values see LEVELS
|
48
|
+
def level=(val)
|
49
|
+
unless LEVELS.include?(val)
|
50
|
+
fail "Unknown log level, valid values are: #{LEVELS}"
|
51
|
+
end
|
52
|
+
# Map the log4r levels to our simplified 3 level system
|
53
|
+
# log4r level order is DEBUG < INFO < WARN < ERROR < FATAL
|
54
|
+
case val
|
55
|
+
when :normal
|
56
|
+
# Output everything except debug statements
|
57
|
+
console.level = Log4r::INFO
|
58
|
+
# Output everything
|
59
|
+
log_files.level = Log4r::DEBUG unless console_only?
|
60
|
+
when :verbose
|
61
|
+
console.level = Log4r::DEBUG
|
62
|
+
log_files.level = Log4r::DEBUG unless console_only?
|
63
|
+
when :silent
|
64
|
+
# We don't use any fatal messages, so this is effectively OFF
|
65
|
+
console.level = Log4r::FATAL
|
66
|
+
log_files.level = Log4r::DEBUG unless console_only?
|
67
|
+
end
|
68
|
+
|
69
|
+
@level = val
|
70
|
+
end
|
71
|
+
|
72
|
+
# Returns the current logger level
|
73
|
+
def level
|
74
|
+
@level
|
75
|
+
end
|
76
|
+
|
77
|
+
def debug(string = '')
|
78
|
+
msg = format_msg('DEBUG', string)
|
79
|
+
log_files.debug msg unless console_only?
|
80
|
+
console.debug msg
|
81
|
+
nil
|
82
|
+
end
|
83
|
+
|
84
|
+
def info(string = '')
|
85
|
+
msg = format_msg('INFO', string)
|
86
|
+
log_files.info msg unless console_only?
|
87
|
+
console.info msg
|
88
|
+
nil
|
89
|
+
end
|
90
|
+
# Legacy methods
|
91
|
+
alias_method :lputs, :info
|
92
|
+
alias_method :lprint, :info
|
93
|
+
|
94
|
+
def success(string = '')
|
95
|
+
msg = format_msg('SUCCESS', string)
|
96
|
+
log_files.info msg unless console_only?
|
97
|
+
console.info msg.green
|
98
|
+
nil
|
99
|
+
end
|
100
|
+
|
101
|
+
def deprecate(string = '')
|
102
|
+
msg = format_msg('DEPRECATED', string)
|
103
|
+
log_files.warn msg unless console_only?
|
104
|
+
console.warn msg.yellow
|
105
|
+
nil
|
106
|
+
end
|
107
|
+
alias_method :deprecated, :deprecate
|
108
|
+
|
109
|
+
def warn(string = '')
|
110
|
+
msg = format_msg('WARNING', string)
|
111
|
+
log_files.warn msg unless console_only?
|
112
|
+
console.warn msg.yellow
|
113
|
+
nil
|
114
|
+
end
|
115
|
+
alias_method :warning, :warn
|
116
|
+
|
117
|
+
def error(string = '')
|
118
|
+
msg = format_msg('ERROR', string)
|
119
|
+
log_files.error msg unless console_only?
|
120
|
+
console.error msg.red
|
121
|
+
nil
|
122
|
+
end
|
123
|
+
|
124
|
+
# Made these all class methods so that they can be read without
|
125
|
+
# instantiating a new logger (mainly for use by the origen save command)
|
126
|
+
def self.log_file
|
127
|
+
"#{log_file_directory}/last.txt"
|
128
|
+
end
|
129
|
+
|
130
|
+
def self.rolling_log_file
|
131
|
+
"#{log_file_directory}/rolling.txt"
|
132
|
+
end
|
133
|
+
|
134
|
+
def self.log_file_directory
|
135
|
+
@log_file_directory ||= begin
|
136
|
+
dir = Origen.config.log_directory
|
137
|
+
FileUtils.mkdir_p dir unless File.exist?(dir)
|
138
|
+
dir
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
def silent?
|
143
|
+
level == :silent
|
144
|
+
end
|
145
|
+
|
146
|
+
def verbose?
|
147
|
+
level == :verbose
|
148
|
+
end
|
149
|
+
|
150
|
+
# Force logger to write any buffered output
|
151
|
+
def flush
|
152
|
+
if Origen.app
|
153
|
+
log_files.outputters.each(&:flush)
|
154
|
+
end
|
155
|
+
console.outputters.each(&:flush)
|
156
|
+
end
|
157
|
+
|
158
|
+
private
|
159
|
+
|
160
|
+
# Returns a Log4r instance that will send to the console
|
161
|
+
def console
|
162
|
+
@console ||= begin
|
163
|
+
console = Log4r::Logger.new 'console'
|
164
|
+
# console.level = QUIET
|
165
|
+
out = Log4r::Outputter.stdout
|
166
|
+
out.formatter = format
|
167
|
+
console.outputters << out
|
168
|
+
console
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
# Returns a Log4r instance that will send to the log files
|
173
|
+
def log_files
|
174
|
+
@log_files ||= begin
|
175
|
+
log_files = Log4r::Logger.new 'log_files'
|
176
|
+
# log_files.level = QUIET
|
177
|
+
file = Log4r::FileOutputter.new('fileOutputter', filename: self.class.log_file, trunc: true)
|
178
|
+
file.formatter = format
|
179
|
+
log_files.outputters << file
|
180
|
+
unless Origen.running_remotely?
|
181
|
+
rolling_file = Log4r::RollingFileOutputter.new('rollingfileOutputter', filename: self.class.rolling_log_file, trunc: false, maxsize: 5_242_880, max_backups: 10)
|
182
|
+
rolling_file.formatter = format
|
183
|
+
log_files.outputters << rolling_file
|
184
|
+
end
|
185
|
+
log_files
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
def relog(msg)
|
190
|
+
if msg =~ /^\[(\w+)\] .*/
|
191
|
+
method = Regexp.last_match(1).downcase
|
192
|
+
if respond_to?(method)
|
193
|
+
send method, msg.sub(/.*\|\|\s*/, '')
|
194
|
+
else
|
195
|
+
info msg
|
196
|
+
end
|
197
|
+
else
|
198
|
+
info msg
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
202
|
+
def format_msg(type, msg)
|
203
|
+
log_time_1 = Time.new
|
204
|
+
delta_t = (log_time_1.to_f - @log_time_0.to_f).round(6)
|
205
|
+
delta_t = '%0.3f' % delta_t
|
206
|
+
delta_t0 = (log_time_1.to_f - @t0.to_f).round(6)
|
207
|
+
delta_t0 = '%0.3f' % delta_t0
|
208
|
+
msg = "[#{type}]".ljust(13) + "#{delta_t0}[#{delta_t}]".ljust(16) + "|| #{msg}"
|
209
|
+
@log_time_0 = log_time_1
|
210
|
+
msg
|
211
|
+
end
|
212
|
+
|
213
|
+
def format
|
214
|
+
Log4r::PatternFormatter.new(pattern: '%m')
|
215
|
+
end
|
216
|
+
end
|
217
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
module Origen
|
2
|
+
module LoggerMethods
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do |klass|
|
6
|
+
Origen.deprecate <<-END
|
7
|
+
The LoggerMethods module is deprecated, use Origen.log instead (or just
|
8
|
+
log from within a class that includes Origen::Model). See here for the new API:
|
9
|
+
http://origen.freescale.net/origen/latest/guides/utilities/logger/
|
10
|
+
Called from the #{klass} class.
|
11
|
+
END
|
12
|
+
end
|
13
|
+
|
14
|
+
def log
|
15
|
+
@log ||= Origen.log
|
16
|
+
end
|
17
|
+
|
18
|
+
def lputs(*args)
|
19
|
+
Origen.log.lputs(*args)
|
20
|
+
end
|
21
|
+
alias_method :lprint, :lputs
|
22
|
+
|
23
|
+
def warn(*args)
|
24
|
+
options = args.last.is_a?(Hash) ? args.pop : {}
|
25
|
+
args.each { |arg| Origen.log.warn arg }
|
26
|
+
end
|
27
|
+
alias_method :warning, :warn
|
28
|
+
|
29
|
+
def error(*args)
|
30
|
+
options = args.last.is_a?(Hash) ? args.pop : {}
|
31
|
+
args.each { |arg| Origen.log.error arg }
|
32
|
+
end
|
33
|
+
|
34
|
+
def alert(*args)
|
35
|
+
options = args.last.is_a?(Hash) ? args.pop : {}
|
36
|
+
args.each { |arg| Origen.log.warn arg }
|
37
|
+
end
|
38
|
+
|
39
|
+
def deprecated(*lines)
|
40
|
+
options = lines.last.is_a?(Hash) ? lines.pop : {}
|
41
|
+
lines.flatten.each do |line|
|
42
|
+
line.split(/\n/).each do |line|
|
43
|
+
Origen.log.deprecate line
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def highlight
|
49
|
+
lputs ''
|
50
|
+
lputs '######################################################################'
|
51
|
+
yield
|
52
|
+
lputs '######################################################################'
|
53
|
+
lputs ''
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
data/lib/origen/mode.rb
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
module Origen
|
2
|
+
# A class to handle the Origen execution mode
|
3
|
+
class Mode
|
4
|
+
MODES = [:production, :debug, :simulation]
|
5
|
+
|
6
|
+
def initialize(_options = {})
|
7
|
+
@current_mode = :production
|
8
|
+
end
|
9
|
+
|
10
|
+
# When called any future changes to the mode will be ignored
|
11
|
+
def freeze
|
12
|
+
@frozen = true
|
13
|
+
end
|
14
|
+
|
15
|
+
def unfreeze
|
16
|
+
@frozen = false
|
17
|
+
end
|
18
|
+
|
19
|
+
def set(val)
|
20
|
+
@current_mode = find_mode(val) unless @frozen
|
21
|
+
end
|
22
|
+
|
23
|
+
def find_mode(name)
|
24
|
+
name = name.to_s.downcase.to_sym
|
25
|
+
if MODES.include?(name)
|
26
|
+
name
|
27
|
+
else
|
28
|
+
mode = MODES.find do |m|
|
29
|
+
m.to_s =~ /^#{name}/
|
30
|
+
end
|
31
|
+
if mode
|
32
|
+
mode
|
33
|
+
else
|
34
|
+
fail "Invalid mode requested, must be one of: #{MODES}"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
# Any mode which is not production will return true here, if
|
40
|
+
# you want to test for only debug mode use Origen.mode == :debug
|
41
|
+
def debug?
|
42
|
+
!production?
|
43
|
+
end
|
44
|
+
|
45
|
+
def production?
|
46
|
+
@current_mode == :production
|
47
|
+
end
|
48
|
+
|
49
|
+
def simulation?
|
50
|
+
@current_mode == :simulation
|
51
|
+
end
|
52
|
+
|
53
|
+
def ==(val)
|
54
|
+
if val.is_a?(Symbol)
|
55
|
+
@current_mode == val
|
56
|
+
else
|
57
|
+
super
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
data/lib/origen/model.rb
ADDED
@@ -0,0 +1,267 @@
|
|
1
|
+
require 'active_support/concern'
|
2
|
+
module Origen
|
3
|
+
# Include this module to identify it as an SoC IP Block, this will automatically
|
4
|
+
# include common modules such as Pin and Register support
|
5
|
+
module Model
|
6
|
+
extend ActiveSupport::Concern
|
7
|
+
|
8
|
+
included do
|
9
|
+
attr_writer :ip_name
|
10
|
+
attr_accessor :version
|
11
|
+
attr_reader :controller
|
12
|
+
|
13
|
+
include Origen::ModelInitializer
|
14
|
+
include Origen::Pins
|
15
|
+
include Origen::Registers
|
16
|
+
include Origen::Callbacks
|
17
|
+
include Origen::Bugs
|
18
|
+
include Origen::Features
|
19
|
+
include Origen::SubBlocks
|
20
|
+
include Origen::Parameters
|
21
|
+
include Origen::Specs
|
22
|
+
end
|
23
|
+
|
24
|
+
module ClassMethods
|
25
|
+
def includes_origen_model
|
26
|
+
true
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def log
|
31
|
+
Origen.log
|
32
|
+
end
|
33
|
+
|
34
|
+
def write_memory(*args)
|
35
|
+
return super if defined?(super)
|
36
|
+
write_register(*args)
|
37
|
+
end
|
38
|
+
|
39
|
+
def read_memory(*args)
|
40
|
+
return super if defined?(super)
|
41
|
+
read_register(*args)
|
42
|
+
end
|
43
|
+
|
44
|
+
def ip_name
|
45
|
+
@ip_name || self.class.to_s.split('::').last.symbolize
|
46
|
+
end
|
47
|
+
|
48
|
+
def wrap_in_controller
|
49
|
+
c = Origen.controllers.find do |params|
|
50
|
+
self.is_a?(params[:model_class]) if params[:model_class]
|
51
|
+
end
|
52
|
+
if c
|
53
|
+
c = c[:controller_class].send(:allocate)
|
54
|
+
if c.method(:initialize).arity == 0
|
55
|
+
c.send(:initialize)
|
56
|
+
else
|
57
|
+
c.send(:initialize, self)
|
58
|
+
end
|
59
|
+
c.send('_model=', self)
|
60
|
+
@controller = c
|
61
|
+
c
|
62
|
+
else
|
63
|
+
controller_class = _resolve_controller_class
|
64
|
+
if controller_class
|
65
|
+
c = controller_class.send(:allocate)
|
66
|
+
if c.method(:initialize).arity == 0
|
67
|
+
c.send(:initialize)
|
68
|
+
else
|
69
|
+
c.send(:initialize, self)
|
70
|
+
end
|
71
|
+
c.extend(Origen::Controller)
|
72
|
+
c.send('_model=', self)
|
73
|
+
@controller = c
|
74
|
+
c
|
75
|
+
else
|
76
|
+
self
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def _resolve_controller_class
|
82
|
+
klass = self.class
|
83
|
+
while klass != Object
|
84
|
+
model_class = klass.to_s.split('::').last
|
85
|
+
controller_class = "#{model_class}Controller"
|
86
|
+
if eval("defined? #{controller_class}")
|
87
|
+
return eval(controller_class)
|
88
|
+
elsif eval("defined? ::#{controller_class}")
|
89
|
+
return eval("::#{controller_class}")
|
90
|
+
end
|
91
|
+
klass = klass.superclass
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
def current_configuration
|
96
|
+
if self.respond_to?(:configuration)
|
97
|
+
configuration
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
def configuration=(id)
|
102
|
+
add_configuration(id)
|
103
|
+
@configuration = id
|
104
|
+
end
|
105
|
+
|
106
|
+
def configuration
|
107
|
+
@configuration
|
108
|
+
end
|
109
|
+
|
110
|
+
def add_configuration(id)
|
111
|
+
configurations << id unless configurations.include?(id)
|
112
|
+
end
|
113
|
+
|
114
|
+
# Returns an array containing the IDs of all known configurations
|
115
|
+
def configurations
|
116
|
+
@configurations ||= []
|
117
|
+
end
|
118
|
+
|
119
|
+
# Execute the supplied block within the context of the given configuration, at the end
|
120
|
+
# the model's configuration attribute will be restored to what it was before calling
|
121
|
+
# this method.
|
122
|
+
def with_configuration(id, _options = {})
|
123
|
+
orig = configuration
|
124
|
+
self.configuration = id
|
125
|
+
yield
|
126
|
+
self.configuration = orig
|
127
|
+
end
|
128
|
+
|
129
|
+
# Returns the current mode/configuration of the top level SoC. If no mode has been specified
|
130
|
+
# yet this will return nil
|
131
|
+
#
|
132
|
+
# $dut = DUT.new
|
133
|
+
# $dut.mode # => default
|
134
|
+
# $dut.mode.default? # => true
|
135
|
+
# $dut.mode.ram_bist? # => false
|
136
|
+
# $dut.mode = :ram_bist
|
137
|
+
# $dut.mode.default? # => false
|
138
|
+
# $dut.mode.ram_bist? # => true
|
139
|
+
def current_mode
|
140
|
+
if @current_mode
|
141
|
+
return _modes[@current_mode] if _modes[@current_mode]
|
142
|
+
fail "The mode #{@current_mode} of #{self.class} has not been defined!"
|
143
|
+
end
|
144
|
+
end
|
145
|
+
alias_method :mode, :current_mode
|
146
|
+
|
147
|
+
# Set the current mode configuration of the current model
|
148
|
+
def current_mode=(id)
|
149
|
+
@current_mode = id.is_a?(ChipMode) ? id.id : id
|
150
|
+
end
|
151
|
+
alias_method :mode=, :current_mode=
|
152
|
+
|
153
|
+
def add_mode(id, options = {})
|
154
|
+
m = ChipMode.new(id, options)
|
155
|
+
m.owner = self
|
156
|
+
yield m if block_given?
|
157
|
+
_add_mode(m)
|
158
|
+
m
|
159
|
+
end
|
160
|
+
|
161
|
+
def has_mode?(id)
|
162
|
+
!!(_modes[id.is_a?(ChipMode) ? id.id : id])
|
163
|
+
end
|
164
|
+
|
165
|
+
# Returns an array containing the IDs of all known modes if no ID is supplied,
|
166
|
+
# otherwise returns an object representing the given mode ID
|
167
|
+
def modes(id = nil, _options = {})
|
168
|
+
id = nil if id.is_a?(Hash)
|
169
|
+
if id
|
170
|
+
_modes[id]
|
171
|
+
else
|
172
|
+
_modes.ids
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
# Executes the given block of code within the context of the given mode, at the end
|
177
|
+
# the mode will be restored back to what it was on entry
|
178
|
+
def with_mode(id, _options = {})
|
179
|
+
orig = mode
|
180
|
+
self.mode = id
|
181
|
+
yield
|
182
|
+
self.mode = orig
|
183
|
+
end
|
184
|
+
|
185
|
+
# Executes the given block of code for each known chip mode, inside the block
|
186
|
+
# the current mode of the top level block will be set to the given mode.
|
187
|
+
#
|
188
|
+
# At the end of the block the current mode will be restored to whatever it
|
189
|
+
# was before entering the block.
|
190
|
+
def with_each_mode
|
191
|
+
begin
|
192
|
+
orig = current_mode
|
193
|
+
rescue
|
194
|
+
orig = nil
|
195
|
+
end
|
196
|
+
modes.each do |_id, mode|
|
197
|
+
self.current_mode = mode
|
198
|
+
yield mode
|
199
|
+
end
|
200
|
+
self.current_mode = orig
|
201
|
+
end
|
202
|
+
alias_method :each_mode, :with_each_mode
|
203
|
+
|
204
|
+
# Sets the modes array to nil. Written so modes created in memory can
|
205
|
+
# be erased so modes defined in Ruby files can be loaded
|
206
|
+
def delete_all_modes
|
207
|
+
@_modes = nil
|
208
|
+
end
|
209
|
+
alias_method :del_all_modes, :delete_all_modes
|
210
|
+
|
211
|
+
# Returns all specs found for the model. if none found it returns an empty array
|
212
|
+
def find_specs
|
213
|
+
specs_found = []
|
214
|
+
# Check for specs the object owns
|
215
|
+
if self.respond_to? :specs
|
216
|
+
object_specs = specs
|
217
|
+
unless object_specs.nil?
|
218
|
+
if object_specs.class == Origen::Specs::Spec
|
219
|
+
specs_found << object_specs
|
220
|
+
else
|
221
|
+
specs_found.concat(object_specs)
|
222
|
+
end
|
223
|
+
end
|
224
|
+
end
|
225
|
+
sub_blocks.each do |_name, sb|
|
226
|
+
next unless sb.respond_to? :specs
|
227
|
+
child_specs = sb.specs
|
228
|
+
unless child_specs.nil?
|
229
|
+
if child_specs.class == Origen::Specs::Spec
|
230
|
+
specs_found << child_specs
|
231
|
+
else
|
232
|
+
specs_found.concat(child_specs)
|
233
|
+
end
|
234
|
+
end
|
235
|
+
end
|
236
|
+
specs_found
|
237
|
+
end
|
238
|
+
|
239
|
+
# Delete all specs and notes for self recursively
|
240
|
+
def delete_all_specs_and_notes(obj = nil)
|
241
|
+
obj = self if obj.nil?
|
242
|
+
obj.delete_all_specs
|
243
|
+
obj.delete_all_notes
|
244
|
+
obj.delete_all_exhibits
|
245
|
+
obj.children.each do |_name, child|
|
246
|
+
next unless child.has_specs?
|
247
|
+
delete_all_specs_and_notes(child)
|
248
|
+
end
|
249
|
+
end
|
250
|
+
|
251
|
+
private
|
252
|
+
|
253
|
+
def _modes
|
254
|
+
@_modes ||= {}
|
255
|
+
end
|
256
|
+
|
257
|
+
def _add_mode(mode)
|
258
|
+
if _modes[mode.id]
|
259
|
+
fail "There is already a mode called #{mode.id}!"
|
260
|
+
else
|
261
|
+
_modes[mode.id] = mode
|
262
|
+
end
|
263
|
+
end
|
264
|
+
end
|
265
|
+
# Legacy API
|
266
|
+
IPBlock = Model
|
267
|
+
end
|