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
-
#reload! ⇒ Object
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.
- #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
118 119 120 121 122 123 124 125 |
# File 'lib/origen/top_level.rb', line 118 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.
88 89 90 91 92 93 94 |
# File 'lib/origen/top_level.rb', line 88 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.
76 77 78 79 80 81 82 83 |
# 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 |
#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
133 134 135 |
# File 'lib/origen/top_level.rb', line 133 def delete_all_packages @_packages = nil end |
#includes_origen_top_level? ⇒ Boolean
127 128 129 |
# File 'lib/origen/top_level.rb', line 127 def includes_origen_top_level? true end |
#ip_name ⇒ Object
69 70 71 |
# File 'lib/origen/top_level.rb', line 69 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
99 100 101 102 103 104 105 106 |
# File 'lib/origen/top_level.rb', line 99 def packages(id = nil, = {}) id, = nil, id if id.is_a?(Hash) if id _packages[id] else _packages.ids end end |
#pinmap=(val) ⇒ Object
47 48 49 |
# File 'lib/origen/top_level.rb', line 47 def pinmap=(val) @pinmap = Pathname.new(val) end |
#reload! ⇒ Object
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.
32 33 34 35 36 |
# File 'lib/origen/top_level.rb', line 32 def reload! Loader.unload Origen.app.reload_target! true end |
#reset(options = {}) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/origen/top_level.rb', line 51 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
43 44 45 |
# File 'lib/origen/top_level.rb', line 43 def reset! reset bang: true end |
#timing ⇒ Object
Top-level timing manager/API, returns an instance of Origen::Pins::Timing
39 40 41 |
# File 'lib/origen/top_level.rb', line 39 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.
111 112 113 114 115 116 |
# File 'lib/origen/top_level.rb', line 111 def with_package(id, = {}) orig = package self.package = id yield self.package = orig end |