Class: OrigenTesters::Test::Interface

Inherits:
Object
  • Object
show all
Includes:
Charz, ProgramGenerators
Defined in:
lib/origen_testers/test/interface.rb

Constant Summary

Constants included from ProgramGenerators

ProgramGenerators::PLATFORMS

Instance Attribute Summary collapse

Attributes included from Charz

#charz_instance, #charz_profiles, #charz_routines, #charz_session, #charz_stack, #eof_charz_tests, #eof_charz_tests_group_name, #skip_group_eof_charz_tests

Instance Method Summary collapse

Methods included from Charz

#add_charz_profile, #add_charz_routine, #charz_active?, #charz_off, #charz_off_truncate, #charz_on, #charz_on_append, #charz_only?, #charz_pause, #charz_resume, #create_charz_routine, #generate_eof_charz_tests, #insert_charz_tests, #set_charz_instance, #set_conditional_charz_id

Methods included from ProgramGenerators

#_load_generator, #pre_initialize, #tester

Methods included from Interface

#add_description!, #add_flow_enable, #add_flow_enable=, #add_meta!, #all_pattern_references, #app_identifier, #atp, #clean_referenced_patterns, #clear_pattern_references, #clear_top_level_flow, #close, #comment, #comments, #compile, #consume_comments, #context_changed?, #context_or_parameter_changed?, #descriptions, #discard_comments, #discard_top_level_flow, #flow_generator, #generating_sub_program?, #identity_map, #import, #merge_pattern_references, #on_program_completion, #parameter_changed?, #pattern_references, #pattern_references_name, #pattern_references_name=, #platform, #record_pattern_reference, #referenced_patterns, #render, #resources_mode, resources_mode?, #resources_mode?, #set_top_level_flow, #test, #top_level_flow, #unique_test_names, #unique_test_names=, with_resources_mode, write=, write?, #write?, #write_files

Methods included from ATP::FlowAPI

#atp, #atp=, #hi_limit, #limit, #lo_limit, #loop

Constructor Details

#initialize(options = {}) ⇒ Interface

Options passed to Flow.create and Library.create will be passed in here, use as desired to configure your interface



12
13
14
15
16
# File 'lib/origen_testers/test/interface.rb', line 12

def initialize(options = {})
  @environment = options[:environment]
  add_charz
  add_my_tml if tester.v93k?
end

Instance Attribute Details

#environmentObject (readonly)

Returns the value of attribute environment.



8
9
10
# File 'lib/origen_testers/test/interface.rb', line 8

def environment
  @environment
end

#include_additional_prb2_testObject

Returns the value of attribute include_additional_prb2_test.



7
8
9
# File 'lib/origen_testers/test/interface.rb', line 7

def include_additional_prb2_test
  @include_additional_prb2_test
end

Instance Method Details

#ac_specset(sheet_name, expression, options = {}) ⇒ Object



666
667
668
669
670
671
672
673
674
# File 'lib/origen_testers/test/interface.rb', line 666

def ac_specset(sheet_name, expression, options = {})
  options = {
    specset: :default,
    nom:     { typ:  nil }
  }.merge(options)

  ss = ac_specsets(sheet_name)
  add_ac_specs(ss, expression, options)
end

#add_ac_specs(ss, expression, options = {}) ⇒ Object

Adds new AC Spec object(s) to the given Specset



694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
# File 'lib/origen_testers/test/interface.rb', line 694

def add_ac_specs(ss, expression, options = {})
  options = {
    specset: :default
  }.merge(options)

  return unless expression.is_a? String
  # collect all variable names within the expression
  vars = expression.scan(/[a-zA-Z][\w]+/).map(&:to_sym)
  vars.each do |var|
    next if var =~ /^(d0_edge|d1_edge|d2_edge|d3_edge|c1_edge|c2_edge)$/
    # The substitutions below are used for backward compatibility
    next if var =~ /^(d_on|d_data|d_ret|d_off|c_open|c_close)$/
    next if var =~ /^(nS|uS|mS|S)$/i
    next if ss.ac_specsets.key?(options[:specset]) && ss.ac_specsets[options[:specset]].include?(var)

    ss.add(var, options)
  end
end

#add_charzObject



96
97
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
# File 'lib/origen_testers/test/interface.rb', line 96

def add_charz
  add_charz_routine :routine1 do |routine|
    routine.name = '_cz__rt1'
  end
  add_charz_routine :routine2 do |routine|
    routine.name = '_cz__rt2'
  end
  add_charz_routine :routine3 do |routine|
    routine.name = '_cz__rt3'
  end
  add_charz_routine :routine4 do |routine|
    routine.name = '_cz__rt4'
  end
  add_charz_routine :routine5 do |routine|
    routine.name = '_cz__rt5'
  end
  add_charz_routine :routine6 do |routine|
    routine.name = '_cz__rt6'
  end
  add_charz_profile :cz do |profile|
    profile.routines = [:routine3]
  end
  add_charz_profile :cz_only do |profile|
    profile.charz_only = true
    profile.routines = [:routine1]
  end
  add_charz_profile :simple_gates do |profile|
    profile.flags = :my_flag
    profile.enables = :my_enable
    profile.routines = [:routine1]
  end
  add_charz_profile :complex_gates do |profile|
    profile.flags = { ['$MyFlag1'] => [:routine1, :routine2], ['$MyFlag2'] => [:routine3], '$MyFlag3' => :routine4 }
    profile.enables = { ['$MyEnable1'] => [:routine1], ['$MyEnable2'] => [:routine2, :routine3], '$MyEnable3' => :routine5 }
    profile.routines = [:routine1, :routine2, :routine3, :routine4, :routine5, :routine6]
  end

  add_charz_profile :simple_anded_flags do |profile|
    profile.and_flags = true
    profile.routines = [:routine1]
  end

  add_charz_profile :simple_anded_enables do |profile|
    profile.and_enables = true
    profile.routines = [:routine1]
  end

  add_charz_profile :complex_anded_flags do |profile|
    profile.and_flags = true
    profile.enables = :my_enable
    profile.routines = [:routine1]
  end

  add_charz_profile :complex_anded_enables do |profile|
    profile.and_enables = true
    profile.flags = :my_flag
    profile.routines = [:routine1]
  end
end

#add_dc_specs(ss, expression, options = {}) ⇒ Object

Adds new DC Spec object(s) to the given Specset



797
798
799
800
801
802
803
804
805
806
807
808
809
# File 'lib/origen_testers/test/interface.rb', line 797

def add_dc_specs(ss, expression, options = {})
  options = {
    specset: :default
  }.merge(options)

  return unless expression.is_a? String
  vars = expression.scan(/[a-zA-Z][\w]+/).map(&:to_sym)
  vars.each do |var|
    next if var =~ /^(nA|uA|mA|A|nV|uV|mV|V)$/i

    ss.add(var, options)
  end
end

#add_my_tmlObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/origen_testers/test/interface.rb', line 18

def add_my_tml
  add_tml :my_hash_tml,
          class_name:   'MyTmlHashNamespace',

          # Here is a test definition.
          # The identifier should be lower-cased and underscored, in-keeping with Ruby naming conventions.
          # By default the class name will be the camel-cased version of this identifier, so 'myTest' in
          # this case.
          my_hash_test: {
            # [OPTIONAL] The C++ test method class name can be overridden from the default like this:
            class_name:             'MyHashExampleClass',
            # [OPTIONAL] If the test method does not require a definition in the testmethodlimits section
            #    of the .tf file, you can suppress like this:
            # render_limits_in_file: false,
            # Parameters can be defined with an underscored symbol as the name, this can be used
            # if the C++ implementation follows the standard V93K convention of calling the attribute
            # the camel cased version, starting with a lower-cased letter, i.e. 'testerState' in this
            # first example.
            # The attribute definition has two required parameters, the type and the default value.
            # The type can be :string, :current, :voltage, :time, :frequency, integer, :double or :boolean
            pin_list:               [:string, ''],
            samples:                [:integer, 1],
            precharge_voltage:      [:voltage, 0],
            settling_time:          [:time, 0],
            # An optional parameter that sets the limits name in the 'testmethodlimits' section
            # of the generated .tf file.  Defaults to 'Functional' if not provided.
            test_name:              [:string, 'HashExample'],
            # An optional 3rd parameter can be supplied to provide an array of allowed values. If supplied,
            # Origen will raise an error upon an attempt to set it to an unlisted value.
            tester_state:           [:string, 'CONNECTED', %w(CONNECTED UNCHANGED DISCONNECTED)],
            force_mode:             [:string, 'VOLT', %w(VOLT CURR)],
            # The name of another parameter can be supplied as the type argument, meaning that the type
            # here will be either :current or :voltage depending on the value of :force_mode
            # force_value: [:force_mode, 3800.mV],
            # In cases where the C++ library has deviated from standard attribute naming conventions
            # (camel-cased with lower cased first character), the absolute attribute name can be given
            # as a string.
            # The Origen accessor for these will be the underscored version, with '.' characters
            # converted to underscores e.g. tm.an_unusual_name
            'hashParameter':        [{ param_name0: [:string, 'NO'], param_name1: [:integer, 0] }],
            'hashParameter2':       [{ param_name0: [:string, 'NO'], param_name1: [:integer, 0] }],
            'nestedHashParameter':  [{
              param_name0:          [:string, ''],
              param_list_strings:   [:list_strings, %w(E1 E2)],
              param_list_classes:   [:list_classes, %w(E1 E2)],
              'param_group.param0': [:string, ''],
              param_name1:          [{
                param_name_int:       [:integer, 0],
                param_name_double:    [:double,  0],
                param_list_strings:   [:list_strings, %w(E1 E2)],
                param_list_classes:   [:list_classes, %w(E1 E2)],
                'param_group.param1': [:string, '']
              }]
            }],
            'nestedHashParameter2': [{
              param_name0: [:string, ''],
              param_name1: [{
                param_name_int: [:integer, 0]
              }]
            }]
          }
  add_tml :my_type_check,
          class_name:         'MyTypeCheck',

          # Here is a test definition.
          # The identifier should be lower-cased and underscored, in-keeping with Ruby naming conventions.
          # By default the class name will be the camel-cased version of this identifier, so 'myTest' in
          # this case.
          my_type_check_test: {
            # [OPTIONAL] The C++ test method class name can be overridden from the default like this:
            class_name:        'MyHashExampleClass',
            int:               [:integer, 1],
            double:            [:double,  1.0],
            int_no_default:    [:integer],
            double_no_default: [:double]
          }
end

#block_loop(name, options) ⇒ Object



384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
# File 'lib/origen_testers/test/interface.rb', line 384

def block_loop(name, options)
  if options[:by_block]
    if tester.j750? || tester.uflex?
      test_instances.group do |group|
        group.name = name
        $dut.blocks.each_with_index do |block, i|
          yield block, i, group
        end
      end
    elsif tester.v93k?
      flow.group name, options do
        $dut.blocks.each_with_index do |block, i|
          yield block, i
        end
      end
    end
  else
    yield
  end
end

#collect_ac_specs(ssname, edge, options = {}) ⇒ Object

Collects AC Spec object(s) from the given expression and adds them to the given Specset



677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
# File 'lib/origen_testers/test/interface.rb', line 677

def collect_ac_specs(ssname, edge, options = {})
  options = {
    nom: { typ:  nil }
  }.merge(options)

  # Create a Specsets object from the UFlex program generator API
  ss = ac_specsets(ssname.to_sym)
  add_ac_specs(ss, edge.clk_per, options)
  add_ac_specs(ss, edge.d0_edge, options)
  add_ac_specs(ss, edge.d1_edge, options)
  add_ac_specs(ss, edge.d2_edge, options)
  add_ac_specs(ss, edge.d3_edge, options)
  add_ac_specs(ss, edge.c1_edge, options)
  add_ac_specs(ss, edge.c2_edge, options)
end

#collect_dc_specs(ssname, level, options = {}) ⇒ Object

Collects DC Spec object(s) from the given expression and adds them to the given Specset



770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
# File 'lib/origen_testers/test/interface.rb', line 770

def collect_dc_specs(ssname, level, options = {})
  options = {
    nom: { typ:  nil },
    min: { min:  nil },
    max: { max:  nil }
  }.merge(options)

  # Create a Specsets object from the UFlex program generator API
  ss = dc_specsets(ssname.to_sym)
  if level.respond_to?(:vmain)
    add_dc_specs(ss, level.vmain, options)
    add_dc_specs(ss, level.valt, options)
    add_dc_specs(ss, level.ifold, options)
  elsif level.respond_to?(:vil)
    add_dc_specs(ss, level.vil, options)
    add_dc_specs(ss, level.vih, options)
    add_dc_specs(ss, level.vol, options)
    add_dc_specs(ss, level.voh, options)
    add_dc_specs(ss, level.vcl, options)
    add_dc_specs(ss, level.vch, options)
    add_dc_specs(ss, level.vt, options)
    add_dc_specs(ss, level.voutlotyp, options)
    add_dc_specs(ss, level.vouthityp, options)
  end
end

#dc_specset(sheet_name, expression, options = {}) ⇒ Object



758
759
760
761
762
763
764
765
766
767
# File 'lib/origen_testers/test/interface.rb', line 758

def dc_specset(sheet_name, expression, options = {})
  options = {
    min: { min:  nil },
    nom: { typ:  nil },
    max: { max:  nil }
  }.merge(options)

  ss = dc_specsets(sheet_name.to_sym)
  add_dc_specs(ss, expression, options)
end

#double_int_type_check(name, options = {}) ⇒ Object



300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
# File 'lib/origen_testers/test/interface.rb', line 300

def double_int_type_check(name, options = {})
  number = options[:number]
  if tester.v93k?
    block_loop(name, options) do |block, i|
      options[:number] = number + i if number && i
      tm = test_methods.my_type_check.my_type_check_test
      tm.int    = '1'
      tm.double = '1.0'
      tm.int_no_default = ''
      tm.double_no_default = ''
      ts = test_suites.run(name, options)
      ts.test_method = tm
      flow.test ts, options
    end
  end
end

#edge(category, pin, options = {}) ⇒ Object

Assign relevant edges in preparation for edgeset/timeset sheet generation



615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
# File 'lib/origen_testers/test/interface.rb', line 615

def edge(category, pin, options = {})
  options = {
    d_src:   'PAT',     # source of the channel drive data (e.g. pattern, drive_hi, drive_lo, etc.)
    d_fmt:   'NR',      # drive data format (NR, RL, RH, etc.)
    d0_edge: '',        # time at which the input drive is turned on
    d1_edge: '',        # time of the initial data drive edge
    d2_edge: '',        # time of the return format data drive edge
    d3_edge: '',        # time at which the input drive is turned off
    c_mode:  'Edge',    # output compare mode
    c1_edge: '',        # time of the initial output compare edge
    c2_edge: '',        # time of the final output compare edge (window compare)
    t_res:   'Machine', # timing resolution (possibly ATE-specific)
    clk_per: ''         # clock period equation - for use with MCG
  }.merge(options)

  @edge_collection = edges
  @edge_collection.add(category, pin, options)
end

#edge_collectionObject



634
635
636
# File 'lib/origen_testers/test/interface.rb', line 634

def edge_collection
  @edge_collection
end

#edgeset(sheet_name, options = {}) ⇒ Object



638
639
640
641
642
643
644
645
646
647
648
649
650
651
# File 'lib/origen_testers/test/interface.rb', line 638

def edgeset(sheet_name, options = {})
  options = {
    edgeset: :es_default,
    period:  'cycle',        # tester cycle period
    t_mode:  'Machine'       # edgeset timing mode (possibly ATE-specific)
  }.merge(options)
  edgeset = options.delete(:edgeset)
  pin = options.delete(:pin)
  edge = options.delete(:edge)

  @edgeset = edgesets(sheet_name, options)
  @edgeset.add(edgeset, pin, edge, options)
  collect_ac_specs(@edgeset.es[edgeset].spec_sheet, edge)
end

#func(name, options = {}) ⇒ Object



173
174
175
176
177
178
179
180
181
182
183
184
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
216
217
218
219
220
221
222
223
224
225
226
227
228
# File 'lib/origen_testers/test/interface.rb', line 173

def func(name, options = {})
  options = {
    duration: :static
  }.merge(options)
  number = options[:number]

  if tester.j750? || tester.uflex?
    block_loop(name, options) do |block, i, group|
      options[:number] = number + i if number && i
      ins = test_instances.functional(name)
      ins.set_wait_flags(:a) if options[:duration] == :dynamic
      ins.pin_levels = options.delete(:pin_levels) if options[:pin_levels]
      if group
        pname = "#{name}_b#{i}_pset"
        patsets.add(pname, [{ pattern: "#{name}_b#{i}.PAT" },
                            { pattern: 'nvm_global_subs.PAT', start_label: 'subr' }])
        ins.pattern = pname
        flow.test(group, options) if i == 0
      else
        pname = "#{name}_pset"
        patsets.add(pname, [{ pattern: "#{name}.PAT" },
                            { pattern: 'nvm_global_subs.PAT', start_label: 'subr' }])
        ins.pattern = pname
        if options[:cz_setup]
          flow.cz(ins, options[:cz_setup], options)
        else
          flow.test(ins, options)
        end
      end
    end

  elsif tester.v93k?
    block_loop(name, options) do |block, i|
      options[:number] = number + i if number && i
      tm = test_methods.ac_tml.ac_test.functional_test
      ts = test_suites.run(name, options)
      ts.test_method = tm
      if tester.smt8?
        ts.spec = options.delete(:pin_levels) if options[:pin_levels]
        ts.spec ||= 'specs.Nominal'
      else
        ts.levels = options.delete(:pin_levels) if options[:pin_levels]
      end
      if block
        ts.pattern = "#{name}_b#{i}"
      else
        ts.pattern = name.to_s
        #    if options[:cz_setup]
        #      flow.cz(ins, options[:cz_setup], options)
        #    else
        #    end
      end
      flow.test ts, options
    end
  end
end

#func_with_charz(name, options = {}) ⇒ Object



230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
# File 'lib/origen_testers/test/interface.rb', line 230

def func_with_charz(name, options = {})
  options = {
    duration: :static
  }.merge(options)

  if tester.v93k?
    if tester.smt7?
      tm = test_methods.ac_tml.ac_test.functional_test
      ts = test_suites.run(name, options)
      ts.test_method = tm
      ts.pattern = 'charz_example'

      test_level_charz = false
      if options[:charz]
        charz_on(*options[:charz])
        test_level_charz = true
      end

      unless charz_only? && !options[:charz_test]
        options[:parent_test_name] = name
        set_conditional_charz_id(options)
        flow.test ts, options
      end

      unless options[:charz_test]
        insert_charz_tests(options.merge(parent_test_name: name, charz_test: true)) do |options|
          charz_name = :"#{name}_#{charz_routines[options[:current_routine]].name}"
          func_with_charz(charz_name, options)
        end
      end

      charz_off if test_level_charz
    else
      fail 'Only SMT7 is Implemented for Charz'
    end
  else
    fail "Tester #{tester.name} Not Yet Implemented for Charz"
  end
end

#func_with_comment(name, options = {}) ⇒ Object



270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
# File 'lib/origen_testers/test/interface.rb', line 270

def func_with_comment(name, options = {})
  if tester.v93k?
    options = {
      duration: :static
    }.merge(options)
    number = options[:number]

    block_loop(name, options) do |block, i|
      options[:number] = number + i if number && i
      tm = test_methods.ac_tml.ac_test.functional_test
      ts = test_suites.run(name, options)
      ts.test_method = tm
      ts.levels = options.delete(:pin_levels) if options[:pin_levels]
      ts.comment = options.delete(:comment) || flow.active_description
      if block
        ts.pattern = "#{name}_b#{i}"
      else
        ts.pattern = name.to_s
        #    if options[:cz_setup]
        #      flow.cz(ins, options[:cz_setup], options)
        #    else
        #    end
      end
      flow.test ts, options
    end
  else
    func(name, options)
  end
end

#global_spec(var, options = {}) ⇒ Object



811
812
813
814
815
816
817
818
819
# File 'lib/origen_testers/test/interface.rb', line 811

def global_spec(var, options = {})
  options = {
    job:     nil,
    value:   nil,
    comment: nil
  }.merge(options)

  global_specs('SpecsGlobal').add(var, job: options[:job], value: options[:value], comment: options[:comment])
end

#group(name, options = {}) ⇒ Object



577
578
579
580
581
# File 'lib/origen_testers/test/interface.rb', line 577

def group(name, options = {})
  flow.group name, options do |group|
    yield group
  end
end

#if_job(*jobs) ⇒ Object Also known as: if_jobs

Test that the block form of flow control methods like this can be overridden by an interface



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

def if_job(*jobs)
  jobs = jobs.flatten
  jobs.delete(:prb9)
  super
end

#job_def(jname, options = {}) ⇒ Object



821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
# File 'lib/origen_testers/test/interface.rb', line 821

def job_def(jname, options = {})
  options = {
    pinmap:         pinmap_sheets.map { |k, v| v.filename.gsub(/\.txt$/, '') },
    instances:      test_instance_sheets.map { |k, v| v.filename.gsub(/\.txt$/, '') },
    flows:          flow_sheets.map { |k, v| v.filename.gsub(/\.txt$/, '') },
    ac_specs:       ac_specset_sheets.map { |k, v| v.filename.gsub(/\.txt$/, '') },
    dc_specs:       dc_specset_sheets.map { |k, v| v.filename.gsub(/\.txt$/, '') },
    patsets:        patset_sheets.map { |k, v| v.filename.gsub(/\.txt$/, '') },
    patgroups:      patgroup_sheets.map { |k, v| v.filename.gsub(/\.txt$/, '') },
    bintables:      [],
    cz:             [],
    test_procs:     [],
    mix_sig_timing: [],
    wave_defs:      [],
    psets:          [],
    sigs_port_map:  [],
    fract_bus:      [],
    comment:        nil
  }.merge(options)

  program_jobs('Jobs').add(jname, options)
end

#level_collectionObject



745
746
747
# File 'lib/origen_testers/test/interface.rb', line 745

def level_collection
  @level_collection
end

#levelset(sheet_name, options = {}) ⇒ Object



749
750
751
752
753
754
755
756
# File 'lib/origen_testers/test/interface.rb', line 749

def levelset(sheet_name, options = {})
  pin = options.delete(:pin)
  level = options.delete(:level)

  @levelset = levelsets(sheet_name)
  @levelset.add(sheet_name, pin, level, options)
  collect_dc_specs(@levelset.spec_sheet, level)
end

#log(msg) ⇒ Object



165
166
167
168
169
170
171
# File 'lib/origen_testers/test/interface.rb', line 165

def log(msg)
  if tester.j750? || tester.uflex?
    flow.logprint(msg)
  else
    flow.log(msg)
  end
end

#meas(name, options = {}) ⇒ Object



506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
# File 'lib/origen_testers/test/interface.rb', line 506

def meas(name, options = {})
  options = {
    duration: :static
  }.merge(options)

  name = "meas_#{name}" unless name.to_s =~ /meas/

  if tester.j750? || tester.uflex?
    if tester.uflex?
      if options[:pins] == :dcvi
        ins = test_instances.dcvi_powersupply(name)
        ins.set_wait_flags(:a) # set wait flag for tester handshake with patterns
        ins.relay_mode = 1 # tlPowered - keep power on
      else
        ins = test_instances.functional(name)
        ins.set_wait_flags(:a) if options[:duration] == :dynamic
        ins.scale = options[:scale]
        ins.units = options[:units]
      end
      ins.pin_levels = options.delete(:pin_levels) if options[:pin_levels]
      ins.lo_limit = options[:lo_limit]
      ins.hi_limit = options[:hi_limit]
      ins.defer_limits = options[:defer_limits]
    else
      if options[:pins] == :hi_v
        ins = test_instances.board_pmu(name)
      elsif options[:pins] == :power
        ins = test_instances.powersupply(name)
      else
        ins = test_instances.pin_pmu(name)
      end
      ins.set_wait_flags(:a) if options[:duration] == :dynamic
      ins.pin_levels = options.delete(:pin_levels) if options[:pin_levels]
      ins.lo_limit = options[:lo_limit]
      ins.hi_limit = options[:hi_limit]
    end

    pname = "#{name}_pset"
    patsets.add(pname, [{ pattern: "#{name}.PAT" },
                        { pattern: 'nvm_global_subs.PAT', start_label: 'subr' }])
    ins.pattern = pname
    if options[:cz_setup]
      flow.cz(ins, options[:cz_setup], options)
    else
      flow.test(ins, options)
    end

  elsif tester.v93k?
    tm = test_methods.dc_tml.dc_test.general_pmu
    ts = test_suites.run(name, options)
    ts.test_method = tm
    if tester.smt8?
      ts.spec = options.delete(:pin_levels) if options[:pin_levels]
      ts.spec ||= 'specs.Nominal'
    else
      ts.levels = options.delete(:pin_levels) if options[:pin_levels]
    end
    ts.lo_limit = options[:lo_limit] if options[:lo_limit]
    ts.hi_limit = options[:hi_limit] if options[:hi_limit]
    ts.pattern = name.to_s
    # if options[:cz_setup]
    #  flow.cz(ins, options[:cz_setup], options)
    # else
    #  use_limit_params = [:lo_limit, :hi_limit, :scale, :units] # define options to strip for flow.test
    #  options_use_limit = options.dup                           # duplicate, as modifying options directly, even an assigned copy modifies original
    #  flow.test(ins, options.reject! { |k, _| use_limit_params.include? k })    # set up test skipping use-limit options
    #  flow.use_limit(name, options_use_limit) if options_use_limit[:hi_limit] || options_use_limit[:lo_limit]  # Only use use-limit if limits present in flow
    # end
    flow.test ts, options
  end

  def group(name, options = {})
    flow.group name, options do |group|
      yield group
    end
  end

  ####################################################
  #######  UltraFLEX Pinmap Stuff ####################
  ####################################################

  # Assign relevant pins for pinmap sheet generation
  def pinmap(name, options = {})
    pinmap = pinmaps("#{name}")
    Origen.top_level.add_pin_group :JTAG, :tdi, :tdo, :tms
    Origen.top_level.power_pin_groups.keys.each do |grp_key|
      pinmap.add_power_pin(grp_key, type: 'Power', comment: "# #{grp_key}")
    end
    Origen.top_level.virtual_pins.keys.each do |util_pin|
      upin = Origen.top_level.virtual_pins(util_pin)
      case upin.type
      when :virtual_pin
        pinmap.add_utility_pin(upin.name, type: 'Utility', comment: "# #{util_pin}")
      when :ate_ch
        pinmap.add_utility_pin(upin.name, type: 'I/O', comment: "# #{util_pin}")
      end
    end
    Origen.top_level.pin.keys.each do |pkey|
      pinmap.add_pin(Origen.top_level.pin(pkey).name, type: 'I/O', comment: "# #{pkey}")
    end
    Origen.top_level.pin_groups.keys.sort.each do |gkey|
      # Do not include pins that are aliased to themselves
      Origen.top_level.pin(gkey).each do |pin|
        pinmap.add_group_pin(gkey, Origen.top_level.pin(pin.id).name, type: 'I/O', comment: "# #{gkey}")
      end
    end
  end

  # Assign relevant edges in preparation for edgeset/timeset sheet generation
  def edge(category, pin, options = {})
    options = {
      d_src:   'PAT',     # source of the channel drive data (e.g. pattern, drive_hi, drive_lo, etc.)
      d_fmt:   'NR',      # drive data format (NR, RL, RH, etc.)
      d0_edge: '',        # time at which the input drive is turned on
      d1_edge: '',        # time of the initial data drive edge
      d2_edge: '',        # time of the return format data drive edge
      d3_edge: '',        # time at which the input drive is turned off
      c_mode:  'Edge',    # output compare mode
      c1_edge: '',        # time of the initial output compare edge
      c2_edge: '',        # time of the final output compare edge (window compare)
      t_res:   'Machine', # timing resolution (possibly ATE-specific)
      clk_per: ''         # clock period equation - for use with MCG
    }.merge(options)

    @edge_collection = edges
    @edge_collection.add(category, pin, options)
  end

  def edge_collection
    @edge_collection
  end

  def edgeset(sheet_name, options = {})
    options = {
      edgeset: :es_default,
      period:  'cycle',        # tester cycle period
      t_mode:  'Machine'       # edgeset timing mode (possibly ATE-specific)
    }.merge(options)
    edgeset = options.delete(:edgeset)
    pin = options.delete(:pin)
    edge = options.delete(:edge)

    @edgeset = edgesets(sheet_name, options)
    @edgeset.add(edgeset, pin, edge, options)
    collect_ac_specs(@edgeset.es[edgeset].spec_sheet, edge)
  end

  def timeset(sheet_name, options = {})
    options = {
      timeset:   :default,
      master_ts: :default
    }.merge(options)
    timeset = options.delete(:timeset)
    pin = options.delete(:pin)
    eset = options.delete(:eset)

    @timeset = timesets(sheet_name, options)
    @timeset.add(timeset, pin, eset, options)
  end

  def ac_specset(sheet_name, expression, options = {})
    options = {
      specset: :default,
      nom:     { typ:  nil }
    }.merge(options)

    ss = ac_specsets(sheet_name)
    add_ac_specs(ss, expression, options)
  end

  # Collects AC Spec object(s) from the given expression and adds them to the given Specset
  def collect_ac_specs(ssname, edge, options = {})
    options = {
      nom: { typ:  nil }
    }.merge(options)

    # Create a Specsets object from the UFlex program generator API
    ss = ac_specsets(ssname.to_sym)
    add_ac_specs(ss, edge.clk_per, options)
    add_ac_specs(ss, edge.d0_edge, options)
    add_ac_specs(ss, edge.d1_edge, options)
    add_ac_specs(ss, edge.d2_edge, options)
    add_ac_specs(ss, edge.d3_edge, options)
    add_ac_specs(ss, edge.c1_edge, options)
    add_ac_specs(ss, edge.c2_edge, options)
  end

  # Adds new AC Spec object(s) to the given Specset
  def add_ac_specs(ss, expression, options = {})
    options = {
      specset: :default
    }.merge(options)

    return unless expression.is_a? String
    # collect all variable names within the expression
    vars = expression.scan(/[a-zA-Z][\w]+/).map(&:to_sym)
    vars.each do |var|
      next if var =~ /^(d0_edge|d1_edge|d2_edge|d3_edge|c1_edge|c2_edge)$/
      # The substitutions below are used for backward compatibility
      next if var =~ /^(d_on|d_data|d_ret|d_off|c_open|c_close)$/
      next if var =~ /^(nS|uS|mS|S)$/i
      next if ss.ac_specsets.key?(options[:specset]) && ss.ac_specsets[options[:specset]].include?(var)

      ss.add(var, options)
    end
  end

  # Assign relevant power supply levels in preparation for levelset sheet generation
  def pwr_level(category, options = {})
    options = {
      vmain: 1.8,              # Main supply voltage
      valt:  1.8,              # Alternate supply voltage
      ifold: 1,                # Supply clamp current
      delay: 0                 # Supply power-up delay
    }.merge(options)

    @level_collection = levels
    @level_collection.add_power_level(category, options)
  end

  # Assign relevant single-ended pin levels in preparation for levelset sheet generation
  def pin_level_se(category, options = {})
    options = {
      vil:       0,            # Input drive low
      vih:       1.8,            # Input drive high
      vol:       1.0,            # Output compare low
      voh:       0.8,            # Output compare high
      vcl:       -1,            # Voltage clamp low
      vch:       2.5,            # Voltage clamp high
      vt:        0.9,            # Termination voltage
      voutlotyp: 0,            #
      vouthityp: 0,            #
      dmode:     'Largeswing-VT' # Driver mode
    }.merge(options)

    @level_collection = levels
    @level_collection.add_se_pin_level(category, options)
  end

  def level_collection
    @level_collection
  end

  def levelset(sheet_name, options = {})
    pin = options.delete(:pin)
    level = options.delete(:level)

    @levelset = levelsets(sheet_name)
    @levelset.add(sheet_name, pin, level, options)
    collect_dc_specs(@levelset.spec_sheet, level)
  end

  def dc_specset(sheet_name, expression, options = {})
    options = {
      min: { min:  nil },
      nom: { typ:  nil },
      max: { max:  nil }
    }.merge(options)

    ss = dc_specsets(sheet_name.to_sym)
    add_dc_specs(ss, expression, options)
  end

  # Collects DC Spec object(s) from the given expression and adds them to the given Specset
  def collect_dc_specs(ssname, level, options = {})
    options = {
      nom: { typ:  nil },
      min: { min:  nil },
      max: { max:  nil }
    }.merge(options)

    # Create a Specsets object from the UFlex program generator API
    ss = dc_specsets(ssname.to_sym)
    if level.respond_to?(:vmain)
      add_dc_specs(ss, level.vmain, options)
      add_dc_specs(ss, level.valt, options)
      add_dc_specs(ss, level.ifold, options)
    elsif level.respond_to?(:vil)
      add_dc_specs(ss, level.vil, options)
      add_dc_specs(ss, level.vih, options)
      add_dc_specs(ss, level.vol, options)
      add_dc_specs(ss, level.voh, options)
      add_dc_specs(ss, level.vcl, options)
      add_dc_specs(ss, level.vch, options)
      add_dc_specs(ss, level.vt, options)
      add_dc_specs(ss, level.voutlotyp, options)
      add_dc_specs(ss, level.vouthityp, options)
    end
  end

  # Adds new DC Spec object(s) to the given Specset
  def add_dc_specs(ss, expression, options = {})
    options = {
      specset: :default
    }.merge(options)

    return unless expression.is_a? String
    vars = expression.scan(/[a-zA-Z][\w]+/).map(&:to_sym)
    vars.each do |var|
      next if var =~ /^(nA|uA|mA|A|nV|uV|mV|V)$/i

      ss.add(var, options)
    end
  end

  def global_spec(var, options = {})
    options = {
      job:     nil,
      value:   nil,
      comment: nil
    }.merge(options)

    global_specs('SpecsGlobal').add(var, job: options[:job], value: options[:value], comment: options[:comment])
  end

  def job_def(jname, options = {})
    options = {
      pinmap:         pinmap_sheets.map { |k, v| v.filename.gsub(/\.txt$/, '') },
      instances:      test_instance_sheets.map { |k, v| v.filename.gsub(/\.txt$/, '') },
      flows:          flow_sheets.map { |k, v| v.filename.gsub(/\.txt$/, '') },
      ac_specs:       ac_specset_sheets.map { |k, v| v.filename.gsub(/\.txt$/, '') },
      dc_specs:       dc_specset_sheets.map { |k, v| v.filename.gsub(/\.txt$/, '') },
      patsets:        patset_sheets.map { |k, v| v.filename.gsub(/\.txt$/, '') },
      patgroups:      patgroup_sheets.map { |k, v| v.filename.gsub(/\.txt$/, '') },
      bintables:      [],
      cz:             [],
      test_procs:     [],
      mix_sig_timing: [],
      wave_defs:      [],
      psets:          [],
      sigs_port_map:  [],
      fract_bus:      [],
      comment:        nil
    }.merge(options)

    program_jobs('Jobs').add(jname, options)
  end

  def reference(reference, options = {})
    options = {
      comment:        nil
    }.merge(options)

    references('Refs').add(reference, options)
  end
end

#meas_multi_limits(name, options = {}) ⇒ Object



481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
# File 'lib/origen_testers/test/interface.rb', line 481

def meas_multi_limits(name, options = {})
  options = {
    duration: :static
  }.merge(options)

  name = "measmulti_#{name}" unless name.to_s =~ /measmulti/

  if tester.uflex?
    ins = test_instances.functional(name)
    ins.set_wait_flags(:a) if options[:duration] == :dynamic
    ins.pin_levels = options.delete(:pin_levels) if options[:pin_levels]
    ins.defer_limits = options[:defer_limits]

    # some made up sub test limits
    options[:sub_tests] = [sub_test('limit1', lo: 0, hi: 7), sub_test('limit2', lo: 3, hi: 8)]

    pname = "#{name}_pset"
    patsets.add(pname, [{ pattern: "#{name}.PAT" },
                        { pattern: 'nvm_global_subs.PAT', start_label: 'subr' }])
    ins.pattern = pname

    flow.test(ins, options)
  end
end

#mto_memory(name, options = {}) ⇒ Object



450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
# File 'lib/origen_testers/test/interface.rb', line 450

def mto_memory(name, options = {})
  options = {
    duration: :static
  }.merge(options)

  if tester.j750?
    block_loop(name, options) do |block, i, group|
      ins = test_instances.mto_memory(name)
      ins.set_wait_flags(:a) if options[:duration] == :dynamic
      ins.pin_levels = options.delete(:pin_levels) if options[:pin_levels]
      if group
        pname = "#{name}_b#{i}_pset"
        patsets.add(pname, [{ pattern: "#{name}_b#{i}.PAT" },
                            { pattern: 'nvm_global_subs.PAT', start_label: 'subr' }])
        ins.pattern = pname
        flow.test(group, options) if i == 0
      else
        pname = "#{name}_pset"
        patsets.add(pname, [{ pattern: "#{name}.PAT" },
                            { pattern: 'nvm_global_subs.PAT', start_label: 'subr' }])
        ins.pattern = pname
        if options[:cz_setup]
          flow.cz(ins, options[:cz_setup], options)
        else
          flow.test(ins, options)
        end
      end
    end
  end
end

#my_hash_test(name, options = {}) ⇒ Object



317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
# File 'lib/origen_testers/test/interface.rb', line 317

def my_hash_test(name, options = {})
  number = options[:number]

  if tester.v93k? && tester.smt8?
    block_loop(name, options) do |block, i|
      options[:number] = number + i if number && i
      tm = test_methods.my_hash_tml.my_hash_test
      tm.hashParameter = {
        param1: {}
      }
      tm.nestedHashParameter = {
        my_param_name0: {
          param_name0:        'hello',
          param_group_param0: 'test_group',
          param_name1:        {
            my_param_name1: {
              param_name_int:     '1',
              param_name_double:  '1.0',
              param_group_param1: 'test_nested_group'
            },
            my_param_name2: {
              param_name_int:    2,
              param_name_double: 2.0
            },
            my_param_name3: {
              param_name_int: 3
            }
          }
        }
      }
      tm.nestedHashParameter2 = {
        my_param_name4: {
          param_name0: 'goodbye'
        },
        my_param_name5: {
          param_name0: 'goodbye forever'
        }
      }
      tm.samples = '2'
      ts = test_suites.run(name, options)
      ts.test_method = tm
      ts.spec = options.delete(:pin_levels) if options[:pin_levels]
      ts.spec ||= 'specs.Nominal'
      flow.test ts, options
    end
  end
end

#my_override_spec_test(name, options = {}) ⇒ Object



365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
# File 'lib/origen_testers/test/interface.rb', line 365

def my_override_spec_test(name, options = {})
  number = options[:number]

  if tester.v93k? && tester.smt8?
    tm = test_methods.ac_tml.ac_test.functional_test
    ts = test_suites.run(name, options)
    ts.test_method = tm
    ts.spec = options.delete(:pin_levels) if options[:pin_levels]
    ts.spec ||= 'specs.Nominal'
    ts.pattern = 'pat1'
    ts.burst = 'sequence1'
    ts.spec_path = 'myCustomSpecPath'
    ts.seq_path  = 'myCustomSeqPath'
    ts.spec_namespace = 'myCustomSpecNamespace'
    ts.seq_namespace  = 'myCustomSeqNamespace'
    flow.test ts, options
  end
end

#nop(options = {}) ⇒ Object



446
447
448
# File 'lib/origen_testers/test/interface.rb', line 446

def nop(options = {})
  flow.nop options
end

#or_ids(options = {}) ⇒ Object

OR 2 IDS together into 1 flag



442
443
444
# File 'lib/origen_testers/test/interface.rb', line 442

def or_ids(options = {})
  flow.or_flags(options[:id1], options[:id2], options)
end

#para(name, options = {}) ⇒ Object



424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
# File 'lib/origen_testers/test/interface.rb', line 424

def para(name, options = {})
  options = {
    high_voltage: false
  }.merge(options)

  if tester.j750?
    if options.delete(:high_voltage)
      ins = test_instances.bpmu(name)
    else
      ins = test_instances.ppmu(name)
    end
    ins.dc_category = 'NVM_PARA'
    flow.test(ins, options)
    patsets.add("#{name}_pset", pattern: "#{name}.PAT")
  end
end

#pin_level_se(category, options = {}) ⇒ Object

Assign relevant single-ended pin levels in preparation for levelset sheet generation



727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
# File 'lib/origen_testers/test/interface.rb', line 727

def pin_level_se(category, options = {})
  options = {
    vil:       0,            # Input drive low
    vih:       1.8,            # Input drive high
    vol:       1.0,            # Output compare low
    voh:       0.8,            # Output compare high
    vcl:       -1,            # Voltage clamp low
    vch:       2.5,            # Voltage clamp high
    vt:        0.9,            # Termination voltage
    voutlotyp: 0,            #
    vouthityp: 0,            #
    dmode:     'Largeswing-VT' # Driver mode
  }.merge(options)

  @level_collection = levels
  @level_collection.add_se_pin_level(category, options)
end

#pinmap(name, options = {}) ⇒ Object

Assign relevant pins for pinmap sheet generation



588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
# File 'lib/origen_testers/test/interface.rb', line 588

def pinmap(name, options = {})
  pinmap = pinmaps("#{name}")
  Origen.top_level.add_pin_group :JTAG, :tdi, :tdo, :tms
  Origen.top_level.power_pin_groups.keys.each do |grp_key|
    pinmap.add_power_pin(grp_key, type: 'Power', comment: "# #{grp_key}")
  end
  Origen.top_level.virtual_pins.keys.each do |util_pin|
    upin = Origen.top_level.virtual_pins(util_pin)
    case upin.type
    when :virtual_pin
      pinmap.add_utility_pin(upin.name, type: 'Utility', comment: "# #{util_pin}")
    when :ate_ch
      pinmap.add_utility_pin(upin.name, type: 'I/O', comment: "# #{util_pin}")
    end
  end
  Origen.top_level.pin.keys.each do |pkey|
    pinmap.add_pin(Origen.top_level.pin(pkey).name, type: 'I/O', comment: "# #{pkey}")
  end
  Origen.top_level.pin_groups.keys.sort.each do |gkey|
    # Do not include pins that are aliased to themselves
    Origen.top_level.pin(gkey).each do |pin|
      pinmap.add_group_pin(gkey, Origen.top_level.pin(pin.id).name, type: 'I/O', comment: "# #{gkey}")
    end
  end
end

#por(options = {}) ⇒ Object



413
414
415
416
417
418
419
420
421
422
# File 'lib/origen_testers/test/interface.rb', line 413

def por(options = {})
  options = {
    instance_not_available: true
  }.merge(options)
  if tester.j750? || tester.uflex?
    flow.test('por_ins', options)
  else
    func('por_ins', options)
  end
end

#pwr_level(category, options = {}) ⇒ Object

Assign relevant power supply levels in preparation for levelset sheet generation



714
715
716
717
718
719
720
721
722
723
724
# File 'lib/origen_testers/test/interface.rb', line 714

def pwr_level(category, options = {})
  options = {
    vmain: 1.8,              # Main supply voltage
    valt:  1.8,              # Alternate supply voltage
    ifold: 1,                # Supply clamp current
    delay: 0                 # Supply power-up delay
  }.merge(options)

  @level_collection = levels
  @level_collection.add_power_level(category, options)
end

#reference(reference, options = {}) ⇒ Object



844
845
846
847
848
849
850
# File 'lib/origen_testers/test/interface.rb', line 844

def reference(reference, options = {})
  options = {
    comment:        nil
  }.merge(options)

  references('Refs').add(reference, options)
end

#shmoo(name, targets, options = {}) ⇒ Object



405
406
407
408
409
410
411
# File 'lib/origen_testers/test/interface.rb', line 405

def shmoo(name, targets, options = {})
  if tester.v93k? && tester.smt8?
    targets = [targets] unless targets.is_a?(Array)
    st = shmoo_tests.run(name, { targets: targets }.merge(options))
    flow.test st, options
  end
end

#timeset(sheet_name, options = {}) ⇒ Object



653
654
655
656
657
658
659
660
661
662
663
664
# File 'lib/origen_testers/test/interface.rb', line 653

def timeset(sheet_name, options = {})
  options = {
    timeset:   :default,
    master_ts: :default
  }.merge(options)
  timeset = options.delete(:timeset)
  pin = options.delete(:pin)
  eset = options.delete(:eset)

  @timeset = timesets(sheet_name, options)
  @timeset.add(timeset, pin, eset, options)
end