Class: OrigenSWD::Driver

Inherits:
Object
  • Object
show all
Defined in:
lib/origen_swd/driver.rb

Overview

To use this driver the owner model must define the following pins (an alias is fine):

:swd_clk
:swd_dio

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(owner, options = {}) ⇒ Driver

Initialize class variables owner - parent object options - any miscellaneous custom arguments Returns nothing.

Examples

DUT.new.swd


20
21
22
23
24
# File 'lib/origen_swd/driver.rb', line 20

def initialize(owner, options = {})
  @owner = owner
  @current_apaddr = 0
  @orundetect = 0
end

Instance Attribute Details

#ownerObject (readonly)

Returns the parent object that instantiated the driver, could be either a DUT object or a protocol abstraction



9
10
11
# File 'lib/origen_swd/driver.rb', line 9

def owner
  @owner
end

Instance Method Details

#get_data(size, options = {}) ⇒ Object

Recieves data stream with SWD protocol size - the length of data options - any miscellaneous custom arguments options - data to be compared, only compared if options is set Returns nothing.



57
58
59
60
61
62
63
64
65
# File 'lib/origen_swd/driver.rb', line 57

def get_data(size, options = {})
  should_store = $dut.pin(:swd_dio).is_to_be_stored?
  owner.pin(:swd_dio).dont_care
  size.times do |bit|
    $tester.store_next_cycle($dut.pin(:swd_dio)) if should_store
    $dut.pin(:swd_dio).assert(options[:compare_data][bit]) if options.key?(:compare_data)
    $tester.cycle
  end
end

#send_data(data, size, options = {}) ⇒ Object

Sends data stream with SWD protocol data - data to be sent size - the length of data options - any miscellaneous custom arguments options - string for pattern label to facilitate pattern overlay Returns nothing.



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/origen_swd/driver.rb', line 32

def send_data(data, size, options = {})
  if options.key?(:overlay)
    $tester.label(options[:overlay])
    size.times do |bit|
      owner.pin(:swd_clk).drive(1)
      $tester.label("// SWD Data Pin #{bit}")
      owner.pin(:swd_dio).drive(data[bit])
      $tester.cycle
    end
    owner.pin(:swd_dio).dont_care
  else
    size.times do |bit|
      owner.pin(:swd_clk).drive(1)
      owner.pin(:swd_dio).drive(data[bit])
      $tester.cycle
    end
    owner.pin(:swd_dio).dont_care
  end
end

#swd_dio_to_0(size) ⇒ Object

Sends specified number of ‘0’ bits size - the length of data Returns nothing.



70
71
72
73
74
75
# File 'lib/origen_swd/driver.rb', line 70

def swd_dio_to_0(size)
  owner.pin(:swd_dio).drive(0)
  size.times do |bit|
    $tester.cycle
  end
end