% render "layouts/basic.html" do %# HTML tags can be embedded in mark down files if you want to do specific custom %# formatting like this, but in most cases that is not required.
.gemspec
~~~ruby
spec.add_development_dependency "origen_jtag", ">= <%= Origen.app.version %>"
~~~
__NOTE:__ You will also need to include require 'origen_jtag'
somewhere in your environment. This can be done in config/environment.rb
for example.
### How To Use
Include the OrigenJTAG
module to add a JTAG driver to your class and
define the required pins.
Normally the pins would be an alias to existing DUT pins and therefore the
JTAG driver module cannot assume them.
Including the module adds a jtag
method which will return an instance of
[OrigenJTAG::Driver
](<%= path "api/OrigenJTAG/Driver.html" %>).
The following attributes can be customized by defining a JTAG_CONFIG
hash:
* **tclk_format** - TCLK timing format, Return High (:rh) or Return Low (:rl). Default is :rh.
* **tclk_multiple** - Number of cycles for a single TCLK pulse to cover, to support cases where TCLK needs to be a fraction of another clock period. Assumes 50% duty cycle, specify only even numbers if > 1. Default is :r1.
* **tdo_strobe** - When using multiple cycles for TCK, which state of TCK to strobe for TDO, :tclk_high or :tclk_low or :tclk_all. Default :tclk_high.
* **tdo_store_cycle** - When using multiple cycles for TCK, which cycle of TCK to store for TDO if store requested (0 to number of tclk_multiple-1). Default 0
Here is an example integration:
~~~ruby
class Pioneer
include OrigenJTAG
include Origen::Pins
# TCK covers 4 tester cycles, 2 high then 2 low for each effective TCK pulse
# Strobe TDO only when TCK high. Only store TDO on last cycle (3)
JTAG_CONFIG = {
:tclk_format => :rl,
:tclk_multiple => 4,
:tdo_strobe => :tclk_high,
:tdo_store_cycle => 3,
}
def initialize
add_pin :tclk
add_pin :tdi
add_pin :tdo
add_pin :tms
end
end
Pioneer.new.jtag # => An instance of OrigenJTAG::Driver
~~~
Two APIs are provided, the primary one provides canned methods to read and
write to the IR and DR registers.
These accept either an absolute data value or an Origen register/bit collection.
~~~ruby
jtag.write_dr 0x1234, :size => 16
# The size option is not required when a register is supplied
jtag.write_dr $dut.reg(:clkdiv)
# Although it can still be added if the register is not the full data width
jtag.write_dr $dut.reg(:clkdiv), :size => 32
# A rich read method is available which supports bit-level read, store and
# overlay operations
$dut.reg(:clkdiv).bits(:div).read(0x55)
jtag.read $dut.reg(:clkdiv)
# Similar methods exist for the instruction register
jtag.write_ir 0x1F, :size => 5
jtag.read_ir 0x1F, :size => 5
~~~
A secondary API provides low level control of the TAP Controller state machine.
~~~ruby
jtag.pause_dr do
jtag.shift_dr do
# The shift method accepts the same arguments as the canned read/write methods
jtag.shift 0x55, :size => 32
end
end
~~~
See the [OrigenJTAG::Driver
](<%= path "api/OrigenJTAG/Driver.html" %>) and
[OrigenJTAG::TAPController
](<%= path "api/OrigenJTAG/TAPController.html" %>)
APIs for more details about the available driver methods.
Any model/controller within a target runtime environment can listen out for JTAG state
changes by implementing the following callback handler:
~~~ruby
def on_jtag_state_change(new_state)
if new_state == :update_dr
# Do something every time we enter this state
end
end
~~~
### How To Setup a Development Environment
[Clone the repository from Github](https://github.com/Origen-SDK/origen_jtag).
An instance of the OrigenJTAG driver is hooked up to a dummy DUT
object for use in the console:
~~~
origen i
> $dut.jtag
=> #