module Origen::TopLevel

Include this module to identify it as a top-level object in Origen, normally an object that represents the SoC/Top-level device.

Origen will then fallback on this top-level object to service any register read/write requests or any pin requests that are generated by lower level objects and which cannot be fulfilled at that level.

The current top level object can then be referenced at any time via Origen.top_level.

Attributes

compiler[RW]

Store the current pattern compiler instance name

pinmap[RW]

Any pattern compilation or other operation that requires access to a pinmap will look for it via this attribute, this should return a path to the pinmap file to be used

Public Instance Methods

add_package(id, _options = {}) { |p| ... } click to toggle source
# File lib/origen/top_level.rb, line 118
def add_package(id, _options = {})
  p = ChipPackage.new
  p.id = id
  p.owner = self
  yield p if block_given?
  _add_package(p)
  p
end
current_package(_options = {}) click to toggle source

Returns the current package configuration of the pin owner, unless specifically specified by the application this will return nil.

# File lib/origen/top_level.rb, line 88
def current_package(_options = {})
  if @current_package_id
    return _packages[@current_package_id] if _packages[@current_package_id]

    fail "The package #{@current_package_id} of #{self.class} has not been defined!"
  end
end
Also aliased as: package
current_package=(val) click to toggle source

Use this to specify the current package option for the given SoC.

This allows different pin configurations to be specified by package.

# File lib/origen/top_level.rb, line 76
def current_package=(val)
  @current_package_id = case val
  when ChipPackage
    val.id
  else
    packages.include?(val) ? val : nil
                        end
end
Also aliased as: package=
delete_all_packages() click to toggle source

Sets the Origen.top_level.packages array to nil. Written so packages created in memory can be erased so packages defined in Ruby files can be loaded

# File lib/origen/top_level.rb, line 133
def delete_all_packages
  @_packages = nil
end
Also aliased as: delete_all_pkgs
delete_all_pkgs()
Alias for: delete_all_packages
includes_origen_top_level?() click to toggle source
# File lib/origen/top_level.rb, line 127
def includes_origen_top_level?
  true
end
ip_name() click to toggle source
# File lib/origen/top_level.rb, line 69
def ip_name
  @ip_name || self.class.to_s.split('::').last.symbolize
end
package(_options = {})
Alias for: current_package
package=(val)
Alias for: current_package=
packages(id = nil, _options = {}) click to toggle source

Returns an array containing the IDs of all known configurations if no ID is supplied, otherwise returns an object representing the given package ID

# File lib/origen/top_level.rb, line 99
def packages(id = nil, _options = {})
  id, options = nil, id if id.is_a?(Hash)
  if id
    _packages[id]
  else
    _packages.ids
  end
end
pinmap=(val) click to toggle source
# File lib/origen/top_level.rb, line 47
def pinmap=(val)
  @pinmap = Pathname.new(val)
end
reload!() click to toggle source

Unloads all modules class defined by the application and reloads the target, use this in the console to pick up changes made to files since you opened it. It will only work if your application uses Origen auto-loading from the app/dir, any files that you have manually required will not be re-loaded and may generally cause problems with the use of this method.

# File lib/origen/top_level.rb, line 32
def reload!
  Loader.unload
  Origen.app.reload_target!
  true
end
reset(options = {}) click to toggle source
# File lib/origen/top_level.rb, line 51
def reset(options = {})
  Origen.app.listeners_for(:before_top_level_reset).each(&:before_top_level_reset)
  if options[:bang]
    Origen.app.listeners_for(:shutdown, top_level: :last).each do |listener|
      listener.shutdown(Pattern.create_options)
    end
    Origen.app.listeners_for(:on_top_level_reset!, top_level: false).each(&:on_top_level_reset!)
  end
  Origen.app.listeners_for(:on_top_level_reset, top_level: false).each(&:on_top_level_reset)
  Origen.app.listeners_for(:reset_registers).each(&:reset_registers)
  if options[:bang]
    Origen.app.listeners_for(:startup).each do |listener|
      listener.startup(Pattern.create_options)
    end
  end
  Origen.app.listeners_for(:after_top_level_reset).each(&:after_top_level_reset)
end
reset!() click to toggle source
# File lib/origen/top_level.rb, line 43
def reset!
  reset bang: true
end
timing() click to toggle source

Top-level timing manager/API, returns an instance of Origen::Pins::Timing

# File lib/origen/top_level.rb, line 39
def timing
  @timing ||= Pins::Timing.new
end
with_package(id, _options = {}) { || ... } click to toggle source

Execute the supplied block within the context of the given package, at the end the model’s package attribute will be restored to what it was before calling this method.

# File lib/origen/top_level.rb, line 111
def with_package(id, _options = {})
  orig = package
  self.package = id
  yield
  self.package = orig
end

Private Instance Methods

_add_package(package) click to toggle source
# File lib/origen/top_level.rb, line 148
def _add_package(package)
  if _packages[package.id]
    fail "There is already a package called #{package.id}!"
  else
    _packages[package.id] = package
  end
end
_packages() click to toggle source
# File lib/origen/top_level.rb, line 144
def _packages
  @_packages ||= {}
end
init_top_level() click to toggle source
# File lib/origen/top_level.rb, line 140
def init_top_level
  Origen.app.add_toplevel_listener(self)
end