In XJEASE the SET statement is the command to access pins via a JTAG device. XJEase works out via the BSDL files and netlist how to access a pin on a non JTAG device from a JTAG device.

The SET statement can perform both reading and writing of the pins. So:

  
SET nCE := 1;          //set the nCE pin to a logic 1
SET DATA := 0xAA;      //set the data bus ( DATA ) to the HEX value 0xAA
SET readvalue := DATA; //read the current value on the DATA bus into readvalue


Any signals which aren’t changed on a SET statement remain in the same state. All SET statements take one JTAG scan except if you are changing the direction of a bus from writing to reading:

  
SET DATA := 0xAA;      //write takes one JTAG scan 
SET readValue := DATA; //read statement after write takes 2 scans 


You can set a bus to be tristate by doing the following:

  
SET DATA := I; // sets the data bus into read mode

Optimisations

Once a pin is in a state, setting it again is optimised away. So the following code only takes one JTAG scan:

  
SET nCS :=0;
SET nCS :=0;
SET nCS :=0;


You can combine accesses so that they all happen on the same JTAG scan by using a comma:

  
SET nCS := 0, nOE := 0, DATA :=I ;        // All happen on the same JTAG scan
SET nCS := 1, nOE := 1, readvalue := DATA;// All happen on the same JTAG scan

In the example above all the access happen on the same JTAG scan. There is however a difference in timing between the reading and writing. “readvalue := DATA;” happens first during the "Capture" State in the JTAG state machine. The actual outputting of nCS happens later. This delay is the delay of scanning the JTAG chain and moving the JTAG state machine to the "Update" state. This on a device with 300 bits in the scan chain and running at 10MHz will be about 30μs.

The Write-to-Write time

Providing the JTAG chain speed isn’t restricted due to lack of data then the write-to-write time is just over 30μs (it is a slightly longer path through the JTAG state machine):

  
SET nCS := 1; //t =0 
SET nOE := 1; //t = 31us 

The Write-to-Read time

The time between writing to one pin and reading another on the following scan is much faster as the time between the "Update" (write) and the "Capture" (Read) is only a few JTAG cycles around the state machine (about 0.3μs in our example). But as explained earlier – if the pin/bus being read is the one which was just written it will take a further complete scan to read the data.

So for SRAM based devices you could have the following read cycle:

  
SET nWE := 1; // not always needed
SET DATA := I;
SET ADDRESS := Address_To_Read_From;
SET nCS := 0;
SET nOE := 0;
SET Readvalue := DATA;
SET nOE := 1;
SET nCS := 1;
SET nWE := 1;  // not always needed


The above takes a large number of JTAG scans. You can make it much quicker by combining SET statements:

  
SET nWE := 1;
SET DATA := I, ADDRESS := Address_To_Read_From, nCS := 0, nOE := 0;
SET Readvalue := DATA, nOE := 1 , nCS := 1, nWE :=1; 


If you can be sure nWE is logic 1 before starting then the first SET can be removed.