Module: Origen::Tester::API
- Included in:
- Origen::Tester
- Defined in:
- lib/origen/tester/api.rb
Overview
This module implements the basic set of methods that a tester must have in order for Origen to talk to it.
They can be overridden by tester specific classes and who may go on to add additional methods of their own.
Essentially this API means that any class that includes Origen::Tester will function as a tester, although it might not do very much!
Instance Attribute Summary (collapse)
-
- (Object) comment_level
Returns the value of attribute comment_level.
-
- (Object) generating
Returns the value of attribute generating.
-
- (Object) includes
Returns the value of attribute includes.
- - (Object) inhibit_comments
- - (Object) inhibit_vectors
Instance Method Summary (collapse)
- - (Object) annotate(_msg, _options = {})
- - (Boolean) any_clocks_running?
-
- (Object) c1(msg, _options = {})
Output a comment in the pattern, normally you would not call this directly and instead use these shorthand methods: cc “Some comment” ss “A single line step comment” step_comment do cc “A multi line” cc “step comment” end.
- - (Object) c2(msg, options = {})
- - (Object) clocks_running (also: #running_clocks)
- - (Object) comment_char
-
- (Object) cycle(options = {})
Generate a vector.
- - (Boolean) doc?
- - (Boolean) generate?
- - (Boolean) generating_pattern?
- - (Boolean) generating_program?
-
- (Object) ignore_fails(*pins)
Ignore fails on the given pins for the duration of the given block, this has the effect of temporarily setting the states of the given pins to don't care.
- - (Object) import_test_time(_file, _options = {})
-
- (Object) inhibit_vectors_and_comments
Allows a section to be run without actually generating any vectors.
- - (Boolean) is_command_based?
- - (Boolean) is_vector_based?
- - (Boolean) j750?
- - (Boolean) j750_hpt?
- - (Object) name
- - (Object) pat_extension (also: #pattern_extension)
- - (Object) pattern_footer(*_args)
- - (Object) pattern_header(*_args)
- - (Object) pattern_section(msg)
- - (Object) pins_need_toggling
- - (Object) pop_running_clock(pin)
- - (Object) program_comment_char
- - (Object) push_running_clock(pin)
- - (Object) slice_repeats(options = {})
- - (Object) snip(_number, _options = {})
- - (Object) ss(msg = nil)
- - (Object) step_comment_prefix
- - (Boolean) ultraflex?
- - (Object) update_running_clocks
- - (Boolean) v93k?
Instance Attribute Details
- (Object) comment_level
Returns the value of attribute comment_level
13 14 15 |
# File 'lib/origen/tester/api.rb', line 13 def comment_level @comment_level end |
- (Object) generating
Returns the value of attribute generating
14 15 16 |
# File 'lib/origen/tester/api.rb', line 14 def @generating end |
- (Object) includes
Returns the value of attribute includes
12 13 14 |
# File 'lib/origen/tester/api.rb', line 12 def includes @includes end |
- (Object) inhibit_comments
172 173 174 |
# File 'lib/origen/tester/api.rb', line 172 def inhibit_comments @inhibit_comments end |
- (Object) inhibit_vectors
164 165 166 |
# File 'lib/origen/tester/api.rb', line 164 def inhibit_vectors @inhibit_vectors end |
Instance Method Details
- (Object) annotate(_msg, _options = {})
86 87 |
# File 'lib/origen/tester/api.rb', line 86 def annotate(_msg, = {}) end |
- (Boolean) any_clocks_running?
220 221 222 |
# File 'lib/origen/tester/api.rb', line 220 def any_clocks_running? @clocks_running.nil? ? false : @clocks_running.count > 0 end |
- (Object) c1(msg, _options = {})
Output a comment in the pattern, normally you would not call this directly and instead use these shorthand methods:
cc "Some comment"
ss "A single line step comment"
step_comment do
cc "A multi line"
cc "step comment"
end
106 107 108 109 110 |
# File 'lib/origen/tester/api.rb', line 106 def c1(msg, = {}) prefix = comment_char + ' ' prefix += step_comment_prefix + ' ' if @step_comment_on push_comment(prefix + msg.to_s) end |
- (Object) c2(msg, options = {})
112 113 114 |
# File 'lib/origen/tester/api.rb', line 112 def c2(msg, = {}) c1(msg, ) end |
- (Object) clocks_running Also known as: running_clocks
224 225 226 |
# File 'lib/origen/tester/api.rb', line 224 def clocks_running @clocks_running end |
- (Object) comment_char
39 40 41 |
# File 'lib/origen/tester/api.rb', line 39 def comment_char @comment_char || '//' end |
- (Object) cycle(options = {})
Generate a vector. Calling this method will generate a vector in the output pattern based on the current pin states and timeset.
182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 |
# File 'lib/origen/tester/api.rb', line 182 def cycle( = {}) = { microcode: '', timeset: current_timeset, pin_vals: current_pin_vals, repeat: nil }.merge() if any_clocks_running? update_running_clocks if [:repeat] slice_repeats().each do |slice| [:repeat] = slice[0] delay(.delete(:repeat), ) do || push_vector() end slice[1].each { |clock_pin_name| clocks_running[clock_pin_name].toggle_clock } [:pin_vals] = current_pin_vals end else push_vector() pins_need_toggling.each { |clock_pin_name| clocks_running[clock_pin_name].toggle_clock } end else if [:repeat] delay(.delete(:repeat), ) do || push_vector() end else push_vector() end end end |
- (Boolean) doc?
78 79 80 |
# File 'lib/origen/tester/api.rb', line 78 def doc? false end |
- (Boolean) generate?
22 23 24 |
# File 'lib/origen/tester/api.rb', line 22 def generate? true end |
- (Boolean) generating_pattern?
26 27 28 |
# File 'lib/origen/tester/api.rb', line 26 def @generating == :pattern end |
- (Boolean) generating_program?
30 31 32 |
# File 'lib/origen/tester/api.rb', line 30 def @generating == :program end |
- (Object) ignore_fails(*pins)
Ignore fails on the given pins for the duration of the given block, this has the effect of temporarily setting the states of the given pins to don't care.
92 93 94 95 96 |
# File 'lib/origen/tester/api.rb', line 92 def ignore_fails(*pins) pins.each(&:suspend) yield pins.each(&:resume) end |
- (Object) import_test_time(_file, _options = {})
216 217 218 |
# File 'lib/origen/tester/api.rb', line 216 def import_test_time(_file, = {}) puts "Sorry but an importer doesn't exist for: #{Origen.tester.class}" end |
- (Object) inhibit_vectors_and_comments
Allows a section to be run without actually generating any vectors. This can be useful to ensure the pin states end up as they otherwise would have if the section had been run. Classic example of this is a subroutine pattern, wrap this around a call to the startup routine to ensure the pin states are as they would have been immediately after the startup.
Example
# Setup state as if I had run startup without actually doing so
$tester.inhibit_vectors_and_comments do
$soc.startup
$top.startup
end
153 154 155 156 157 158 159 160 161 |
# File 'lib/origen/tester/api.rb', line 153 def inhibit_vectors_and_comments inhibit_vectors = @inhibit_vectors inhibit_comments = @inhibit_comments @inhibit_vectors = true @inhibit_comments = true yield @inhibit_vectors = inhibit_vectors # Restore to their initial state @inhibit_comments = inhibit_comments end |
- (Boolean) is_command_based?
62 63 64 |
# File 'lib/origen/tester/api.rb', line 62 def is_command_based? !is_vector_based? end |
- (Boolean) is_vector_based?
57 58 59 60 |
# File 'lib/origen/tester/api.rb', line 57 def is_vector_based? return @vector_based if defined?(@vector_based) true end |
- (Boolean) j750?
66 67 68 |
# File 'lib/origen/tester/api.rb', line 66 def j750? false end |
- (Boolean) j750_hpt?
82 83 84 |
# File 'lib/origen/tester/api.rb', line 82 def j750_hpt? false end |
- (Object) name
18 19 20 |
# File 'lib/origen/tester/api.rb', line 18 def name @name || self.class end |
- (Object) pat_extension Also known as: pattern_extension
34 35 36 |
# File 'lib/origen/tester/api.rb', line 34 def pat_extension @pat_extension || 'txt' end |
- (Object) pattern_footer(*_args)
50 51 |
# File 'lib/origen/tester/api.rb', line 50 def (*_args) end |
- (Object) pattern_header(*_args)
47 48 |
# File 'lib/origen/tester/api.rb', line 47 def pattern_header(*_args) end |
- (Object) pattern_section(msg)
116 117 118 119 120 121 122 123 |
# File 'lib/origen/tester/api.rb', line 116 def pattern_section(msg) if yield else step_comment(msg) yield end end |
- (Object) pins_need_toggling
262 263 264 265 266 267 268 |
# File 'lib/origen/tester/api.rb', line 262 def pins_need_toggling toggle_ary = [] clocks_running.each do |name, clock_pin| toggle_ary.push("#{name}") if clock_pin.next_edge == cycle_count end toggle_ary end |
- (Object) pop_running_clock(pin)
233 234 235 236 |
# File 'lib/origen/tester/api.rb', line 233 def pop_running_clock(pin) fail "ERROR: No clocks running, doesn't make sense to pop one" unless any_clocks_running? @clocks_running.delete(pin.name.to_s) end |
- (Object) program_comment_char
43 44 45 |
# File 'lib/origen/tester/api.rb', line 43 def program_comment_char @program_comment_char || comment_char end |
- (Object) push_running_clock(pin)
229 230 231 |
# File 'lib/origen/tester/api.rb', line 229 def push_running_clock(pin) @clocks_running.nil? ? @clocks_running = { pin.name.to_s => pin } : @clocks_running[pin.name.to_s] = pin end |
- (Object) slice_repeats(options = {})
238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 |
# File 'lib/origen/tester/api.rb', line 238 def slice_repeats( = {}) slices = {} repeat_ary = [] clocks_running.each do |name, clock_pin| if clock_pin.next_edge < (cycle_count + [:repeat]) pin_slices = (clock_pin.next_edge..(cycle_count + [:repeat])).step(clock_pin.half_period).to_a pin_slices.insert(0, cycle_count) else pin_slices = [cycle_count] end pin_slices.each do |cycle| slices[cycle].nil? ? slices[cycle] = name : slices[cycle] = "#{slices[cycle]},#{name}" end slices[cycle_count + [:repeat]] = '' if pin_slices[-1] != cycle_count + [:repeat] end slices.keys.sort.each do |edge_cycles| # puts "Toggle #{slices[edge_cycles]} on #{edge_cycles}" repeat_ary.push([edge_cycles, slices[edge_cycles].split(',')]) end (repeat_ary.count - 1).downto(1).each { |i| repeat_ary[i][0] = repeat_ary[i][0] - repeat_ary[i - 1][0] } repeat_ary[1..-1] end |
- (Object) snip(_number, _options = {})
139 140 141 |
# File 'lib/origen/tester/api.rb', line 139 def snip(_number, = {}) yield end |
- (Object) ss(msg = nil)
125 126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/origen/tester/api.rb', line 125 def ss(msg = nil) div = step_comment_prefix.length div = 1 if div == 0 c1(step_comment_prefix * (70 / div)) @step_comment_on = true if block_given? yield else c1(msg) end @step_comment_on = false c1(step_comment_prefix * (70 / div)) end |
- (Object) step_comment_prefix
53 54 55 |
# File 'lib/origen/tester/api.rb', line 53 def step_comment_prefix @step_comment_prefix || '##' end |
- (Boolean) ultraflex?
74 75 76 |
# File 'lib/origen/tester/api.rb', line 74 def ultraflex? false end |
- (Object) update_running_clocks
270 271 272 273 274 |
# File 'lib/origen/tester/api.rb', line 270 def update_running_clocks clocks_running.each do |_name, clock_pin| clock_pin.update_clock end end |
- (Boolean) v93k?
70 71 72 |
# File 'lib/origen/tester/api.rb', line 70 def v93k? false end |