Class: OrigenTesters::SmartestBasedTester::Base::Flow

Inherits:
ATP::Formatter show all
Includes:
Flow
Defined in:
lib/origen_testers/smartest_based_tester/base/flow.rb

Direct Known Subclasses

V93K::Flow, V93K_SMT8::Flow

Constant Summary collapse

RELATIONAL_OPERATOR_STRINGS =
{
  eq: '==',
  ne: '!=',
  gt: '>',
  ge: '>=',
  lt: '<',
  le: '<='
}

Constants included from Flow

Flow::PROGRAM_MODELS_DIR

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Flow

#active_description, #at_run_start, callstack, cc_comments, cc_comments=, #children, comment_stack, #context_changed?, flow_comments, flow_comments=, #generate_unique_label, ht_comments, ht_comments=, #is_the_flow?, #model, name_stack, #nop, #orig_render, #parent, #path, #program, #render, #save_program, #sig, #test, #top_level, #top_level?, unique_ids, unique_ids=

Methods included from ATP::FlowAPI

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

Methods included from Generator

#close, #collection, #collection=, #compiler, #current_dir, #dont_diff=, execute_source, #file_extension, #file_pipeline, #filename=, #identity_map, #import, #inhibit_output, #name, #on_close, original_reference_file, original_reference_file=, #output_file, #output_inhibited?, #platform, #reference_file, #render, #set_flow_description, #stats, #to_be_written?, #write_from_template, #write_to_file

Methods inherited from ATP::Formatter

#format, format, run, run_and_format, #run_and_format

Methods inherited from ATP::Processor

#clean_flag, #extract_volatiles, #handler_missing, #process, #process_all, #run, #volatile?, #volatile_flags

Instance Attribute Details

#add_flow_enableObject

Returns the value of attribute add_flow_enable.


21
22
23
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 21

def add_flow_enable
  @add_flow_enable
end

#flow_bypassObject

Returns the value of attribute flow_bypass.


21
22
23
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 21

def flow_bypass
  @flow_bypass
end

#flow_descriptionObject

Returns the value of attribute flow_description.


21
22
23
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 21

def flow_description
  @flow_description
end

#flow_name(filename = nil) ⇒ Object

Returns the value of attribute flow_name.


21
22
23
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 21

def flow_name
  @flow_name
end

#linesObject

Returns the value of attribute lines.


17
18
19
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 17

def lines
  @lines
end

#set_runtime_variablesObject (readonly)

Returns an array containing all runtime variables which get set by the flow


19
20
21
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 19

def set_runtime_variables
  @set_runtime_variables
end

#stackObject

Returns the value of attribute stack.


17
18
19
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 17

def stack
  @stack
end

#subdirectoryObject

Returns the value of attribute subdirectory.


21
22
23
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 21

def subdirectory
  @subdirectory
end

#test_methodsObject

Returns the value of attribute test_methods.


17
18
19
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 17

def test_methods
  @test_methods
end

#test_suitesObject

Returns the value of attribute test_suites.


17
18
19
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 17

def test_suites
  @test_suites
end

#var_filenameObject

Returns the value of attribute var_filename.


17
18
19
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 17

def var_filename
  @var_filename
end

Class Method Details

.generate_flag_name(flag) ⇒ Object


23
24
25
26
27
28
29
30
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 23

def self.generate_flag_name(flag)
  case flag[0]
  when '$'
    flag[1..-1]
  else
    flag.upcase
  end
end

Instance Method Details

#all_sub_flowsObject

Returns an array containing all sub-flow objects, not just the immediate children


154
155
156
157
158
159
160
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 154

def all_sub_flows
  @all_sub_flows ||= begin
    sub_flows = []
    extract_sub_flows(self, sub_flows)
    sub_flows
  end
end

#astObject


142
143
144
145
146
147
148
149
150
151
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 142

def ast
  @ast = nil unless @finalized
  @ast ||= begin
    unique_id = smt8? ? nil : sig
    atp.ast(unique_id: unique_id, optimization: :smt,
          implement_continue: !tester.force_pass_on_continue,
          optimize_flags_when_continue: !tester.force_pass_on_continue
           )
  end
end

#at_flow_endObject


137
138
139
140
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 137

def at_flow_end
  # Take whatever the test modes are set to at the end of the flow as what we go with
  @test_modes = tester.limitfile_test_modes
end

#at_flow_startObject


117
118
119
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 117

def at_flow_start
  model # Call to ensure the signature gets populated
end

#capture_linesObject

Any calls to line made within the given block will be returned in an array, rather than immediately being put into the @lines array


261
262
263
264
265
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 261

def capture_lines
  @lines_buffer << []
  yield
  @lines_buffer.pop
end

#clean_job(job) ⇒ Object


691
692
693
694
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 691

def clean_job(job)
  var = smt8? ? 'JOB' : '@JOB'
  [job].flatten.map { |j| "#{var} == \"#{j.to_s.upcase}\"" }
end

#extract_sub_flows(flow, sub_flows) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


163
164
165
166
167
168
169
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 163

def extract_sub_flows(flow, sub_flows)
  flow.children.each do |id, sub_flow|
    sub_flows << sub_flow
    extract_sub_flows(sub_flow, sub_flows)
  end
  sub_flows
end

#filenameObject


56
57
58
59
60
61
62
63
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 56

def filename
  base = super.gsub('_flow', '')
  if smt8?
    flow_name(base) + '.flow'
  else
    base
  end
end

#finalize(options = {}) ⇒ Object

This is called by Origen on each flow after they have all been executed but before they are finally written/rendered


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
229
230
231
232
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 179

def finalize(options = {})
  if smt8?
    return unless top_level? || options[:called_by_top_level]
    super
    @finalized = true
    # All flows have now been executed and the top-level contains the final AST.
    # The AST contained in each child flow may not be complete since it has not been subject to the
    # full-flow processing, e.g. to set flags in the event of a reference to a test being made from
    # outside of a sub-flow.
    # So here we substitute the AST in all sub-flows with the corresponding sub-flow node from the
    # top-level AST, then we finalize the sub-flows with the final AST in place and then later final
    # writing/rendering will be called as normal.
    if top_level?
      ast.find_all(:sub_flow, recursive: true).each do |sub_flow_ast|
        sub_flow = sub_flow_from(sub_flow_ast)
        unless sub_flow
          fail "Something went wrong, couldn't find the sub-flow object for path #{path}"
        end
        # on_fail and on_pass nodes are removed because they will be rendered by the sub-flow's parent
        sub_flow.instance_variable_set(:@ast, sub_flow_ast.remove(:on_fail, :on_pass).updated(:flow))
        sub_flow.instance_variable_set(:@finalized, true)  # To stop the AST being regenerated
      end
      options[:called_by_top_level] = true
      all_sub_flows.each { |f| f.finalize(options) }
      options.delete(:called_by_top_level)
    end
  else
    super
    @finalized = true
  end
  if smt8?
    @indent = (add_flow_enable && top_level?) ? 3 : 2
  else
    @indent = add_flow_enable ? 2 : 1
  end
  @lines = []
  @lines_buffer = []
  @open_test_methods = []
  @open_test_names = []
  @post_test_lines = []
  @stack = { on_fail: [], on_pass: [] }
  @set_runtime_variables = ast.excluding_sub_flows.set_flags
  process(ast)
  unless smt8?
    unless flow_variables[:empty?]
      Origen.interface.variables_file(self).add_variables(flow_variables)
    end
  end
  test_suites.finalize
  test_methods.finalize
  if tester.create_limits_file && top_level?
    render_limits_file
  end
end

#flow_enable_var_nameObject


65
66
67
68
69
70
71
72
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 65

def flow_enable_var_name
  var = filename.sub(/\..*/, '').upcase
  if smt8?
    'ENABLE'
  else
    generate_flag_name("#{var}_ENABLE")
  end
end

#flow_variablesObject


98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 98

def flow_variables
  @flow_variables ||= begin
    vars = Processors::ExtractFlowVars.new.run(ast)
    if !smt8? || (smt8? && top_level?)
      if add_flow_enable
        if add_flow_enable == :enabled
          vars[:all][:referenced_enables] << [flow_enable_var_name, 1]
          vars[:this_flow][:referenced_enables] << [flow_enable_var_name, 1]
        else
          vars[:all][:referenced_enables] << [flow_enable_var_name, 0]
          vars[:this_flow][:referenced_enables] << [flow_enable_var_name, 0]
        end
        vars[:empty?] = false
      end
    end
    vars
  end
end

#generate_expr_string(node, options = {}) ⇒ Object


500
501
502
503
504
505
506
507
508
509
510
511
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 500

def generate_expr_string(node, options = {})
  return node unless node.respond_to?(:type)
  case node.type
  when :eq, :ne, :gt, :ge, :lt, :le
    result = "#{generate_expr_term(node.to_a[0])} "             # operand 1
    result += "#{RELATIONAL_OPERATOR_STRINGS[node.type]} "      # relational condition
    result += "#{generate_expr_term(node.to_a[1])}"             # operand 2
    result
  else
    fail "Relational operator '#{node.type}' not  supported"
  end
end

#generate_expr_term(val) ⇒ Object


513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 513

def generate_expr_term(val)
  return val if val.is_a?(Fixnum) || val.is_a?(Integer) || val.is_a?(Float)
  case val[0]
  when '$'
    if smt8?
      "#{val[1..-1]}"
    else
      "@#{val[1..-1]}"
    end
  else
    if val.is_a? String
      "\"#{val}\""
    else
      val
    end
  end
end

#hardware_bin_descriptionsObject


94
95
96
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 94

def hardware_bin_descriptions
  @hardware_bin_descriptions ||= {}
end

#limits_fileObject


133
134
135
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 133

def limits_file
  @limits_file
end

#line(str, options = {}) ⇒ Object


242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 242

def line(str, options = {})
  if options[:already_indented]
    line = str
  else
    if smt8?
      line = ('    ' * @indent) + str
    else
      line = '    ' + ('   ' * (@indent - 1)) + str
    end
  end
  if @lines_buffer.last
    @lines_buffer.last << line
  else
    @lines << line
  end
end

#on_condition_flag(node, state) ⇒ Object


383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 383

def on_condition_flag(node, state)
  flag, *nodes = *node
  else_node = node.find(:else)
  if smt8?
    if flag.is_a?(Array)
      condition = flag.map { |f| "(#{generate_flag_name(f)} == 1)" }.join(' || ')
    else
      condition = "#{generate_flag_name(flag)} == 1"
    end
    line "if (#{condition}) {"
  else
    if flag.is_a?(Array)
      condition = flag.map { |f| "@#{generate_flag_name(f)} == 1" }.join(' or ')
    else
      condition = "@#{generate_flag_name(flag)} == 1"
    end
    line "if #{condition} then"
    line '{'
  end
  @indent += 1
  if state
    process_all(node.children - [else_node])
  else
    process(else_node) if else_node
  end
  @indent -= 1
  if smt8?
    line '} else {'
  else
    line '}'
    line 'else'
    line '{'
  end
  @indent += 1
  if state
    process(else_node) if else_node
  else
    process_all(node.children - [else_node])
  end
  @indent -= 1
  line '}'
end

#on_disable(node) ⇒ Object


550
551
552
553
554
555
556
557
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 550

def on_disable(node)
  flag = node.value.upcase
  if smt8?
    line "#{flag} = 0;"
  else
    line "@#{flag} = 0;"
  end
end

#on_enable(node) ⇒ Object


541
542
543
544
545
546
547
548
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 541

def on_enable(node)
  flag = node.value.upcase
  if smt8?
    line "#{flag} = 1;"
  else
    line "@#{flag} = 1;"
  end
end

#on_group(node) ⇒ Object

Note that for smt8?, this should never be hit anymore since groups are now generated as sub-flows


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
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 610

def on_group(node)
  on_fail = node.children.find { |n| n.try(:type) == :on_fail }
  on_pass = node.children.find { |n| n.try(:type) == :on_pass }
  group_name = unique_group_name(node.find(:name).value)
  if smt8?
    line '// *******************************************************'
    line "// GROUP - #{group_name}"
    line '// *******************************************************'
  else
    line '{'
  end
  @indent += 1
  stack[:on_fail] << on_fail if on_fail
  stack[:on_pass] << on_pass if on_pass
  process_all(node.children - [on_fail, on_pass])
  stack[:on_fail].pop if on_fail
  stack[:on_pass].pop if on_pass
  @indent -= 1
  bypass = node.find(:bypass).try(:value) || flow_bypass
  comment = node.find(:comment).try(:value) || ''
  if smt8?
    line '// *******************************************************'
    line "// /GROUP - #{group_name}"
    line '// *******************************************************'
  else
    if bypass
      line "}, groupbypass, open,\"#{group_name}\", \"\""
    else
      line "}, open,\"#{group_name}\", \"\""
    end
  end
end

#on_if_enabled(node) ⇒ Object Also known as: on_unless_enabled


426
427
428
429
430
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 426

def on_if_enabled(node)
  flag, *nodes = *node
  state = node.type == :if_enabled
  on_condition_flag(node, state)
end

#on_if_flag(node) ⇒ Object Also known as: on_unless_flag


433
434
435
436
437
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 433

def on_if_flag(node)
  flag, *nodes = *node
  state = node.type == :if_flag
  on_condition_flag(node, state)
end

#on_if_job(node) ⇒ Object Also known as: on_unless_job


350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 350

def on_if_job(node)
  jobs, *nodes = *node
  jobs = clean_job(jobs)
  state = node.type == :if_job
  if smt8?
    if jobs.size == 1
      condition = jobs.first
    else
      condition = jobs.map { |j| "(#{j})" }.join(' || ')
    end
    line "if (#{condition}) {"
  else
    condition = jobs.join(' or ')
    line "if #{condition} then"
    line '{'
  end
  @indent += 1
  process_all(node) if state
  @indent -= 1
  if smt8?
    line '} else {'
  else
    line '}'
    line 'else'
    line '{'
  end
  @indent += 1
  process_all(node) unless state
  @indent -= 1
  line '}'
end

#on_log(node) ⇒ Object


672
673
674
675
676
677
678
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 672

def on_log(node)
  if smt8?
    line "println(\"#{node.to_a[0]}\");"
  else
    line "print_dl(\"#{node.to_a[0]}\");"
  end
end

#on_loop(node, options = {}) ⇒ Object


465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 465

def on_loop(node, options = {})
  # TODO: don't have the SMT8 way to do this yet
  if smt8?
    fail 'Flow loop control not yet supported for SMT8!'
  end
  start = node.to_a[0]
  stop = node.to_a[1]
  step = node.to_a[2]
  if node.to_a[3].nil?
    fail 'You must supply a loop variable name!'
  else
    var = generate_flag_name(node.to_a[3])
  end
  test_num_inc = node.to_a[4]
  unless smt8?
    var = "@#{var}"
  end
  num = (stop - start) / step + 1
  # Handle increment/decrement
  if step < 0
    compare = '>'
    incdec = "- #{step * -1}"
  else
    compare = '<'
    incdec = "+ #{step}"
  end
  line "for #{var} = #{start}; #{var} #{compare} #{stop + step} ; #{var} = #{var} #{incdec}; do"
  line "test_number_loop_increment = #{test_num_inc}"
  line '{'
  @indent += 1
  process_all(node.children)
  @indent -= 1
  line '}'
end

#on_render(node) ⇒ Object


344
345
346
347
348
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 344

def on_render(node)
  node.to_a[0].split("\n").each do |l|
    line(l)
  end
end

#on_set(node) ⇒ Object


531
532
533
534
535
536
537
538
539
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 531

def on_set(node)
  flag = generate_flag_name(node.to_a[0])
  val = generate_expr_term(node.to_a[1])
  if smt8?
    line "#{flag} = #{val};"
  else
    line "@#{flag} = #{val};"
  end
end

#on_set_flag(node) ⇒ Object


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
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 559

def on_set_flag(node)
  flag = generate_flag_name(node.value)
  # This means if we are currently generating an on_test node and tester.force_pass_on_continue has been set
  if @open_test_methods.last
    if pass_branch?
      if smt8?
        @post_test_lines.last << "#{flag} = #{@open_test_names.last}.setOnPassFlags;"
      else
        if @open_test_methods.last.respond_to?(:on_pass_flag)
          if @open_test_methods.last.on_pass_flag == ''
            @open_test_methods.last.on_pass_flag = flag
          else
            Origen.log.error "The test method cannot set #{flag} on passing, because it already sets: #{@open_test_methods.last.on_pass_flag}"
            Origen.log.error "  #{node.source}"
            exit 1
          end
        else
          Origen.log.error 'Force pass on continue has been requested, but the test method does not have an :on_pass_flag attribute:'
          Origen.log.error "  #{node.source}"
          exit 1
        end
      end
    else
      if smt8?
        @post_test_lines.last << "#{flag} = #{@open_test_names.last}.setOnFailFlags;"
      else
        if @open_test_methods.last.respond_to?(:on_fail_flag)
          if @open_test_methods.last.on_fail_flag == ''
            @open_test_methods.last.on_fail_flag = flag
          else
            Origen.log.error "The test method cannot set #{flag} on failing, because it already sets: #{@open_test_methods.last.on_fail_flag}"
            Origen.log.error "  #{node.source}"
            exit 1
          end
        else
          Origen.log.error 'Force pass on continue has been requested, but the test method does not have an :on_fail_flag attribute:'
          Origen.log.error "  #{node.source}"
          exit 1
        end
      end
    end
  else
    if smt8?
      line "#{flag} = 1;"
    else
      line "@#{flag} = 1;"
    end
  end
end

#on_set_result(node) ⇒ Object


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
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 643

def on_set_result(node)
  bin = node.find(:bin).try(:value)
  desc = node.find(:bin).to_a[1]
  sbin = node.find(:softbin).try(:value)
  sdesc = node.find(:softbin).to_a[1] || 'fail'
  overon = (node.find(:not_over_on).try(:value) == true) ? 'not_over_on' : 'over_on'
  if bin && desc
    hardware_bin_descriptions[bin] ||= desc
  end

  if smt8?
    # Currently only rendering pass bins or those not associated with a test (should come from the bin
    # table if its associated with a test)
    if node.to_a[0] == 'pass' || @open_test_methods.empty?
      line "addBin(#{sbin || bin});"
    end
  else
    if node.to_a[0] == 'pass'
      line "stop_bin \"#{sbin}\", \"\", , good, noreprobe, green, #{bin}, over_on;"
    else
      if tester.create_limits_file
        line 'multi_bin;'
      else
        line "stop_bin \"#{sbin}\", \"#{sdesc}\", , bad, noreprobe, red, #{bin}, #{overon};"
      end
    end
  end
end

#on_test(node) ⇒ Object


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
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
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
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 267

def on_test(node)
  test_suite = node.find(:object).to_a[0]
  if test_suite.is_a?(String)
    name = test_suite
  else
    name = test_suite.name
    test_method = test_suite.test_method
    if test_method.respond_to?(:test_name) && test_method.test_name == '' &&
       n = node.find(:name)
      test_method.test_name = n.value
    end
  end

  if node.children.any? { |n| t = n.try(:type); t == :on_fail || t == :on_pass } ||
     !stack[:on_pass].empty? || !stack[:on_fail].empty?
    if smt8?
      line "#{name}.execute();"
    else
      line "run_and_branch(#{name})"
    end
    process_all(node.to_a.reject { |n| t = n.try(:type); t == :on_fail || t == :on_pass })
    on_pass = node.find(:on_pass)
    on_fail = node.find(:on_fail)

    if on_fail && on_fail.find(:continue) && tester.force_pass_on_continue
      if test_method.respond_to?(:force_pass)
        test_method.force_pass = 1
      else
        Origen.log.error 'Force pass on continue has been enabled, but the test method does not have a force_pass attribute!'
        Origen.log.error "  #{node.source}"
        exit 1
      end
      @open_test_methods << test_method
    else
      if test_method.respond_to?(:force_pass)
        test_method.force_pass = 0
      end
      @open_test_methods << nil
    end

    if smt8?
      line "if (#{name}.pass) {"
    else
      line 'then'
      line '{'
    end
    @indent += 1
    pass_branch do
      process_all(on_pass) if on_pass
      stack[:on_pass].each { |n| process_all(n) }
    end
    @indent -= 1
    if smt8?
      line '} else {'
    else
      line '}'
      line 'else'
      line '{'
    end
    @indent += 1
    fail_branch do
      process_all(on_fail) if on_fail
      stack[:on_fail].each { |n| process_all(n) }
    end
    @indent -= 1
    line '}'

    @open_test_methods.pop
  else
    if smt8?
      line "#{name}.execute();"
    else
      line "run(#{name});"
    end
  end
end

#on_top_level_setObject


121
122
123
124
125
126
127
128
129
130
131
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 121

def on_top_level_set
  if top_level?
    if smt8?
      @limits_file = platform::LimitsFile.new(self, manually_register: true, filename: filename.sub(/\..*/, ''), test_modes: @test_modes)
    else
      @limits_file = platform::LimitsFile.new(self, manually_register: true, filename: "#{name}_limits", test_modes: @test_modes)
    end
  else
    @limits_file = top_level.limits_file
  end
end

#on_whenever(node) ⇒ Object Also known as: on_whenever_any, on_whenever_all


440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 440

def on_whenever(node)
  expressions, *nodes = *node

  case node.type
  when :whenever_all
    condition = expressions.map { |e| "#{generate_expr_string(e)}" }.join(' and ')
  when :whenever_any
    condition = expressions.map { |e| "#{generate_expr_string(e)}" }.join(' or ')
  else
    condition = expressions.map { |e| "#{generate_expr_string(e)}" }.join('ERROR')
  end

  line "if #{condition} then"
  line '{'
  @indent += 1
  process_all(node.children)
  @indent -= 1
  line '}'
  line 'else'
  line '{'
  line '}'
end

#render_limits_fileObject


234
235
236
237
238
239
240
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 234

def render_limits_file
  if limits_file
    limits_file.test_modes = @test_modes
    limits_file.generate(ast)
    limits_file.write_to_file
  end
end

#smt8?Boolean

Returns:

  • (Boolean)

32
33
34
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 32

def smt8?
  tester.smt8?
end

#sub_flow_from(sub_flow_ast) ⇒ Object

Returns the sub_flow object corresponding to the given sub_flow AST


172
173
174
175
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 172

def sub_flow_from(sub_flow_ast)
  path = sub_flow_ast.find(:path).value
  sub_flow = all_sub_flows.find { |f| File.join(f.subdirectory, f.filename) == path }
end

#unique_group_name(name) ⇒ Object


680
681
682
683
684
685
686
687
688
689
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 680

def unique_group_name(name)
  @group_names ||= {}
  if @group_names[name]
    @group_names[name] += 1
    "#{name}_#{@group_names[name]}"
  else
    @group_names[name] = 1
    name
  end
end