Class: Origen::Tester::VectorPipeline

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(group_size) ⇒ VectorPipeline

Returns a new instance of VectorPipeline.



6
7
8
9
# File 'lib/origen/tester/vector_pipeline.rb', line 6

def initialize(group_size)
  @group_size = group_size
  @pipeline = []
end

Instance Attribute Details

#group_sizeObject (readonly)

Returns the value of attribute group_size.



4
5
6
# File 'lib/origen/tester/vector_pipeline.rb', line 4

def group_size
  @group_size
end

#pipelineObject (readonly)

Returns the value of attribute pipeline.



4
5
6
# File 'lib/origen/tester/vector_pipeline.rb', line 4

def pipeline
  @pipeline
end

Instance Method Details

#<<(vector) ⇒ Object

Add a vector/comment to the pipeline



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/origen/tester/vector_pipeline.rb', line 12

def <<(vector)
  if vector.is_a?(Vector)
    consume_comments(vector)
    if vector.repeat > 1
      add_repeat_vector(vector)
    else
      pipeline << vector
    end
  else
    comments << vector
  end
end

#emptyObject

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



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/origen/tester/vector_pipeline.rb', line 42

def empty
  if !pipeline.empty? || !comments.empty?
    pipeline.each do |vector|
      vector.comments.each do |comment|
        yield comment
      end
      yield vector
    end
    comments.each do |comment|
      yield comment
    end
    @pipeline = []
    @comments = []
  end
end

#flushObject

If there are complete groups sitting at the top of the pipeline then this will yield them back line by line, stopping when 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



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/origen/tester/vector_pipeline.rb', line 29

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