Hybrid SPI- and GPIO-based JTAG interface emulation method, emulated JTAG interface, and test device
By using a hybrid SPI and GPIO approach to simulate the JTAG interface, the problems of insufficient timing accuracy and high resource consumption in existing technologies are solved, achieving high-frequency JTAG communication and low CPU usage, thus improving system performance.
Patent Information
- Application Number
- PCT/CN2025/146986
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2025-05-16
- Filing Date
- 2025-12-30
- Publication Date
- 2026-11-19
AI Technical Summary
In existing technologies, simulating the JTAG interface using GPIO suffers from insufficient timing precision and high resource consumption, making it difficult to meet the needs of high-frequency communication and consuming a large number of CPU cycles, leading to decreased system performance and conflicts in real-time tasks.
A hybrid SPI and GPIO approach is used to simulate the JTAG interface. The clock pin of the SPI interface is used as the test clock, the MOSI pin is used as the test data input signal, and the MISO pin is used as the test data output signal. The GPIO interface is used as the test mode selection pin. State machine control and data transmission are performed in combination with the simulated JTAG data transmission rules.
It improved the transmission rate, reduced CPU utilization, enabled high-frequency JTAG communication, and reduced the impact on system performance.
Smart Images

Figure CN2025146986_19112026_PF_FP_ABST
Abstract
Description
Methods for simulating a JTAG interface using a hybrid SPI and GPIO approach, the simulated JTAG interface, and testing equipment. Technical Field
[0001] This application relates to the field of signal processing technology, and in particular to a method for simulating a JTAG interface using a hybrid SPI and GPIO approach, the simulated JTAG interface, and testing equipment. Background Technology
[0002] JTAG (Joint Test Action Group) is a standard interface protocol defined by the IEEE 1149.1 standard, primarily used for testing, debugging, and in-circuit programming of electronic devices. The basic working principle of the JTAG interface is to define a TAP (Test Access Port) internally within the chip. Developers use a JTAG debugger connected to the chip's external JTAG interface to access the chip's internal TAP port to scan various scan units and write or read the status of the scan registers, thereby testing and debugging the chip. Each scan unit corresponds to an external pin, and each external pin has a scan register (BSR) unit. Connecting the scan registers of all pins together forms a scan chain.
[0003] Control of the TAP is accomplished through the TAP Controller. The TAP Controller's state machine has 16 synchronous states. During state machine transitions, for MCUs without a built-in JTAG state machine peripheral, debugging functions can be implemented by simulating JTAG signal pins via GPIO. Specifically, this involves software-controlled GPIO level toggling to simulate the JTAG protocol's state machine logic (such as state transitions and data shifts). For example, precise control of the TCK clock edge and TMS level combination via loops or interrupts allows the target chip's JTAG state machine to switch to specific modes (such as register shifts and data register captures) as needed. However, this method has the following drawbacks:
[0004] (1) Insufficient timing accuracy: The toggle speed of GPIO is limited by the instruction execution speed and hardware delay of the MCU, making it difficult to meet the requirements of high-frequency JTAG communication (such as exceeding several MHz). During high-frequency communication, timing deviations or jitter (such as inaccurate clock edges caused by interrupt interference) can easily lead to communication errors or complete failure.
[0005] (2) High resource consumption: The simulated JTAG state machine needs to continuously control the GPIO pin level through software, which consumes a large number of CPU cycles (e.g., through blocking loops or intensive interrupt handling). This not only leads to a decrease in system performance, but may also conflict with other real-time tasks (such as timer interrupts and serial communication), and may even further reduce efficiency due to the coarse-grained control of the delay function. Summary of the Invention
[0006] In view of the shortcomings of the prior art described above, the purpose of this application is to provide a method for simulating a JTAG interface using a hybrid SPI and GPIO approach, a simulated JTAG interface, and a testing device, in order to solve at least one problem in the prior art.
[0007] To achieve the above and other related objectives, a first aspect of this application provides a method for simulating a JTAG interface using a hybrid SPI and GPIO configuration, comprising: selecting an SPI interface and a GPIO interface for simulation, and operating the SPI interface in a host mode and a first communication mode; using the clock pin of the SPI interface as a test clock pin, the MOSI pin of the SPI interface as a test data input signal pin, the MISO pin of the SPI interface as a test data output signal pin, and the GPIO interface as a test mode selection pin to obtain a simulated JTAG interface; and performing transmission control and state control on the simulated JTAG interface based on simulated JTAG data transmission rules to test the chip under test.
[0008] In some embodiments of the first aspect of this application, state machine control of the simulated JTAG interface specifically includes: controlling the output level of the GPIO interface to control the TAP controller of the chip under test to perform state transitions.
[0009] In some embodiments of the first aspect of this application, the simulated JTAG data transmission rules include: obtaining the number of clock cycles of the current TAP controller state; if the number of clock cycles of the current TAP controller state is equal to 1, then controlling the SPI interface to perform data transmission of the current TAP controller state with the chip under test in single-cycle data transmission mode; if the number of clock cycles of the current TAP controller state is greater than 1, then controlling the SPI interface to perform data transmission of the current TAP controller state with the chip under test in multi-cycle data transmission mode.
[0010] In some embodiments of the first aspect of this application, controlling the SPI interface to perform data transmission with the chip under test in the current TAP controller state in a single-cycle data transmission mode specifically includes: setting the read / write mode of the SPI interface to a half-duplex write-only mode and setting the data width of the SPI interface to a preset single-cycle transmission data width; and in the current TAP controller state, controlling the SPI interface to send data for one SPI clock cycle to the chip under test.
[0011] In some embodiments of the first aspect of this application, controlling the SPI interface to transmit data of the current TAP controller state with the chip under test in a multi-cycle data transmission mode specifically includes: setting the read / write mode of the SPI interface according to the TDO data of the current TAP controller state; when the SPI interface is set to half-duplex write-only mode, controlling the SPI interface to send the TDI data of the current TAP controller state to the chip under test in segments; when the SPI interface is set to full-duplex read / write mode, controlling the SPI interface to send the TDI data of the current TAP controller state to the chip under test in segments and receive the TDO data of the current TAP controller state in segments from the chip under test.
[0012] In some embodiments of the first aspect of this application, before controlling the SPI interface to transmit data with the chip under test in the current TAP controller state in a multi-cycle data transmission mode, the data width of the SPI interface is configured to a preset multi-cycle transmission data width.
[0013] In some embodiments of the first aspect of this application, when the SPI interface is configured in half-duplex write-only mode, controlling the SPI interface to send TDI data of the current TAP controller state to the chip under test in segments includes: determining the integer and remainder of the segmented transmission based on the number of clock cycles of the current TAP controller state and the width of the multi-cycle transmission data; controlling the SPI interface to send TDI data to the chip under test a corresponding integer number of segmented transmissions according to the width of the multi-cycle transmission data; and then reconfiguring the data width of the SPI interface according to the remainder of the segmented transmissions, so that the SPI interface sends the remaining TDI data according to the data width of the remainder of the corresponding segmented transmissions.
[0014] In some embodiments of the first aspect of this application, when the SPI interface is set to full-duplex read / write mode, controlling the SPI interface to send TDI data of the current TAP controller state to the chip under test in segments and to receive TDO data of the current TAP controller state in segments from the chip under test, specifically includes: determining the integer and remainder of the segmented transmission based on the number of clock cycles of the current TAP controller state and the width of the multi-cycle transmission data; controlling the SPI interface to send TDI data of the corresponding integer number of segmented transmissions to the chip under test according to the width of the multi-cycle transmission data and simultaneously receiving TDO data of the corresponding integer number of segmented transmissions from the chip under test; and then reconfiguring the data width of the SPI interface according to the remainder of the segmented transmission, so that the SPI interface sends the remaining TDI data and receives the remaining TDO data according to the data width of the remainder of the corresponding segmented transmission.
[0015] To achieve the above and other related objectives, a second aspect of this application provides a hybrid SPI and GPIO simulated JTAG interface for connecting a chip under test (DUT), comprising: an SPI interface and a GPIO interface; wherein, the clock pin of the SPI interface serves as a test clock pin, the MOSI pin of the SPI interface serves as a test data input signal pin, the MISO pin of the SPI interface serves as a test data output signal pin, and the GPIO pin serves as a test mode selection pin; the SPI interface operates in host mode and a first communication mode; based on simulated JTAG data transmission rules, transmission control and status control are performed on the simulated JTAG interface to test the DUT.
[0016] To achieve the above and other related objectives, a third aspect of this application provides a test device that tests the chip under test via a JTAG interface that is a hybrid simulation of SPI and GPIO as described above.
[0017] As described above, the method for simulating a JTAG interface using a hybrid SPI and GPIO approach, the simulated JTAG interface, and the testing equipment of this application have the following beneficial effects:
[0018] This application implements the simulation of the JTAG interface through the SPI interface and the GPIO interface, which improves the transmission rate and reduces the CPU utilization. Attached Figure Description
[0019] Figure 1 shows a flowchart of a method for simulating a JTAG interface using a hybrid SPI and GPIO approach according to an embodiment of this application.
[0020] Figure 2 shows a schematic diagram of the positions of the SPI interface and the GPIO interface in a specific embodiment of this application.
[0021] Figure 3 shows a schematic diagram of the positions of the SPI interface and the GPIO interface in another specific embodiment of this application.
[0022] Figure 4 shows a schematic diagram of the state machine of the TAP controller in one embodiment of this application.
[0023] Figure 5 shows a timing diagram of SPI and GPIO simulating a data register operation in one embodiment of this application.
[0024] Figure 6 shows a timing diagram of a primary data register in one embodiment of this application.
[0025] Figure 7 shows a schematic diagram of the data transmission process in one embodiment of this application. Detailed Implementation
[0026] The following specific examples illustrate the implementation of this application. Those skilled in the art can easily understand other advantages and effects of this application from the content disclosed in this specification. This application can also be implemented or applied through other different specific embodiments, and various details in this specification can also be modified or changed based on different viewpoints and applications without departing from the spirit of this application. It should be noted that, unless otherwise specified, the following embodiments and features in the embodiments can be combined with each other.
[0027] In the embodiments of this application, the terms "first" and "second" are used to distinguish identical or similar items with essentially the same function and effect. Those skilled in the art will understand that the terms "first" and "second" do not limit the quantity or execution order, and that the terms "first" and "second" do not necessarily imply that they are different.
[0028] It should be noted that, in the embodiments of this application, the words "exemplary" or "for example" indicate examples, illustrations, or descriptions. Any embodiment or design described as "exemplary" or "for example" in this application should not be construed as being more preferred or advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary" or "for example" is intended to present the relevant concepts in a concrete manner.
[0029] In this application embodiment, "at least one" refers to one or more, and "more than one" refers to two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, or B alone, where A and B can be singular or plural. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship. "At least one of the following" or similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one of a, b, or c can represent: a, b, c, ab, ac, bc, or abc, where a, b, and c can be single or multiple.
[0030] To facilitate understanding of the embodiments of this application, a detailed description will first be provided with reference to FIG1. FIG1 shows a flowchart illustrating a method for simulating a JTAG interface using a hybrid SPI and GPIO approach according to an embodiment of the present invention. The method for simulating a JTAG interface using a hybrid SPI and GPIO approach in this embodiment mainly includes the following steps:
[0031] Step S11: Select the SPI interface and GPIO interface for simulation, and make the SPI interface work in host mode and first communication mode.
[0032] It should be understood that in SPI communication, the master is the party controlling the communication process. It is responsible for generating the clock signal (SCK), controlling the sending and receiving of data, and managing the start and end of communication. Master mode is a working state of the SPI interface, in which the master exchanges data with one or more slave devices through the SPI interface.
[0033] It should also be understood that the SPI protocol defines four communication modes through clock polarity (CPOL) and clock phase (CPHA): SPI mode 0, SPI mode 1, SPI mode 2, and SPI mode 3. SPI mode 1 is the first communication mode in this embodiment. SPI mode 1 means that the SPI SLCK clock is low when idle (CPOL = 0), and data is sampled and output on even-numbered clock edges (CPHA = 1). It is important to note that the SPI interface must operate in master mode and SPI mode 1 to achieve the subsequent control functionality of this invention.
[0034] In one specific embodiment, as shown in Figure 2, the SPI interface and GPIO interface located on the same electronic device can be used as the SPI interface and GPIO interface for simulation. Alternatively, as shown in Figure 3, the SPI interface and GPIO interface located on two different electronic devices can be used as the SPI interface and GPIO interface for simulation. The types of electronic devices include, but are not limited to: central processing unit (CPU), microcontroller unit (MCU) (also known as a single-chip microcomputer), digital signal processor (DSP), field-programmable gate array (FPGA), etc. Alternatively, the SPI interface and GPIO interface located on the chip under test can be used as the SPI interface and GPIO interface for simulation.
[0035] In one embodiment, the SPI interface includes a clock (SCLK) pin, a MOSI pin, and a MISO pin.
[0036] Step S12: Use the clock pin of the SPI interface as the test clock (TCK) pin, the MOSI pin of the SPI interface as the test data input signal (TDI) pin, the MISO pin of the SPI interface as the test data output signal (TDO) pin, and the GPIO interface as the test mode select (TMS) pin to obtain a simulated JTAG interface.
[0037] It should be understood that the standard JTAG interface defines the following signal pins:
[0038] TDI (Test Data Input): Serial input pin for instructions, test data, and programming data. Data is shifted in on the rising edge of TCK. Mandatory requirement of IEEE 1149.1 standard.
[0039] TDO (Test Data Output): Serial data output pin used for instructions, test data, and programming data. Data is shifted out on the falling edge of TCK. Mandatory requirement of IEEE 1149.1 standard.
[0040] TMS (Test Mode Select): Provides a control signal to determine the input pin for state machine transitions in the TAP controller. Transitions within the state machine occur on the rising edge of TCK. Therefore, the TMS signal must be established before the rising edge of TCK to ensure correct state transitions. The TMS signal is sampled on the rising edge of TCK to determine the next state. Mandatory requirement of the IEEE 1149.1 standard.
[0041] TCK (Test clock input): Clock input for boundary scan test (BST) circuits. Some operations occur on the rising edge of the clock. Mandatory requirement of the IEEE 1149.1 standard.
[0042] TRST: Internal TAP controller reset signal input. Not mandatory by the IEEE 1149.1 standard. The TAP controller can also be reset via TMS.
[0043] Specifically, the SCLK clock signal output from the clock pin of the SPI interface is the TCK signal, the MOSI signal output from the MOSI pin of the SPI interface is the TDI signal, the MISO signal output from the MISO pin of the SPI interface is the TDO signal, and the signal output from the GPIO interface is the TMS signal.
[0044] It should be noted that the JTAG physical layer protocol is implemented through the SPI interface. Hardware-level signal mapping (SPI SCLK and TCK, MOSI and TDI, MISO and TDO) ensures the timing accuracy of the TCK signal. The SPI interface can generate precise and high-frequency (above 20MHz) clocks, and guarantees equidistant clock intervals, avoiding the latency and jitter issues that occur with GPIO. The SPI MOSI and MISO pins serve as TDI / TDO pins, utilizing the SPI FIFO and DMA to achieve high-speed data flow. Compared to GPIO bit operations (<5MHz), SPI hardware acceleration can reach over 20MHz, a speed improvement of 4 times.
[0045] Step S13: Based on the simulated JTAG data transmission rules, perform transmission control and state machine control on the simulated JTAG interface to test the chip under test.
[0046] It should be understood that the simulated JTAG interface establishes a connection with the chip under test (DUT) by accessing the DUT's TAP port.
[0047] In one embodiment, the specific method for state machine control of the simulated JTAG interface includes controlling the output level of the GPIO interface to control the TAP controller of the chip under test to perform state transitions. It should be noted that this invention precisely controls the TMS state switching through GPIO.
[0048] Specifically, as shown in Figure 4, the state machine of the TAP controller of the chip under test has 16 synchronous states, divided into the data register (DR) path and the instruction register (IR) path. The next state of the TAP controller is determined by the TMS signal, which is sampled and activated on the rising edge of TCK.
[0049] The 16 synchronization states specifically include:
[0050] 1. Test-Logic-Reset: Initial reset state; all operations must begin from this state. When the TRST signal is active (low level), this state is entered directly. Even without the TRST signal, TMS=1 for five consecutive TCK cycles will force entry into this state. Within one TCK cycle, when TMS=0, the Run-Test / Idle state is entered; when TMS=1, the state remains unchanged.
[0051] 2. Run-Test / Idle: Idle state, waiting for test commands or operations. Within one TCK cycle, when TMS=0, the state remains unchanged; when TMS=1, it enters the Select-DR-Scan state.
[0052] 3. Select-DR-Scan: Preparation state for selecting the data register (DR) scan path. Within one TCK cycle, when TMS = 0, it enters the Capture-DR state; when TMS = 1, it enters the Select-IR-Scan state.
[0053] 4. Capture-DR: Captures the current value of the data register (DR) in preparation for the shift operation. Within one TCK cycle, when TMS = 0, it enters the Shift-DR state; when TMS = 1, it enters the Exit1-DR state.
[0054] 5. Shift-DR: Shifts data in the data register (serial input TDI, output TDO), and can shift multiple bits of data over consecutive TCK cycles. Within one TCK cycle, when TMS = 0, it remains in the same state and continues to perform shift operations; when TMS = 1, it enters the Exit1-DR state.
[0055] 6. Exit1-DR: Exit the Shift-DR state and prepare for updating or pausing. Within a TCK cycle, when TMS = 0, it enters the Pause-DR state; when TMS = 1, it enters the Update-DR state.
[0056] 7. Pause-DR: Temporarily suspends the shift operation of the TDI-Shift Register-TDO serial channel. Within one TCK cycle, when TMS = 0, the state remains unchanged and remains in the paused state. When TMS = 1, it enters the Exit2-DR state.
[0057] 8. Exit2-DR: Temporary state of the TAP controller. Within one TCK cycle, when TMS = 0, the TAP re-enters the Shift-DR state; when TMS = 1, it enters the Update-DR state, ending the scan operation.
[0058] 9. Update-DR: Updates the shifted data to the target register or chip pin. Within one TCK cycle, when TMS = 0, it enters the Run-Test / Idle state; when TMS = 1, it enters the Select-DR-Scan state.
[0059] 10. Select-IR-Scan: The preparation state for selecting the instruction register (IR) scan path. Within one TCK cycle, when TMS=0, it enters the Capture-IR state, and when TMS=1, it enters the Select-DR-Scan state.
[0060] 11. Capture-IR: Captures the current value of the instruction register (IR) to prepare for shift operation. Within one TCK cycle, when TMS = 0, it enters the Shift-IR state; when TMS = 1, it enters the Exit1-IR state.
[0061] 12. Shift-IR: Shifts data in the instruction register (serial input TDI, output TDO), and can shift multiple bits of data over consecutive TCK cycles. Within one TCK cycle, when TMS = 0, the state remains unchanged, and the shift operation continues; when TMS = 1, it enters the Exit1-IR state.
[0062] 13. Exit1-IR: Exit the Shift-IR state and prepare for updating or pausing. Within a TCK cycle, when TMS = 0, it enters the Pause-IR state; when TMS = 1, it enters the Update-IR state.
[0063] 14. Pause-IR: Temporarily suspends the shift operation of the TDI-Shift Register-TDO serial channel. Within one TCK cycle, when TMS = 0, the state remains unchanged and remains in the paused state. When TMS = 1, it enters the Exit2-IR state.
[0064] 15. Exit2-IR: Temporary state of the TAP controller. Within one TCK cycle, when TMS = 0, the TAP re-enters the Shift-IR state; when TMS = 1, it enters the Update-IR state, ending the scan operation.
[0065] 16. Update-IR: The value in the shift register is latched into the instruction register on the falling edge of TCK. Once latched successfully, the new instruction becomes the current instruction. Within one TCK cycle, when TMS = 0, it enters the Run-Test / Idle state; when TMS = 1, it enters the Select-DR-Scan state.
[0066] The specific methods for controlling the state machine of the TAP controller to perform state transitions via GPIO pins include:
[0067] During one SPI clock cycle, the TAP controller's state machine is in state A (state A can be any of the 16 states mentioned above). If a level information tms_level is input to the electronic device containing the GPIO interface during this SPI clock cycle, the electronic device will configure the output level of the GPIO interface according to the level information. When tms_level is 0, the output level of the GPIO interface is configured as 0; when tms_level is 1, the output level of the GPIO interface is configured as 1. Then, the output level of the GPIO interface is sampled at the rising edge of the next clock cycle. Based on the sampled output level of the GPIO interface and state A, and according to the state machine switching rules shown in Figure 4, the TAP controller's state machine is controlled to jump to the corresponding state.
[0068] For example, in one SPI clock cycle T1, the TAP controller's state machine is in the Test-Logic-Reset state. During this SPI clock cycle, the electronics containing the GPIO interface input tms_level = 0, and the electronics configure the GPIO interface's output level to 0. The GPIO interface's output level is sampled at the rising edge of the next SPI clock cycle T2. The sampled GPIO interface output level is 0. As can be seen from the state machine switching rules shown in Figure 4, the TAP controller's state machine switches from the Test-Logic-Reset state to the Run-Test / Idle state within the SPI clock cycle T2.
[0069] In one embodiment, the simulated JTAG data transmission rules include: obtaining the number of clock cycles of the current TAP controller state; if the number of clock cycles of the current TAP controller state is equal to 1, then controlling the SPI interface to transmit data of the current TAP controller state with the chip under test in single-cycle data transmission mode; if the number of clock cycles of the current TAP controller state is greater than 1, then controlling the SPI interface to transmit data of the current TAP controller state with the chip under test in multi-cycle data transmission mode.
[0070] Specifically, as shown in Figures 5 and 6, the clock cycle count (tck_count) for the Test-Logic-Reset, Run-Test / Idle, Select-DR-Scan, Capture-DR, Exit1-DR, Pause-DR, Exit2-DR, Update-DR, Select-IR-Scan, Capture-IR, Shift-IR, Exit1-IR, Exit1-IR, Pause-IR, and Exit2-IR states is 1. The TDI and TDO data for these states are all empty. In Shift-DR or Shift-IR states, data or instructions are transmitted via continuous TCK cycles of shifting. For example, in ARM debugging, 3 ACK bits (ACK[2:0]) need to be shifted before transmission to provide feedback on the operation status (e.g., ACK_OK = 000 indicates success, ACK_FAIL = 010 indicates error). The maximum number of shift bits depends on the target device design and is theoretically unlimited. For example, reading the status register may only require 32 bits; reading memory content may require thousands or even tens of thousands of bits. For data exceeding 32 bits, segmented transmission can be implemented. The number of clock cycles in both Shift-DR and Shift-IR states is greater than 1. The number of clock cycles in either Shift-DR or Shift-IR state is determined by the number of bits in the test instruction input in the Shift-DR or Shift-IR state.
[0071] In one embodiment, controlling the SPI interface to transmit data with the chip under test in the current TAP controller state in single-cycle data transmission mode specifically includes: setting the read / write mode of the SPI interface to half-duplex write-only mode and setting the data width of the SPI interface to a preset single-cycle transmission data width; and in the current TAP controller state, controlling the SPI interface to send data for one SPI clock cycle to the chip under test.
[0072] Specifically, as shown in Figure 7, if the current TAP controller state's clock cycle count is equal to 1, it means the current TAP controller state is maintained for one SPI clock cycle. Therefore, the SPI interface's read / write mode is set to half-duplex write-only mode. In half-duplex write-only mode, the SPI interface only sends data to the chip under test. The single-cycle data transmission width is typically set to 1 bit. Under the current TAP controller state, the test device controls the SPI interface to send one SPI clock cycle's worth of data to the chip under test.
[0073] In one embodiment, before controlling the SPI interface to transmit data with the chip under test (TAP) in multi-cycle data transmission mode according to the current TAP controller state, the data width of the SPI interface is configured to a preset multi-cycle transmission data width. It should be noted that the data width of the SPI interface is adjustable between 1 and 32 bits, and the multi-cycle transmission data width can be set to 4 bits, 8 bits, 16 bits, 32 bits, etc., and this embodiment does not limit this. Furthermore, by dynamically configuring the SPI bit width, the specific bit width requirements of different stages of the JTAG protocol can be matched, reducing unnecessary clock cycles compared to a fixed bit width scheme. A hybrid mode of 32-bit block transmission + remaining bit processing can be implemented, enabling optimal performance for transmission of any number of bits.
[0074] In one embodiment, controlling the SPI interface to transmit data of the current TAP controller state with the chip under test in a multi-cycle data transmission mode specifically includes: setting the read / write mode of the SPI interface according to the TDO data of the current TAP controller state; when the SPI interface is set to half-duplex write-only mode, controlling the SPI interface to send the TDI data of the current TAP controller state to the chip under test in segments; when the SPI interface is set to full-duplex read / write mode, controlling the SPI interface to send the TDI data of the current TAP controller state to the chip under test in segments and receive the TDO data of the current TAP controller state in segments from the chip under test.
[0075] Specifically, if the number of clock cycles for the current TAP controller state is greater than 1, it indicates that the current TAP controller state is generally Shift-DR or Shift-IR. In this case, the data width of the SPI interface is set to the pre-defined multi-cycle transmission data width. In Shift-DR or Shift-IR states, TDI data is always present, while TDO data may or may not be present. When TDO data is absent, the SPI interface's read / write mode is configured to half-duplex write-only mode, controlling the SPI interface to send TDI data only to the chip under test. When TDO data is present, the SPI interface's read / write mode is configured to full-duplex read / write mode, controlling the SPI interface to send TDI data to the chip under test and to receive TDO data from the chip under test.
[0076] In one embodiment, when the SPI interface is configured in half-duplex write-only mode, controlling the SPI interface to send TDI data of the current TAP controller state to the chip under test in segments includes: determining the integer and remainder of the segmented transmission based on the number of clock cycles of the current TAP controller state and the multi-cycle transmission data width; controlling the SPI interface to send TDI data to the chip under test a corresponding integer number of segmented transmissions according to the multi-cycle transmission data width; and then reconfiguring the data width of the SPI interface according to the remainder of the segmented transmissions, so that the SPI interface sends the remaining TDI data according to the data width of the remainder of the corresponding segmented transmissions.
[0077] For example, in Shift-DR mode, the clock cycle count is 132, and the SPI interface needs to send 132 bits of TDI data to the chip under test. The multi-cycle data width is 8 bits. The integer value for segmented transmission is calculated to be 132 divided by 8, which equals 16. The remainder for segmented transmission is calculated to be 132 divided by 8, which equals 4. First, the SPI interface sends 16 8-bit data signals to the chip under test. After these 16 signals are sent, the SPI interface's data width is configured to 4, and then one 4-bit data signal is sent to the chip under test.
[0078] In one embodiment, when the SPI interface is configured in full-duplex read / write mode, the process of sending TDI data of the current TAP controller state to the chip under test (DUT) in segments and receiving TDO data of the current TAP controller state in segments from the DUT specifically includes: determining the integer and remainder of the segmented transmission based on the number of clock cycles of the current TAP controller state and the width of the multi-cycle transmission data; controlling the SPI interface to send TDI data of the corresponding integer number of segmented transmissions to the DUT according to the width of the multi-cycle transmission data and simultaneously receiving TDO data of the corresponding integer number of segmented transmissions from the DUT; and then reconfiguring the data width of the SPI interface according to the remainder of the segmented transmission, so that the SPI interface sends the remaining TDI data and receives the remaining TDO data according to the data width of the remainder of the corresponding segmented transmission.
[0079] Specifically, as shown in Figure 7, after calculating the integer and remainder of the segmented transmission, the SPI interface first sends a TDI data corresponding to the multi-cycle transmission data width bits to the chip under test (DUT), and simultaneously receives a TDO data corresponding to the multi-cycle transmission data width bits from the DUT. After this data transmission and reception is completed, the integer of the segmented transmission is decremented by 1. This data transmission and reception process is then repeated until the integer of the segmented transmission equals 0. The data width of the SPI interface is then reconfigured to the remainder of the segmented transmission, and finally, a TDI data corresponding to the remainder bits of the segmented transmission is sent, and simultaneously, a TDO data corresponding to the remainder bits of the segmented transmission is received from the DUT.
[0080] For example, in Shift-DR mode, the clock cycle count is 41. The SPI interface needs to send 41 bits of TDI data and 41 bits of TDO data to the chip under test (DUT). The multi-cycle data width is 8 bits. The integer value for segmented transmission is calculated as 41 divided by 8, which equals 5. The remainder for segmented transmission is calculated as 41 divided by 8, which equals 1. First, the SPI interface sends 5 8-bit TDI data segments to the DUT and simultaneously receives 5 8-bit TDO data segments. After all 5 8-bit TDI and 5 8-bit TDO data segments have been sent and received, the SPI interface's data width is configured to 1, and then 1 bit of data is sent to and received from the DUT.
[0081] In one embodiment, as shown in FIG7, if the integer of the segmented transmission is equal to 0, the data width of the SPI interface is directly configured to the remainder of the segmented transmission, and then TDI data corresponding to the remainder bits of the segmented transmission is sent once, and TDO data corresponding to the remainder bits of the segmented transmission is received from the chip under test once.
[0082] It should be noted that when transmitting long data, this invention directly configures the corresponding bit width and automatically generates a continuous clock using the SPI interface, which improves the speed by 32 times compared to bit-by-bit operation.
[0083] This transmission achieves efficient physical layer conversion of the JTAG protocol through intelligent collaboration between the SPI hardware peripheral and GPIO. Compared to existing GPIO emulation solutions, the SPI hardware controller directly drives TCK clock generation and TDI / TDO data streams. Utilizing its built-in FIFO buffer and automatic clock control mechanism, it achieves over 30 times speedup in continuous 32-bit data transmission while significantly reducing CPU load. This hardware acceleration feature is particularly suitable for long instruction chain operation scenarios. Combined with precise GPIO control of TMS state switching, it achieves zero-wait state transmission at higher frequencies and stable clock rates while maintaining protocol timing accuracy.
[0084] This hybrid architecture significantly improves signal integrity metrics, and the regularized clock edges generated by the SPI hardware enhance setup / hold time margins.
[0085] Similar to the above embodiments, this application also provides a JTAG interface that uses a hybrid SPI and GPIO simulation to connect to a chip under test (DUT), including: an SPI interface and a GPIO interface; wherein, the clock pin of the SPI interface serves as a test clock pin, the MOSI pin of the SPI interface serves as a test data input signal pin, the MISO pin of the SPI interface serves as a test data output signal pin, and the GPIO pin serves as a test mode selection pin; the SPI interface operates in host mode and a first communication mode; based on the simulated JTAG data transmission rules, transmission control and status control are performed on the simulated JTAG interface to test the DUT.
[0086] It should be understood that the specific implementation of the JTAG interface simulated in this embodiment has been described in the above method embodiments, and will not be repeated here.
[0087] In one specific embodiment, as shown in Figure 2, the SPI interface and the GPIO interface can be located on the same electronic device. Alternatively, as shown in Figure 3, the SPI interface and the GPIO interface are located on two separate electronic devices. The types of electronic devices include, but are not limited to: a central processing unit (CPU), a microcontroller unit (MCU) (also known as a single-chip microcomputer), a digital signal processor (DSP), and a field-programmable gate array (FPGA), etc. Alternatively, the SPI interface and the GPIO interface may be located on the chip under test.
[0088] Similar to the above embodiments, this application also provides a test device for testing the chip under test through a JTAG interface that is a hybrid simulation of SPI and GPIO as described above.
[0089] It should be understood that the specific implementation of the JTAG interface emulated by the hybrid SPI and GPIO of this embodiment has been described in the above embodiments and will not be repeated here.
[0090] In one specific embodiment, the JTAG interface, which is a hybrid simulation of SPI and GPIO, can be located on the test equipment or on the chip under test.
[0091] As used in this specification, the terms "component," "module," "system," etc., are used to refer to computer-related entities, hardware, firmware, combinations of hardware and software, software, or software in execution. For example, a component can be, but is not limited to, a process running on a processor, a processor, an object, an executable file, an execution thread, a program, and / or a computer. As illustrated, applications running on computing devices and computing devices can both be components. One or more components may reside in a process and / or an execution thread, and components may be located on a single computer and / or distributed among two or more computers. Furthermore, these components can be executed from various computer-readable media on which various data structures are stored. Components can communicate, for example, via local and / or remote processes based on signals having one or more data packets (e.g., data from two components interacting with another component between a local system, a distributed system, and / or a network, such as the Internet interacting with other systems via signals).
[0092] Those skilled in the art will recognize that the various illustrative logical blocks and steps described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this application.
[0093] Those skilled in the art will understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0094] In the several embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.
[0095] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0096] In addition, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0097] In the above embodiments, the functions of each functional unit can be implemented entirely or partially through software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented entirely or partially in the form of a computer program product. A computer program product includes one or more computer instructions (programs). When the computer program instructions (programs) are loaded and executed on a computer, all or part of the flow or function according to the embodiments of this application is generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. Computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available media can be magnetic media (e.g., floppy disks, hard disks, magnetic tapes), optical media (e.g., high-density digital video discs, DVDs), or semiconductor media (e.g., solid-state disks, SSDs, etc.).
[0098] If a function is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0099] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
[0100] In summary, this application provides a method for simulating a JTAG interface using a hybrid SPI and GPIO interface, a simulated JTAG interface, and a testing device. The method includes: selecting an SPI interface and a GPIO interface for simulation, and operating the SPI interface in host mode and a first communication mode; using the clock pin of the SPI interface as a test clock pin, the MOSI pin of the SPI interface as a test data input signal pin, and the MISO pin of the SPI interface as a test data output signal pin, and using the GPIO interface as a test mode selection pin, to obtain the simulated JTAG interface; and performing transmission control and state machine control on the simulated JTAG interface based on the simulated JTAG data transmission rules to test the chip under test. This application achieves JTAG interface simulation through SPI and GPIO interfaces, improving the transmission rate and reducing CPU utilization. Therefore, this application effectively overcomes various shortcomings in the prior art and has high industrial applicability.
[0101] The above embodiments are merely illustrative of the principles and effects of this application and are not intended to limit this application. Any person skilled in the art can modify or alter the above embodiments without departing from the spirit and scope of this application. Therefore, all equivalent modifications or alterations made by those skilled in the art without departing from the spirit and technical concept disclosed in this application should still be covered by the claims of this application.
Claims
1. A method of hybrid analog JTAG interface of SPI and GPIO, characterized in that, include: Select the SPI interface and GPIO interface for simulation, and make the SPI interface work in host mode and first communication mode; By using the clock pin of the SPI interface as the test clock pin, the MOSI pin of the SPI interface as the test data input signal pin, the MISO pin of the SPI interface as the test data output signal pin, and the GPIO interface as the test mode selection pin, a simulated JTAG interface is obtained. Based on simulated JTAG data transmission rules, transmission control and status control are performed on the simulated JTAG interface to test the chip under test.
2. The method of claim 1, wherein, The specific implementation of state machine control for the simulated JTAG interface includes controlling the output level of the GPIO interface to control the TAP controller of the chip under test to perform state transitions.
3. The method of claim 2, wherein, The simulated JTAG data transmission rules include: Get the number of clock cycles for the current TAP controller status; If the number of clock cycles in the current TAP controller state is equal to 1, then the SPI interface is controlled to transmit the current TAP controller state data with the chip under test in single-cycle data transmission mode. If the number of clock cycles in the current TAP controller state is greater than 1, then the SPI interface is controlled to transmit the current TAP controller state data with the chip under test in multi-cycle data transmission mode.
4. The method of claim 3, wherein, Controlling the SPI interface to transmit the current TAP controller state data with the chip under test in single-cycle data transmission mode specifically includes: Set the read / write mode of the SPI interface to half-duplex write-only mode and set the data width of the SPI interface to a preset single-cycle transmission data width; under the current TAP controller state, control the SPI interface to send one SPI clock cycle of data to the chip under test.
5. The method of claim 3, wherein, Controlling the SPI interface to transmit the current TAP controller state data with the chip under test in multi-cycle data transmission mode specifically includes: Based on the TDO data of the current TAP controller status, set the read / write mode of the SPI interface; When the SPI interface is set to half-duplex write-only mode, the SPI interface is controlled to send the TDI data of the current TAP controller status to the chip under test in segments. When the SPI interface is set to full-duplex read / write mode, the SPI interface is controlled to send TDI data of the current TAP controller state to the chip under test in segments and receive TDO data of the current TAP controller state from the chip under test in segments.
6. The method of claim 5, wherein, Before controlling the SPI interface to transmit data with the chip under test in the current TAP controller state in the multi-cycle data transmission mode, the data width of the SPI interface is configured to a preset multi-cycle transmission data width.
7. The method of claim 6, wherein, When the SPI interface is configured in half-duplex write-only mode, the SPI interface is controlled to send TDI data of the current TAP controller state to the chip under test in segments, specifically including: Based on the number of clock cycles in the current TAP controller state and the width of the multi-cycle transmission data, determine the integer and remainder for segmented transmission; The SPI interface is controlled to send TDI data to the chip under test an integer number of times corresponding to the multi-cycle transmission data width. Then, the data width of the SPI interface is reconfigured according to the remainder of the segmented transmission, so that the SPI interface sends the remaining TDI data according to the data width of the remainder of the corresponding segmented transmission.
8. The method of claim 6, wherein, When the SPI interface is set to full-duplex read / write mode, the SPI interface is controlled to send TDI data of the current TAP controller state to the chip under test segment and receive TDO data of the current TAP controller state from the chip under test segment, specifically including: The integer and remainder of the segmented transmission are determined based on the number of clock cycles in the current TAP controller state and the width of the multi-cycle transmission data. The SPI interface is controlled to send TDI data of an integer number of segments to the chip under test according to the multi-cycle transmission data width, and at the same time receive TDO data of an integer number of segments from the chip under test. Then, the data width of the SPI interface is reconfigured according to the remainder of the segmented transmission, so that the SPI interface sends the remaining TDI data and receives the remaining TDO data according to the data width of the remainder of the corresponding segmented transmission.
9. A JTAG interface with mixed analog SPI and GPIO, characterized in that, The device connects to the chip under test (DUT), including an SPI interface and a GPIO interface. The clock pin of the SPI interface serves as the test clock pin, the MOSI pin as the test data input signal pin, the MISO pin as the test data output signal pin, and the GPIO pin as the test mode selection pin. The SPI interface operates in host mode and a first communication mode. Based on simulated JTAG data transmission rules, transmission control and status control are performed on the simulated JTAG interface to test the DUT.
10. A test apparatus, characterized by, The test equipment performs tests on the chip under test through the JTAG interface that is a hybrid simulation of SPI and GPIO as described in claim 9.
