Module: Origen::TopLevel
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/origen/top_level.rb
Overview
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.
Instance Method Summary collapse
- #add_package(id, _options = {}) {|p| ... } ⇒ Object
-
#current_package(_options = {}) ⇒ Object
(also: #package)
Returns the current package configuration of the pin owner, unless specifically specified by the application this will return nil.
-
#current_package=(val) ⇒ Object
(also: #package=)
Use this to specify the current package option for the given SoC.
-
#delete_all_packages ⇒ Object
(also: #delete_all_pkgs)
Sets the Origen.top_level.packages array to nil.
- #includes_origen_top_level? ⇒ Boolean
- #ip_name ⇒ Object
-
#packages(id = nil, _options = {}) ⇒ Object
Returns an array containing the IDs of all known configurations if no ID is supplied, otherwise returns an object representing the given package ID.
- #pinmap=(val) ⇒ Object
- #reset(options = {}) ⇒ Object
- #reset! ⇒ Object
-
#with_package(id, _options = {}) ⇒ Object
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.
Instance Method Details
#add_package(id, _options = {}) {|p| ... } ⇒ Object
96 97 98 99 100 101 102 103 |
# File 'lib/origen/top_level.rb', line 96 def add_package(id, = {}) p = ChipPackage.new p.id = id p.owner = self yield p if block_given? _add_package(p) p end |
#current_package(_options = {}) ⇒ Object Also known as: package
Returns the current package configuration of the pin owner, unless specifically specified by the application this will return nil.
67 68 69 70 71 72 |
# File 'lib/origen/top_level.rb', line 67 def current_package( = {}) 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 |
#current_package=(val) ⇒ Object Also known as: package=
Use this to specify the current package option for the given SoC.
This allows different pin configurations to be specified by package.
60 61 62 |
# File 'lib/origen/top_level.rb', line 60 def current_package=(val) @current_package_id = val.is_a?(ChipPackage) ? val.id : val end |
#delete_all_packages ⇒ Object Also known as: delete_all_pkgs
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
111 112 113 |
# File 'lib/origen/top_level.rb', line 111 def delete_all_packages @_packages = nil end |
#includes_origen_top_level? ⇒ Boolean
105 106 107 |
# File 'lib/origen/top_level.rb', line 105 def includes_origen_top_level? true end |
#ip_name ⇒ Object
53 54 55 |
# File 'lib/origen/top_level.rb', line 53 def ip_name @ip_name || self.class.to_s.split('::').last.symbolize end |
#packages(id = nil, _options = {}) ⇒ Object
Returns an array containing the IDs of all known configurations if no ID is supplied, otherwise returns an object representing the given package ID
77 78 79 80 81 82 83 84 |
# File 'lib/origen/top_level.rb', line 77 def packages(id = nil, = {}) id, = nil, id if id.is_a?(Hash) if id _packages[id] else _packages.ids end end |
#pinmap=(val) ⇒ Object
31 32 33 |
# File 'lib/origen/top_level.rb', line 31 def pinmap=(val) @pinmap = Pathname.new(val) end |
#reset(options = {}) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/origen/top_level.rb', line 35 def reset( = {}) Origen.app.listeners_for(:before_top_level_reset).each(&:before_top_level_reset) if [:bang] Origen.app.listeners_for(:shutdown, top_level: :last).each do |listener| listener.shutdown(Pattern.) 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 [:bang] Origen.app.listeners_for(:startup).each do |listener| listener.startup(Pattern.) end end Origen.app.listeners_for(:after_top_level_reset).each(&:after_top_level_reset) end |
#reset! ⇒ Object
27 28 29 |
# File 'lib/origen/top_level.rb', line 27 def reset! reset bang: true end |
#with_package(id, _options = {}) ⇒ Object
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.
89 90 91 92 93 94 |
# File 'lib/origen/top_level.rb', line 89 def with_package(id, = {}) orig = package self.package = id yield self.package = orig end |