Module: Origen
- Extended by:
- Utility::TimeAndDate
- Defined in:
- lib/origen/boot/api.rb,
lib/origen.rb,
lib/origen/log.rb,
lib/origen/bugs.rb,
lib/origen/mode.rb,
lib/origen/pins.rb,
lib/origen/chips.rb,
lib/origen/fuses.rb,
lib/origen/model.rb,
lib/origen/ports.rb,
lib/origen/specs.rb,
lib/origen/tests.rb,
lib/origen/users.rb,
lib/origen/value.rb,
lib/origen/client.rb,
lib/origen/clocks.rb,
lib/origen/errata.rb,
lib/origen/limits.rb,
lib/origen/loader.rb,
lib/origen/memory.rb,
lib/origen/models.rb,
lib/origen/netlist.rb,
lib/origen/utility.rb,
lib/origen/boot/app.rb,
lib/origen/bugs/bug.rb,
lib/origen/database.rb,
lib/origen/features.rb,
lib/origen/location.rb,
lib/origen/org_file.rb,
lib/origen/pins/pin.rb,
lib/origen/callbacks.rb,
lib/origen/chip_mode.rb,
lib/origen/encodings.rb,
lib/origen/generator.rb,
lib/origen/registers.rb,
lib/origen/top_level.rb,
lib/origen/undefined.rb,
lib/origen/chips/chip.rb,
lib/origen/chips/note.rb,
lib/origen/components.rb,
lib/origen/controller.rb,
lib/origen/models/mux.rb,
lib/origen/parameters.rb,
lib/origen/ports/port.rb,
lib/origen/specs/note.rb,
lib/origen/specs/spec.rb,
lib/origen/sub_blocks.rb,
lib/origen/tests/test.rb,
lib/origen/users/ldap.rb,
lib/origen/users/user.rb,
lib/origen/application.rb,
lib/origen/commands/rc.rb,
lib/origen/pins/timing.rb,
lib/origen/site_config.rb,
lib/origen/chip_package.rb,
lib/origen/clocks/clock.rb,
lib/origen/commands/web.rb,
lib/origen/file_handler.rb,
lib/origen/limits/limit.rb,
lib/origen/location/map.rb,
lib/origen/netlist/list.rb,
lib/origen/utility/diff.rb,
lib/origen/commands/mode.rb,
lib/origen/commands/site.rb,
lib/origen/componentable.rb,
lib/origen/generator/job.rb,
lib/origen/location/base.rb,
lib/origen/pins/pin_bank.rb,
lib/origen/ports/section.rb,
lib/origen/power_domains.rb,
lib/origen/registers/bit.rb,
lib/origen/registers/reg.rb,
lib/origen/specs/exhibit.rb,
lib/origen/generator/flow.rb,
lib/origen/global_methods.rb,
lib/origen/logger_methods.rb,
lib/origen/model/exporter.rb,
lib/origen/parameters/set.rb,
lib/origen/pins/other_pin.rb,
lib/origen/pins/pin_clock.rb,
lib/origen/pins/power_pin.rb,
lib/origen/remote_manager.rb,
lib/origen/specs/checkers.rb,
lib/origen/specs/override.rb,
lib/origen/utility/mailer.rb,
lib/origen/version_string.rb,
lib/origen/application/lsf.rb,
lib/origen/chips/doc_entry.rb,
lib/origen/code_generators.rb,
lib/origen/commands/target.rb,
lib/origen/generator/stage.rb,
lib/origen/parameters/live.rb,
lib/origen/pins/ground_pin.rb,
lib/origen/pins/pin_common.rb,
lib/origen/commands/helpers.rb,
lib/origen/core_ext/integer.rb,
lib/origen/features/feature.rb,
lib/origen/fuses/fuse_field.rb,
lib/origen/limits/limit_set.rb,
lib/origen/pins/timing/wave.rb,
lib/origen/pins/virtual_pin.rb,
lib/origen/registers/domain.rb,
lib/origen/revision_control.rb,
lib/origen/utility/csv_data.rb,
lib/origen/errata/hw_erratum.rb,
lib/origen/generator/pattern.rb,
lib/origen/model_initializer.rb,
lib/origen/operating_systems.rb,
lib/origen/specs/mode_select.rb,
lib/origen/utility/collector.rb,
lib/origen/utility/file_diff.rb,
lib/origen/value/bin_str_val.rb,
lib/origen/value/hex_str_val.rb,
lib/origen/application/runner.rb,
lib/origen/application/target.rb,
lib/origen/chips/design_entry.rb,
lib/origen/generator/compiler.rb,
lib/origen/generator/renderer.rb,
lib/origen/parameters/missing.rb,
lib/origen/regression_manager.rb,
lib/origen/site_config/config.rb,
lib/origen/specs/doc_resource.rb,
lib/origen/specs/power_supply.rb,
lib/origen/utility/block_args.rb,
lib/origen/application/plugins.rb,
lib/origen/application/release.rb,
lib/origen/code_generators/dut.rb,
lib/origen/generator/resources.rb,
lib/origen/netlist/connectable.rb,
lib/origen/pins/function_proxy.rb,
lib/origen/pins/pin_collection.rb,
lib/origen/pins/timing/timeset.rb,
lib/origen/registers/container.rb,
lib/origen/specs/creation_info.rb,
lib/origen/specs/documentation.rb,
lib/origen/specs/spec_features.rb,
lib/origen/application/deployer.rb,
lib/origen/code_generators/base.rb,
lib/origen/commands/environment.rb,
lib/origen/commands/interactive.rb,
lib/origen/generator/comparator.rb,
lib/origen/models/scan_register.rb,
lib/origen/org_file/interceptor.rb,
lib/origen/ports/bit_collection.rb,
lib/origen/revision_control/git.rb,
lib/origen/code_generators/block.rb,
lib/origen/code_generators/klass.rb,
lib/origen/code_generators/model.rb,
lib/origen/ports/port_collection.rb,
lib/origen/revision_control/base.rb,
lib/origen/specs/version_history.rb,
lib/origen/utility/input_capture.rb,
lib/origen/utility/time_and_date.rb,
lib/origen/application/statistics.rb,
lib/origen/code_generators/module.rb,
lib/origen/code_generators/semver.rb,
lib/origen/org_file/interceptable.rb,
lib/origen/application/environment.rb,
lib/origen/application/lsf_manager.rb,
lib/origen/code_generators/actions.rb,
lib/origen/code_generators/feature.rb,
lib/origen/code_generators/timever.rb,
lib/origen/clocks/clocks_collection.rb,
lib/origen/database/key_value_store.rb,
lib/origen/generator/pattern_finder.rb,
lib/origen/generator/pattern_thread.rb,
lib/origen/registers/bit_collection.rb,
lib/origen/registers/msb0_delegator.rb,
lib/origen/registers/reg_collection.rb,
lib/origen/application/configuration.rb,
lib/origen/database/key_value_stores.rb,
lib/origen/revision_control/perforce.rb,
lib/origen/generator/pattern_iterator.rb,
lib/origen/generator/pattern_sequence.rb,
lib/origen/power_domains/power_domain.rb,
lib/origen/application/plugins_manager.rb,
lib/origen/application/version_tracker.rb,
lib/origen/generator/pattern_sequencer.rb,
lib/origen/revision_control/subversion.rb,
lib/origen/code_generators/block_common.rb,
lib/origen/errata/sw_erratum_workaround.rb,
lib/origen/revision_control/design_sync.rb,
lib/origen/application/workspace_manager.rb,
lib/origen/application/command_dispatcher.rb,
lib/origen/power_domains/power_domains_collection.rb
Overview
Shim to handle Ruby < 2.4.0, where [] is implemented in Integer/Bignum instead of Integer
Defined Under Namespace
Modules: Boot, Bugs, Callbacks, Chips, Clocks, CodeGenerators, CommandHelpers, Component, Componentable, ConsoleMethods, Controller, Database, Errata, Features, Fuses, GlobalMethods, IntegerExtension, Limits, Loader, Location, LoggerMethods, Memory, Model, ModelInitializer, Models, Netlist, Parameters, PersistentCallbacks, Pins, Ports, PowerDomains, Registers, RevisionControl, Specs, SubBlocks, Tests, TopLevel, Users, Utility Classes: Application, BinStrValError, ChipMode, ChipPackage, Client, DesignSyncError, FileHandler, Generator, GitError, HexStrValError, Log, Mode, OperatingSystems, OrgFile, OrigenError, PerforceError, RegressionManager, RemoteManager, RevisionControlUninitializedError, SiteConfig, SubBlock, SyntaxError, UndefinedClass, Value, VersionString
Constant Summary collapse
- APP_CONFIG =
File.join('config', 'application.rb')
- IPBlock =
Legacy API
Model- CoreCallbacks =
PersistentCallbacks- ENCODINGS =
{ utf8: { inverted_exclamation_mark: "\u00A1", cent_sign: "\u00A2", pound_sign: "\u00A3", currency_sign: "\u00A4", yen_sign: "\u00A5", broken_bar: "\u00A6", section_sign: "\u00A7", diaeresis: "\u00A8", copyright_sign: "\u00A9", feminine_ordinal_indicator: "\u00AA", left_pointing_double_angle_quotation_mark: "\u00AB", not_sign: "\u00AC", soft_hyphen: "\u00AD", registered_sign: "\u00AE ", macron: "\u00AF", degree_sign: "\u00B0", plus_minus_sign: "\u00B1", superscript_two: "\u00B2", superscript_three: "\u00B3", acute_accent: "\u00B4", micro_sign: "\u00B5", pilcrow_sign: "\u00B6", middle_dot: "\u00B7", cedilla: "\u00B8", superscript_one: "\u00B9", masculine_ordinal_indicator: "\u00BA", right_pointing_double_angle_quotation_mark: "\u00BB", vulgar_fraction_one_quarter: "\u00BC", vulgar_fraction_one_half: "\u00BD", vulgar_fraction_three_quarters: "\u00BE", inverted_question_mark: "\u00BF", latin_capital_letter_a_with_grave: "\u00C0", latin_capital_letter_a_with_acute: "\u00C1", latin_capital_letter_a_with_circumflex: "\u00C2", latin_capital_letter_a_with_tilde: "\u00C3", latin_capital_letter_a_with_diaeresis: "\u00C4", latin_capital_letter_a_with_ring_above: "\u00C5", latin_capital_letter_ae: "\u00C6", latin_capital_letter_c_with_cedilla: "\u00C7", latin_capital_letter_e_with_grave: "\u00C8", latin_capital_letter_e_with_acute: "\u00C9", latin_capital_letter_e_with_circumflex: "\u00CA", latin_capital_letter_e_with_diaeresis: "\u00CB", latin_capital_letter_i_with_grave: "\u00CC", latin_capital_letter_i_with_acute: "\u00CD", latin_capital_letter_i_with_circumflex: "\u00CE", latin_capital_letter_i_with_diaeresis: "\u00CF", latin_capital_letter_eth: "\u00D0", latin_capital_letter_n_with_tilde: "\u00D1", latin_capital_letter_o_with_grave: "\u00D2", latin_capital_letter_o_with_acute: "\u00D3", latin_capital_letter_o_with_circumflex: "\u00D4", latin_capital_letter_o_with_tilde: "\u00D5", latin_capital_letter_o_with_diaeresis: "\u00D6", multiplication_sign: "\u00D7", latin_capital_letter_o_with_stroke: "\u00D8", latin_capital_letter_u_with_grave: "\u00D9", latin_capital_letter_u_with_acute: "\u00DA", latin_capital_letter_u_with_circumflex: "\u00DB", latin_capital_letter_u_with_diaeresis: "\u00DC", latin_capital_letter_y_with_acute: "\u00DD", latin_capital_letter_thorn: "\u00DE", latin_small_letter_sharp_s: "\u00DF", latin_small_letter_a_with_grave: "\u00E0", latin_small_letter_a_with_acute: "\u00E1", latin_small_letter_a_with_circumflex: "\u00E2", latin_small_letter_a_with_tilde: "\u00E3", latin_small_letter_a_with_diaeresis: "\u00E4", latin_small_letter_a_with_ring_above: "\u00E5", latin_small_letter_ae: "\u00E6", latin_small_letter_c_with_cedilla: "\u00E7", latin_small_letter_e_with_grave: "\u00E8", latin_small_letter_e_with_acute: "\u00E9", latin_small_letter_e_with_circumflex: "\u00EA", latin_small_letter_e_with_diaeresis: "\u00EB", latin_small_letter_i_with_grave: "\u00EC", latin_small_letter_i_with_acute: "\u00ED", latin_small_letter_i_with_circumflex: "\u00EE", latin_small_letter_i_with_diaeresis: "\u00EF", latin_small_letter_eth: "\u00F0", latin_small_letter_n_with_tilde: "\u00F1", latin_small_letter_o_with_grave: "\u00F2", latin_small_letter_o_with_acute: "\u00F3", latin_small_letter_o_with_circumflex: "\u00F4", latin_small_letter_o_with_tilde: "\u00F5", latin_small_letter_o_with_diaeresis: "\u00F6", division_sign: "\u00F7", latin_small_letter_o_with_stroke: "\u00F8", latin_small_letter_u_with_grave: "\u00F9", latin_small_letter_u_with_acute: "\u00FA", latin_small_letter_u_with_circumflex: "\u00FB", latin_small_letter_u_with_diaeresis: "\u00FC", latin_small_letter_y_with_acute: "\u00FD", latin_small_letter_thorn: "\u00FE", latin_small_letter_y_with_diaeresis: "\u00FF", ohm_sign: "\u03A9" } }
Instance Attribute Summary collapse
-
#switch_user ⇒ Object
readonly
Returns the value of attribute switch_user.
Class Method Summary collapse
- ._applications_lookup ⇒ Object private
- ._build_web_dir ⇒ Object
- ._deployer ⇒ Object
- ._require_web_directory ⇒ Object
- ._start_server ⇒ Object
- .add_interface(interface_class) ⇒ Object
-
.after_app_loaded(&block) ⇒ Object
Sometimes it is necessary to refer to the app instance before it is fully loaded, which can lead to runtime errors.
-
.app(plugin = nil, _options = {}) ⇒ Object
(also: application)
Returns the current (top-level) application instance.
-
.app! ⇒ Object
(also: application!)
Equivalent to application except that if called from code in a plugin this will return that plugin’s application instance.
- .application_loaded? ⇒ Boolean (also: app_loaded?)
-
.clean_help_line(str) ⇒ Object
Uniformly justifies the given help command line for display in a command line help output.
- .client ⇒ Object
- .command_dispatcher ⇒ Object
-
.compile(file, options = {}) ⇒ Object
Compile the given file and return the result as a string.
- .configuration ⇒ Object (also: config)
- .controllers ⇒ Object
-
.current_command ⇒ Object
Returns the name of the currently executing Origen command (a String), e.g.
-
.current_user(options = {}) ⇒ Object
private
Use User.current to retrieve the current user, this is an internal API that will be cleaned up (removed) in future.
-
.debug? ⇒ Boolean
(also: debugger?)
Returns true if Origen is running with the -d or –debug switches enabled.
- .debugger_enabled? ⇒ Boolean
- .deprecate(*msgs) ⇒ Object (also: deprecated)
- .development? ⇒ Boolean
- .disable_profiling ⇒ Object
- .enable_debugger ⇒ Object
- .enable_profiling ⇒ Object
- .environment ⇒ Object
- .file_handler ⇒ Object
-
.find_app_by_root(path_to_origen_root, options = {}) ⇒ Object
(also: application_instance, app_instance)
private
Return the application instance from the given path to an Origen application workspace, i.e.
- .flow ⇒ Object
- .generator ⇒ Object
- .has_plugin?(plugin) ⇒ Boolean
-
.home ⇒ Object
Returns the home directory of Origen (i.e., the primary place that Origen operates out of).
-
.hostname ⇒ Object
Platform independent means of retrieving the hostname.
- .import_manager ⇒ Object (also: imports_manager)
-
.in_app_workspace? ⇒ Boolean
Returns true if Origen is running in an application workspace.
-
.interface(options = {}) ⇒ Object
Returns the (application defined) test program interface for the given tester if one has been defined, otherwise returns nil.
- .interface_loaded? ⇒ Boolean
-
.interface_present? ⇒ Boolean
Returns true if an interface is defined for the current tester.
- .interfaces ⇒ Object
- .launch_time ⇒ Object
-
.ldap ⇒ Object
Returns an instance of Origen::Users::LDAP which provides methods to query and authorize users against a company’s LDAP-based employee directory.
-
.listeners_for(*args) ⇒ Object
This is the application-facing API for implementing custom callbacks, the top-level application, all plugin application instances, and any application objects that include the Origen::Callbacks module will be returned.
-
.load_application(options = {}) ⇒ Object
Loads the top-level application and all of its plugins, but not the target.
- .load_target(t = nil, options = {}) ⇒ Object
- .loading_top_level? ⇒ Boolean private
- .log ⇒ Object
-
.lsf ⇒ Object
Picks between either the global lsf_manager or the application’s LSF manager.
-
.lsf! ⇒ Object
Returns the Origen LSF instance, not the lsf_manager.
- .lsf_manager ⇒ Object
- .mailer ⇒ Object
-
.mode ⇒ Object
Returns an object tracking the Origen execution mode/configuration, an instance of Origen::Mode.
- .mode=(val) ⇒ Object
- .os ⇒ Object
- .pattern ⇒ Object
- .pin_bank ⇒ Object
- .plugins ⇒ Object
- .plugins_loaded? ⇒ Boolean
- .plugins_manager ⇒ Object (also: plugin_manager, current_plugin)
- .profile(message) ⇒ Object
-
.register_acronym(name) ⇒ Object
Let’s Origen know about any domain specific acronyms used with an application, this will cause them to be translated between underscored and camel-cased versions correctly.
- .register_application(app) ⇒ Object
- .regression_manager ⇒ Object
- .remote_manager ⇒ Object (also: remotes_manager)
-
.reset_interface(options = {}) ⇒ Object
Resets the tester interface (instantiates a new one).
- .resources ⇒ Object
- .root(plugin = nil) ⇒ Object (also: app_root)
-
.root! ⇒ Object
Like Origen.root but this will return the plugin root if called by plugin code.
-
.running_globally? ⇒ Boolean
(also: invoked_globally?)
Shortcut method to find if Origen was invoked from within an application or from the global Origen install.
-
.running_interactively? ⇒ Boolean
(also: interactive?)
Returns true if Origen is running interactively.
- .running_locally? ⇒ Boolean
- .running_on_linux? ⇒ Boolean
- .running_on_windows? ⇒ Boolean
- .running_remotely=(val) ⇒ Object
- .running_remotely? ⇒ Boolean (also: running_remotely)
- .running_simulation? ⇒ Boolean
-
.session(reload = false) ⇒ Object
Provides a global Origen session stored at ~/.origen/session (Origen.home).
- .set_development_mode ⇒ Object
- .site_config ⇒ Object
-
.split_caller_line(line) ⇒ Object
OS agnostic split of a caller line into file and line number.
- .target ⇒ Object
- .tester ⇒ Object
- .time ⇒ Object
-
.top ⇒ Object
Returns the full path to the Origen core top-level directory.
-
.top_level ⇒ Object
Returns the current top-level (DUT) object if one has been defined (by instantiating an object that includes Origen::TopLevel).
-
.validate_origen_dev_configuration! ⇒ Object
private
Validates that when the current app is OrigenCore then the origen executable is coming from the same workspace.
- .version(options = {}) ⇒ Object
-
.with_boot_environment ⇒ Object
private
Turns off bundler and all plugins if the app is loaded within this block.
-
.with_origen_root(path) ⇒ Object
private
Ugly hack to force Origen.root references to the plugin’s top-level when loading the environment.rb of the plugin.
- .with_source_file(file) ⇒ Object private
-
.with_user(user_obj, &block) ⇒ Object
This is similar to the command line of ‘sudo <user_name>’.
Methods included from Utility::TimeAndDate
Instance Attribute Details
#switch_user ⇒ Object (readonly)
Returns the value of attribute switch_user.
134 135 136 |
# File 'lib/origen.rb', line 134 def switch_user @switch_user end |
Class Method Details
._applications_lookup ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
274 275 276 |
# File 'lib/origen.rb', line 274 def _applications_lookup @_applications_lookup ||= { name: {}, root: {} } end |
._build_web_dir ⇒ Object
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/origen/commands/web.rb', line 115 def self._build_web_dir _deployer.create_web_server_dir dir = Pathname.new(_deployer.web_server_dir).relative_path_from(Pathname.pwd) puts "Web server directory created at: #{dir}" puts '' puts "Compile any files you want to test into the #{dir}/content directory, e.g.:" puts " origen c app/templates/file.md.erb -o #{dir}/content" puts '' puts 'To turn them into web pages:' puts " cd #{dir}" if Origen.running_on_windows? puts ' nanoc' else puts ' env LANG=en_US.UTF-8 nanoc' end puts '' puts 'To start a web server for remote viewing:' puts " cd #{dir}/output" puts ' origen web serve' end |
._deployer ⇒ Object
138 139 140 141 142 |
# File 'lib/origen/commands/web.rb', line 138 def self._deployer @_deployer ||= Origen.app.deployer @_deployer.test = true @_deployer end |
._require_web_directory ⇒ Object
65 66 67 68 69 70 71 72 73 |
# File 'lib/origen/commands/web.rb', line 65 def self._require_web_directory unless Origen.config.web_directory puts 'To run that command you must specify the location of your webserver, for example:' puts '' puts '# config/application.rb' puts 'config.web_directory = "/proj/.web_origen/html/origen"' exit 1 end end |
._start_server ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/origen/commands/web.rb', line 75 def self._start_server # Get the current host require 'socket' # gethostbyname is deprecated in favor of Addrinfo#getaddrinfo # rubocop:disable Lint/DeprecatedClassMethods host = Socket.gethostbyname(Socket.gethostname).first.downcase # rubocop:enable Lint/DeprecatedClassMethods # Get a free port port = 8000 # preferred port begin server = TCPServer.new('127.0.0.1', port) rescue Errno::EADDRINUSE # port = rand(65000 - 1024) + 1024 port += 1 retry end server.close # Start the server puts '' puts "Point your browser to this address: http://#{host}:#{port}" puts '' puts 'To shut down the server use CTRL-C' puts '' # Previously this shelled out to `ruby -run -e httpd`, but that spawns a fresh # Ruby outside the bundle. webrick was extracted from the standard library in # Ruby 3.0, so the bundled gem is not visible to that subprocess and the server # fails to start on Ruby 3+/4.0. Run webrick in-process instead so it resolves # from the bundle on every supported Ruby. require 'webrick' # No BindAddress is set, so webrick listens on all interfaces (matching the old # `ruby -run -e httpd` behaviour) and the advertised hostname URL stays reachable. httpd = WEBrick::HTTPServer.new( Port: port, DocumentRoot: Dir.pwd ) trap('INT') { httpd.shutdown } httpd.start end |
.add_interface(interface_class) ⇒ Object
635 636 637 |
# File 'lib/origen.rb', line 635 def add_interface(interface_class) interfaces << interface_class end |
.after_app_loaded(&block) ⇒ Object
Sometimes it is necessary to refer to the app instance before it is fully loaded, which can lead to runtime errors.
Such code can be wrapped in this method to ensure that it will run safely by differing it until the app is fully loaded.
If the application is already loaded by the time this is called, then it will execute straight away.
Origen.after_app_loaded do |app|
app.do_something
end
594 595 596 597 598 599 600 601 |
# File 'lib/origen.rb', line 594 def after_app_loaded(&block) if application_loaded? yield app else @after_app_loaded_blocks ||= [] @after_app_loaded_blocks << block end end |
.app(plugin = nil, _options = {}) ⇒ Object Also known as: application
Returns the current (top-level) application instance
207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 |
# File 'lib/origen.rb', line 207 def app(plugin = nil, = {}) plugin, = nil, plugin if plugin.is_a?(Hash) if plugin load_application app = _applications_lookup[:name][plugin.to_sym] if app app else puts "Couldn't find application instance called #{plugin}, known names are:" puts " #{_applications_lookup[:name].keys.join(', ')}" puts fail 'Origen.root lookup error!' end else load_application end end |
.app! ⇒ Object Also known as: application!
Equivalent to application except that if called from code in a plugin this will return that plugin’s application instance
228 229 230 231 232 233 234 235 236 237 |
# File 'lib/origen.rb', line 228 def app! file = caller[0] path = @current_source_dir || Pathname.new(file).dirname path = path.parent until File.exist?(File.join(path, APP_CONFIG)) || path.root? if path.root? fail "Something went wrong resoving Origen.app! from: #{caller[0]}" end find_app_by_root(path) end |
.application_loaded? ⇒ Boolean Also known as: app_loaded?
197 198 199 |
# File 'lib/origen.rb', line 197 def application_loaded? @application_loaded end |
.clean_help_line(str) ⇒ Object
Uniformly justifies the given help command line for display in a command line help output
151 152 153 154 155 156 157 158 159 160 |
# File 'lib/origen.rb', line 151 def clean_help_line(str) if str =~ /^\s\s\s\s\s\s\s*(.*)/ (' ' * 20) + Regexp.last_match(1) # http://rubular.com/r/MKmU4xZgO2 elsif str =~ /^\s*([^\s]+)\s+(.*)/ ' ' + Regexp.last_match(1).ljust(19) + Regexp.last_match(2) else str end end |
.command_dispatcher ⇒ Object
321 322 323 |
# File 'lib/origen.rb', line 321 def command_dispatcher @command_dispatcher ||= Application::CommandDispatcher.new end |
.compile(file, options = {}) ⇒ Object
Compile the given file and return the result as a string
618 619 620 621 622 623 624 625 626 627 628 629 |
# File 'lib/origen.rb', line 618 def compile(file, = {}) # This has to operate on a new instance so that helper methods can use the inline # compiler within an isolated context c = Origen::Generator::Compiler.new # It needs to be placed on the stack so that the global render method references # the correct compiler instance $_compiler_stack ||= [] $_compiler_stack << c r = c.compile_inline(file, ) $_compiler_stack.pop r end |
.configuration ⇒ Object Also known as: config
325 326 327 |
# File 'lib/origen.rb', line 325 def configuration app.config end |
.controllers ⇒ Object
514 515 516 |
# File 'lib/origen.rb', line 514 def controllers @controllers ||= [] end |
.current_command ⇒ Object
Returns the name of the currently executing Origen command (a String), e.g. ‘generate’, ‘program’, ‘compile’, etc.
800 801 802 |
# File 'lib/origen.rb', line 800 def current_command @current_command end |
.current_user(options = {}) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Use User.current to retrieve the current user, this is an internal API that will be cleaned up (removed) in future
690 691 692 693 694 695 696 697 698 699 |
# File 'lib/origen.rb', line 690 def current_user( = {}) @current_user = nil if [:refresh] if app_loaded? || in_app_workspace? return @switch_user unless @switch_user.nil? @current_user ||= application.current_user else @current_user ||= User.new(User.current_user_id) end end |
.debug? ⇒ Boolean Also known as: debugger?
Returns true if Origen is running with the -d or –debug switches enabled
733 734 735 |
# File 'lib/origen.rb', line 733 def debug? @debug || false end |
.debugger_enabled? ⇒ Boolean
742 743 744 |
# File 'lib/origen.rb', line 742 def debugger_enabled? debug? end |
.deprecate(*msgs) ⇒ Object Also known as: deprecated
771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 |
# File 'lib/origen.rb', line 771 def deprecate(*msgs) _deprecate(*msgs) if Origen.app # If an app deprecation return the caller who called the deprecated method if caller[0] =~ /#{Origen.root}/ c = caller[1] # If an Origen deprecation then return the first caller from the current app else c = caller.find { |line| line =~ /#{Origen.root}/ } end else c = caller[1] end c =~ /(.*):(\d+):.*/ begin _deprecate "Called by #{Regexp.last_match[1]}:#{Regexp.last_match[2]}", rescue # For this to fail it means the deprecated method was called by IRB or similar # and in that case there is no point advising who called anyway end end |
.development? ⇒ Boolean
746 747 748 749 |
# File 'lib/origen.rb', line 746 def development? # This should be integrated with Origen.config.mode in the future @development end |
.disable_profiling ⇒ Object
166 167 168 |
# File 'lib/origen.rb', line 166 def disable_profiling @profiling = false end |
.enable_debugger ⇒ Object
738 739 740 |
# File 'lib/origen.rb', line 738 def enable_debugger @debug = true end |
.enable_profiling ⇒ Object
162 163 164 |
# File 'lib/origen.rb', line 162 def enable_profiling @profiling = true end |
.environment ⇒ Object
345 346 347 |
# File 'lib/origen.rb', line 345 def environment application.environment end |
.file_handler ⇒ Object
472 473 474 |
# File 'lib/origen.rb', line 472 def file_handler @file_handler ||= FileHandler.new end |
.find_app_by_root(path_to_origen_root, options = {}) ⇒ Object Also known as: application_instance, app_instance
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return the application instance from the given path to an Origen application workspace, i.e. Origen.app conventionally returns the current application instance, this method returns the same thing that would be returned from the given remote workspace.
290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 |
# File 'lib/origen.rb', line 290 def find_app_by_root(path_to_origen_root, = {}) app = _applications_lookup[:root][Pathname.new(path_to_origen_root).realpath.to_s] if !app || [:reload] # If the application is already defined then un-define it, this is to allow it to # be reloaded. # This option feels like it doesn't belong here, but is part of the legacy import # require system. When that has been removed in future so can this reload system, under # bundler app versions will be resolved before loading them so there will be no need # for this if app begin Object.send(:remove_const, app.class.to_s) rescue # Nothing to do here end end require File.join(path_to_origen_root, APP_CONFIG) app = _applications_lookup[:root][Pathname.new(path_to_origen_root).realpath.to_s] end return app if app puts "Couldn't find application instance with root #{path_to_origen_root}, known roots are:" _applications_lookup[:root].keys.each do |key| puts " #{key}" end puts fail 'Application lookup error!' end |
.flow ⇒ Object
502 503 504 |
# File 'lib/origen.rb', line 502 def flow generator.flow end |
.generator ⇒ Object
456 457 458 |
# File 'lib/origen.rb', line 456 def generator @generator ||= Generator.new end |
.has_plugin?(plugin) ⇒ Boolean
240 241 242 |
# File 'lib/origen.rb', line 240 def has_plugin?(plugin) _applications_lookup[:name][plugin.to_sym].nil? ? false : true end |
.home ⇒ Object
Returns the home directory of Origen (i.e., the primary place that Origen operates out of)
811 812 813 |
# File 'lib/origen.rb', line 811 def home File.(Origen.site_config.home_dir) end |
.hostname ⇒ Object
Platform independent means of retrieving the hostname
10 11 12 13 14 15 |
# File 'lib/origen/boot/api.rb', line 10 def self.hostname # gethostbyname is deprecated in favor of Addrinfo#getaddrinfo # rubocop:disable Lint/DeprecatedClassMethods Socket.gethostbyname(Socket.gethostname).first.downcase # rubocop:enable Lint/DeprecatedClassMethods end |
.import_manager ⇒ Object Also known as: imports_manager
480 481 482 483 |
# File 'lib/origen.rb', line 480 def import_manager Origen.deprecated 'Origen.import_manager is deprecated, use Origen.app.plugins instead' app.plugins end |
.in_app_workspace? ⇒ Boolean
Returns true if Origen is running in an application workspace
350 351 352 353 354 355 356 357 358 |
# File 'lib/origen.rb', line 350 def in_app_workspace? return @in_app_workspace if defined? @in_app_workspace @in_app_workspace ||= begin path = Pathname.new(Dir.pwd) path = path.parent until path.root? || File.exist?(File.join(path, APP_CONFIG)) !path.root? end end |
.interface(options = {}) ⇒ Object
Returns the (application defined) test program interface for the given tester if one has been defined, otherwise returns nil
678 679 680 |
# File 'lib/origen.rb', line 678 def interface( = {}) @interface || reset_interface() end |
.interface_loaded? ⇒ Boolean
672 673 674 |
# File 'lib/origen.rb', line 672 def interface_loaded? !!@interface end |
.interface_present? ⇒ Boolean
Returns true if an interface is defined for the current tester
683 684 685 |
# File 'lib/origen.rb', line 683 def interface_present? !!interface(silence_no_interface_error: true) end |
.interfaces ⇒ Object
631 632 633 |
# File 'lib/origen.rb', line 631 def interfaces @interfaces ||= [] end |
.launch_time ⇒ Object
608 609 610 |
# File 'lib/origen.rb', line 608 def launch_time @launch_time ||= time_now end |
.ldap ⇒ Object
Returns an instance of Origen::Users::LDAP which provides methods to query and authorize users against a company’s LDAP-based employee directory
280 281 282 |
# File 'lib/origen.rb', line 280 def ldap @ldap ||= Origen::Users::LDAP.new end |
.listeners_for(*args) ⇒ Object
This is the application-facing API for implementing custom callbacks, the top-level application, all plugin application instances, and any application objects that include the Origen::Callbacks module will be returned
Origen system callbacks should use Origen.app.listeners_for instead, that version will return only the current plugin instance instead of them all (yes we need to make the API more obvious).
443 444 445 446 447 448 449 450 451 452 453 454 |
# File 'lib/origen.rb', line 443 def listeners_for(*args) callback = args.shift max = args.first.is_a?(Numeric) ? args.shift : nil listeners = [Origen.app] + Origen.app.plugins + Origen.app.instantiated_callback_listeners listeners = listeners.select { |l| l.respond_to?(callback) } if max && listeners.size > max fail "You can only define a #{callback} callback #{max > 1 ? (max.to_s + 'times') : 'once'}, however you have declared it #{listeners.size} times for instances of: #{listeners.map(&:class)}" end listeners end |
.load_application(options = {}) ⇒ Object
Loads the top-level application and all of its plugins, but not the target
In most cases this should never need to be called directly and will be called automatically the first time the application is referenced via Origen.app
532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 |
# File 'lib/origen.rb', line 532 def load_application( = {}) # If running globally (outside of an app workspace), instantiate a bare bones app to help # many of Origen's features that expect an app to be present. @application ||= if running_globally? @plugins_loaded = true # Now load the app @loading_top_level = true require 'origen/global_app' @application = _applications_lookup[:root][root.to_s] @loading_top_level = false @application_loaded = true @application else # Make sure the top-level root is always in the load path, it seems that some existing # plugins do some strange things to require stuff from the top-level app and rely on this path = File.join(root, 'lib') $LOAD_PATH.unshift(path) unless $LOAD_PATH.include?(path) if File.exist?(File.join(root, 'Gemfile')) && !@with_boot_environment # Don't understand the rules here, belt and braces approach for now to make # sure that all Origen plugins are auto-required (otherwise Origen won't know # about them to plug them into the application) Bundler.require Bundler.require(:development) Bundler.require(:runtime) Bundler.require(:default) end @plugins_loaded = true # Now load the app @loading_top_level = true require File.join(root, APP_CONFIG) @application = _applications_lookup[:root][root.to_s] @loading_top_level = false if @with_boot_environment @application.plugins.disable_current else Origen.remote_manager.require! end boot = File.join(root, 'config', 'boot.rb') require boot if File.exist?(boot) env = File.join(root, 'config', 'environment.rb') require env if File.exist?(env) dev = File.join(root, 'config', 'development.rb') require dev if File.exist?(dev) validate_origen_dev_configuration! ([@application] + Origen.app.plugins).each(&:on_loaded) @application_loaded = true Array(@after_app_loaded_blocks).each { |b| b.call(@application) } @application end end |
.load_target(t = nil, options = {}) ⇒ Object
338 339 340 341 342 343 |
# File 'lib/origen.rb', line 338 def load_target(t = nil, = {}) t, = nil, t if t.is_a?(Hash) target.temporary = t if t application.load_target!() application.runner.prepare_and_validate_workspace end |
.loading_top_level? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
604 605 606 |
# File 'lib/origen.rb', line 604 def loading_top_level? @loading_top_level end |
.lsf ⇒ Object
Picks between either the global lsf_manager or the application’s LSF manager
820 821 822 823 824 825 826 |
# File 'lib/origen.rb', line 820 def lsf if running_globally? lsf_manager else application.lsf_manager end end |
.lsf! ⇒ Object
Returns the Origen LSF instance, not the lsf_manager. Use Origen.lsf for that
829 830 831 |
# File 'lib/origen.rb', line 829 def lsf! @lsf ||= Origen::Application::LSF.new end |
.lsf_manager ⇒ Object
815 816 817 |
# File 'lib/origen.rb', line 815 def lsf_manager @lsf_manager ||= Origen::Application::LSFManager.new end |
.mailer ⇒ Object
330 331 332 |
# File 'lib/origen.rb', line 330 def mailer application.mailer end |
.mode ⇒ Object
Returns an object tracking the Origen execution mode/configuration, an instance of Origen::Mode
757 758 759 |
# File 'lib/origen.rb', line 757 def mode @mode ||= Origen::Mode.new end |
.mode=(val) ⇒ Object
761 762 763 |
# File 'lib/origen.rb', line 761 def mode=(val) mode.set(val) end |
.os ⇒ Object
29 30 31 |
# File 'lib/origen/operating_systems.rb', line 29 def self.os @operating_systems ||= OperatingSystems.new end |
.pattern ⇒ Object
498 499 500 |
# File 'lib/origen.rb', line 498 def pattern generator.pattern end |
.pin_bank ⇒ Object
468 469 470 |
# File 'lib/origen.rb', line 468 def pin_bank @pin_bank ||= Pins::PinBank.new end |
.plugins ⇒ Object
192 193 194 195 |
# File 'lib/origen.rb', line 192 def plugins Origen.deprecate 'Origen.plugins is deprecated, use Origen.app.plugins instead' Origen.app.plugins end |
.plugins_loaded? ⇒ Boolean
202 203 204 |
# File 'lib/origen.rb', line 202 def plugins_loaded? @plugins_loaded end |
.plugins_manager ⇒ Object Also known as: plugin_manager, current_plugin
486 487 488 489 |
# File 'lib/origen.rb', line 486 def plugins_manager Origen.deprecated 'Origen.plugins_manager and Origen.current_plugin are deprecated, use Origen.app.plugins instead' app.plugins end |
.profile(message) ⇒ Object
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 |
# File 'lib/origen.rb', line 170 def profile() if @profiling caller[0] =~ /.*\/(\w+\.rb):(\d+).*/ if block_given? start = Time.now yield duration_in_ms = ((Time.now - start) * 1000).round puts "#{duration_in_ms}ms".ljust(10) + "#{Regexp.last_match[1]}:#{Regexp.last_match[2]} '#{}'" else puts "#{Time.now} - #{Regexp.last_match[1]}:#{Regexp.last_match[2]} #{}" end else yield if block_given? end end |
.register_acronym(name) ⇒ Object
Let’s Origen know about any domain specific acronyms used with an application, this will cause them to be translated between underscored and camel-cased versions correctly
835 836 837 838 839 840 |
# File 'lib/origen.rb', line 835 def register_acronym(name) require 'active_support/core_ext/string/inflections' ActiveSupport::Inflector.inflections(:en) do |inflect| inflect.acronym(name) end end |
.register_application(app) ⇒ Object
186 187 188 189 190 |
# File 'lib/origen.rb', line 186 def register_application(app) _applications_lookup[:name][app.name] = app _applications_lookup[:root][app.root.to_s] = app @plugins = nil end |
.regression_manager ⇒ Object
476 477 478 |
# File 'lib/origen.rb', line 476 def regression_manager @regression_manager ||= RegressionManager.new end |
.remote_manager ⇒ Object Also known as: remotes_manager
493 494 495 |
# File 'lib/origen.rb', line 493 def remote_manager @remote_manager ||= RemoteManager.new end |
.reset_interface(options = {}) ⇒ Object
Resets the tester interface (instantiates a new one). Any supplied options are passed to the interface initialization.
641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 |
# File 'lib/origen.rb', line 641 def reset_interface( = {}) # The doc interface should in future be phased out, but for now assume that an explicitly # declared interface is for the non-doc case if [:interface] && !Origen.tester.doc? @interface = eval([:interface]).new() else int = interfaces.find { |i| i.supports?(Origen.tester) } if int @interface = int.new() else if defined? OrigenTesters::NoInterface @interface = OrigenTesters::NoInterface.new else unless .delete(:silence_no_interface_error) fail "No interface has been defined for tester: #{Origen.tester.class}" end end end end @interface._load_generator if @interface.respond_to?(:_load_generator) if @interface.respond_to?(:at_flow_start) @interface.at_flow_start else @interface.reset_globals if @interface.respond_to?(:reset_globals) end if @interface.respond_to?(:on_interface_reset) @interface.on_interface_reset end @interface end |
.resources ⇒ Object
506 507 508 |
# File 'lib/origen.rb', line 506 def resources generator.resources end |
.root(plugin = nil) ⇒ Object Also known as: app_root
367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 |
# File 'lib/origen.rb', line 367 def root(plugin = nil) if plugin app(plugin).root else if @root_fudge_active app.root else @root ||= begin path = Pathname.new(Dir.pwd) path = path.parent until path.root? || File.exist?(File.join(path, APP_CONFIG)) if path.root? @running_globally = true path = Pathname.new($_origen_invocation_pwd || Dir.pwd) else @in_app_workspace = true end path end end end end |
.root! ⇒ Object
Like Origen.root but this will return the plugin root if called by plugin code
391 392 393 394 395 396 397 398 399 400 |
# File 'lib/origen.rb', line 391 def root! file = caller[0] path = Pathname.new(file).dirname path = path.parent until path.root? || File.exist?(File.join(path, APP_CONFIG)) if path.root? fail "Something went wrong resolving Origen.root! from: #{caller[0]}" end path.realpath end |
.running_globally? ⇒ Boolean Also known as: invoked_globally?
Shortcut method to find if Origen was invoked from within an application or from the global Origen install. This is just the opposite of in_app_workspace?
362 363 364 |
# File 'lib/origen.rb', line 362 def running_globally? @running_globally ||= !in_app_workspace? end |
.running_interactively? ⇒ Boolean Also known as: interactive?
Returns true if Origen is running interactively. That is, the command was ‘origen i’
727 728 729 |
# File 'lib/origen.rb', line 727 def running_interactively? !!@running_interactively end |
.running_locally? ⇒ Boolean
714 715 716 |
# File 'lib/origen.rb', line 714 def running_locally? !running_remotely? end |
.running_on_linux? ⇒ Boolean
705 706 707 |
# File 'lib/origen.rb', line 705 def running_on_linux? !running_on_windows? end |
.running_on_windows? ⇒ Boolean
701 702 703 |
# File 'lib/origen.rb', line 701 def running_on_windows? Origen.os.windows? end |
.running_remotely=(val) ⇒ Object
718 719 720 |
# File 'lib/origen.rb', line 718 def running_remotely=(val) @running_remotely = val end |
.running_remotely? ⇒ Boolean Also known as: running_remotely
709 710 711 |
# File 'lib/origen.rb', line 709 def running_remotely? @running_remotely end |
.running_simulation? ⇒ Boolean
722 723 724 |
# File 'lib/origen.rb', line 722 def running_simulation? !!(defined?(OrigenSim) && Origen.tester && Origen.tester.sim?) end |
.session(reload = false) ⇒ Object
Provides a global Origen session stored at ~/.origen/session (Origen.home)
805 806 807 808 |
# File 'lib/origen.rb', line 805 def session(reload = false) @session = nil if reload @session ||= Database::KeyValueStores.new(self, persist: false) end |
.set_development_mode ⇒ Object
751 752 753 |
# File 'lib/origen.rb', line 751 def set_development_mode @development = true end |
.site_config ⇒ Object
435 436 437 |
# File 'lib/origen/site_config.rb', line 435 def self.site_config @site_config ||= SiteConfig.new end |
.split_caller_line(line) ⇒ Object
OS agnostic split of a caller line into file and line number
843 844 845 846 847 |
# File 'lib/origen.rb', line 843 def split_caller_line(line) arr = line.split(':') arr[0] = arr[0] + ':' + arr.delete_at(1) if Origen.os.windows? arr end |
.target ⇒ Object
334 335 336 |
# File 'lib/origen.rb', line 334 def target application.target end |
.tester ⇒ Object
464 465 466 |
# File 'lib/origen.rb', line 464 def tester application && application.tester end |
.time ⇒ Object
510 511 512 |
# File 'lib/origen.rb', line 510 def time @time ||= Origen::Tester::Time.new end |
.top ⇒ Object
Returns the full path to the Origen core top-level directory
613 614 615 |
# File 'lib/origen.rb', line 613 def top @origen_top ||= Pathname.new(File.dirname(__FILE__)).parent end |
.top_level ⇒ Object
Returns the current top-level (DUT) object if one has been defined (by instantiating an object that includes Origen::TopLevel).
767 768 769 |
# File 'lib/origen.rb', line 767 def top_level application.top_level end |
.validate_origen_dev_configuration! ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Validates that when the current app is OrigenCore then the origen executable is coming from the same workspace
255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 |
# File 'lib/origen.rb', line 255 def validate_origen_dev_configuration! if Origen.app.name == :origen_core if Origen.root != Origen.top puts 'It looks like you are trying to develop Origen core, but you are running an Origen' puts 'executable from another workspace!' if Origen.running_on_windows? puts 'To resolve this error you must add the following directory to your Windows PATH:' puts " #{Origen.root}\\bin" else puts 'To resolve this error run:' puts " cd #{Origen.root}" puts ' source source_setup' end exit 1 end end end |
.version(options = {}) ⇒ Object
518 519 520 521 522 523 524 525 526 |
# File 'lib/origen.rb', line 518 def version( = {}) @version = nil if [:refresh] return @version if @version && ![:refresh] if [:refresh] || !defined?(Origen::VERSION) load File.join(Pathname.new(File.dirname(__FILE__)).parent, 'config', 'version.rb') end @version = Origen::VersionString.new(Origen::VERSION) end |
.with_boot_environment ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Turns off bundler and all plugins if the app is loaded within this block
429 430 431 432 433 |
# File 'lib/origen.rb', line 429 def with_boot_environment @with_boot_environment = true yield @with_boot_environment = false end |
.with_origen_root(path) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Ugly hack to force Origen.root references to the plugin’s top-level when loading the environment.rb of the plugin
References to Origen.root in a plugin environment.rb is deprecated and this will be removed in future once all plugins load through bundler
409 410 411 412 413 414 415 416 |
# File 'lib/origen.rb', line 409 def with_origen_root(path) orig = app.root @root_fudge_active = true app.root = Pathname.new(path) yield app.root = orig @root_fudge_active = false end |
.with_source_file(file) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
245 246 247 248 249 |
# File 'lib/origen.rb', line 245 def with_source_file(file) @current_source_dir = Pathname.new(file).dirname yield @current_source_dir = nil end |
.with_user(user_obj, &block) ⇒ Object
This is similar to the command line of ‘sudo <user_name>’. The main use case is when someone is running with a Service Account and needs to change to an actually user instead of the service account
421 422 423 424 425 |
# File 'lib/origen.rb', line 421 def with_user(user_obj, &block) @switch_user = user_obj block.call @switch_user = nil end |