Class: Origen::Generator

Inherits:
Object show all
Defined in:
lib/origen/generator.rb,
lib/origen/generator/job.rb,
lib/origen/generator/flow.rb,
lib/origen/generator/stage.rb,
lib/origen/generator/pattern.rb,
lib/origen/generator/compiler.rb,
lib/origen/generator/renderer.rb,
lib/origen/generator/resources.rb,
lib/origen/generator/comparator.rb,
lib/origen/generator/pattern_finder.rb,
lib/origen/generator/pattern_iterator.rb

Defined Under Namespace

Modules: Comparator, Renderer Classes: AbortError, Compiler, Flow, Job, Pattern, PatternFinder, PatternIterator, Resources, Stage

Instance Method Summary collapse

Instance Method Details

#compile_file_or_directory(file, options) ⇒ Object



61
62
63
# File 'lib/origen/generator.rb', line 61

def compile_file_or_directory(file, options)
  Job.new(file, { compile: true, default_dir: "#{Origen.root}/templates" }.merge(options)).run
end

#compilerObject



69
70
71
# File 'lib/origen/generator.rb', line 69

def compiler
  @compiler ||= Compiler.new
end

#create_iteratorObject



77
78
79
80
81
82
83
# File 'lib/origen/generator.rb', line 77

def create_iterator
  iterator = PatternIterator.new
  Origen.after_app_loaded do |app|
    app.pattern_iterators << iterator
  end
  iterator
end

#flowObject



20
21
22
# File 'lib/origen/generator.rb', line 20

def flow
  @flow ||= Flow.new
end

#generate_pattern(file, options) ⇒ Object



32
33
34
# File 'lib/origen/generator.rb', line 32

def generate_pattern(file, options)
  Job.new(file, options).run
end

#generate_program(file, options) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/origen/generator.rb', line 36

def generate_program(file, options)
  Origen.file_handler.resolve_files(file, ignore_with_prefix: '_', default_dir: "#{Origen.root}/program") do |path|
    Origen.file_handler.current_file = path
    j = Job.new(path, options)
    j.pattern = path
    j.run
  end
  Origen.interface.write_files(options)
  unless options[:quiet] || Origen.tester.is_a?(OrigenTesters::Doc)
    if options[:referenced_pattern_list]
      file = "#{Origen.root}/list/#{options[:referenced_pattern_list]}"
    else
      file = Origen.config.referenced_pattern_list
    end
    puts "Referenced pattern list written to: #{Pathname.new(file).relative_path_from(Pathname.pwd)}"
    dir = Pathname.new(file).dirname
    FileUtils.mkdir_p(dir) unless dir.exist?
    File.open(file, 'w') do |f|
      Origen.interface.referenced_patterns.uniq.sort.each do |pat|
        f.puts pat
      end
    end
  end
end

#merge_file_or_directory(file, options) ⇒ Object



65
66
67
# File 'lib/origen/generator.rb', line 65

def merge_file_or_directory(file, options)
  Job.new(file, options).run
end

#option_pipelineObject



85
86
87
# File 'lib/origen/generator.rb', line 85

def option_pipeline
  @option_pipeline ||= []
end

#patternObject



16
17
18
# File 'lib/origen/generator.rb', line 16

def pattern
  @pattern ||= Pattern.new
end

#pattern_finderObject



73
74
75
# File 'lib/origen/generator.rb', line 73

def pattern_finder
  @pattern_finder ||= PatternFinder.new
end

#resourcesObject



24
25
26
# File 'lib/origen/generator.rb', line 24

def resources
  @resources ||= Resources.new
end

#stageObject



28
29
30
# File 'lib/origen/generator.rb', line 28

def stage
  @stage ||= Stage.new
end