NIKHEF NATIONAL INSTITUTE FOR NUCLEAR AND HIGH ENERGY PHYSICS 

DEPARTMENT OF ELECTRONIC TECHNOLOGY 

P.O.box 41882, NL 1009 DB AMSTERDAM

 

 
LPT_JTAG Hard- and software to drive JTAG compatible ports 
version: may 20 1998 
 

  
The LPT_JTAG software is a program written in QBASIC. It takes a datafile as an input, generates a few output files and drives the LPT port. A special (home made) cable from the PC's LPT-port to the JTAG port is required.

Check for most recent version: http://www.nikhef.nl/user/d01/lpt_jtag/ 


Fast access to chapters:

General Commands Example Example 2 Software Hardware TAP controller


LPT_JTAG interface.

The LPT_JTAG software is a small program written in QBASIC. It takes a datafile as an input and generates a few output files. A special cable from the PC's LPT-port to the JTAG port is required.

Please note that in this version of the Basic program, the cable specification has changed. This is done to minimize (remove) the cross-talk between TDO and TCK. Especially TCK is very sensitive to noise. At NIKHEF we use long cables and RS 485 translators to access self programmed JTAG ports. In the past we had problems with cross-talk from TDO to TCK. If you are using this stuff already, you have to swap pins 2 and 8 on the D25 connector. Use this connector specification with software of May 1 1998 or later.

The program takes the <name>.idt input file from the data subdirectory and checks the syntax. <name>.log is generated, containing the original statements and the expanded loops. Endless loops will run until a key is hit. Endless loops are defined by omitting the number of loops. The logging is limited to showing the complete sequence once. The data read back is recorded 4 times in the <name>.log file. The data received is represented in binary format. Loops cannot be nested. When the input data is entered in hexadecimal format it is converted into a multiple of 4 bits. Hexadecimal data should start with '0X' or '$'. A comment starts with ';', the rest of the line is ignored by the parser. There is no difference between upper and lower case. The <name>.odt file just holds the data send and received in binary format. The <name>.err file lists the syntax errors with the corresponding line numbers in the source file (<name>.idt). If multiple input files are run after another, the line numbers are not reset.

 
 

 
 

Commands: 
TMS0 reset TMS (default)
TMS1 set TMS
RST0 reset TRST (default)
RST1 set TRST
PEN0 disable programming mode (default)
PEN1 enable programming mode (some AMD devices)
TRG0 reset trigger signal (no TCK generation) (default)
TRG1 set trigger signal (no TCK generation)
UNI0 reset signal UNI (no TCK generation)
UNI1 set signal UNI (no TCK generation)
LOOP start an endless loop
LOOP n start n loops
ENDL end of the loop
WAIT execution pauses until keyboard input
WAIT n execution pauses n seconds
IDAT 01010[+] binary input data (01010 generates 5 TCKs), see IDAT
IDAT $24F[+] 
IDAT 0X24f
hexadecimal data (24F generates 12 TCKs)
BYP0 normal operation (default)
BYP1 enable bypass (TI device)
TCKN n generate n TCKs
SADD a send decimal address a via shadow protocol (TI)
SADD $a 
SADD 0Xa
send hexadecimal address a via shadow protocol (TI)
; start of comment text (untill end of line)
VSYS generates a stimulus file for the v-system simulator, see VSYS
ESYS end vector generation, see VSYS
TMON1 switch on tap monitor (default).
TMON0 switch off tap monitor
LOG1 switch on logging of data read back on screen (default)
LOG0 switch off logging
ECHO the rest of the line is echoed to screen
? Interactively asks for a parameter
! Inserts the parameter defined at "?"
TRST and program_enable are active low signals on the JTAG port. The user defines in the input file whether they are active (1). The software takes care of the inversion.

With the last data bit transmitted, also TMS must be set, see IDAT.

 



 

 
 
Example: 
test.idt 
meaning 
test.log 
TMS0,rst1, rst0  make TMS low, make TRST high, make TRST low 1 TMS0,rst1, rst0
TMS1,tms2 ; flut make TMS high, make tms two -> syntax error. flut is a comment 2 TMS1,tms2 ; flut 
syntax error: >TMS2< in line 2
loop Start of an endless loop 3 loop 

--- begin_loop 0 
(endless loop)

idat 010101010101 binary data to be send, LSB first. 4 idat 010101010101 
read 1 > 111111111111
trg1,trg0 set and reset triggerbit 5 trg1,trg0
endl end of the loop, exit here when a key is hit 6 endl 
read 2 > 111111111111 
read 3 > 111111111111 
read 4 > 111111111111 
--- manual end_loop 
(executed 55 times)
idat $2a7bcdef  hexadecimal data to be send (2 is converted to 0010) 7 idat $2a7bcdef 
read > 00101010011110111100110111101111
loop 3; all devices loops the statements up to 'endl' 3 times 8 loop 3; all devices 
--- begin_loop 3
tms1   9 tms1
TMS0   10 TMS0
endl   --- loop 2 
9 tms1 
10 TMS0 
11 endl 
--- loop 1 
9 tms1 
10 TMS0 
11 endl 
--- end_loop
tms1,tms0   12 tms1,tms0
rst1,rst0   13 rst1,rst0
     
 Return to top


 

Example 2

Inputfile t_pulse.idt:
; this is to test the testpulses in pause_dr
; and pause_ir
;loop
tms1, tckn 5 ; reset
tms0,tms1,tms1,tms0,tms0 ;reset to shift_ir
;idat 01 ; test
idat 00 ; test +clk
;tms1,
tms0,tms1,tms1,tms1,tms0,tms0; shift_ir to shift_dr
idat $ffff ffff ffff 0000 0000 0000; test pattern
;tms1,
tms0; shift_dr to pause_dr
tckn 5; test pulses in pause_dr
tms1,tms1,tms1,tms1,tms0,tms0; pause_dr to shift_ir
;idat 01 ; test
idat 00; test +clk
;tms1,
tms0; shift_ir to pause_ir
tckn 5; test pulses in pause_ir
trg1,trg0
;endl
Outputfile t_pulse.log:
t_pulse.log, created: 07-14-1997 11:42:05
24 ; this is to test the testpulses in pause_dr
25 ; and pause_ir
26 ;loop
27 tms1, tckn 5 ; reset
28 tms0,tms1,tms1,tms0,tms0 ;reset to shift_ir
29 ;idat 01 ; test
30 idat 00 ; test +clk
read > 01
(implicit TMS1 sent with last bit)
31 ;tms1,
32 tms0,tms1,tms1,tms1,tms0,tms0; shift_ir to shift_dr
33 idat $ffff ffff ffff 0000 0000 0000; test pattern
read > 111111111111111111111111111111111111111111111111000000000000000000000000000000000000000000000000
(implicit TMS1 sent with last bit)
34 ;tms1,
35 tms0; shift_dr to pause_dr
36 tckn 5; test pulses in pause_dr
37 tms1,tms1,tms1,tms1,tms0,tms0; pause_dr to shift_ir
38 ;idat 01 ; test
39 idat 00; test +clk
read > 01
(implicit TMS1 sent with last bit)
40 ;tms1,
41 tms0; shift_ir to pause_ir
42 tckn 5; test pulses in pause_ir
43 trg1,trg0
44 ;endl

The line numbers are incremented while the program is running. This useful when a number of input files are run after another.

 Return to top




Software

The software is written QBASIC because this gives easy access to the LPT port and because I am not a software expert. lpt_jtag.bas can be run in a DOS-window in Windows. Using lpt_jtag.pif the program can conveniently be started via an icon. Adjusting the file properties, the proper default subdirectory (location of the program) should be defined. The Basic program searches for input files in the subdirectory data. The output files are stored in the same subdirectory. You must correct the path definition in the beginning of the program. This is where it says: dir$="D:\HENKG\JTAG\DATA".
For a specific use at NIKHEF, the <name>.log file can be converted to a file set into the subdirectory data\vme\. This option becomes available at the end of a series of input files. It is not likely this is of any use outside our institute.

TMS
TMS is used to step through the TAP-controller. I choose to do this on a low level (instead of go from idle to shift_dr) to have full control over my programmed JTAG ports.

RST
RST is (hardly ever) used to reset the TAP-controller. I advise you not to use it if possible.

PEN
Program enable is foreseen to be used with MACH devices. The program enable pin on these chips enables the JTAG port to load a new functionallity (to re-program them).

TRG
TRG can be used as a trigger to the oscilloscope when debugging the system under test. It is not used in the connector on the board under test.

UNI
UNI is used at NIKHEF to generate test pulses to our boards. A sort of general purpose signal. Much like TRG.

LOOP
LOOP creates a loop as in Basic. The ENDL defines the end of the sequence to be looped through. Without parameters it is an endless loop, untill a keyboard input is seen (Enter). A parameter defines the number of loops (decimal). Loops cannot be nested. The rest of the line, containing the loop statement, is ignored. So, don't put anything else then a comment there. In an endless loop the generation of <name>.ODT and <name>.LOG is paused after three loops and continued when the loop is left.

WAIT
WAIT stops execution of the <name>.idt file untill user input (Space). When a parameter is used, it defines the number of seconds to pause (decimal).

IDAT

The IDAT command sends data to the device under test and reads back the results from the device. When hexadecimal data is specified, always a multiple of 4 bits are generated. With the last bit transmitted, TMS is set high according to the 1149 specifications. The last bit is shifted when the TAP controller goes from shift to exit1, either in instruction or data mode. For long registers, a single data string might not be very convenient. For this reason multiple idat commands can be given. The concatenation character '+' prevents the automatic TMS generation here.

So the command:

idat $abc; load all registers Can also be written as: idat $c+; load register 1 (bits 3:0)

idat $ab; load the 8 bit register 2 (bits 11:4)

Take care of the proper order. The standard defines that the least significant bit appears at TDO first. In the .log and .odt file the data read is displayed below each idat command. Every four bits a space is inserted to increase readability.

BYP
The bypass command is used at NIKHEF to set a signal to the addressable JTAG interface on our boards to ignore the addressing and directly connect to the JTAG chain. See also SADD.

TCKN
On TCK the TAP-controller moves through its states or it shifts data or instruction bits. The signal can also be used to perform internal tests in certain states. With TCKN the parameter is required and interpreted decimal.

SADD
The shadow protocol is used to address a certain card in a bus-structure. It is defined by Texas Instruments and a description can be found in  the datasheet of the 74ABT8996 for example.

VSYS
The VSYS command will switch the program from generating output to the LPT port, to generating force commands for the V-System VHDL simulator. It will usually be the first command in an input file (<name>.idt). It is useful to check measurement results against simulation results in self defined JTAG ports. The ESYS command ends the vector generation. So one can convert just a part of the input file into simulation stimuli.

When in the VSYS mode some commands are ignored: PEN0, PEN1, TRG0, TRG1, BYP0, BYP1 and WAIT. Loops are expanded in the usual way and endless loops will generate (large) files, until stopped manually. The file generated is named <name>.do, the usual extension for a simulator macro file. The ESYS command ends the generation. Multiple VSYS-ESYS sequences may be used to build the macro.

TMON
The TMON command switches the tap monitor on and off. When a command line is fully executed and echoed in the .log file, the current TAP-state is added to the .log file in the same line between < > brackets.
Example:

Result:
LOG
The log command switches the logging of data read back from the JTAG chain on and off. In this way only the interesting parts of (binary) strings of data, returned by the chain, can be displayed. See the example with ECHO.

ECHO
ECHO displays the rest of the line on screen while <name>.idt is processed. This can be useful when boards are tested and one wishes to compare values returned from the chain with values expected.
Example:


?,!
The question mark "?" asks the user to input a parameter. This either decimal or hexadecimal. At NIKHEF we use it to define the address of the card on the bus to be accessed. The exclamation mark "!" is used to pass the parameter to the chain.
Example:
 

 Return to top




Hardware
 On most computers, the base address of the LPT port #1 is 378 (hex). This can be checked by the command MSD in DOS mode. For port #2 (or older computers) you may have to change the address into 3BC in the routine xchange by setting the variable oldcomp to 1.
 
 
The signals on the LPT port 
Pin 
signal usage
STRB -
D0 P_Ena *
D1 TDO (output)
D2 TMS
D3 UNI
D4 _BYPASS (TI)
D5 _TRST
D6 TCK *
D7 Trigger
10 
_ACK -
11 
BUSY -
12 
P_END -
13 
SEL -
14 
AUTO_F -
15 
_ERROR TDI (input)
16 
_INIT -
17 
SEL_INP -
18...25 
GND GND
The TDO (output of the PC) connects to the TDI of the device under test.
 
* : These signals changed since may 1998 (why). Use this specification with software of May 1 1998 or later.

At NIKHEF we defined a 10 pin header to connect the LPT cable.
 

The signals on the JTAG connector (dual row) 
1 TCK
_BYPASS (TI devices)
TMS
GND
TDI (input of device under test)
Vcc
TDO (input of PC)
GND
_TRST
10 
P_ENA
The bypass signal can be used to overrule the address decoding of addressable scan-path devices, such as TI's 74ABT8996. Some AMD devices have a program enable pin. P_Ena is used by the Mach_Pro software (Vantis). A different cable is needed to program the MACH devices.
Trigger and Uni are used for other purposes then JTAG, such as triggering a scope.

 Return to top

 




TAP controller

Since you can never find the TAP controller's state diagram when you need it, here it is.