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

Attributes included from Generator

#output_directory

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

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



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

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

#astObject



150
151
152
153
154
155
156
157
158
159
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 150

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



145
146
147
148
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 145

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



125
126
127
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 125

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



279
280
281
282
283
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 279

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

#clean_job(job) ⇒ Object



748
749
750
751
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 748

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.



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

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



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

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



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
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 187

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



73
74
75
76
77
78
79
80
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 73

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

#flow_variablesObject



106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 106

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



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

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



561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 561

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



102
103
104
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 102

def hardware_bin_descriptions
  @hardware_bin_descriptions ||= {}
end

#limits_fileObject



141
142
143
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 141

def limits_file
  @limits_file
end

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



260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 260

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



401
402
403
404
405
406
407
408
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
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 401

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



598
599
600
601
602
603
604
605
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 598

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

#on_enable(node) ⇒ Object



589
590
591
592
593
594
595
596
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 589

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



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

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



444
445
446
447
448
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 444

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



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

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



368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 368

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



729
730
731
732
733
734
735
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 729

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



492
493
494
495
496
497
498
499
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
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 492

def on_loop(node, options = {})
  start = node.to_a[0]
  if start.is_a?(String)
    start = generate_flag_name(start)
    unless smt8?
      start = "@#{start}"
    end
  end
  stop = node.to_a[1]
  if stop.is_a?(String) && smt8?
    stop = generate_flag_name(stop)
  elsif stop.is_a?(String)
    fail 'loops with \'stop\' defined as a variable cannot be supported in the defined environments.'
  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 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
  if tester.smt7?
    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 '}'
  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



362
363
364
365
366
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 362

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

#on_set(node) ⇒ Object



579
580
581
582
583
584
585
586
587
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 579

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



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

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



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

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



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
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 285

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



129
130
131
132
133
134
135
136
137
138
139
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 129

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



657
658
659
660
661
662
663
664
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 657

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



458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 458

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

#render_limits_fileObject



252
253
254
255
256
257
258
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 252

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



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

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



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

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



737
738
739
740
741
742
743
744
745
746
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 737

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