Sha256: cb4a256c7db8547a371cbe2e5c0c277576f85d2c79da771f8557e4fae6e2181d

Contents?: true

Size: 1.4 KB

Versions: 9

Compression:

Stored size: 1.4 KB

Contents

module Origen
  class Generator
    class Resources
      attr_accessor :top_level

      def create(options = {}, &block)
        # Refresh the target to start all settings from scratch each time
        # This is an easy way to reset all registered values
        Origen.app.reload_target!
        Origen.tester.generating = :program
        sub_flow = @top_level
        @top_level ||= true
        job.output_file_body = options.delete(:name).to_s if options[:name]
        if sub_flow
          interface = Origen.interface
          interface.resources_mode do
            opts = Origen.generator.option_pipeline.pop || {}
            interface.instance_exec(opts, &block)
          end
          interface.close(sub_resource: true)
        else
          Origen.log.info "Generating... #{Origen.file_handler.current_file.basename}"
          interface = Origen.reset_interface(options)
          Origen.app.listeners_for(:on_resource_start).each do |listener|
            listener.on_resource_start(options)
          end
          interface.resources_mode do
            interface.instance_eval(&block)
          end
          Origen.app.listeners_for(:on_resource_end).each do |listener|
            listener.on_resource_end(options)
          end
          interface.close
        end
      end

      def reset
        @top_level = false
      end

      def job
        Origen.app.current_job
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
origen-0.60.17 lib/origen/generator/resources.rb
origen-0.60.16 lib/origen/generator/resources.rb
origen-0.60.14 lib/origen/generator/resources.rb
origen-0.60.13 lib/origen/generator/resources.rb
origen-0.60.12 lib/origen/generator/resources.rb
origen-0.60.11 lib/origen/generator/resources.rb
origen-0.60.10 lib/origen/generator/resources.rb
origen-0.60.9 lib/origen/generator/resources.rb
origen-0.60.8 lib/origen/generator/resources.rb