Module: OrigenTesters::Interface

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

Overview

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

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.resources_mode?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/origen_testers/interface.rb', line 25

def self.resources_mode?
  !!@resources_mode
end

.with_resources_modeObject



18
19
20
21
22
23
# File 'lib/origen_testers/interface.rb', line 18

def self.with_resources_mode
  orig = @resources_mode
  @resources_mode = true
  yield
  @resources_mode = orig
end

.write=(val) ⇒ Object



29
30
31
# File 'lib/origen_testers/interface.rb', line 29

def self.write=(val)
  @write = val
end

.write?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/origen_testers/interface.rb', line 33

def self.write?
  !!@write
end

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



47
48
49
# File 'lib/origen_testers/interface.rb', line 47

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

#clean_referenced_patternsObject

Remove duplicates and file extensions from the referenced pattern lists



125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/origen_testers/interface.rb', line 125

def clean_referenced_patterns
  refs = [:referenced_patterns]
  refs << :referenced_subroutine_patterns if Origen.tester.v93k?
  refs.each do |ref|
    ref = send(ref)
    ref.uniq!
    ref.map! do |pat|
      pat.sub(/\..*/, '')
    end
    ref.uniq!
  end
end

#clear_top_level_flowObject



171
172
173
# File 'lib/origen_testers/interface.rb', line 171

def clear_top_level_flow
  @@top_level_flow = nil
end

#close(options = {}) ⇒ Object



51
52
53
54
55
# File 'lib/origen_testers/interface.rb', line 51

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

#comment(text) ⇒ Object

Add a comment line into the buffer



139
140
141
# File 'lib/origen_testers/interface.rb', line 139

def comment(text)
  comments << text
end

#commentsObject



143
144
145
# File 'lib/origen_testers/interface.rb', line 143

def comments
  @@comments ||= []
end

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

Compile a template file



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/origen_testers/interface.rb', line 58

def compile(file, options = {})
  return unless write?
  # Any options passed in from an interface will be passed to the compiler and to
  # the templates being compiled
  options[:initial_options] = options
  Origen.file_handler.preserve_state do
    begin
      file = Origen.file_handler.clean_path_to_template(file)
      Origen.generator.compile_file_or_directory(file, options)
    rescue
      file = Origen.file_handler.clean_path_to(file)
      Origen.generator.compile_file_or_directory(file, options)
    end
  end
end

#consume_commentsObject

Returns the buffered description comments and clears the buffer



152
153
154
155
156
# File 'lib/origen_testers/interface.rb', line 152

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



181
182
183
# File 'lib/origen_testers/interface.rb', line 181

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

#discard_commentsObject



147
148
149
# File 'lib/origen_testers/interface.rb', line 147

def discard_comments
  @@comments = nil
end

#flow_generatorObject



163
164
165
# File 'lib/origen_testers/interface.rb', line 163

def flow_generator
  flow
end

#identity_mapObject

:nodoc:



199
200
201
# File 'lib/origen_testers/interface.rb', line 199

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

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



74
75
76
77
78
79
80
# File 'lib/origen_testers/interface.rb', line 74

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

#on_program_completion(options = {}) ⇒ Object



101
102
103
104
105
# File 'lib/origen_testers/interface.rb', line 101

def on_program_completion(options = {})
  reset_globals
  @@referenced_patterns = nil
  @@referenced_subroutine_patterns = nil
end

#platformObject



203
204
205
206
207
208
209
210
211
# File 'lib/origen_testers/interface.rb', line 203

def platform
  # This branch to support the ProgramGenerators module where the generator
  # is included into an interface instance and not the class
  if singleton_class.const_defined? :PLATFORM
    singleton_class::PLATFORM
  else
    self.class::PLATFORM
  end
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


110
111
112
# File 'lib/origen_testers/interface.rb', line 110

def referenced_patterns
  @@referenced_patterns ||= []
end

#referenced_subroutine_patternsObject

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

Origen.interface.referenced_subroutine_patterns << pattern


117
118
119
120
121
122
# File 'lib/origen_testers/interface.rb', line 117

def referenced_subroutine_patterns
  unless Origen.tester.v93k?
    fail 'referenced_subroutine_patterns is currently only implemented for V93k!'
  end
  @@referenced_subroutine_patterns ||= []
end

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



82
83
84
85
86
87
88
# File 'lib/origen_testers/interface.rb', line 82

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 Also known as: with_resources_mode

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.



188
189
190
191
192
# File 'lib/origen_testers/interface.rb', line 188

def resources_mode
  OrigenTesters::Interface.with_resources_mode do
    yield
  end
end

#resources_mode?Boolean

Returns:

  • (Boolean)


195
196
197
# File 'lib/origen_testers/interface.rb', line 195

def resources_mode?
  OrigenTesters::Interface.resources_mode?
end

#set_top_level_flowObject



167
168
169
# File 'lib/origen_testers/interface.rb', line 167

def set_top_level_flow
  @@top_level_flow = flow_generator.output_file
end

#top_level_flowObject Also known as: top_level_flow_filename



158
159
160
# File 'lib/origen_testers/interface.rb', line 158

def top_level_flow
  @@top_level_flow ||= nil
end

#write?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/origen_testers/interface.rb', line 37

def write?
  OrigenTesters::Interface.write?
end

#write_files(options = {}) ⇒ Object



90
91
92
93
94
95
96
97
98
99
# File 'lib/origen_testers/interface.rb', line 90

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
  clean_referenced_patterns
  flow.save_program
end