Module: OrigenTesters::Interface
- Extended by:
- ActiveSupport::Concern
- Includes:
- ATP::FlowAPI
- Included in:
- ProgramGenerators
- 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 Classes: PatternArray
Class Method Summary collapse
Instance Method Summary collapse
- #add_description!(options) ⇒ Object
-
#add_flow_enable ⇒ Object
Returns whether the tester has been configured to wrap top-level flow modules with an enable or not.
-
#add_flow_enable=(value) ⇒ Object
Set to :enabled to have the current flow wrapped by an enable flow variable that is enabled by default (top-level flow has to disable modules it doesn’t want).
- #add_meta!(options) ⇒ Object
- #all_pattern_references ⇒ Object
-
#app_identifier ⇒ Object
This identifier will be used to make labels and other references unique to the current application.
-
#atp ⇒ Object
Returns the abstract test program model for the current flow.
-
#clean_referenced_patterns ⇒ Object
Remove duplicates and file extensions from the referenced pattern lists.
- #clear_top_level_flow ⇒ Object
- #close(options = {}) ⇒ Object
-
#comment(text) ⇒ Object
Add a comment line into the buffer.
- #comments ⇒ Object
-
#compile(file, options = {}) ⇒ Object
Compile a template file.
-
#consume_comments ⇒ Object
Returns the buffered description comments and clears the buffer.
-
#descriptions ⇒ Object
A storage Hash that all generators can push comment descriptions into when generating.
- #discard_comments ⇒ Object
- #flow_generator ⇒ Object
-
#identity_map ⇒ Object
:nodoc:.
- #import(file, options = {}) ⇒ Object
- #on_program_completion(options = {}) ⇒ Object
- #pattern_references ⇒ Object
- #pattern_references_name ⇒ Object
- #pattern_references_name=(name) ⇒ Object
- #platform ⇒ Object
-
#record_pattern_reference(name, options = {}) ⇒ Object
A secondary pattern is one where the pattern has been created by Origen as an output from generating another pattern (a primary pattern).
-
#referenced_patterns ⇒ Object
deprecated
Deprecated.
Use record_pattern_reference instead
- #render(file, options = {}) ⇒ Object
-
#resources_mode ⇒ Object
(also: #with_resources_mode)
Any tests generated within the given block will be generated in resources mode.
- #resources_mode? ⇒ Boolean
- #set_top_level_flow ⇒ Object
- #test(name, options = {}) ⇒ Object
- #top_level_flow ⇒ Object (also: #top_level_flow_filename)
-
#unique_test_names ⇒ Object
Returns the value defined on if/how to make test names unique within a flow.
-
#unique_test_names=(val) ⇒ Object
Set the value of unique_test_names.
- #write? ⇒ Boolean
- #write_files(options = {}) ⇒ Object
Class Method Details
.resources_mode? ⇒ Boolean
33 34 35 |
# File 'lib/origen_testers/interface.rb', line 33 def self.resources_mode? !!@resources_mode end |
.with_resources_mode ⇒ Object
26 27 28 29 30 31 |
# File 'lib/origen_testers/interface.rb', line 26 def self.with_resources_mode orig = @resources_mode @resources_mode = true yield @resources_mode = orig end |
.write=(val) ⇒ Object
37 38 39 |
# File 'lib/origen_testers/interface.rb', line 37 def self.write=(val) @write = val end |
.write? ⇒ Boolean
41 42 43 |
# File 'lib/origen_testers/interface.rb', line 41 def self.write? !!@write end |
Instance Method Details
#add_description!(options) ⇒ Object
152 153 154 |
# File 'lib/origen_testers/interface.rb', line 152 def add_description!() flow.send(:add_description!, ) end |
#add_flow_enable ⇒ Object
Returns whether the tester has been configured to wrap top-level flow modules with an enable or not.
Returns nil if not.
Returns :enabled if the enable is configured to be on by default, or :disabled if it is configured to be off by default.
75 76 77 |
# File 'lib/origen_testers/interface.rb', line 75 def add_flow_enable @add_flow_enable end |
#add_flow_enable=(value) ⇒ Object
Set to :enabled to have the current flow wrapped by an enable flow variable that is enabled by default (top-level flow has to disable modules it doesn’t want).
Set to :disabled to have the opposite, where the top-level flow has to enable all modules.
Set to nil to have no wrapping. While this is the default, setting this to nil will override any setting of the attribute of the same name that has been set at tester-level by the target.
88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/origen_testers/interface.rb', line 88 def add_flow_enable=(value) return unless flow.respond_to?(:add_flow_enable=) if value if value == :enable || value == :enabled flow.add_flow_enable = :enabled elsif value == :disable || value == :disabled flow.add_flow_enable = :disabled else fail "Unknown add_flow_enable value, #{value}, must be :enabled or :disabled" end else flow.add_flow_enable = nil end end |
#add_meta!(options) ⇒ Object
148 149 150 |
# File 'lib/origen_testers/interface.rb', line 148 def () flow.send(:add_meta!, ) end |
#all_pattern_references ⇒ Object
233 234 235 236 |
# File 'lib/origen_testers/interface.rb', line 233 def all_pattern_references pattern_references @@pattern_references end |
#app_identifier ⇒ Object
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
109 110 111 |
# File 'lib/origen_testers/interface.rb', line 109 def app_identifier Origen.config.initials || 'Anon App' end |
#atp ⇒ Object
Returns the abstract test program model for the current flow
50 51 52 |
# File 'lib/origen_testers/interface.rb', line 50 def atp flow.model end |
#clean_referenced_patterns ⇒ Object
Remove duplicates and file extensions from the referenced pattern lists
261 262 263 264 265 266 267 268 269 270 271 272 |
# File 'lib/origen_testers/interface.rb', line 261 def clean_referenced_patterns refs = [:referenced_patterns] # refs << :referenced_subroutine_patterns if Origen.tester.v93k? refs.each do |ref| var = send(ref) var = var.uniq.map do |pat| pat = pat.sub(/\..*/, '') pat unless pat =~ /_part\d+$/ end.uniq.compact singleton_class.class_variable_set("@@#{ref}", var) end end |
#clear_top_level_flow ⇒ Object
307 308 309 |
# File 'lib/origen_testers/interface.rb', line 307 def clear_top_level_flow @@top_level_flow = nil end |
#close(options = {}) ⇒ Object
113 114 115 116 117 |
# File 'lib/origen_testers/interface.rb', line 113 def close( = {}) sheet_generators.each do |generator| generator.close() end end |
#comment(text) ⇒ Object
Add a comment line into the buffer
275 276 277 |
# File 'lib/origen_testers/interface.rb', line 275 def comment(text) comments << text end |
#comments ⇒ Object
279 280 281 |
# File 'lib/origen_testers/interface.rb', line 279 def comments @@comments ||= [] end |
#compile(file, options = {}) ⇒ Object
Compile a template file
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/origen_testers/interface.rb', line 120 def compile(file, = {}) return unless write? # Any options passed in from an interface will be passed to the compiler and to # the templates being compiled [:initial_options] = Origen.file_handler.preserve_state do begin file = Origen.file_handler.clean_path_to_template(file) Origen.generator.compile_file_or_directory(file, ) rescue file = Origen.file_handler.clean_path_to(file) Origen.generator.compile_file_or_directory(file, ) end end end |
#consume_comments ⇒ Object
Returns the buffered description comments and clears the buffer
288 289 290 291 292 |
# File 'lib/origen_testers/interface.rb', line 288 def consume_comments c = comments discard_comments c end |
#descriptions ⇒ Object
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
317 318 319 |
# File 'lib/origen_testers/interface.rb', line 317 def descriptions @@descriptions ||= Parser::DescriptionLookup.new end |
#discard_comments ⇒ Object
283 284 285 |
# File 'lib/origen_testers/interface.rb', line 283 def discard_comments @@comments = nil end |
#flow_generator ⇒ Object
299 300 301 |
# File 'lib/origen_testers/interface.rb', line 299 def flow_generator flow end |
#identity_map ⇒ Object
:nodoc:
335 336 337 |
# File 'lib/origen_testers/interface.rb', line 335 def identity_map # :nodoc: @@identity_map ||= ::OrigenTesters::Generator::IdentityMap.new end |
#import(file, options = {}) ⇒ Object
136 137 138 139 140 141 142 |
# File 'lib/origen_testers/interface.rb', line 136 def import(file, = {}) # 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, ) end |
#on_program_completion(options = {}) ⇒ Object
167 168 169 170 171 |
# File 'lib/origen_testers/interface.rb', line 167 def on_program_completion( = {}) reset_globals @@pattern_references = {} @@referenced_patterns = nil end |
#pattern_references ⇒ Object
217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 |
# File 'lib/origen_testers/interface.rb', line 217 def pattern_references @@pattern_references ||= {} @@pattern_references[pattern_references_name] ||= { main: { all: [], origen: [], ate: [] }, subroutine: { all: [], origen: [], ate: [] } } end |
#pattern_references_name ⇒ Object
242 243 244 |
# File 'lib/origen_testers/interface.rb', line 242 def pattern_references_name @pattern_references_name || 'global' end |
#pattern_references_name=(name) ⇒ Object
238 239 240 |
# File 'lib/origen_testers/interface.rb', line 238 def pattern_references_name=(name) @pattern_references_name = name end |
#platform ⇒ Object
339 340 341 342 343 344 345 346 347 |
# File 'lib/origen_testers/interface.rb', line 339 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 |
#record_pattern_reference(name, options = {}) ⇒ Object
A secondary pattern is one where the pattern has been created by Origen as an output from generating another pattern (a primary pattern). For example, on V93K anytime a tester handshake is done, the pattern will be split into separate components, such as meas_bgap.avc (the primary pattern) and meas_bgap_part1.avc (a secondary pattern).
Any such secondary pattern references should be pushed to this array, rather than the referenced_patterns array. By using the dedicated secondary array, the pattern will not appear in the referenced.list file so that Origen is not asked to generate it (since it will be created naturally from the primary pattern reference). However if the ATE requires a reference to the pattern (e.g. the V93K pattern master file), then it will be included in the relevant ATE files.
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 |
# File 'lib/origen_testers/interface.rb', line 185 def record_pattern_reference(name, = {}) if name.is_a?(String) || name.is_a?(Symbol) name = name.to_s else fail "Pattern name must be a string or a symbol, not a #{name.class}" end # Help out the user and force any multi-part patterns to :ate type unless [:type] if name.sub(/\..*/, '') =~ /part\d+$/ [:type] = :ate end end unless [:type] == :origen # Inform the current generator that it has a new pattern reference to handle if respond_to?(:pattern_reference_recorded) pattern_reference_recorded(name, ) end end base = [:subroutine] ? pattern_references[:subroutine] : pattern_references[:main] case [:type] when :origen base[:origen] << name when :ate base[:ate] << name when nil base[:all] << name else fail "Unknown pattern reference type, #{options[:type]}, valid values are :origen or :ate" end nil end |
#referenced_patterns ⇒ Object
Use record_pattern_reference instead
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
If the ATE platform also has a pattern list, e.g. the pattern master file on V93K, then this will also be updated. Duplicates will be automatically eliminated, so no duplicate checking should be performed on the application side.
256 257 258 |
# File 'lib/origen_testers/interface.rb', line 256 def referenced_patterns @@referenced_patterns ||= PatternArray.new end |
#render(file, options = {}) ⇒ Object
144 145 146 |
# File 'lib/origen_testers/interface.rb', line 144 def render(file, = {}) flow.render(file, ) end |
#resources_mode ⇒ Object 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.
324 325 326 327 328 |
# File 'lib/origen_testers/interface.rb', line 324 def resources_mode OrigenTesters::Interface.with_resources_mode do yield end end |
#resources_mode? ⇒ Boolean
331 332 333 |
# File 'lib/origen_testers/interface.rb', line 331 def resources_mode? OrigenTesters::Interface.resources_mode? end |
#set_top_level_flow ⇒ Object
303 304 305 |
# File 'lib/origen_testers/interface.rb', line 303 def set_top_level_flow @@top_level_flow = flow_generator.output_file end |
#test(name, options = {}) ⇒ Object
45 46 47 |
# File 'lib/origen_testers/interface.rb', line 45 def test(name, = {}) flow.test(name, ) end |
#top_level_flow ⇒ Object Also known as: top_level_flow_filename
294 295 296 |
# File 'lib/origen_testers/interface.rb', line 294 def top_level_flow @@top_level_flow ||= nil end |
#unique_test_names ⇒ Object
Returns the value defined on if/how to make test names unique within a flow
59 60 61 |
# File 'lib/origen_testers/interface.rb', line 59 def unique_test_names @unique_test_names end |
#unique_test_names=(val) ⇒ Object
Set the value of unique_test_names
64 65 66 |
# File 'lib/origen_testers/interface.rb', line 64 def unique_test_names=(val) @unique_test_names = val end |
#write? ⇒ Boolean
54 55 56 |
# File 'lib/origen_testers/interface.rb', line 54 def write? OrigenTesters::Interface.write? end |
#write_files(options = {}) ⇒ Object
156 157 158 159 160 161 162 163 164 165 |
# File 'lib/origen_testers/interface.rb', line 156 def write_files( = {}) sheet_generators.each do |generator| generator.finalize() end sheet_generators.each do |generator| generator.write_to_file() if generator.to_be_written? end clean_referenced_patterns flow.save_program end |