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
-
#timing ⇒ Object
Top-level timing manager/API, returns an instance of Origen::Pins::Timing.
-
#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
106 107 108 109 110 111 112 113 |
# File 'lib/origen/top_level.rb', line 106 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.
77 78 79 80 81 82 |
# File 'lib/origen/top_level.rb', line 77 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.
65 66 67 68 69 70 71 72 |
# File 'lib/origen/top_level.rb', line 65 def current_package=(val) @current_package_id = case val when ChipPackage val.id else packages.include?(val) ? val : nil end 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
121 122 123 |
# File 'lib/origen/top_level.rb', line 121 def delete_all_packages @_packages = nil end |
#includes_origen_top_level? ⇒ Boolean
115 116 117 |
# File 'lib/origen/top_level.rb', line 115 def includes_origen_top_level? true end |
#ip_name ⇒ Object
58 59 60 |
# File 'lib/origen/top_level.rb', line 58 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
87 88 89 90 91 92 93 94 |
# File 'lib/origen/top_level.rb', line 87 def packages(id = nil, = {}) id, = nil, id if id.is_a?(Hash) if id _packages[id] else _packages.ids end end |
#pinmap=(val) ⇒ Object
36 37 38 |
# File 'lib/origen/top_level.rb', line 36 def pinmap=(val) @pinmap = Pathname.new(val) end |
#reset(options = {}) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/origen/top_level.rb', line 40 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
32 33 34 |
# File 'lib/origen/top_level.rb', line 32 def reset! reset bang: true end |
#timing ⇒ Object
Top-level timing manager/API, returns an instance of Origen::Pins::Timing
28 29 30 |
# File 'lib/origen/top_level.rb', line 28 def timing @timing ||= Pins::Timing.new 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.
99 100 101 102 103 104 |
# File 'lib/origen/top_level.rb', line 99 def with_package(id, = {}) orig = package self.package = id yield self.package = orig end |