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, #loop

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

#add_global_flag, #clean_flag, #extract_globals, #extract_volatiles, #global_flag?, #global_flags, #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

rubocop:disable Lint/DuplicateMethods



100
101
102
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 100

def flow_bypass
  @flow_bypass
end

#flow_descriptionObject

rubocop:disable Lint/DuplicateMethods



104
105
106
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 104

def flow_description
  @flow_description
end

#flow_name(filename = nil) ⇒ Object

rubocop:disable Lint/DuplicateMethods



88
89
90
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 88

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

rubocop:disable Lint/DuplicateMethods



52
53
54
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 52

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

rubocop:disable Lint/DuplicateMethods



44
45
46
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 44

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



168
169
170
171
172
173
174
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 168

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

#astObject



157
158
159
160
161
162
163
164
165
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 157

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



152
153
154
155
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 152

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



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

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



287
288
289
290
291
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 287

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

#clean_job(job) ⇒ Object



772
773
774
775
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 772

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.



177
178
179
180
181
182
183
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 177

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



70
71
72
73
74
75
76
77
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 70

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



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

def finalize(options = {})
  if smt8?
    return unless top_level? || options[:called_by_top_level]

    super
    # Refresh the ast before finalized gets set to true
    # If ast gets called by the user the finalized flag will lock it to the incorrect value
    ast
    @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
  global_flags.each do |global_var_name|
    @set_runtime_variables.delete(global_var_name)
    @set_runtime_variables.delete('$' + global_var_name)
  end
  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 smt8?
    shmoo_tests.finalize
  end
  if tester.create_limits_file && top_level?
    render_limits_file
  end
end

#flow_enable_var_nameObject



79
80
81
82
83
84
85
86
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 79

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

#flow_variablesObject



112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 112

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
    Origen.interface.set_flow_variables(vars) if Origen.interface.respond_to?(:set_flow_variables)
    vars
  end
end

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



570
571
572
573
574
575
576
577
578
579
580
581
582
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 570

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



584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 584

def generate_expr_term(val)
  return val if 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



108
109
110
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 108

def hardware_bin_descriptions
  @hardware_bin_descriptions ||= {}
end

#limits_fileObject



148
149
150
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 148

def limits_file
  @limits_file
end

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



268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 268

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



409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 409

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



622
623
624
625
626
627
628
629
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 622

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

#on_enable(node) ⇒ Object



613
614
615
616
617
618
619
620
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 613

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



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

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



452
453
454
455
456
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 452

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



459
460
461
462
463
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 459

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



376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 376

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



753
754
755
756
757
758
759
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 753

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



500
501
502
503
504
505
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
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 500

def on_loop(node, options = {})
  start = node.to_a[0]
  if start.is_a?(String) || start.is_a?(Symbol)
    start = generate_flag_name(start)
    unless smt8?
      start = "@#{start}"
    end
  end
  stop = node.to_a[1]
  if stop.is_a?(String) || stop.is_a?(Symbol)
    stop = generate_flag_name(stop)
    if tester.smt7?
      stop = "@#{stop}"
    end
  end
  step = node.to_a[2]
  if smt8? && !(step == -1 || step == 1)
    fail 'SMT8 does not support steps other than -1 or 1.'
  end

  if step.is_a?(String) || step.is_a?(Symbol)
    step = generate_flag_name(step)
    if tester.smt7?
      step = "@#{step}"
    end
  end
  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.is_a?(Numeric) && step < 0
    compare = '>'
    incdec = "- #{step * -1}"
  else
    compare = '<'
    incdec = "+ #{step}"
  end
  if tester.smt7?
    unless stop.is_a?(String)
      stop = "#{stop + step}"
    end
    line "for #{var} = #{start}; #{var} #{compare} #{stop} ; #{var} = #{var} #{incdec}; do"
    unless tester.disable_test_number_loop_increment || options[:disable_test_number_loop_increment]
      line "test_number_loop_increment = #{test_num_inc}"
    end
    line '{'
    @indent += 1
    process_all(node.children)
    @indent -= 1
    line '}'
  elsif smt8?
    line "for (#{var} : #{start}..#{stop})"
    line '{'
    @indent += 1
    process_all(node.children)
    @indent -= 1
    line '}'
  else
    fail 'Environment was not supported for flow loops.'
  end
end

#on_render(node) ⇒ Object



370
371
372
373
374
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 370

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

#on_set(node) ⇒ Object



603
604
605
606
607
608
609
610
611
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 603

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



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

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



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

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



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
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 293

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



136
137
138
139
140
141
142
143
144
145
146
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 136

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_unset_flag(node) ⇒ Object



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

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

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



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

def on_whenever(node)
  expressions, *nodes = *node
  and_string = ' and '
  or_string  = ' or '
  if smt8?
    and_string = ' && '
    or_string  = ' || '
  end
  case node.type
  when :whenever_all
    condition = expressions.map { |e| "#{generate_expr_string(e)}" }.join(and_string)
  when :whenever_any
    condition = expressions.map { |e| "#{generate_expr_string(e)}" }.join(or_string)
  else
    condition = expressions.map { |e| "#{generate_expr_string(e)}" }.join('ERROR')
  end

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

#qualified_nameObject



36
37
38
39
40
41
42
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 36

def qualified_name
  @qualified_name ||= if parent
                        "#{parent.qualified_name}.#{name}"
                      else
                        name.to_s
                      end
end

#render_limits_fileObject



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

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

#set_var_filename(new_var_filename) ⇒ Object



48
49
50
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 48

def set_var_filename(new_var_filename)
  @var_filename = new_var_filename
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



186
187
188
189
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 186

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



761
762
763
764
765
766
767
768
769
770
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 761

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