Class: OrigenTesters::SmartestBasedTester::Base::FlowNode

Inherits:
Object
  • Object
show all
Includes:
FlowControlAPI
Defined in:
lib/origen_testers/smartest_based_tester/base/flow_node.rb

Direct Known Subclasses

V93K::FlowNode

Defined Under Namespace

Modules: FlowControlAPI

Constant Summary collapse

TYPES =
[:run, :run_and_branch, :print, :print_to_datalog, :good_bin, :bad_bin, :group,
 :assign_value, :if_then
]
ATTRS =
{
  good_bin:         {
    soft_bin:      nil,
    soft_bin_desc: nil,
    bin:           nil,
    bin_desc:      nil,
    bin_type:      :good,
    reprobe:       false,
    color:         :green,
    overon:        true
  },
  bad_bin:          {
    soft_bin:      nil,
    soft_bin_desc: 'fail',
    bin:           nil,
    bin_desc:      nil,
    bin_type:      :bad,
    reprobe:       false,
    color:         :red,
    overon:        true
  },
  run:              {
    nodes:      [],
    else_nodes: [],
    test_suite: nil,
    id:         nil
  },
  run_and_branch:   {
    nodes:      [],
    else_nodes: [],
    test_suite: nil,
    id:         nil
  },
  if_then:          {
    condition:  nil,
    nodes:      [],
    else_nodes: []
  },
  print:            {
    value: nil
  },
  print_to_datalog: {
    value: nil
  },
  group:            {
    name:    nil,
    nodes:   [],
    comment: nil,
    bypass:  nil
  },
  assign_value:     {
    variable: nil,
    value:    nil
  }
}
ALIASES =
{
  good_bin: {
    sbin:    :soft_bin,
    softbin: :soft_bin
  },
  bad_bin:  {
    sbin:    :soft_bin,
    softbin: :soft_bin
  }
}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from FlowControlAPI

#continue_on_fail, #enable, #enable=, #flag_clear=, #flag_true=, #if_job=, #if_jobs, #run_if_all_failed, #run_if_all_passed, #run_if_any_failed, #run_if_any_passed, #set_flag_on_fail, #set_flag_on_pass, #set_flag_on_ran, #unless_enable, #unless_enable=, #unless_job=, #unless_jobs

Constructor Details

#initialize(type, attrs = {}) ⇒ FlowNode

Returns a new instance of FlowNode.



96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# File 'lib/origen_testers/smartest_based_tester/base/flow_node.rb', line 96

def initialize(type, attrs = {})
  unless attrs.delete(:called_internally)
    fail "Don't use FlowNode.new, use FlowNode.create instead"
  end
  @flow = attrs.delete(:_flow)
  ATTRS[type].each do |attr, default|
    define_singleton_method("#{attr}=") do |v|
      instance_variable_set("@#{attr}", v)
    end
    define_singleton_method("#{attr}") do
      instance_variable_get("@#{attr}")
    end
    send("#{attr}=", default.respond_to?(:each) ? default.dup : default)
  end
  if ALIASES[type]
    ALIASES[type].each do |alias_, attr|
      define_singleton_method("#{alias_}=") do |v|
        send("#{attr}=", v)
      end
      define_singleton_method("#{alias_}") do
        send(attr)
      end
    end
  end
  @type = type
  attrs.each do |k, v|
    send("#{k}=", v) if respond_to?("#{k}=")
  end
end

Instance Attribute Details

#deletedObject Also known as: deleted?

Returns the value of attribute deleted.



5
6
7
# File 'lib/origen_testers/smartest_based_tester/base/flow_node.rb', line 5

def deleted
  @deleted
end

#flowObject (readonly)

Returns the value of attribute flow.



8
9
10
# File 'lib/origen_testers/smartest_based_tester/base/flow_node.rb', line 8

def flow
  @flow
end

#idObject

Returns the value of attribute id.



5
6
7
# File 'lib/origen_testers/smartest_based_tester/base/flow_node.rb', line 5

def id
  @id
end

#parentObject

Returns the value of attribute parent.



5
6
7
# File 'lib/origen_testers/smartest_based_tester/base/flow_node.rb', line 5

def parent
  @parent
end

#renderedObject Also known as: rendered?

Returns the value of attribute rendered.



5
6
7
# File 'lib/origen_testers/smartest_based_tester/base/flow_node.rb', line 5

def rendered
  @rendered
end

#typeObject

Returns the value of attribute type.



5
6
7
# File 'lib/origen_testers/smartest_based_tester/base/flow_node.rb', line 5

def type
  @type
end

Class Method Details

.create(flow, type, attrs = {}) ⇒ Object

Call this instead of FlowNode.new, this will return a dedicated object for the given type if one exists, otherwise it will instantiate a generic FlowNode object



87
88
89
90
91
92
93
94
# File 'lib/origen_testers/smartest_based_tester/base/flow_node.rb', line 87

def self.create(flow, type, attrs = {})
  unless TYPES.include?(type)
    fail "Uknown flow node type :#{type}, valid types are #{TYPES.map { |t| ':' + t.to_s }.join(', ')}"
  end
  attrs[:_flow] = flow
  attrs[:called_internally] = true
  FlowNode.new(type, attrs)
end

.platformObject



466
467
468
# File 'lib/origen_testers/smartest_based_tester/base/flow_node.rb', line 466

def self.platform
  Origen.interface.platform
end

Instance Method Details

#bin?Boolean

Returns:

  • (Boolean)


462
463
464
# File 'lib/origen_testers/smartest_based_tester/base/flow_node.rb', line 462

def bin?
  [:stop_bin, :bad_bin].include?(@type)
end

#empty?Boolean

Returns:

  • (Boolean)


314
315
316
317
318
319
320
321
322
323
# File 'lib/origen_testers/smartest_based_tester/base/flow_node.rb', line 314

def empty?
  return false if type == :run
  if respond_to?(:nodes)
    nodes.each { |n| return false unless n.deleted? || n.rendered? || n.empty? }
    if respond_to?(:else_nodes)
      else_nodes.each { |n| return false unless n.deleted? || n.rendered? || n.empty? }
    end
    true
  end
end

#finalize(options = {}) ⇒ Object



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
443
444
445
446
447
448
# File 'lib/origen_testers/smartest_based_tester/base/flow_node.rb', line 403

def finalize(options = {})
  case type
  when :good_bin, :bad_bin
    if bin && bin_desc
      flow.hardware_bin_descriptions[bin] = bin_desc
    end
  end

  # Implement job/enable branches
  unless if_jobs.empty?
    condition = if_jobs.map { |j| "@JOB == \"#{j}\"" }.join(' or ')
    node = FlowNode.create(flow, :if_then)
    node.parent = parent
    node.condition = condition
    node.nodes << self
    parent[parent.index(self)] = node
    self.parent = node.nodes
  end
  unless unless_jobs.empty?
    condition = unless_jobs.map { |j| "@JOB != \"#{j}\"" }.join(' and ')
    node = FlowNode.create(flow, :if_then)
    node.parent = parent
    node.condition = condition
    node.nodes << self
    parent[parent.index(self)] = node
    self.parent = node.nodes
  end
  if enable
    condition = "@#{enable.to_s.upcase} == 1"
    node = FlowNode.create(flow, :if_then)
    node.parent = parent
    node.condition = condition
    node.nodes << self
    parent[parent.index(self)] = node
    self.parent = node.nodes
  end
  if unless_enable
    condition = "@#{unless_enable.to_s.upcase} == 1"
    node = FlowNode.create(flow, :if_then)
    node.parent = parent
    node.condition = condition
    node.else_nodes << self
    parent[parent.index(self)] = node
    self.parent = node.else_nodes
  end
end

#group?Boolean

Returns:

  • (Boolean)


450
451
452
# File 'lib/origen_testers/smartest_based_tester/base/flow_node.rb', line 450

def group?
  type == :group
end

#if_then?Boolean

Returns:

  • (Boolean)


458
459
460
# File 'lib/origen_testers/smartest_based_tester/base/flow_node.rb', line 458

def if_then?
  type == :if_then
end

#inspectObject



126
127
128
# File 'lib/origen_testers/smartest_based_tester/base/flow_node.rb', line 126

def inspect
  "<#{self.class}:#{object_id} type: #{type}>"
end

#lines(options = {}) ⇒ Object



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
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
399
400
401
# File 'lib/origen_testers/smartest_based_tester/base/flow_node.rb', line 325

def lines(options = {})
  return [] if empty?
  # Convert Run nodes to Run and Branch as required
  if type == :run && (!nodes.empty? || !else_nodes.empty?)
    self.type = :run_and_branch
  end
  case type
  when :good_bin, :bad_bin
    l = ["stop_bin \"#{soft_bin || bin}\", \"#{soft_bin_desc}\", , #{bin_type}, #{reprobe ? 'reprobe' : 'noreprobe'}, #{color}, #{bin}, #{overon ? 'over_on' : 'not_over_on'};"]
  when :print
    l = ["print(\"#{value}\");"]
  when :print_to_datalog
    l = ["print_dl(\"#{value}\");"]
  when :run
    l = ["run(#{test_suite.name});"]
  when :run_and_branch
    l = [
      "run_and_branch(#{test_suite.name})",
      'then',
      '{'
    ]
    nodes.each do |node|
      l << node.lines(indent: 3) unless node.rendered
      node.rendered = true
    end
    l += [
      '}',
      'else',
      '{'
    ]
    else_nodes.each do |node|
      l << node.lines(indent: 3) unless node.rendered
      node.rendered = true
    end
    l << '}'
    l.flatten!

  when :if_then
    c = condition == :skip ? '1' : condition
    l = [
      "if #{c} then",
      '{'
    ]
    nodes.each do |node|
      l << node.lines(indent: 3) unless node.rendered
      node.rendered = true
    end
    l += [
      '}',
      'else',
      '{'
    ]
    else_nodes.each do |node|
      l << node.lines(indent: 3) unless node.rendered
      node.rendered = true
    end
    l << '}'
    l.flatten!

  when :group
    l = ['{']
    nodes.each do |node|
      l << node.lines(indent: 3) unless node.rendered
      node.rendered = true
    end
    l << "}, #{bypass ? 'groupbypass, ' : ''}open,\"#{name}\", \"#{comment}\""
    l.flatten!
  when :assign_value
    l = ["@#{variable.to_s.upcase} = #{value};"]
  else
    fail "Don't know how to render: #{type}"
  end
  if options[:indent]
    l.map! { |line| (' ' * options[:indent]) + line }
  end
  l
end

#platformObject



470
471
472
# File 'lib/origen_testers/smartest_based_tester/base/flow_node.rb', line 470

def platform
  self.class.platform
end

#test?Boolean

Returns:

  • (Boolean)


454
455
456
# File 'lib/origen_testers/smartest_based_tester/base/flow_node.rb', line 454

def test?
  [:run, :run_and_branch].include?(@type)
end