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: Compiler, Flow, Job, Pattern, PatternFinder, PatternIterator, Resources, Stage

Instance Method Summary collapse

Instance Method Details

#compile_file_or_directory(file, options) ⇒ Object


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

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

#compilerObject


67
68
69
# File 'lib/origen/generator.rb', line 67

def compiler
  @compiler ||= Compiler.new
end

#create_iteratorObject


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

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

#flowObject


18
19
20
# File 'lib/origen/generator.rb', line 18

def flow
  @flow ||= Flow.new
end

#generate_pattern(file, options) ⇒ Object


30
31
32
# File 'lib/origen/generator.rb', line 30

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

#generate_program(file, options) ⇒ Object


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

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


63
64
65
# File 'lib/origen/generator.rb', line 63

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

#option_pipelineObject


83
84
85
# File 'lib/origen/generator.rb', line 83

def option_pipeline
  @option_pipeline ||= []
end

#patternObject


14
15
16
# File 'lib/origen/generator.rb', line 14

def pattern
  @pattern ||= Pattern.new
end

#pattern_finderObject


71
72
73
# File 'lib/origen/generator.rb', line 71

def pattern_finder
  @pattern_finder ||= PatternFinder.new
end

#resourcesObject


22
23
24
# File 'lib/origen/generator.rb', line 22

def resources
  @resources ||= Resources.new
end

#stageObject


26
27
28
# File 'lib/origen/generator.rb', line 26

def stage
  @stage ||= Stage.new
end