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 = {}) ⇒ Tester

Returns a new instance of Tester.



8
9
10
11
# File 'lib/origen_sim/tester.rb', line 8

def initialize(options = {})
  simulator.configure(options)
  super()
end

Instance Method Details

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



71
72
73
# File 'lib/origen_sim/tester.rb', line 71

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

#captureObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/origen_sim/tester.rb', line 20

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



17
18
# File 'lib/origen_sim/tester.rb', line 17

def handshake(options = {})
end

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



75
76
77
78
79
# File 'lib/origen_sim/tester.rb', line 75

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



57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/origen_sim/tester.rb', line 57

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



46
47
48
49
50
51
52
53
54
# File 'lib/origen_sim/tester.rb', line 46

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



13
14
15
# File 'lib/origen_sim/tester.rb', line 13

def simulator
  OrigenSim.simulator
end

#startObject

Start the simulator



36
37
38
# File 'lib/origen_sim/tester.rb', line 36

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


95
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
# File 'lib/origen_sim/tester.rb', line 95

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



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

def sync_up
  simulator.sync_up
end