module Origen

Helper methods here and in the required files can be used by Origen during the bootup process. (e.g., in site config ERB files) This can be expanded as needed to provide more helpers.

Shim to handle Ruby < 2.4.0, where [] is implemented in Fixnum/Bignum instead of Integer

Constants

APP_CONFIG
CoreCallbacks

The regular callbacks module will register listeners that expire upon the next target load, normally this is what is wanted at app level since things should start afresh every time the target is loaded.

However within Origen core (and possibly some plugins) it is often the case that registered listeners will be objects that are not re-instantiated upon target load and persist for the entire Origen thread. In this case use the PersistentCallbacks module instead of the regular Callbacks module to make these objects register as permanent listeners.

ENCODINGS
IPBlock

Include this module to identify it as an SoC IP Block, this will automatically include common modules such as Pin and Register support

Attributes

switch_user[R]

Public Class Methods

_applications_lookup() click to toggle source

@api private

# File lib/origen.rb, line 218
def _applications_lookup
  @_applications_lookup ||= { name: {}, root: {} }
end
_build_web_dir() click to toggle source
# File lib/origen/commands/web.rb, line 102
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() click to toggle source
# File lib/origen/commands/web.rb, line 125
def self._deployer
  @_deployer ||= Origen.app.deployer
  @_deployer.test = true
  @_deployer
end
_require_web_directory() click to toggle source
# 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() click to toggle source
# 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 ''
  system "ruby -run -e httpd . -p #{port}"
end
add_interface(interface_class) click to toggle source
# File lib/origen.rb, line 579
def add_interface(interface_class)
  interfaces << interface_class
end
after_app_loaded() { |app| ... } click to toggle source

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
# File lib/origen.rb, line 538
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 = {}) click to toggle source

Returns the current (top-level) application instance

# File lib/origen.rb, line 151
def app(plugin = nil, _options = {})
  plugin, options = 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
Also aliased as: application
app!() click to toggle source

Equivalent to application except that if called from code in a plugin this will return that plugin’s application instance

# File lib/origen.rb, line 172
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
Also aliased as: application!
app_instance(path_to_origen_root, options = {})
Alias for: find_app_by_root
app_loaded?()
Alias for: application_loaded?
app_root(plugin = nil)
Alias for: root
application(plugin = nil, _options = {})
Alias for: app
application!()
Alias for: app!
application_instance(path_to_origen_root, options = {})
Alias for: find_app_by_root
application_loaded?() click to toggle source
# File lib/origen.rb, line 141
def application_loaded?
  @application_loaded
end
Also aliased as: app_loaded?
clean_help_line(str) click to toggle source

Uniformly justifies the given help command line for display in a command line help output

# File lib/origen.rb, line 95
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
client() click to toggle source
# File lib/origen.rb, line 404
def client
  @client ||= Client.new
end
command_dispatcher() click to toggle source
# File lib/origen.rb, line 265
def command_dispatcher
  @command_dispatcher ||= Application::CommandDispatcher.new
end
compile(file, options = {}) click to toggle source

Compile the given file and return the result as a string

# File lib/origen.rb, line 562
def compile(file, options = {})
  # 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, options)
  $_compiler_stack.pop
  r
end
config()
Alias for: configuration
configuration() click to toggle source
# File lib/origen.rb, line 269
def configuration
  app.config
end
Also aliased as: config
controllers() click to toggle source
# File lib/origen.rb, line 458
def controllers
  @controllers ||= []
end
current_command() click to toggle source

Returns the name of the currently executing Origen command (a String), e.g. ‘generate’, ‘program’, ‘compile’, etc.

# File lib/origen.rb, line 744
def current_command
  @current_command
end
current_plugin()
Alias for: plugins_manager
current_user(options = {}) click to toggle source

Use User.current to retrieve the current user, this is an internal API that will be cleaned up (removed) in future @api private

# File lib/origen.rb, line 634
def current_user(options = {})
  @current_user = nil if options[: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?() click to toggle source

Returns true if Origen is running with the -d or –debug switches enabled

# File lib/origen.rb, line 677
def debug?
  @debug || false
end
Also aliased as: debugger?
debugger?()
Alias for: debug?
debugger_enabled?() click to toggle source
# File lib/origen.rb, line 686
def debugger_enabled?
  debug?
end
deprecate(*msgs) click to toggle source
# File lib/origen.rb, line 715
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]}", options
  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
Also aliased as: deprecated
deprecated(*msgs)
Alias for: deprecate
development?() click to toggle source
# File lib/origen.rb, line 690
def development?
  # This should be integrated with Origen.config.mode in the future
  @development
end
disable_profiling() click to toggle source
# File lib/origen.rb, line 110
def disable_profiling
  @profiling = false
end
enable_debugger() click to toggle source
# File lib/origen.rb, line 682
def enable_debugger
  @debug = true
end
enable_profiling() click to toggle source
# File lib/origen.rb, line 106
def enable_profiling
  @profiling = true
end
environment() click to toggle source
# File lib/origen.rb, line 289
def environment
  application.environment
end
file_handler() click to toggle source
# File lib/origen.rb, line 416
def file_handler
  @file_handler ||= FileHandler.new
end
find_app_by_root(path_to_origen_root, options = {}) click to toggle source

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.

@api private

# File lib/origen.rb, line 234
def find_app_by_root(path_to_origen_root, options = {})
  app = _applications_lookup[:root][Pathname.new(path_to_origen_root).realpath.to_s]
  if !app || options[: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() click to toggle source
# File lib/origen.rb, line 446
def flow
  generator.flow
end
generator() click to toggle source
# File lib/origen.rb, line 400
def generator
  @generator ||= Generator.new
end
has_plugin?(plugin) click to toggle source
# File lib/origen.rb, line 184
def has_plugin?(plugin)
  _applications_lookup[:name][plugin.to_sym].nil? ? false : true
end
home() click to toggle source

Returns the home directory of Origen (i.e., the primary place that Origen operates out of)

# File lib/origen.rb, line 755
def home
  File.expand_path(Origen.site_config.home_dir)
end
hostname() click to toggle source

Platform independent means of retrieving the hostname

# 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() click to toggle source
# File lib/origen.rb, line 424
def import_manager
  Origen.deprecated 'Origen.import_manager is deprecated, use Origen.app.plugins instead'
  app.plugins
end
Also aliased as: imports_manager
imports_manager()
Alias for: import_manager
in_app_workspace?() click to toggle source

Returns true if Origen is running in an application workspace

# File lib/origen.rb, line 294
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
interactive?()
interface(options = {}) click to toggle source

Returns the (application defined) test program interface for the given tester if one has been defined, otherwise returns nil

# File lib/origen.rb, line 622
def interface(options = {})
  @interface || reset_interface(options)
end
interface_loaded?() click to toggle source
# File lib/origen.rb, line 616
def interface_loaded?
  !!@interface
end
interface_present?() click to toggle source

Returns true if an interface is defined for the current tester

# File lib/origen.rb, line 627
def interface_present?
  !!interface(silence_no_interface_error: true)
end
interfaces() click to toggle source
# File lib/origen.rb, line 575
def interfaces
  @interfaces ||= []
end
invoked_globally?()
Alias for: running_globally?
launch_time() click to toggle source
# File lib/origen.rb, line 552
def launch_time
  @launch_time ||= time_now
end
ldap() click to toggle source

Returns an instance of Origen::Users::LDAP which provides methods to query and authorize users against a company’s LDAP-based employee directory

# File lib/origen.rb, line 224
def ldap
  @ldap ||= Origen::Users::LDAP.new
end
listeners_for(*args) click to toggle source

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).

# File lib/origen.rb, line 387
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 = {}) click to toggle source

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

# File lib/origen.rb, line 476
def load_application(options = {})
  # 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 = {}) click to toggle source
# File lib/origen.rb, line 282
def load_target(t = nil, options = {})
  t, options = nil, t if t.is_a?(Hash)
  target.temporary = t if t
  application.load_target!(options)
  application.runner.prepare_and_validate_workspace
end
loading_top_level?() click to toggle source

@api private

# File lib/origen.rb, line 548
def loading_top_level?
  @loading_top_level
end
log() click to toggle source
# File lib/origen.rb, line 738
def log
  @log ||= Log.new
end
lsf() click to toggle source

Picks between either the global lsf_manager or the application’s LSF manager

# File lib/origen.rb, line 764
def lsf
  if running_globally?
    lsf_manager
  else
    application.lsf_manager
  end
end
lsf!() click to toggle source

Returns the Origen LSF instance, not the lsf_manager. Use Origen.lsf for that

# File lib/origen.rb, line 773
def lsf!
  @lsf ||= Origen::Application::LSF.new
end
lsf_manager() click to toggle source
# File lib/origen.rb, line 759
def lsf_manager
  @lsf_manager ||= Origen::Application::LSFManager.new
end
mailer() click to toggle source
# File lib/origen.rb, line 274
def mailer
  application.mailer
end
mode() click to toggle source

Returns an object tracking the Origen execution mode/configuration, an instance of Origen::Mode

# File lib/origen.rb, line 701
def mode
  @mode ||= Origen::Mode.new
end
mode=(val) click to toggle source
# File lib/origen.rb, line 705
def mode=(val)
  mode.set(val)
end
os() click to toggle source
# File lib/origen/operating_systems.rb, line 29
def self.os
  @operating_systems ||= OperatingSystems.new
end
pattern() click to toggle source
# File lib/origen.rb, line 442
def pattern
  generator.pattern
end
pin_bank() click to toggle source
# File lib/origen.rb, line 412
def pin_bank
  @pin_bank ||= Pins::PinBank.new
end
plugin_manager()
Alias for: plugins_manager
plugins() click to toggle source
# File lib/origen.rb, line 136
def plugins
  Origen.deprecate 'Origen.plugins is deprecated, use Origen.app.plugins instead'
  Origen.app.plugins
end
plugins_loaded?() click to toggle source
# File lib/origen.rb, line 146
def plugins_loaded?
  @plugins_loaded
end
plugins_manager() click to toggle source
# File lib/origen.rb, line 430
def plugins_manager
  Origen.deprecated 'Origen.plugins_manager and Origen.current_plugin are deprecated, use Origen.app.plugins instead'
  app.plugins
end
Also aliased as: plugin_manager, current_plugin
profile(message) { || ... } click to toggle source
# File lib/origen.rb, line 114
def profile(message)
  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]} '#{message}'"
    else
      puts "#{Time.now} - #{Regexp.last_match[1]}:#{Regexp.last_match[2]} #{message}"
    end
  else
    yield if block_given?
  end
end
register_acronym(name) click to toggle source

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

# File lib/origen.rb, line 779
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) click to toggle source
# File lib/origen.rb, line 130
def register_application(app)
  _applications_lookup[:name][app.name] = app
  _applications_lookup[:root][app.root.to_s] = app
  @plugins = nil
end
regression_manager() click to toggle source
# File lib/origen.rb, line 420
def regression_manager
  @regression_manager ||= RegressionManager.new
end
remote_manager() click to toggle source
# File lib/origen.rb, line 437
def remote_manager
  @remote_manager ||= RemoteManager.new
end
Also aliased as: remotes_manager
remotes_manager()
Alias for: remote_manager
reset_interface(options = {}) click to toggle source

Resets the tester interface (instantiates a new one). Any supplied options are passed to the interface initialization.

# File lib/origen.rb, line 585
def reset_interface(options = {})
  # 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 options[:interface] && !Origen.tester.doc?
    @interface = eval(options[:interface]).new(options)
  else
    int = interfaces.find { |i| i.supports?(Origen.tester) }
    if int
      @interface = int.new(options)
    else
      if defined? OrigenTesters::NoInterface
        @interface = OrigenTesters::NoInterface.new
      else
        unless options.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() click to toggle source
# File lib/origen.rb, line 450
def resources
  generator.resources
end
root(plugin = nil) click to toggle source
# File lib/origen.rb, line 311
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
Also aliased as: app_root
root!() click to toggle source

Like Origen.root but this will return the plugin root if called by plugin code

# File lib/origen.rb, line 335
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?() click to toggle source

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?

# File lib/origen.rb, line 306
def running_globally?
  @running_globally ||= !in_app_workspace?
end
Also aliased as: invoked_globally?
running_interactively?() click to toggle source

Returns true if Origen is running interactively. That is, the command was ‘origen i’

# File lib/origen.rb, line 671
def running_interactively?
  !!@running_interactively
end
Also aliased as: interactive?
running_locally?() click to toggle source
# File lib/origen.rb, line 658
def running_locally?
  !running_remotely?
end
running_on_linux?() click to toggle source
# File lib/origen.rb, line 649
def running_on_linux?
  !running_on_windows?
end
running_on_windows?() click to toggle source
# File lib/origen.rb, line 645
def running_on_windows?
  Origen.os.windows?
end
running_remotely()
Alias for: running_remotely?
running_remotely=(val) click to toggle source
# File lib/origen.rb, line 662
def running_remotely=(val)
  @running_remotely = val
end
running_remotely?() click to toggle source
# File lib/origen.rb, line 653
def running_remotely?
  @running_remotely
end
Also aliased as: running_remotely
running_simulation?() click to toggle source
# File lib/origen.rb, line 666
def running_simulation?
  !!(defined?(OrigenSim) && Origen.tester && Origen.tester.sim?)
end
session(reload = false) click to toggle source

Provides a global Origen session stored at ~/.origen/session (Origen.home)

# File lib/origen.rb, line 749
def session(reload = false)
  @session = nil if reload
  @session ||= Database::KeyValueStores.new(self, persist: false)
end
set_development_mode() click to toggle source
# File lib/origen.rb, line 695
def set_development_mode
  @development = true
end
site_config() click to toggle source
# File lib/origen/site_config.rb, line 438
def self.site_config
  @site_config ||= SiteConfig.new
end
split_caller_line(line) click to toggle source

OS agnostic split of a caller line into file and line number

# File lib/origen.rb, line 787
def split_caller_line(line)
  arr = line.split(':')
  arr[0] = arr[0] + ':' + arr.delete_at(1) if Origen.os.windows?
  arr
end
target() click to toggle source
# File lib/origen.rb, line 278
def target
  application.target
end
tester() click to toggle source
# File lib/origen.rb, line 408
def tester
  application && application.tester
end
time() click to toggle source
# File lib/origen.rb, line 454
def time
  @time ||= Origen::Tester::Time.new
end
top() click to toggle source

Returns the full path to the Origen core top-level directory

# File lib/origen.rb, line 557
def top
  @origen_top ||= Pathname.new(File.dirname(__FILE__)).parent
end
top_level() click to toggle source

Returns the current top-level (DUT) object if one has been defined (by instantiating an object that includes Origen::TopLevel).

# File lib/origen.rb, line 711
def top_level
  application.top_level
end
validate_origen_dev_configuration!() click to toggle source

Validates that when the current app is OrigenCore then the origen executable is coming from the same workspace

@api private

# File lib/origen.rb, line 199
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 = {}) click to toggle source
# File lib/origen.rb, line 462
def version(options = {})
  @version = nil if options[:refresh]
  return @version if @version && !options[:refresh]

  if options[: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() { || ... } click to toggle source

Turns off bundler and all plugins if the app is loaded within this block @api private

# File lib/origen.rb, line 373
def with_boot_environment
  @with_boot_environment = true
  yield
  @with_boot_environment = false
end
with_origen_root(path) { || ... } click to toggle source

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

@api private

# File lib/origen.rb, line 353
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) { || ... } click to toggle source

@api private

# File lib/origen.rb, line 189
def with_source_file(file)
  @current_source_dir = Pathname.new(file).dirname
  yield
  @current_source_dir = nil
end
with_user(user_obj, &block) click to toggle source

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

# File lib/origen.rb, line 365
def with_user(user_obj, &block)
  @switch_user = user_obj
  block.call
  @switch_user = nil
end

Private Class Methods

_deprecate(*lines) click to toggle source
# File lib/origen.rb, line 799
def _deprecate(*lines)
  options = lines.last.is_a?(Hash) ? lines.pop : {}
  lines.flatten.each do |line|
    line.split(/\n/).each do |line|
      log.deprecate line
    end
  end
end
current_command=(val) click to toggle source
# File lib/origen.rb, line 795
def current_command=(val)
  @current_command = val
end