Module: Origen::Tester::Interface

Extended by:
ActiveSupport::Concern
Defined in:
lib/origen/tester/interface.rb

Overview

Include this module in any class you define as a test interface

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#app_identifierObject

This identifier will be used to make labels and other references unique to the current application. This will help to avoid name duplication if a program is comprised of many modules generated by Origen.

Override in the application interface to customize, by default the identifier will be Origen.config.initials



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

def app_identifier
  Origen.config.initials || 'Anon App'
end

#clear_top_level_flowObject



108
109
110
# File 'lib/origen/tester/interface.rb', line 108

def clear_top_level_flow
  @@top_level_flow = nil
end

#close(options = {}) ⇒ Object



23
24
25
26
27
# File 'lib/origen/tester/interface.rb', line 23

def close(options = {})
  sheet_generators.each do |generator|
    generator.close(options)
  end
end

#comment(text) ⇒ Object

Add a comment line into the buffer



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

def comment(text)
  comments << text
end

#commentsObject



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

def comments
  @@comments ||= []
end

#compile(file, options = {}) ⇒ Object

Compile a template file



30
31
32
33
34
35
36
37
38
39
40
# File 'lib/origen/tester/interface.rb', line 30

def compile(file, options = {})
  Origen.file_handler.preserve_state do
    begin
      file = Origen.file_handler.clean_path_to_template(file)
      Origen.generator.compile_file_or_directory(file, initial_options: options)
    rescue
      file = Origen.file_handler.clean_path_to(file)
      Origen.generator.compile_file_or_directory(file, initial_options: options)
    end
  end
end

#consume_commentsObject

Returns the buffered description comments and clears the buffer



89
90
91
92
93
# File 'lib/origen/tester/interface.rb', line 89

def consume_comments
  c = comments
  discard_comments
  c
end

#descriptionsObject

A storage Hash that all generators can push comment descriptions into when generating. At the end of a generation run this will contain all descriptions for all flows that were just created.

Access via Origen.interface.descriptions



118
119
120
# File 'lib/origen/tester/interface.rb', line 118

def descriptions
  @@descriptions ||= Parser::DescriptionLookup.new
end

#discard_commentsObject



84
85
86
# File 'lib/origen/tester/interface.rb', line 84

def discard_comments
  @@comments = nil
end

#flow_generatorObject



100
101
102
# File 'lib/origen/tester/interface.rb', line 100

def flow_generator
  flow
end

#identity_mapObject

:nodoc:



136
137
138
# File 'lib/origen/tester/interface.rb', line 136

def identity_map # :nodoc:
  @@identity_map ||= Origen::Tester::Generator::IdentityMap.new
end

#import(file, options = {}) ⇒ Object



42
43
44
45
46
47
48
# File 'lib/origen/tester/interface.rb', line 42

def import(file, options = {})
  # Attach the import request to the first generator, when it imports
  # it any generated resources will automatically find their way to the
  # correct generator/collection
  generator = flow || sheet_generators.first
  generator.import(file, options)
end

#referenced_patternsObject

All generators should push to this array whenever they reference a pattern so that it is captured in the pattern list, e.g.

Origen.interface.referenced_patterns << pattern


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

def referenced_patterns
  @@referenced_patterns ||= []
end

#render(file, options = {}) ⇒ Object



50
51
52
53
54
55
56
# File 'lib/origen/tester/interface.rb', line 50

def render(file, options = {})
  if sheet_generators.size > 1
    fail "You must specify which generator to render content to! e.g.  i.test_instances.render '#{file}'"
  else
    sheet_generators.first.render(file, options)
  end
end

#resources_modeObject

Any tests generated within the given block will be generated in resources mode. Generally this means that all resources for a given test will be generated but flow entries will be inhibited.



125
126
127
128
129
130
# File 'lib/origen/tester/interface.rb', line 125

def resources_mode
  orig = @resources_mode
  @resources_mode = true
  yield
  @resources_mode = orig
end

#resources_mode?Boolean

Returns:

  • (Boolean)


132
133
134
# File 'lib/origen/tester/interface.rb', line 132

def resources_mode?
  @resources_mode
end

#set_top_level_flowObject



104
105
106
# File 'lib/origen/tester/interface.rb', line 104

def set_top_level_flow
  @@top_level_flow = flow_generator.output_file
end

#top_level_flowObject Also known as: top_level_flow_filename



95
96
97
# File 'lib/origen/tester/interface.rb', line 95

def top_level_flow
  @@top_level_flow ||= nil
end

#write_files(options = {}) ⇒ Object



58
59
60
61
62
63
64
65
66
# File 'lib/origen/tester/interface.rb', line 58

def write_files(options = {})
  sheet_generators.each do |generator|
    generator.finalize(options)
  end
  sheet_generators.each do |generator|
    generator.write_to_file(options) if generator.to_be_written?
  end
  reset_globals
end