Class: Origen::Generator::Flow

Inherits:
Object
  • Object
show all
Defined in:
lib/origen/generator/flow.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/flow.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/origen/generator/flow.rb', line 6

def create(options = {}, &block)
  # Origen.deprecated 'Origen core will no longer support program generation in v1, add the origen_testers plugin to your application to fix this warning'
  # 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
  # Make the top level flow globally available, this helps to assign test descriptions
  # to the correct flow whenever tests are instantiated from sub-flows
  if Origen.interface_loaded? && Origen.interface.top_level_flow
    sub_flow = true
    if Origen.tester.doc?
      Origen.interface.flow.start_section
    end
  else
    sub_flow = false
  end
  job.output_file_body = options.delete(:name).to_s if options[:name]
  if sub_flow
    interface = Origen.interface
    opts = Origen.generator.option_pipeline.pop || {}
    Origen.interface.startup(options) if Origen.interface.respond_to?(:startup)
    interface.instance_exec(opts, &block)
    Origen.interface.shutdown(options) if Origen.interface.respond_to?(:shutdown)
    if Origen.tester.doc?
      Origen.interface.flow.stop_section
    end
    interface.close(flow: true, sub_flow: true)
  else
    unless tester.try(:sim?)
      Origen.log.info "Generating... #{Origen.file_handler.current_file.basename}"
    end
    interface = Origen.reset_interface(options)
    Origen.interface.set_top_level_flow
    Origen.interface.flow_generator.set_flow_description(Origen.interface.consume_comments)
    options[:top_level] = true
    Origen.app.listeners_for(:on_flow_start).each do |listener|
      listener.on_flow_start(options)
    end
    Origen.interface.startup(options) if Origen.interface.respond_to?(:startup)
    interface.instance_eval(&block)
    Origen.interface.shutdown(options) if Origen.interface.respond_to?(:shutdown)
    interface.at_flow_end if interface.respond_to?(:at_flow_end)
    Origen.app.listeners_for(:on_flow_end).each do |listener|
      listener.on_flow_end(options)
    end
    interface.close(flow: true)
  end
end

#jobObject



59
60
61
# File 'lib/origen/generator/flow.rb', line 59

def job
  Origen.app.current_job
end

#resetObject



55
56
57
# File 'lib/origen/generator/flow.rb', line 55

def reset
  Origen.interface.clear_top_level_flow if Origen.interface_loaded?
end