OrigenSpi (0.1.0)


This plugin implements SPI protocol with the tester acting as the master. There are 4 pins standard to SPI, however only sclk is required by this plugin. Any pins that aren’t provided are ignored. This plugin seeks to be very flexible given that the SPI standard is itself very flexible.

How To Install

In your Gemfile add:

gem "origen_spi"

or if your application is a plugin, then add this to your .gemspec

spec.add_runtime_dependency "origen_spi", ">= 0.1.0"

NOTE: In the case of a plugin, you will also need to require 'origen_spi' somewhere in your environment.

How To Use

The spi driver is intended to be instantiated as a sub_block. The configuration can be passed in as a hash and / or can be changed after instantiation. See API for more details.

        sub_block :spi, class_name:   'OrigenSpi::Driver',
                        sclk_pin:     dut.pin(:sclk),
                        mosi_pin:     dut.pin(:mosi),
                        miso_pin:     dut.pin(:miso),
                        ss_pin:       dut.pin(:ss),
                        # :rl - return low - input data changes while sclk is low and is latched on rising edge
                        clk_format:   :rl,
                        # drive state of 0 activates the slave port
                        ss_active:    0,
                        # wait time after ss_active and before any sclk activity
                        clk_wait_time: {time_in_cycles: 2},
                        # number of sclks per tester.cycle
                        clk_multiple: 1,
                        data_order:   :lsb0
  # configuration can be changed after instantiation like this
  dut.spi.clk_multiple = 80
  dut.spi.miso_compare_cycle = 79
  dut.spi.ss_pin = nil

Once the driver is instantiated shift operations can be performed by calls to the shift method (overlay/store/masking etc. is handled):

  # shift out, masking input compares
  dut.spi.shift master_out: 0xFF, size: 32
  # shift out, register - size doesn't need to be passed when register is provided
  dut.spi.shift master_out: dut.my_reg
  # shift in read examples:
  dut.spi.shift master_in: 0xFF, size: 32
  # provide a register to mask or store (mark the bits appropriately)
  dut.spi.shift master_in: dut.my_reg
  # simultaneous shift in/out
  dut.spi.shift master_out: some_value_or_reg, master_in: some_other_value_or_reg

How To Setup a Development Environment

To setup a development environment:

  git clone https://github.com/Origen-SDK/origen_spi.git