Sha256: fd498d19312a46e2fa8a9eb775a011fa45f96883ff9da9ea6232d6838be333e9

Contents?: true

Size: 1.96 KB

Versions: 1

Compression:

Stored size: 1.96 KB

Contents

module OrigenSWD
  # To use this driver the owner model must define the following pins (an alias is fine):
  #   :swd_clk
  #   :swd_dio
  #
  class Driver
    # Returns the parent object that instantiated the driver, could be
    # either a DUT object or a protocol abstraction
    attr_reader :owner

    # Initialize class variables
    def initialize(owner, options = {})
      @owner = owner
      @current_apaddr = 0
      @orundetect = 0
    end

    # Sends data stream with SWD protocol
    #  -data = data to be sent
    #  -size = the length of data
    #  -options[:overlay] = string for pattern label to facilitate pattern overlay
    #  -no return value
    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

    # Recieves data stream with SWD protocol
    #  -size = the length of data
    #  -options[:compare_data] = data to be compared, only compared if options is set
    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

    # Sends specified number of '0' bits
    #  -size = the length of data
    #  -no return value
    def swd_dio_to_0(size)
      owner.pin(:swd_dio).drive(0)
      size.times do |bit|
        $tester.cycle
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
origen_swd-0.3.7 lib/origen_swd/driver.rb