Module: OrigenTesters::Charz

Included in:
Test::Interface
Defined in:
lib/origen_testers/charz.rb,
lib/origen_testers/charz/profile.rb,
lib/origen_testers/charz/routine.rb,
lib/origen_testers/charz/session.rb,
lib/origen_testers/charz/routines/shmoo_routine.rb,
lib/origen_testers/charz/routines/search_routine.rb

Defined Under Namespace

Classes: CharzTuple, Profile, Routine, SearchRoutine, Session, ShmooRoutine

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#charz_instanceObject

If there is a current instance present, that should always be used. However when running EOF charz, the instance to be used is no longer set, so instead of referencing the session, use the one that we've stored already



23
# File 'lib/origen_testers/charz.rb', line 23

attr_accessor :charz_stack, :charz_routines, :charz_profiles, :charz_session, :charz_instance, :eof_charz_tests, :skip_group_eof_charz_tests, :eof_charz_tests_group_name

#charz_profilesHash

Returns user defined charz profiles.

Returns:

  • (Hash)

    user defined charz profiles



23
# File 'lib/origen_testers/charz.rb', line 23

attr_accessor :charz_stack, :charz_routines, :charz_profiles, :charz_session, :charz_instance, :eof_charz_tests, :skip_group_eof_charz_tests, :eof_charz_tests_group_name

#charz_routinesHash

Returns user defined charz routines.

Returns:

  • (Hash)

    user defined charz routines



23
# File 'lib/origen_testers/charz.rb', line 23

attr_accessor :charz_stack, :charz_routines, :charz_profiles, :charz_session, :charz_instance, :eof_charz_tests, :skip_group_eof_charz_tests, :eof_charz_tests_group_name

#charz_sessionSession

Returns current charz session, based on data in the top of the charz_stack.

Returns:

  • (Session)

    current charz session, based on data in the top of the charz_stack



23
# File 'lib/origen_testers/charz.rb', line 23

attr_accessor :charz_stack, :charz_routines, :charz_profiles, :charz_session, :charz_instance, :eof_charz_tests, :skip_group_eof_charz_tests, :eof_charz_tests_group_name

#charz_stackArray

Returns FILO queue of charz session defining data.

Returns:

  • (Array)

    FILO queue of charz session defining data



23
24
25
# File 'lib/origen_testers/charz.rb', line 23

def charz_stack
  @charz_stack
end

#eof_charz_testsArray

Returns charz tests to be added at the end of the flow.

Returns:

  • (Array)

    charz tests to be added at the end of the flow



23
# File 'lib/origen_testers/charz.rb', line 23

attr_accessor :charz_stack, :charz_routines, :charz_profiles, :charz_session, :charz_instance, :eof_charz_tests, :skip_group_eof_charz_tests, :eof_charz_tests_group_name

#eof_charz_tests_group_nameString, Symbol

Returns group name to be used to for eof charz tests.

Returns:

  • (String, Symbol)

    group name to be used to for eof charz tests



23
# File 'lib/origen_testers/charz.rb', line 23

attr_accessor :charz_stack, :charz_routines, :charz_profiles, :charz_session, :charz_instance, :eof_charz_tests, :skip_group_eof_charz_tests, :eof_charz_tests_group_name

#skip_group_eof_charz_testsBoolean

Returns whether or not to wrap eof charz tests in a group.

Returns:

  • (Boolean)

    whether or not to wrap eof charz tests in a group



23
# File 'lib/origen_testers/charz.rb', line 23

attr_accessor :charz_stack, :charz_routines, :charz_profiles, :charz_session, :charz_instance, :eof_charz_tests, :skip_group_eof_charz_tests, :eof_charz_tests_group_name

Instance Method Details

#add_charz_profile(id, options = {}, &block) ⇒ Object

Add a new charz profile to @charz_profiles A charz profile is a collection of one or more charz routines, as well as flow control and placement data for the charz tests generated by those routines

Examples:

create a profile containing 2 routines, end of flow placement, whose tests are only ran if the parent fails

add_charz_profile :my_profile do |prof|
  prof.routines  = [:my_routine1, :my_routine2]
  prof.placement = :eof
  prof.on_result = :on_fail
end

Parameters:

  • id (Symbol)

    charz_profile id, will be the key value in the @charz_profiles hash. Must not have been previously used

  • options (Hash) (defaults to: {})

    charz_profile options



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

def add_charz_profile(id, options = {}, &block)
  if charz_profiles.ids.include?(id)
    Origen.log.error("Cannot create charz profile '#{id}', it already exists!")
    fail
  end
  charz_profiles[id] = Profile.new(id, options.merge(defined_routines: charz_routines.ids), &block)
end

#add_charz_routine(id, options = {}, &block) ⇒ Object

Add a new charz routine to @charz_routines A charz routine is a object that contains all the necessary info specific to a characterization test Its intended to be used in combination with an existing point test (regular non charz test) to create a characterization version of the point test

To use your own Routine classes, override the create_charz_routine method in your interface

Examples:

create a 1d search routine that searches vdd, from 900mv to 300mv, resolution of 5mv

add_charz_routine :my_routine, type: search do |rt|
  rt.start = 900.mv
  rt.stop  = 300.mv
  rt.res   = 5.mv
  rt.spec  = 'vdd'
end

Parameters:

  • id (Symbol)

    charz_routine id, will be the key value in the @charz_routines hash. Must not have been previously used

  • options (Hash) (defaults to: {})

    charz_routine options

Options Hash (options):

  • :type (Symbol)

    :search or :'1d' will create a SearchRoutine, :shmoo or :'2d' will create a ShmooRoutine, nil will create a Routine



78
79
80
81
82
83
84
# File 'lib/origen_testers/charz.rb', line 78

def add_charz_routine(id, options = {}, &block)
  if charz_routines.ids.include?(id)
    Origen.log.error("Cannot create charz routine '#{id}', it already exists!")
    fail
  end
  charz_routines[id] = create_charz_routine(id, options, &block)
end

#charz_active?Boolean

Queries the current charz session to see if its active, indicating point tests should be generating charz tests

Returns:

  • (Boolean)


126
127
128
# File 'lib/origen_testers/charz.rb', line 126

def charz_active?
  charz_session.active?
end

#charz_offObject

Removes the current session generating data off the charz stack If charz data is still on the stack afterward, the session will update to reflect the new data if not, the session will become inactive



148
149
150
151
152
153
154
155
156
157
# File 'lib/origen_testers/charz.rb', line 148

def charz_off
  charz_stack.pop
  unless charz_session.update(charz_stack.last) || charz_stack.empty?
    Origen.log.error 'charz_on failed to create a valid charz session'
    fail
  end
  if charz_stack.empty?
    set_charz_instance(nil)
  end
end

#charz_off_truncateObject

Removes the current sessions last instance. If the session only had one instance, this is functionally the same as charz_off If charz data is still on the stack afterward, the session will update to reflect the new data if not, the session will become inactive



210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
# File 'lib/origen_testers/charz.rb', line 210

def charz_off_truncate
  session = charz_stack.pop || []
  session.pop
  unless session.empty?
    charz_stack.push(session)
  end

  unless charz_session.update(charz_stack.last) || charz_stack.empty?
    Origen.log.error 'charz_on failed to create a valid charz session'
    fail
  end
  if charz_stack.empty?
    set_charz_instance(nil)
  end
end

#charz_on(charz_id, options = {}) ⇒ Object

Pushes a charz object (either a profile or a routine) onto the stack, along with any optional updates to modify the current session Once pushed, the charz_session will attempt to update itself with the new data, failing if the resulting session is invalid

If a block is passed, yield the block of tests to enable charz for those tests, then disable charz with a charz_off call

Parameters:

  • charz_id (Symbol)

    either a routine or profile id. Method fails if the id can't be found in @charz_routines or @charz_profiles

  • options (Hash) (defaults to: {})

    charz_on options

Options Hash (options):

  • :type (Symbol) — default: :profile

    whether the charz_id refers to a charz profile or routine



167
168
169
170
171
172
173
174
175
176
177
# File 'lib/origen_testers/charz.rb', line 167

def charz_on(charz_id, options = {})
  charz_stack.push([get_charz_tuple(charz_id, options)])
  unless charz_session.update(charz_stack.last)
    Origen.log.error 'charz_on failed to create a valid charz session'
    fail
  end
  if block_given?
    yield
    charz_off
  end
end

#charz_on_append(charz_id, options = {}) ⇒ Object

Pushes a charz object (either a profile or a routine) onto the current sessions instance stack, along with any optional updates to modify that instance. This will result in subsequent charzable point tests in being processed against each of the current instances. In other words, this new push will not take priority over the current stack head, but instead append to it. Once pushed, the charz_session will attempt to update itself with the new data, failing if the resulting session is invalid

If a block is passed, yield the block of tests to enable charz for those tests, then disable charz with a charz_off_truncate call

Parameters:

  • charz_id (Symbol)

    either a routine or profile id. Method fails if the id can't be found in @charz_routines or @charz_profiles

  • options (Hash) (defaults to: {})

    charz_on options

Options Hash (options):

  • :type (Symbol) — default: :profile

    whether the charz_id refers to a charz profile or routine



189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
# File 'lib/origen_testers/charz.rb', line 189

def charz_on_append(charz_id, options = {})
  charz_tuple = get_charz_tuple(charz_id, options)

  # take the current session and append to its instance stack
  session = charz_stack.pop || []
  session.push(charz_tuple)
  charz_stack.push(session)

  unless charz_session.update(charz_stack.last)
    Origen.log.error 'charz_on failed to create a valid charz session'
    fail
  end
  if block_given?
    yield
    charz_off_truncate
  end
end

#charz_only?Boolean

Queries the current charz session to see if point tests should skip generation, only adding the resulting charz test

Returns:

  • (Boolean)


131
132
133
# File 'lib/origen_testers/charz.rb', line 131

def charz_only?
  charz_active? && charz_session.charz_only?
end

#charz_pauseObject

Pauses the current charz session, preventing point tests from generating charz tests even if the session is valid



136
137
138
# File 'lib/origen_testers/charz.rb', line 136

def charz_pause
  charz_session.pause
end

#charz_resumeObject

Resumes the current charz session. If the session isn't valid (ie charz_resume before setting up the session) then nothing will happen



141
142
143
# File 'lib/origen_testers/charz.rb', line 141

def charz_resume
  charz_session.resume
end

#create_charz_routine(id, options = {}, &block) ⇒ Routine

Called by add_charz_routine, split out from that method to make it easier to override this handler from a user's interface This is the method to override if you want to use custom Routines specifc to your company's implementation

Parameters:

  • id (Symbol)

    charz_routine id, will be the key value in the @charz_routines hash. Must not have been previously used

  • options (Hash) (defaults to: {})

    charz_routine options

Options Hash (options):

  • :type (Symbol)

    :search or :'1d' will create a SearchRoutine, :shmoo or :'2d' will create a ShmooRoutine, nil will create a Routine

Returns:

  • (Routine)

    a charz routine object



93
94
95
96
97
98
99
100
101
102
# File 'lib/origen_testers/charz.rb', line 93

def create_charz_routine(id, options = {}, &block)
  case options[:type]
  when :search, :'1d'
    SearchRoutine.new(id, options, &block)
  when :shmoo, :'2d'
    ShmooRoutine.new(id, options, &block)
  else
    Routine.new(id, options, &block)
  end
end

#generate_eof_charz_testsObject

called automatically right after a top_level shutdown, generates end of flow charz tests user should not have to reference this call explicitly



304
305
306
307
308
309
310
311
312
313
314
315
# File 'lib/origen_testers/charz.rb', line 304

def generate_eof_charz_tests
  unless eof_charz_tests.empty?
    if skip_group_eof_charz_tests
      eof_charz_tests.map(&:call)
    else
      group_name = eof_charz_tests_group_name || 'End of Flow Charz Tests'
      group group_name do
        eof_charz_tests.map(&:call)
      end
    end
  end
end

#insert_charz_tests(options, &block) ⇒ Object

Called after the relevant point test has been inserted into the flow Takes the options used to build the previous point test as well as insert_charz_test specific options to then drill down to the point of the flow where the charz test would go, at which point control is handed back to the user's interface to handle creating and inserting the test. This will occur for each instance in the current session's instance stack

By default, this method will handle:

- the placement of the test (inline aka right after the point test, end of flow, or other)
- wrapping the created charz tests in a group (skippable, group name defaults to <point test name> charz <session name>)
- conditionally executing the charz tests based on if the point test passed or failed (see set_conditional_charz_id)
- conditionally executing some/all charz tests based on a mix of enables and flags

After the above is determined, the user regains control on a per-routine (if multiple routines) basis to then process generating the charz test



267
268
269
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
299
300
# File 'lib/origen_testers/charz.rb', line 267

def insert_charz_tests(options, &block)
  if charz_active?
    if options[:id]
      # two purposes:
      # 1) prevent all charz tests inadverntently using the same ID as their parent
      # 2) used in on_result behavior
      current_id = options.delete(:id)
      options[:last_test_id] ||= current_id
    end
    charz_session.loop_instances do
      case charz_instance.placement
      when :inline
        create_charz_group(options, &block)
      when :eof
        # collect the current instance and options into a proc, stored in eof_charz_tests to be called later
        current_instance = charz_instance.clone
        eof_charz_tests << proc do
          set_charz_instance(current_instance)
          create_charz_group(options, &block)
        end
      else
        # inline is the default behavior, and eof (end of flow) has built in support.
        if respond_to?(:"create_#{charz_instance.placement}_charz_tests")
          send(:"create_#{charz_instance.placement}_charz_tests", options, &block)
        elsif respond_to?(:"insert_#{charz_instance.placement}_charz_tests")
          send(:"insert_#{charz_instance.placement}_charz_tests", options, &block)
        else
          Origen.log.error "No handling specified for #{charz_instance.placement} placement charz tests"
          fail
        end
      end
    end
  end
end

#set_charz_instance(instance) ⇒ Object



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

def set_charz_instance(instance)
  @charz_instance = instance
  charz_session.stored_instance = instance
end

#set_conditional_charz_id(*args) ⇒ Object

An optional helper method to automatically assign an id to tests that will be generating charz tests that depend on the result of the parent test

Parameters:

  • options (Hash)

    the options for a test before its created and added to the flow

  • instance (TestInstance, #name)

    <Optional> the test instance whose name is stored in .name, alternatively pass the name in the options hash under :parent_test_name



229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
# File 'lib/origen_testers/charz.rb', line 229

def set_conditional_charz_id(*args)
  case args.size
  when 1
    options = args[0]
    parent_test_name = options[:parent_test_name]
  when 2
    instance = args[0]
    options = args[1]
    parent_test_name = instance.name
  else
    Origen.log.error 'Too many arguments passed to set_conditional_charz_id. Pass either (test_instance, options), or just (options)'
    fail
  end
  unless options[:id]
    if charz_active?
      if charz_session.on_result?
        md5_id = Digest::MD5.new
        md5_id << parent_test_name.to_s
        md5_id << options.to_s
        md5_id << charz_session.id.to_s
        options[:id] = "auto_charz_id_#{md5_id}".to_sym
      end
    end
  end
end