Class: OrigenSim::Tester

Inherits:
Object
  • Object
show all
Includes:
OrigenTesters::VectorBasedTester
Defined in:
lib/origen_sim/tester.rb

Overview

Responsible for interfacing the simulator with Origen

Constant Summary collapse

TEST_PROGRAM_GENERATOR =
OrigenSim::Generator

Instance Method Summary collapse

Constructor Details

#initialize(options = {}, &block) ⇒ Tester

Returns a new instance of Tester.



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/origen_sim/tester.rb', line 8

def initialize(options = {}, &block)
  # Use Origen's collector to allow options to be set either from the options hash, or from the block
  if block_given?
    opts = Origen::Utility.collector(hash: options, merge_method: :keep_hash, &block).to_hash
  else
    opts = options
  end

  simulator.configure(opts, &block)
  super()
end

Instance Method Details

#c1(msg, options = {}) ⇒ Object



78
79
80
# File 'lib/origen_sim/tester.rb', line 78

def c1(msg, options = {})
  simulator.write_comment(msg) if @step_comment_on
end

#captureObject



27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/origen_sim/tester.rb', line 27

def capture
  simulator.sync do
    @sync_pins = []
    @sync_cycles = 0
    yield
  end
  @sync_pins.map do |pin|
    if @sync_cycles.size == 1
      simulator.peek("origen.pins.#{pin.id}.sync_memory[0]")
    else
      simulator.peek("origen.pins.#{pin.id}.sync_memory[#{@sync_cycles - 1}:0]")
    end
  end
end

#handshake(options = {}) ⇒ Object



24
25
# File 'lib/origen_sim/tester.rb', line 24

def handshake(options = {})
end

#loop_vectors(name, number_of_loops, options = {}) ⇒ Object Also known as: loop_vector



82
83
84
85
86
# File 'lib/origen_sim/tester.rb', line 82

def loop_vectors(name, number_of_loops, options = {})
  number_of_loops.times do
    yield
  end
end

#push_vector(options) ⇒ Object

This method intercepts vector data from Origen, removes white spaces and compresses repeats



64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/origen_sim/tester.rb', line 64

def push_vector(options)
  unless options[:timeset]
    puts 'No timeset defined!'
    puts 'Add one to your top level startup method or target like this:'
    puts '$tester.set_timeset("nvmbist", 40)   # Where 40 is the period in ns'
    exit 1
  end
  simulator.cycle(options[:repeat] || 1)
  if @after_next_vector
    @after_next_vector.call(@after_next_vector_args)
    @after_next_vector = nil
  end
end

#set_timeset(name, period_in_ns) ⇒ Object



53
54
55
56
57
58
59
60
61
# File 'lib/origen_sim/tester.rb', line 53

def set_timeset(name, period_in_ns)
  super
  # Need to remove this once OrigenTesters does it
  dut.timeset = name
  dut.current_timeset_period = period_in_ns

  # Now update the simulator with the new waves
  simulator.on_timeset_changed
end

#simulatorObject



20
21
22
# File 'lib/origen_sim/tester.rb', line 20

def simulator
  OrigenSim.simulator
end

#startObject

Start the simulator



43
44
45
# File 'lib/origen_sim/tester.rb', line 43

def start
  simulator.start
end

#store_next_cycle(*pins) ⇒ Object

Capture the next vector generated

This method applies a store request to the next vector to be generated, note that is does not actually generate a new vector.

The captured data is added to the captured_data array.

This method is intended to be used by pin drivers, see the #capture method for the application level API.

Examples:

tester.store_next_cycle
tester.cycle                # This is the vector that will be captured


102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# File 'lib/origen_sim/tester.rb', line 102

def store_next_cycle(*pins)
  options = pins.last.is_a?(Hash) ? pins.pop : {}
  if pins.empty?
    pins = dut.rtl_pins.values
  else
    pins_orig = pins.dup
    pins_orig.each do |p|
      if p.is_a? Origen::Pins::PinCollection
        pins.concat(p.map(&:id).map { |p| dut.pin(p) })
        pins.delete(p)
      end
    end
  end
  if simulator.sync_active?
    @sync_cycles += 1
    pins.each do |pin|
      @sync_pins << pin unless @sync_pins.include?(pin)
    end
  end
  pins.each(&:capture)
  # A store request is only valid for one cycle, this tells the simulator
  # to stop after the next vector is generated
  after_next_vector do
    pins.each { |pin| simulator.put("h^#{pin.simulation_index}") }
  end
end

#sync_upObject

Blocks the Origen process until the simulator indicates that it has processed all operations up to this point



49
50
51
# File 'lib/origen_sim/tester.rb', line 49

def sync_up
  simulator.sync_up
end