Class: OrigenTesters::VectorPipeline

Inherits:
Object
  • Object
show all
Defined in:
lib/origen_testers/vector_pipeline.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(group_size) ⇒ VectorPipeline

Returns a new instance of VectorPipeline.



10
11
12
13
14
15
16
17
# File 'lib/origen_testers/vector_pipeline.rb', line 10

def initialize(group_size)
  @group_size = group_size
  @pipeline = []
  # A new pipeline is instantiated per-pattern, so don't need to worry about
  # clearing this
  @vector_count = 0
  @cycle_count = 0
end

Instance Attribute Details

#cycle_countObject (readonly)

Returns the value of attribute cycle_count.



8
9
10
# File 'lib/origen_testers/vector_pipeline.rb', line 8

def cycle_count
  @cycle_count
end

#group_sizeObject (readonly)

Returns the value of attribute group_size.



3
4
5
# File 'lib/origen_testers/vector_pipeline.rb', line 3

def group_size
  @group_size
end

#pipelineObject (readonly)

Returns the value of attribute pipeline.



3
4
5
# File 'lib/origen_testers/vector_pipeline.rb', line 3

def pipeline
  @pipeline
end

#vector_countObject (readonly)

Used to keep track of how many vectors since the last reset of the pipeline (i.e. since pattern start). This is used to implement padding if there is a minimum vector requirement.



7
8
9
# File 'lib/origen_testers/vector_pipeline.rb', line 7

def vector_count
  @vector_count
end

Instance Method Details

#<<(vector) ⇒ Object

Add a vector/comment to the pipeline



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/origen_testers/vector_pipeline.rb', line 31

def <<(vector)
  if vector.is_a?(Vector)
    level_period(vector) do |vector|
      consume_comments(vector)
      if vector.repeat > 1
        add_repeat_vector(vector)
      else
        pipeline << vector
      end
    end
    # Keep a persistent record of the last vector so that we know what it
    # was after the pipeline has been flushed
    @last_vector = pipeline.last
  elsif vector.is_a?(Symbol)
    case vector
    when :align
      duplicate_last_vector until aligned?
    when :align_last
      duplicate_last_vector until aligned_to_last?
    else
      fail "Uknown vector generator instruction: #{vector}"
    end
  else
    comments << vector
  end
end

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

Call at the end to force a flush out of any remaining vectors



76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/origen_testers/vector_pipeline.rb', line 76

def empty(options = {}, &block)
  if !pipeline.empty? || !comments.empty?
    if options[:min_vectors]
      comment_written = false
      while @vector_count < options[:min_vectors] - pipeline.size
        unless comment_written
          yield "#{$tester.comment_char} PADDING VECTORS ADDED TO MEET MIN #{options[:min_vectors]} FOR PATTERN"
          comment_written = true
        end
        yield_vector(@last_vector, &block)
      end
    end
    duplicate_last_vector until aligned?
    pipeline.each do |vector|
      vector.comments.each do |comment|
        yield comment
      end
      yield_vector(vector, &block)
    end

    comments.each do |comment|
      yield comment
    end
    @pipeline = []
    @comments = []
  end
end

#flush(&block) ⇒ Object

If there are complete groups sitting at the top of the pipeline then this will yield them back line by line, stopping after the last complete group and leaving any remaining single vectors in the pipeline

If there are no complete groups present then it will just return



63
64
65
66
67
68
69
70
71
72
73
# File 'lib/origen_testers/vector_pipeline.rb', line 63

def flush(&block)
  while lead_group_finalized?
    lead_group.each do |vector|
      vector.comments.each do |comment|
        yield comment
      end
      yield_vector(vector, &block)
    end
    pipeline.shift(group_size)
  end
end

#push_comment(comment) ⇒ Object



19
20
21
# File 'lib/origen_testers/vector_pipeline.rb', line 19

def push_comment(comment)
  comments << comment
end

#push_microcode(code) ⇒ Object



23
24
25
26
27
28
# File 'lib/origen_testers/vector_pipeline.rb', line 23

def push_microcode(code)
  if $tester.v93k? && code =~ /JSUB/
    @vector_count += 1
  end
  comments << code
end