The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Device::Jtag::USB::FTCJTAG - Perl extension for communicating with JTAG devices using the FTDI FTCJTAG driver.

SYNOPSIS

  use Device::Jtag::USB::FTCJTAG;
  my $jtag = Device::Jtag::USB::FTCJTAG->new();
  $jtag->write_dev_ir(0, 'user1');
  $jtag->write_dev_dr(0, $string_of_bits);

DESCRIPTION

A JTAG device driver for Perl using the FTDI Chip FTCJTAG driver (see http://ftdichip.com/Projects/MPSSE/FTCJTAG.htm). The driver is designed for use with the FTDI Chip FT2232 USB UART/FIFO IC (see http://ftdichip.com/Products/FT2232C.htm). A hardware device is required which incorporates the FT2232 chip in a form that (a) connects to a PC's USB port on one end and (b) connects to the JTAG interface of a target device (or devices). One such device is the Amontec JTAGKey (see http://www.amontec.com/jtagkey.shtml).

EXPORT

None by default.

CONSTRUCTOR

new()

Creates the object. After creating the object, the device(s) on the JTAG scan chain must be defined. This is done by assigning to the 'di' (device info) hash key of the variable returned by the constructor.

For example, if the JTAG scan chain consists of a XC3S1200E FPGA followed by a XCF04S Flash PROM, the chain is defined as follows:

  my $jtag = Device::Jtag::USB::FTCJTAG->new();
  $jtag->{di} = [                        # define device information for devices on scan chain
    {name   => 'XC3S1200E FPGA',         # device 0 nickname
     idregx => '^.1c2e093',              # device 0 idcode reg expression
     ircmds => {idcode => '001001',      # device 0 instructions
                user1  => '000010',
                user2  => '000011',
                bypass => '111111'}},

    {name   => 'XCF0XS Platform Flash',  # device 1 nickname
     idregx => '^.504.093',              # device 1 idcode reg expression
     ircmds => {idcode => '11111110',    # device 1 instructions
                bypass => '11111111'}}
  ];

The values for idregx and the instruction register commands are defined in the target device's BSDL file. These are typically available for download from the manufacturer's website. For BSDL models from Xilinx, visit "/www.xilinx.com/xlnx/xil_sw_updates_home.jsp#BSDL Models" in http:. A regular expression is used for the device's IDCODE because a given devices IDCODE will vary based upon package type, etc.

METHODS

verify_chain()

Read the IDCODEs of the devices on the scan chain and check them against the IDCODEs defined in the JTAG object to verify that they are correct.

write_dev_ir(DEVICE, INSTRUCTION, [ENDSTATE])

Writes INSTRUCTION to JTAG instruction register of device number DEVICE of the scan chain, leaving that device in ENDSTATE when done. The INSTRUCTION must be the hash key of one of the instructions defined for DEVICE. If no ENDSTATE is supplied in the function call, a default of RUN_TEST_IDLE is assumed.

write_dev_dr(DEVICE, DATA, [ENDSTATE])

Writes DATA to JTAG data register of device number DEVICE of the scan chain, leaving that device in ENDSTATE when done. DATA should be formatted as a string of 0s and 1s representing the binary value to be written to the device. If no ENDSTATE is supplied in the function call, a default of RUN_TEST_IDLE is assumed.

read_dev_dr(DEVICE, [ENDSTATE])

Reads JTAG data register or device number DEVICE of the scan chain, leaving that device in ENDSTATE when done. DATA is returned formatted as a string of 0s and 1s representing the binary value of the data. The number of bits read from the device is 32. If no ENDSTATE is supplied in the function call, a default of RUN_TEST_IDLE is assumed.

SEE ALSO

http://ftdichip.com/Projects/MPSSE/FTCJTAG.htm FTDI Chip FTCJTAG driver page.

http://ftdichip.com/Products/FT2232C.htm FTDI Chip FT2232 device page.

http://www.amontec.com/jtagkey.shtml Amontec JTAGKey device page.

http://www.xilinx.com/bvdocs/appnotes/xapp139.pdf Information on JTAG tap controllers.

TO DO

Add autodetection of scan chain devices and auto-assignment of IDCODE value and INSTRUCTION definitions from BSDL files.

HISTORY

  • 0.01 - First release

    Basic first release. By default, assumes devices on JTAG scan chain are (0) Xilinx XC3S1200E FPGA and (1) Xilinx XCF04S Flash PROM.

AUTHOR

Toby Deitrich http://toby.deitrich.net/

COPYRIGHT AND LICENSE

Copyright (C) 2007 by Toby Deitrich

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.