Class: Origen::Generator::Resources

Inherits:
Object
  • Object
show all
Defined in:
lib/origen/generator/resources.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#top_levelObject

Returns the value of attribute top_level.



4
5
6
# File 'lib/origen/generator/resources.rb', line 4

def top_level
  @top_level
end

Instance Method Details

#create(options = {}, &block) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/origen/generator/resources.rb', line 6

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

#jobObject



41
42
43
# File 'lib/origen/generator/resources.rb', line 41

def job
  Origen.app.current_job
end

#resetObject



37
38
39
# File 'lib/origen/generator/resources.rb', line 37

def reset
  @top_level = false
end