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_thread.rb,
lib/origen/generator/pattern_iterator.rb,
lib/origen/generator/pattern_sequence.rb,
lib/origen/generator/pattern_sequencer.rb

Defined Under Namespace

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

Instance Method Summary collapse

Instance Method Details

#compile_file_or_directory(file, options) ⇒ Object



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

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

#compilerObject



76
77
78
# File 'lib/origen/generator.rb', line 76

def compiler
  @compiler ||= Compiler.new
end

#create_iteratorObject



84
85
86
87
88
89
90
# File 'lib/origen/generator.rb', line 84

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

#flowObject



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

def flow
  @flow ||= Flow.new
end

#generate_pattern(file, options) ⇒ Object



35
36
37
38
39
40
41
# File 'lib/origen/generator.rb', line 35

def generate_pattern(file, options)
  if options[:sequence]
    options[:patterns] = file
    file = options[:sequence]
  end
  Job.new(file, options).run
end

#generate_program(file, options) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/origen/generator.rb', line 43

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



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

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

#option_pipelineObject



92
93
94
# File 'lib/origen/generator.rb', line 92

def option_pipeline
  @option_pipeline ||= []
end

#patternObject



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

def pattern
  @pattern ||= Pattern.new
end

#pattern_finderObject



80
81
82
# File 'lib/origen/generator.rb', line 80

def pattern_finder
  @pattern_finder ||= PatternFinder.new
end

#resourcesObject



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

def resources
  @resources ||= Resources.new
end

#stageObject



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

def stage
  @stage ||= Stage.new
end