Class: Origen::Tester::Ultraflex::Generator::TestInstances
- Inherits:
-
Object
- Object
- Origen::Tester::Ultraflex::Generator::TestInstances
- Includes:
- Generator
- Defined in:
- lib/origen/tester/ultraflex/generator/test_instances.rb
Defined Under Namespace
Classes: IndexedString
Constant Summary
- TEMPLATE =
"#{Origen.top}/lib/origen/tester/ultraflex/generator/templates/instances.txt.erb"
- OUTPUT_POSTFIX =
'instances'
Instance Method Summary (collapse)
- - (Object) add(name, type, options = {})
- - (Object) bpmu(name, options = {}) (also: #board_pmu)
- - (Object) empty(name, options = {})
-
- (Object) finalize(_options = {})
:nodoc:.
- - (Object) functional(name, options = {})
-
- (Object) group(name = nil, options = {}) {|@current_group| ... }
(also: #add_group)
IG-XL doesn't have a formal instance group type and instead declares them anonymously whenever test instances of the same name appear consecutively in the test instance sheet.
- - (Object) other(name, options = {})
- - (Object) ppmu(name, options = {}) (also: #pin_pmu)
-
- (Object) sort!
:nodoc:.
-
- (Object) uniq!
:nodoc:.
Methods included from Generator
#close, #collection, #collection=, #compiler, #current_dir, #dont_diff=, execute_source, #file_extension, #file_pipeline, #filename, #filename=, #identity_map, #import, #inhibit_output, #on_close, #output_file, #output_inhibited?, #reference_file, #render, #set_flow_description, #stats, #to_be_written?, #write_from_template, #write_to_file
Instance Method Details
- (Object) add(name, type, options = {})
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/origen/tester/ultraflex/generator/test_instances.rb', line 19 def add(name, type, = {}) = { test_instance_class: TestInstance }.merge() ins = .delete(:test_instance_class).new(name, type, ) if @current_group @current_group << ins else collection << ins end c = Origen.interface.consume_comments Origen.interface.descriptions.add_for_test_definition(name, c) ins end |
- (Object) bpmu(name, options = {}) Also known as: board_pmu
149 150 151 |
# File 'lib/origen/tester/ultraflex/generator/test_instances.rb', line 149 def bpmu(name, = {}) add(name, :board_pmu, ) end |
- (Object) empty(name, options = {})
163 164 165 |
# File 'lib/origen/tester/ultraflex/generator/test_instances.rb', line 163 def empty(name, = {}) add(name, :empty, ) end |
- (Object) finalize(_options = {})
:nodoc:
93 94 95 96 |
# File 'lib/origen/tester/ultraflex/generator/test_instances.rb', line 93 def finalize( = {}) # :nodoc: uniq! sort! end |
- (Object) functional(name, options = {})
159 160 161 |
# File 'lib/origen/tester/ultraflex/generator/test_instances.rb', line 159 def functional(name, = {}) add(name, :functional, ) end |
- (Object) group(name = nil, options = {}) {|@current_group| ... } Also known as: add_group
IG-XL doesn't have a formal instance group type and instead declares them anonymously whenever test instances of the same name appear consecutively in the test instance sheet. However when it comes to generating a test program life becomes much easier if we have a way to explicitly declare instances as part of a group - this makes duplicate tracking and sorting of the test instance sheet much easier.
Use this method to generate instance groups via a block. Within the the block you should generate instances as normal and they will automatically be assigned to the current group. Note that the name of the instances generated within the group is discarded and replaced with the name of the group. Origen automatically appends “grp” to this name to highlight instances that were generated as part of the group.
test_instances.group("erase_all_blocks") do |group|
# Generate instances here as normal
test_instances.functional("erase_blk0")
test_instances.functional("erase_blk1")
end
The group object is passed into the block but usually you should not need to interact with this directly except maybe to set the name if it is not yet established at the point where the group is initiated:
test_instances.group do |group|
# Generate instances here as normal
group.name = "group_blah"
end
A common way to generate groups is to create a helper method in your application which is responsible for creating groups as required:
def group_wrapper(name, )
if [:by_block]
test_instances.group(name) do |group|
yield group
end
else
yield
end
end
In that case the group argument becomes quite useful for branching based on whether you are generating a group or standalone instances:
group_wrapper(name, ) do |group|
if group
# Generate group instances
else
# Generate standalone instances
end
end
84 85 86 87 88 89 90 |
# File 'lib/origen/tester/ultraflex/generator/test_instances.rb', line 84 def group(name = nil, = {}) name, = nil, name if name.is_a?(Hash) @current_group = TestInstanceGroup.new(name, ) collection << @current_group yield @current_group @current_group = nil end |
- (Object) other(name, options = {})
167 168 169 |
# File 'lib/origen/tester/ultraflex/generator/test_instances.rb', line 167 def other(name, = {}) add(name, :other, ) end |
- (Object) ppmu(name, options = {}) Also known as: pin_pmu
154 155 156 |
# File 'lib/origen/tester/ultraflex/generator/test_instances.rb', line 154 def ppmu(name, = {}) add(name, :pin_pmu, ) end |
- (Object) sort!
:nodoc:
138 139 140 141 142 143 144 145 146 147 |
# File 'lib/origen/tester/ultraflex/generator/test_instances.rb', line 138 def sort! # :nodoc: # Present the instances in the final sheet in alphabetical order collection.map!.with_index do |ins, _i| if ins.is_a?(String) # Can happen if content has been rendered in from a template ins = IndexedString.new(ins) end ins end collection.sort! { |a, b| [a.name.to_s] <=> [b.name.to_s] } end |
- (Object) uniq!
:nodoc:
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/origen/tester/ultraflex/generator/test_instances.rb', line 98 def uniq! # :nodoc: uniques = [] versions = {} multi_version_tests = {} collection.each do |instance| # If a uniquely named instance is found add it, otherwise update the version # of the current instance to match that of the existing instance that it duplicates unless uniques.any? do |i| if i == instance instance.version = i.version true else false end end if instance.respond_to?(:version=) versions[instance.unversioned_name] ||= 0 versions[instance.unversioned_name] += 1 if versions[instance.unversioned_name] > 1 multi_version_tests[instance.unversioned_name] = true end instance.version = versions[instance.unversioned_name] end uniques << instance end end # This final loop disables the version identifier for tests that have only a single version, # this makes it clearer when multiple versions exist - whenever you see a v1 you know there # is at least a v2 also. collection.map! do |instance| if instance.respond_to?(:version=) unless multi_version_tests[instance.unversioned_name] instance.append_version = false end end instance end self.collection = uniques end |