[go: up one dir, main page]

CN1912849A - Chip dynamic tracing method of microprocessor - Google Patents

Chip dynamic tracing method of microprocessor Download PDF

Info

Publication number
CN1912849A
CN1912849A CN 200610030754 CN200610030754A CN1912849A CN 1912849 A CN1912849 A CN 1912849A CN 200610030754 CN200610030754 CN 200610030754 CN 200610030754 A CN200610030754 A CN 200610030754A CN 1912849 A CN1912849 A CN 1912849A
Authority
CN
China
Prior art keywords
register
dynamic tracking
observation point
address
signal
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN 200610030754
Other languages
Chinese (zh)
Other versions
CN100401267C (en
Inventor
胡越黎
熊兵
孙斌
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
University of Shanghai for Science and Technology
Original Assignee
University of Shanghai for Science and Technology
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by University of Shanghai for Science and Technology filed Critical University of Shanghai for Science and Technology
Priority to CNB2006100307547A priority Critical patent/CN100401267C/en
Publication of CN1912849A publication Critical patent/CN1912849A/en
Application granted granted Critical
Publication of CN100401267C publication Critical patent/CN100401267C/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Debugging And Monitoring (AREA)

Abstract

本发明涉及一种微处理器的片上动态跟踪方法。本方法通过一个集成在处理器内部的片上动态跟踪模块(On-Chip Tracer:OCT),将程序执行过程中的某些位置设置为观察点,然后对这些观察点处指定的内部寄存器的信息进行跟踪、记录和实时的输出。本发明的方法可应用于8051系列微处理器领域,亦可应用于其他微处理器领域。

The invention relates to an on-chip dynamic tracking method of a microprocessor. This method uses an on-chip dynamic tracking module (On-Chip Tracer: OCT) integrated in the processor to set certain positions in the program execution process as observation points, and then perform information on the internal registers specified at these observation points. Tracking, logging and real-time output. The method of the invention can be applied to the field of 8051 series microprocessors, and can also be applied to the fields of other microprocessors.

Description

微处理器的片上动态跟踪方法On-chip Dynamic Tracking Method of Microprocessor

技术领域technical field

本发明涉及一种微处理器的片上动态跟踪方法,可应用于8051系列的单片微处理器,也可应用于其他微处理器、微处理器领域。The invention relates to an on-chip dynamic tracking method of a microprocessor, which can be applied to 8051 series single-chip microprocessors, and can also be applied to other microprocessors and microprocessor fields.

背景技术Background technique

动态跟踪(Dynamic Trace)是指实时地记录程序运行的轨迹信息,并把这些信息通过某种手段传送到外部的调试工具进行分析和调试的过程。在以微处理器为核心的嵌入式系统的调试开发过程中,为了方便捕捉高速信号以及对处理器进行调试,比如根据程序执行历史进行查错、恢复、修改等,需要记录处理器高速运行时的轨迹。因此,在大多数的逻辑分析仪和在线仿真器等设备中,都有用于动态跟踪处理器运行轨迹的跟踪部件,用来监测处理器的各种内部信息,这样调试者就可以方便地检测程序执行流程、查找程序错误、重构程序运行轨迹等。不过,在实现动态跟踪的通常做法中,都需要一个较大容量的存储器来暂存各种被跟踪的处理器内部信息。因此,对于片上动态跟踪来说,在处理器内部集成一个用于动态跟踪的存储器会增大设计的难度以及生产成本等。Dynamic Trace (Dynamic Trace) refers to the process of recording the trajectory information of program operation in real time, and transmitting this information to an external debugging tool for analysis and debugging by some means. In the debugging and development process of embedded systems with microprocessors as the core, in order to facilitate the capture of high-speed signals and debug the processor, such as checking, recovering, and modifying according to the program execution history, it is necessary to record the high-speed running time of the processor. traces of. Therefore, in most devices such as logic analyzers and in-circuit emulators, there are tracking components used to dynamically track the running track of the processor, which are used to monitor various internal information of the processor, so that the debugger can easily detect the program. Execute the process, find program errors, reconstruct the program running track, etc. However, in the common practice of realizing dynamic tracking, a large-capacity memory is required to temporarily store various internal information of the processor being tracked. Therefore, for on-chip dynamic tracking, integrating a memory for dynamic tracking inside the processor will increase design difficulty and production cost.

发明内容Contents of the invention

本发明的目的在于提供一种微处理器的片上动态跟踪方法。通过一个集成在处理器内部的独立的片上跟踪模块(On-Chip Tracer:OCT),可以将程序执行过程中调试者关心的一些位置设置为观察点(Watchpoint),并对这些位置的信息进行跟踪、记录和实时的输出,以实现动态跟踪的目的。而且整个过程不需要专门的跟踪缓冲单元,只需少量的寄存器就能满足数据的暂存要求。The object of the present invention is to provide a dynamic tracking method on a microprocessor chip. Through an independent on-chip trace module (On-Chip Tracer: OCT) integrated inside the processor, some positions that the debugger cares about during program execution can be set as watchpoints (Watchpoint), and the information of these positions can be tracked , recording and real-time output to achieve the purpose of dynamic tracking. Moreover, the whole process does not need a special tracking buffer unit, and only a small number of registers can meet the temporary storage requirements of data.

为达到上述目的,本发明的构思如下:For achieving the above object, design of the present invention is as follows:

构建一个集成在处理器内部的片上动态跟踪模块(On-Chip Tracer:OCT),通过这个模块将程序执行过程中的某些位置标记为观察点,然后在程序执行的过程中,将每条指令的地址与这些观察点进行比较来检测观察点。如果有观察点被检测到,则CPU暂停运行,等待OCT模块将该观察点处指定的内部寄存器的信息串行输出到外部的调试工具进行分析。若数据输出完毕,则通知处理器自动恢复程序的执行。如果遇到下一个观察点,就再重复前面的跟踪、记录和输出过程。如此往复,直到程序执行完毕或者调试者暂停或终止本次的动态跟踪过程。Construct an on-chip dynamic tracking module (On-Chip Tracer: OCT) integrated in the processor, through this module, certain positions in the program execution process are marked as observation points, and then during the program execution, each instruction The address of the watchpoint is compared with these watchpoints to detect watchpoints. If an observation point is detected, the CPU suspends the operation and waits for the OCT module to serially output the information of the internal register specified at the observation point to an external debugging tool for analysis. If the data output is complete, the processor is notified to resume the execution of the program automatically. If the next observation point is encountered, the previous tracking, recording and output process is repeated. This goes on and on until the execution of the program is completed or the debugger suspends or terminates the current dynamic tracking process.

根据上述构思,本发明采用下述技术方案:According to above-mentioned design, the present invention adopts following technical scheme:

一种微处理器的片上动态跟踪方法,其特征在于通过一个片上动态跟踪模块(OCT),将程序执行过程中的某些位置设置为观察点(Watchpoint),然后对这些观察点处指定的内部寄存器的信息进行跟踪、记录和实时的输出;其具体步骤为:A kind of on-chip dynamic tracking method of microprocessor is characterized in that by an on-chip dynamic tracking module (OCT), some positions in the program execution process are set as watchpoints (Watchpoint), and then the specified internal Register information is tracked, recorded and output in real time; the specific steps are:

a.设置一个异步的串行收发子模块,以实现OCT模块与处理器外部的通信;a. Set an asynchronous serial transceiver sub-module to realize the communication between the OCT module and the outside of the processor;

b.设定一个调试命令寄存器DBGCMD,来存储调试者向OCT模块所发出的动态跟踪调试命令;b. Set a debug command register DBGCMD to store the dynamic tracking debug command sent by the debugger to the OCT module;

c.设定n个观察点地址寄存器WPi(i=0~n-1),来存储被调试者设置为观察点的程序的首地址;c. setting n observation point address registers WPi (i=0~n-1), to store the head address of the program that the debugged is set as the observation point;

d.设定一个内部寄存器选择信号寄存器SFR_SEL,来存储在每个观察点处被跟踪和记录的内部寄存器的选择信号;d. Set an internal register selection signal register SFR_SEL to store the selection signal of the internal register tracked and recorded at each observation point;

e.设定一个当前指令首地址寄存器PCC,来自动存储CPU当前正在执行的指令的首地址;e. Set a current instruction first address register PCC to automatically store the first address of the instruction currently being executed by the CPU;

f.通过“启动动态跟踪命令”来启动动态跟踪过程,然后在动态跟踪的过程中,OCT模块根据情况进行动态跟踪操作,并设定相关信号。f. Start the dynamic tracking process through the "start dynamic tracking command", and then during the dynamic tracking process, the OCT module performs dynamic tracking operations according to the situation and sets related signals.

上述设置一个异步串行收发子模块的方法为:The above method of setting an asynchronous serial transceiver sub-module is as follows:

该串行收发子模块采用半双工的异步串行通信模式,通过1根信号线与处理器外部进行串行通信,而且发送和接收是两个独立的过程。接收部分的主要目的是接收调试工具发出的各种调试命令,以及与各个命令有关的数据和程序地址,而发送的目的则是将每个观察点处被选择出的内部寄存器的内容串行输出。同时,接收和发送过程都采用了1位停止位(1电平)+有效数据位+1位起始位(0电平)的数据帧格式(分别见图2(a)和图3)。The serial transceiver sub-module adopts a half-duplex asynchronous serial communication mode, and performs serial communication with the outside of the processor through a signal line, and sending and receiving are two independent processes. The main purpose of the receiving part is to receive various debugging commands issued by the debugging tool, as well as the data and program addresses related to each command, and the purpose of sending is to serially output the contents of the selected internal registers at each observation point . At the same time, the data frame format of 1 stop bit (1 level) + valid data bit + 1 start bit (0 level) is adopted in both receiving and sending processes (see Figure 2(a) and Figure 3 respectively).

与串行通信相关的一些信号和寄存器的定义如下(见图4):Some signals and registers related to serial communication are defined as follows (see Figure 4):

a.NEA:异步串行收发子模块与处理器外部进行通信的外部引脚,在OCT模块内部则分为NEA_I(串行数据输入端)和NEA_O(串行数据输出端);a.NEA: The external pin of the asynchronous serial transceiver sub-module communicates with the outside of the processor. Inside the OCT module, it is divided into NEA_I (serial data input terminal) and NEA_O (serial data output terminal);

b.RX_CLK/TX_CLK:分别是异步串行收发子模块接收和发送串行数据时的采样时钟,频率都是处理器时钟频率的1/100;b. RX_CLK/TX_CLK: They are the sampling clocks when the asynchronous serial transceiver sub-module receives and sends serial data, and the frequency is 1/100 of the processor clock frequency;

c.RX_SHIFT/TX_SHIFT:分别是异步串行收发子模块接收和发送数据时的串行移位脉冲,频率都是RX_CLK/TX_CLK的1/8,因此,通信的波特率为处理器工作速度的1/800;c. RX_SHIFT/TX_SHIFT: They are the serial shift pulses when the asynchronous serial transceiver sub-module receives and sends data respectively, and the frequency is 1/8 of RX_CLK/TX_CLK. Therefore, the baud rate of communication is the speed of the processor 1/800;

d.RX_SHIFTER:接收移位寄存器,接收的是各个调试命令以及相关的数据和地址,数据格式见图2;d. RX_SHIFTER: Receive shift register, which receives various debugging commands and related data and addresses. The data format is shown in Figure 2;

e.TX_SHIFTER_1:发送移位寄存器,发送的是在每个观察点处内部寄存器的数据和该观察点的地址,数据格式见图3。e.TX_SHIFTER_1: Transmit shift register, which transmits the data of the internal register at each observation point and the address of the observation point. The data format is shown in Figure 3.

上述的设定一个调试命令寄存器DBGCMD的方法为:The above method of setting a debug command register DBGCMD is as follows:

定义DBGCMD为一个4位的寄存器,它被用来存储调试工具所发出的调试命令的二进制编码,并将接收到的调试命令译码为相应的控制信号。Define DBGCMD as a 4-bit register, which is used to store the binary code of the debugging command issued by the debugging tool, and decode the received debugging command into a corresponding control signal.

DBGCMD可以存储8个与动态跟踪相关的命令,见表1。其中,DBGCMD中没有用到的其他二进制编码暂时保留,可以在以后进行扩展。DBGCMD can store 8 commands related to dynamic tracking, see Table 1. Among them, other binary codes not used in DBGCMD are temporarily reserved and can be expanded in the future.

                 表1 DBGCMD存储的动态跟踪命令   二进制编码   命令符号   功能描述   0000   DBG_RST   在调试状态下对整个微处理器系统进行复位   1010   WP_SET   将程序中的某条指令设置为一个观察点   1011   WP_REMOVE   移除一个指定的观察点   1100   WP_CLR   一次性清除所有的观察点   0011   SFR_SET   设定在每个观察点处需要被跟踪和记录的内部寄存器   1101   D_DBG   启动动态跟踪过程   1110   D_DBG_PAUSE   暂停动态跟踪过程   1111   D_DBG_Stop   停止动态跟踪过程 Table 1 Dynamic tracking commands stored in DBGCMD binary code command symbol Functional description 0000 DBG_RST Reset the entire microprocessor system in debug state 1010 WP_SET Set an instruction in the program as a watchpoint 1011 WP_REMOVE remove a specified watchpoint 1100 WP_CLR Clear all watchpoints at once 0011 SFR_SET Set the internal registers that need to be tracked and logged at each watchpoint 1101 D_DBG Start dynamic tracking process 1110 D_DBG_PAUSE Pause dynamic tracking process 1111 D_DBG_Stop Stop dynamic tracking process

上述的设定n个观察点地址寄存器WPi(i=0~n-1)的方法为:The above method of setting n observation point address registers WPi (i=0~n-1) is as follows:

定义WPi(i=0~n-1)为n个16位的寄存器,存储的是被设定为观察点的指令的首地址。系统复位后,这n个观察点地址寄存器的值都为高阻值。Define WPi (i=0˜n−1) as n 16-bit registers, which store the first address of the instruction set as the observation point. After the system is reset, the values of the n observation point address registers are all high resistance values.

OCT模块根据以下三种情况来设置或者清除观察点:The OCT module sets or clears watchpoints according to the following three situations:

a)若接收到WP_SET命令,OCT模块就将与该命令一起接收到的16位地址作为一个观察点的地址存储在一个WPi寄存器中(存储的顺序是从WP0开始,最后到WPn-1)。如果调试者设置的观察点超过n个,则第n+1个观察点的地址就覆盖掉第1个观察点,第n+2个观察点覆盖掉第2个,依次类推。a) If the WP_SET command is received, the OCT module will store the 16-bit address received together with the command as the address of an observation point in a WPi register (the order of storage starts from WP0 and ends at WPn-1). If the debugger sets more than n watch points, the address of the n+1 watch point will cover the first watch point, the n+2 watch point will cover the second watch point, and so on.

b)若接收到WP_REMOVE命令,OCT模块就会将此时接收到的16位地址与先前设定为观察点的地址相比较,然后将与该地址匹配的观察点移除。b) If the WP_REMOVE command is received, the OCT module will compare the 16-bit address received at this time with the address previously set as the observation point, and then remove the observation point that matches the address.

c)若接收到WP_CLR命令,OCT模块就将所有的观察点一次性全部清除,被清除后的观察点寄存器的数据都为高阻值。c) If the WP_CLR command is received, the OCT module will clear all the observation points at one time, and the data in the observation point registers after being cleared are all high resistance values.

上述的设定一个内部寄存器选择信号寄存器SFR_SEL的方法为:The method of setting an internal register selection signal register SFR_SEL above is:

定义SFR_SEL为一个n位的寄存器,它的每一位按序对应n个常用的内部寄存器,它的定义如下:  内部寄存器n选择信号   ……  内部寄存器2选择信号  内部寄存器1选择信号 Define SFR_SEL as an n-bit register, each of which corresponds to n commonly used internal registers in sequence, and its definition is as follows: Internal register n select signal ... Internal register 2 select signal Internal register 1 select signal

当接收到选择内部寄存器命令SFR_SET的时候,OCT模块就将此时与SFR_SET命令一起接收到的n位寄存器选择信号(见图2(d))存储在SFR_SEL中。此时如果SFR_SEL的某一位为1,则这一位所对应的内部寄存器就要被跟踪,同时该内部寄存器的内容在每个观察点处都要被输出。反之,如果这一位为0,那么对应的这个内部寄存器就不需要被跟踪和记录。When the internal register selection command SFR_SET is received, the OCT module stores the n-bit register selection signal (see Figure 2(d)) received together with the SFR_SET command in SFR_SEL. At this time, if a certain bit of SFR_SEL is 1, the internal register corresponding to this bit will be tracked, and the content of the internal register will be output at each observation point. Conversely, if this bit is 0, then the corresponding internal register does not need to be tracked and recorded.

上述的设定一个当前指令首地址寄存器PCC的方法为:The above method of setting a current instruction first address register PCC is as follows:

定义PCC为1个16位的地址寄存器,存储的是当前正在执行的指令的16位首地址。它的值由OCT模块自动设定。系统复位后,PCC的值为00h。Define PCC as a 16-bit address register, which stores the 16-bit first address of the instruction currently being executed. Its value is automatically set by the OCT module. After system reset, the value of PCC is 00h.

设定PCC寄存器的具体方法是:在程序执行的过程中,在每条指令的第1个时钟周期,把指向该条指令的程序指针的值送到PCC寄存器中。PCC会一直保存这个地址,直到下一条指令的第1个时钟周期到来的时候,就更新为新的地址。The specific method of setting the PCC register is: in the process of program execution, in the first clock cycle of each instruction, send the value of the program pointer pointing to the instruction to the PCC register. PCC will keep this address until the first clock cycle of the next instruction arrives, and it will be updated to a new address.

上述在动态跟踪的过程中根据情况进行动态跟踪操作有如下三种:There are three types of dynamic tracking operations according to the situation in the above dynamic tracking process:

a.如果动态跟踪过程启动后,OCT模块没有接收到其他控制命令,则OCT模块就会在程序执行的过程中自动比较WPi(i=0~n-1)和PCC的内容来进行观察点的检测。如果检测到观察点,OCT模块就把该观察点处被选中的内部寄存器的信息串行输出到外部的调试工具进行分析。a. If the OCT module does not receive other control commands after the dynamic tracking process is started, the OCT module will automatically compare the contents of WPi (i=0~n-1) and PCC to carry out the observation point during the program execution process detection. If an observation point is detected, the OCT module serially outputs the information of the selected internal register at the observation point to an external debugging tool for analysis.

检测观察点并输出内部寄存器信息的具体步骤为:The specific steps to detect the observation point and output the internal register information are as follows:

a)WP_MATCH:观察点匹配信号,高电平有效;a) WP_MATCH: observation point matching signal, active high;

WP_STOP:观察点匹配停止信号;WP_STOP: watch point match stop signal;

检测观察点的方法见图7。在程序执行的过程中,在每条指令的第3个时钟周期,将n个观察点地址寄存器WPi(i=0~n-1)的内容分别与当前指令首地址寄存器PCC进行比较。只要有一个观察点地址寄存器的内容与PCC的内容完全匹配,就说明检测到了一个观察点,于是WP_MATCH信号立即有效。在执行完该观察点处的指令后,CPU还需要再执行一条空操作指令NOP以保证指令执行过程的完整性。然后,在该NOP指令的第2个时钟周期,WP_STOP信号有效,同时,OCT模块将所有被选择出的内部寄存器的值都存储在对应的暂存寄存器中,而与那些没有被选中的内部寄存器所对应的暂存寄存器的内容则都为0。在紧接着WP_STOP信号有效之后的下一个时钟周期,OCT模块进入串行发送的准备阶段。See Figure 7 for the method of detecting observation points. During program execution, at the third clock cycle of each instruction, the contents of n observation point address registers WPi (i=0~n-1) are compared with the current instruction first address register PCC respectively. As long as the content of a watchpoint address register exactly matches the content of the PCC, it means that a watchpoint has been detected, so the WP_MATCH signal is immediately valid. After executing the instruction at the observation point, the CPU needs to execute another no-operation instruction NOP to ensure the integrity of the instruction execution process. Then, in the second clock cycle of the NOP instruction, the WP_STOP signal is valid, and at the same time, the OCT module stores the values of all selected internal registers in the corresponding temporary registers, and those internal registers that are not selected The contents of the corresponding scratch registers are all 0. In the next clock cycle immediately after the WP_STOP signal is valid, the OCT module enters the preparation stage for serial transmission.

b)TX_SFR_DATA:存储n个内部寄存器数据和当前观察点首地址的寄存器;b) TX_SFR_DATA: a register that stores n internal register data and the first address of the current observation point;

TX_SHIFTER_1:发送移位寄存器;TX_SHIFTER_1: transmit shift register;

TX_BEGIN:发送开始信号;TX_BEGIN: send start signal;

CPU_STOP:停止CPU工作时钟的信号。CPU_STOP: The signal to stop the CPU working clock.

在串行发送的准备阶段,即NOP指令的第3个时钟周期,TX_BEGIN信号有效,串行收发子模块将n个暂存寄存器的内容和当前观察点的首地址都按序存放在寄存器TX_SFR_DATA中。然后,又将TX_SFR_DATA与1位起始位和1位停止位按序存放在发送移位寄存器TX_SHIFTER_1中。从NOP指令的第4个时钟周期开始,OCT模块进入串行发送的输出阶段,见图7。同时,CPU_STOP信号有效,CPU停止运行。In the preparation stage of serial transmission, that is, the third clock cycle of the NOP instruction, the TX_BEGIN signal is valid, and the serial transceiver sub-module stores the contents of the n temporary registers and the first address of the current observation point in the register TX_SFR_DATA in sequence . Then, store TX_SFR_DATA, 1 start bit and 1 stop bit in sequence in the transmit shift register TX_SHIFTER_1. Starting from the fourth clock cycle of the NOP instruction, the OCT module enters the output stage of serial transmission, as shown in Figure 7. At the same time, the CPU_STOP signal is valid, and the CPU stops running.

c)TX_END:串行输出的结束信号。c) TX_END: The end signal of the serial output.

在串行发送的输出阶段,串行收发子模块将TX_SHIFTER_1的内容串行送出,且输出的时候低位在前,左端不断补0。当停止位到达TX_SHIFTER_1的最右端时,停止位左端的全零信号被一个“全零检测器”检测到,于是TX_END信号立即有效,OCT模块便停止串行发送过程。见图4。In the output stage of serial transmission, the serial transceiver sub-module sends the content of TX_SHIFTER_1 serially, and when outputting, the low bit is in front, and the left end is continuously filled with 0. When the stop bit reaches the rightmost end of TX_SHIFTER_1, the all zero signal at the left end of the stop bit is detected by an "all zero detector", so the TX_END signal is immediately valid, and the OCT module stops the serial transmission process. See Figure 4.

b.如果动态跟踪过程启动后,在动态跟踪的过程中,OCT模块接收到暂停动态跟踪的命令D_DBG_PAUSE,则在当前指令的最后一个时钟周期,CPU_STOP信号有效,CPU停止运行,整个系统进入动态跟踪的暂停状态。此时,调试者可以根据被检测到的观察点处的处理器内部信息来分析程序的运行情况,从而查找程序错误、重构程序流程等。b. If the dynamic tracking process starts, the OCT module receives the command D_DBG_PAUSE to suspend dynamic tracking during the dynamic tracking process, then in the last clock cycle of the current instruction, the CPU_STOP signal is valid, the CPU stops running, and the entire system enters dynamic tracking suspended state. At this time, the debugger can analyze the operation of the program according to the internal information of the processor at the detected observation point, so as to find program errors, reconstruct the program flow, and so on.

若系统当前正处于动态跟踪的暂停状态,如果调试者再次发出暂停动态跟踪的命令D_DBG_PAUSE,则系统立即退出暂停状态,并重新进入动态跟踪过程。同时CPU_STOP信号立即无效,CPU从先前暂停处的下一条指令开始重新运行。If the system is currently in the pause state of the dynamic trace, if the debugger issues the command D_DBG_PAUSE to pause the dynamic trace again, the system will immediately exit the pause state and re-enter the dynamic trace process. At the same time, the CPU_STOP signal is invalid immediately, and the CPU restarts from the next instruction at the previous pause.

c.如果动态跟踪过程启动后,在动态跟踪的过程中,OCT模块接收到停止动态跟踪的命令D_DBG_STOP,则系统立即退出动态跟踪过程,并等待调试者发出新的动态跟踪命令。c. If the dynamic tracking process starts and the OCT module receives the command D_DBG_STOP to stop the dynamic tracking during the dynamic tracking process, the system immediately exits the dynamic tracking process and waits for the debugger to issue a new dynamic tracking command.

本发明与现有技术相比较,具有以下的突出实质性特点和显著优点:通过一个片上的动态跟踪模块(OCT),可以由调试者将程序执行过程中的一些关键位置设置为观察点(Watchpoint),然后通过检测观察点来触发串行发送,将该观察点处内部寄存器的内容输出到外部的调试工具进行分析,用少量的寄存器实现对内部寄存器的跟踪和记录。本发明已在8051系列的MCU上实现了对程序运行过程的动态跟踪,亦可应用于其他微处理器和微处理器领域。Compared with the prior art, the present invention has the following prominent substantive features and remarkable advantages: through an on-chip dynamic tracking module (OCT), some key positions in the program execution process can be set as watchpoints (Watchpoints) by the debugger ), and then trigger serial transmission by detecting the observation point, output the content of the internal register at the observation point to an external debugging tool for analysis, and use a small number of registers to track and record the internal register. The invention has realized the dynamic tracking of the program running process on the 8051 series MCU, and can also be applied to other microprocessors and microprocessor fields.

附图说明:Description of drawings:

图1是动态跟踪的工作流程图。Figure 1 is a workflow diagram of dynamic tracking.

图2是串行接收时的数据帧格式示图。Figure 2 is a diagram of the data frame format during serial reception.

图3是串行发送时的数据帧格式示图。Fig. 3 is a diagram of the data frame format during serial transmission.

图4是串行通信子模块的内部结构示意图。Fig. 4 is a schematic diagram of the internal structure of the serial communication sub-module.

图5是片上跟踪模块(OCT)的内部结构示意图。FIG. 5 is a schematic diagram of the internal structure of an on-chip tracking module (OCT).

图6是SFR_SEL寄存器的每一位与24个内部寄存器的对应关系图。Figure 6 is a diagram of the correspondence between each bit of the SFR_SEL register and 24 internal registers.

图7是检测观察点的时序图。FIG. 7 is a timing chart for detecting watchpoints.

具体实施方式Detailed ways

本发明的一个优选实施例结合附图详述如下:A preferred embodiment of the present invention is described in detail as follows in conjunction with accompanying drawing:

本微处理器的片上动态跟踪方法,通过一个片上动态跟踪模块(OCT),采用下述的工作流程(见图1)来实现对处理器运行过程的动态跟踪:The on-chip dynamic tracking method of this microprocessor, through an on-chip dynamic tracking module (OCT), adopts the following workflow (see Fig. 1) to realize the dynamic tracking to the processor running process:

1)由调试者指定程序中的若干观察点。在本实例中,设定n=8,共8个观察点地址寄存器WPi(0~7),因此,调试者可以任意设置0~8个观察点。1) Several observation points in the program are specified by the debugger. In this example, n=8 is set, and there are 8 watchpoint address registers WPi (0-7) in total. Therefore, the debugger can arbitrarily set 0-8 watchpoints.

2)由调试者指定在各个观察点处需要被跟踪和记录的内部寄存器。在本实例中设定24个常用的内部寄存器可供选择,而且这24个内部寄存器的选择互相独立,调试者可以视情况选择1~24个需要被跟踪和记录的内部寄存器。2) Internal registers that need to be traced and recorded at each observation point are specified by the debugger. In this example, 24 commonly used internal registers are set for selection, and the selection of these 24 internal registers is independent of each other. The debugger can select 1 to 24 internal registers that need to be tracked and recorded according to the situation.

3)通过启动动态跟踪命令D_DBG来启动动态跟踪的过程。然后在动态跟踪的过程中,CPU正常运行,只是在每条指令的开始,都要把8个观察点寄存器与当前指令首地址寄存器PCC进行比较以检测观察点。3) Start the process of dynamic tracking by starting the dynamic tracking command D_DBG. Then in the process of dynamic tracking, the CPU runs normally, but at the beginning of each instruction, the 8 observation point registers are compared with the current instruction first address register PCC to detect the observation point.

4)在动态跟踪的过程中,如果检测到观察点,则CPU立即停止运行,并等待OCT模块将该观察点处那些被选中的内部寄存器的内容串行输出。待输出过程结束,CPU立即恢复运行。4) In the process of dynamic tracking, if an observation point is detected, the CPU stops running immediately, and waits for the OCT module to serially output the contents of those selected internal registers at the observation point. After the output process ends, the CPU resumes operation immediately.

5)在动态跟踪的过程中,如果没有检测到观察点,则CPU继续运行,OCT模块继续动态跟踪过程,直到程序执行完毕或者调试者发出动态跟踪的暂停或停止命令。5) During the dynamic tracking process, if no observation point is detected, the CPU continues to run, and the OCT module continues the dynamic tracking process until the program is executed or the debugger issues a dynamic tracking pause or stop command.

6)在动态跟踪的过程中,如果调试者发出停止动态跟踪的命令D_DBG_STOP,则整个系统立即退出动态跟踪模式,并等待调试者发出新的调试命令。6) In the process of dynamic tracking, if the debugger issues the command D_DBG_STOP to stop dynamic tracking, the entire system immediately exits the dynamic tracking mode and waits for the debugger to issue a new debugging command.

7)在动态跟踪的过程中,如果调试者发出暂停动态跟踪的命令D_DBG_PAUSE,则系统进入暂停状态,此时调试者可以根据每个观察点处内部寄存器的信息来分析程序的执行情况。若调试者再次发出暂停命令,则系统立即退出暂停状态,并回到动态跟踪过程。7) In the process of dynamic tracking, if the debugger issues the command D_DBG_PAUSE to suspend dynamic tracking, the system enters the pause state. At this time, the debugger can analyze the execution of the program according to the information of the internal registers at each observation point. If the debugger issues the suspend command again, the system will immediately exit the suspend state and return to the dynamic tracking process.

本实施例在接收和发送串行数据时,采用图2和图3所示的数据帧格式,接收和发送的数据都包括1位起始位和1位停止位,只是各自的有效数据位不同而已。同时,定义起始位为0电平,停止位为1电平。接收和发送时的有效数据位的定义分别为:In this embodiment, when receiving and sending serial data, the data frame format shown in Figure 2 and Figure 3 is adopted, and the data received and sent include 1 start bit and 1 stop bit, but the effective data bits are different That's all. At the same time, the start bit is defined as 0 level, and the stop bit is 1 level. The definitions of valid data bits when receiving and sending are respectively:

1)由于接收的有效数据是调试工具所发出的各种动态跟踪命令(定义见前述的表1),以及与各个命令相关的数据和程序地址,因此,对不同的命令来说,需要定义不同的有效数据格式,不过它们的有效数据位数都是28位(不包括2位标志位)。各个命令以及与该命令相关的有效数据位分别定义如下:1) Since the valid data received are various dynamic tracking commands issued by the debugging tool (see Table 1 above for definitions), as well as the data and program addresses related to each command, therefore, for different commands, it is necessary to define different valid data format, but their valid data bits are 28 bits (excluding 2 flag bits). Each command and the valid data bits associated with the command are defined as follows:

·WP_SET/WP_REMOVE命令:设置和清除指定观察点的命令,与这两个命令相关的数据位是无效位,而16位地址则是需要被设置的观察点或者是需要被移除的观察点的地址。WP_SET/WP_REMOVE command: command to set and clear the specified watch point, the data bits related to these two commands are invalid bits, and the 16-bit address is the watch point that needs to be set or the watch point that needs to be removed address.

·WP_CLR命令:清除所有8个观察点的命令,与该命令相关的数据位和地址位此时都无效;·WP_CLR command: command to clear all 8 observation points, the data bits and address bits related to this command are invalid at this time;

·SFR_SET命令:选择每个观察点处需要被跟踪和记录的内部寄存器的命令,与该命令一起接收到的8位数据和16位地址合起来作为24个内部寄存器的选择信号;SFR_SET command: the command to select the internal register that needs to be tracked and recorded at each observation point, and the 8-bit data and 16-bit address received together with the command are used as the selection signal of 24 internal registers;

·D_DBG命令:动态跟踪的启动命令,与此命令相关的数据位无效,而16位地址则是CPU开始执行程序的起始地址;D_DBG command: the start command of dynamic tracking, the data bits related to this command are invalid, and the 16-bit address is the starting address of the CPU to start executing the program;

·D_DBG_PAUSE/D_DBG_STOP命令:动态跟踪的暂停和停止命令,与这两个命令相关的数据位和地址位都无效。· D_DBG_PAUSE/D_DBG_STOP command: Pause and stop command of dynamic tracking, the data bits and address bits related to these two commands are invalid.

2)发送时候的有效数据由每个观察点处被选择出的内部寄存器的数据和当前观察点的地址组成(见图3)。不过,为了保证每次串行输出的位数一致,那些没有被选中的内部寄存器的内容也以全0数据输出。因此,总共有24个内部寄存器和1个16位的地址需要输出。2) The valid data at the time of sending is composed of the data of the selected internal register at each observation point and the address of the current observation point (see FIG. 3 ). However, in order to ensure that the number of serial output bits is consistent each time, the contents of those internal registers that are not selected are also output as all 0 data. Therefore, a total of 24 internal registers and a 16-bit address need to be output.

为了实现OCT模块与外部调试工具的串行通信,本实施例采用了下述的异步串行通信结构(见图4):In order to realize the serial communication between the OCT module and the external debugging tool, the present embodiment adopts the following asynchronous serial communication structure (see Fig. 4):

·NEA:通信子模块与处理器外部进行串行通信的引脚;NEA: the pin for serial communication between the communication sub-module and the outside of the processor;

·NEAOE:串行通信时,接收和发送过程复用NEA引脚的使能信号;NEAOE: During serial communication, the enable signal of the NEA pin is multiplexed during receiving and sending;

·NEA_I/NEA_O:分别是通信子模块内部的串行接收和串行发送数据端;NEA_I/NEA_O: respectively the serial receiving and serial sending data terminals inside the communication sub-module;

·RX_CLK/TX_CLK:分别是接收和发送过程的工作时钟;RX_CLK/TX_CLK: the working clocks of receiving and sending processes respectively;

·RX_SHIFT/TX_SHIFT:分别是接收和发送过程的串行移位脉冲;RX_SHIFT/TX_SHIFT: the serial shift pulses of the receiving and sending processes respectively;

·RX_SHIFTER/TX_SHIFTER_1:分别是接收和发送过程的移位寄存器;RX_SHIFTER/TX_SHIFTER_1: the shift registers for receiving and sending processes respectively;

·RX_START/RX_OVER:分别是接收过程的开始和结束信号;RX_START/RX_OVER: the start and end signals of the receiving process, respectively;

·TX_BEGIN/TX_SEND:分别是发送过程的启动和输出信号;TX_BEGIN/TX_SEND: the start and output signals of the sending process, respectively;

·DBGCMD/RX_DATA/RX_ADDR:分别是接收过程结束后,接收到的调试命令、数据和地址的暂存寄存器。·DBGCMD/RX_DATA/RX_ADDR: They are the temporary storage registers of the debug command, data and address received after the receiving process is completed.

·TX_SFR_DATA:存储24个内部寄存器数据和当前观察点首地址的寄存器。TX_SFR_DATA: A register that stores 24 internal register data and the first address of the current observation point.

从图4可以看出,该串行通信子模块分成两个独立的部分:接收部分和发送部分。当处于发送状态时(TX_BEGIN或者TX_SEND信号有效),NEAOE信号有效(1电平),此时的NEA引脚用作输出(即NEA_O),反之若NEAOE信号无效,则NEA用作输入(NEA_I)。As can be seen from Figure 4, the serial communication sub-module is divided into two independent parts: the receiving part and the sending part. When in the sending state (TX_BEGIN or TX_SEND signal is valid), the NEAOE signal is valid (1 level), and the NEA pin at this time is used as an output (ie NEA_O), otherwise if the NEAOE signal is invalid, NEA is used as an input (NEA_I) .

1)接收的过程如下:1) The receiving process is as follows:

首先,系统复位时或者上一次的接收过程结束之后,30位全1信号被写入一个30位的接收移位寄存器RX_SHIFTER中。然后,若接收控制器在NEA_I端检测到从1到0的负跳变,RX_START信号就立即有效,于是在接收移位脉冲RX_CLK的控制下,出现在NEA_I端的数据被串行向右移入RX_SHIFTER,直到起始位0到达RX_SHIFTER的最右端。此时,0检测器检测到RX_SHIFTER最右端的0信号,于是使接收完毕信号RX_OVER有效,同时把接收到RX_SHIFTER中的命令、数据和地址分别存储到DBGCMD、RX_DATA和RX_ADDR三个寄存器中。First, when the system is reset or after the last receiving process is over, a 30-bit all-1 signal is written into a 30-bit receiving shift register RX_SHIFTER. Then, if the receiving controller detects a negative transition from 1 to 0 at the NEA_I terminal, the RX_START signal is immediately valid, so under the control of the receiving shift pulse RX_CLK, the data appearing at the NEA_I terminal is serially shifted to the right into RX_SHIFTER, Until the start bit 0 reaches the rightmost end of RX_SHIFTER. At this time, the 0 detector detects the 0 signal at the rightmost end of RX_SHIFTER, so that the received signal RX_OVER is valid, and at the same time, the command, data and address received in RX_SHIFTER are stored in the three registers DBGCMD, RX_DATA and RX_ADDR respectively.

另外,在采样NEA_I端信号的时候,采用了3取2的判决方法来提高接收的准确性和抗干扰性。也就是用与RX_CLK同频率的采样时钟CLK_SAMP(频率是移位脉冲RX_SHIFT的8倍)在每个接收字符的中间连续采样3次,然后取3个中至少2个相同的采样结果作为该字符的真实值。In addition, when sampling the signal at the NEA_I terminal, a decision method of 2 out of 3 is adopted to improve the accuracy of reception and anti-interference. That is, use the sampling clock CLK_SAMP with the same frequency as RX_CLK (the frequency is 8 times the shift pulse RX_SHIFT) to continuously sample 3 times in the middle of each received character, and then take at least 2 of the 3 same sampling results as the character. actual value.

2)发送的过程如下:2) The sending process is as follows:

若检测到观察点,也即是WP_STOP和WP_MATCH信号同时有效的时候,发送过程的启动信号TX_BEGIN有效,且存储在TX_SFR_DATA中的内部寄存器的数据和当前观察点的地址被下载到发送移位寄存器TX_SHIFTER_1中。同时,由一个D触发器产生的1信号作为停止位被写进TX_SHIFTER_1的最左端。然后,TX_SEND信号有效,TX_SHIFTER_1中的数据在发送移位脉冲TX_SHIFT的控制下被串行右移到NEA_O信号线上。在数据右移的过程中,D触发器不断向TX_SHIFTER_1写入0信号,直到停止位到达TX_SHIFTER_1的最右端。此时,停止位左端的全0数据被一个全0检测器检测到,于是触发TX_END信号,通知发送控制器停止发送数据。If the observation point is detected, that is, when the WP_STOP and WP_MATCH signals are valid at the same time, the start signal TX_BEGIN of the transmission process is valid, and the data of the internal register stored in TX_SFR_DATA and the address of the current observation point are downloaded to the transmission shift register TX_SHIFTER_1 middle. At the same time, a 1 signal generated by a D flip-flop is written into the leftmost end of TX_SHIFTER_1 as a stop bit. Then, the TX_SEND signal is valid, and the data in TX_SHIFTER_1 is serially shifted right to the NEA_O signal line under the control of the sending shift pulse TX_SHIFT. In the process of data shifting to the right, the D flip-flop continuously writes 0 signals to TX_SHIFTER_1 until the stop bit reaches the rightmost end of TX_SHIFTER_1. At this time, the all 0 data at the left end of the stop bit is detected by an all 0 detector, and the TX_END signal is triggered to notify the sending controller to stop sending data.

经上述串行通信子模块接收到的动态跟踪调试命令共有8个。为了存储接收到的这些调试命令,定义了1个4位的调试命令寄存器DBGCMD来存储这8个调试命令的二进制编码(见表1)。其中,DBGCMD中没有用到的那些二进制编码暂时保留,可以在以后进行扩展。There are 8 dynamic tracking and debugging commands received by the above-mentioned serial communication sub-module. In order to store these debug commands received, a 4-bit debug command register DBGCMD is defined to store the binary codes of these 8 debug commands (see Table 1). Among them, those binary codes that are not used in DBGCMD are temporarily reserved and can be expanded in the future.

存储在DBGCMD中的动态跟踪命令可以控制OCT模块完成各种对处理器的动态跟踪功能(见图5),包括:观察点的设置、内部寄存器的选择以及在动态跟踪的过程中检测观察点等。The dynamic tracking command stored in DBGCMD can control the OCT module to complete various dynamic tracking functions for the processor (see Figure 5), including: setting of observation points, selection of internal registers, and detection of observation points during dynamic tracking, etc. .

1)观察点的设置:1) Setting of observation points:

·WP0~WP7:8个观察点地址寄存器,存储的是被设置为观察点的指令的首地址。系统复位的时候,8个观察点地址寄存器WPi(i=0~7)的内容都是高阻值。·WP0~WP7: 8 watchpoint address registers, which store the first address of the instruction set as watchpoint. When the system is reset, the contents of the 8 observation point address registers WPi (i=0~7) are all high resistance values.

观察点的设置由专门的“观察点设置网络”来实现(见图5),根据接收到的不同命令,可以进行观察点的不同设置:The setting of the observation point is realized by a special "observation point setting network" (see Figure 5). According to different commands received, different settings of the observation point can be performed:

i)如果接收到观察点设置命令WP_SET,观察点设置网络就将此时一并接收到的16位地址(见图2(b))作为一个观察点的地址写入到其中一个WPi中,写入的顺序是从WP0开始,然后到WP7结束。调试者可以根据情况设置0~8个观察点。如果调试者所设置的观察点超过了8个,那么第9个观察点就会覆盖掉第1个,而第10个覆盖掉第2个,依此类推。i) If the observation point setting command WP_SET is received, the observation point setting network will write the 16-bit address (see Fig. 2 (b)) received at this time into one of the WPi as the address of an observation point, and write The order of entry starts from WP0 and ends with WP7. The debugger can set 0 to 8 observation points according to the situation. If the debugger sets more than 8 observation points, the 9th observation point will cover the 1st one, and the 10th one will cover the 2nd one, and so on.

ii)如果接收到观察点移除命令WP_REMOVE,观察点设置网络就将此时接收到的16位地址(见图2(b))与已经被设置为观察点的地址相比较,然后将匹配的那个观察点移除掉。ii) If the watchpoint removal command WP_REMOVE is received, the watchpoint setting network will compare the 16-bit address (see Figure 2(b)) received at this time with the address that has been set as the watchpoint, and then match the That watchpoint is removed.

iii)如果接收到观察点清除命令WP_CLR,观察点设置网络就将所有的8个观察点一起清除掉。iii) If the watchpoint clearing command WP_CLR is received, the watchpoint setting network will clear all 8 watchpoints together.

2)内部寄存器的选择:2) Selection of internal registers:

·SFR_SEL:寄存器选择信号寄存器,大小为24位,存储的是24个内部寄存器的选择信号。系统复位时,24位选择信号都为0。·SFR_SEL: Register selection signal register, the size is 24 bits, which stores the selection signals of 24 internal registers. When the system is reset, the 24-bit selection signals are all 0.

设置完观察点之后,调试者还需要指定在每个观察点处需要被跟踪和记录的内部寄存器,这是通过“内部寄存器选择网络”来实现的(见图5)。如果OCT模块接收到SFR_SET命令,内部寄存器选择网络就将此时与该命令一起获得的“24位内部寄存器选择信号”(见图2(d)所示)存储在寄存器SFR_SEL中,然后根据SFR_SEL每一位的状态选择出对应的内部寄存器。After setting the watchpoints, the debugger also needs to specify the internal registers that need to be tracked and recorded at each watchpoint, which is realized through the "internal register selection network" (see Figure 5). If the OCT module receives the SFR_SET command, the internal register selection network will store the "24-bit internal register selection signal" obtained together with the command (see Figure 2(d)) in the register SFR_SEL, and then according to SFR_SEL every The state of a bit selects the corresponding internal register.

SFR_SEL寄存器的每一位都是一个独立的寄存器选择信号,高电平有效,而且与24个常用内部寄存器一一对应(见图6)。因此,一共有24个内部寄存器可供选择,调试者可以任意选择其中的0~24个。例如,如果SFR_SEL的最低位SFR_SEL.0为1,则与之对应的累加器ACC就被选中,因此在每个观察点处ACC都要被跟踪和记录,但如果SFR_SEL.0为0,则ACC就不需要被跟踪和记录。其他内部寄存器的选择方式与之相同。Each bit of the SFR_SEL register is an independent register selection signal, active high, and corresponds to 24 commonly used internal registers one by one (see Figure 6). Therefore, there are 24 internal registers to choose from, and the debugger can choose 0-24 of them arbitrarily. For example, if the lowest bit SFR_SEL.0 of SFR_SEL is 1, the corresponding accumulator ACC is selected, so ACC must be tracked and recorded at each observation point, but if SFR_SEL.0 is 0, ACC There is no need to be tracked and recorded. The other internal registers are selected in the same way.

3)在动态跟踪的过程中检测观察点:3) Detect observation points during dynamic tracking:

如果调试者已经设置好观察点,并设置好在每个观察点处需要被跟踪和记录的内部寄存器,就可以用D_DBG命令启动动态跟踪过程,然后,CPU会从与该命令一起获得的“起始地址”(见图2(e))处开始运行。在CPU正常运行的过程中,OCT模块自动进行观察点的检测。检测观察点的方法如图7所示:If the debugger has set watchpoints and internal registers that need to be traced and recorded at each watchpoint, you can use the D_DBG command to start the dynamic trace process, and then the CPU will start from the "start" obtained with this command. Start address" (see Figure 2(e)) to start running. During the normal operation of the CPU, the OCT module automatically detects the observation points. The method of detecting observation points is shown in Figure 7:

·PCC:当前正在执行的指令的16位首地址寄存器。PCC: The 16-bit first address register of the instruction currently being executed.

·WP_MATCH:观察点匹配信号。· WP_MATCH: Watchpoint match signal.

·WP_STOP:观察点匹配停止信号。· WP_STOP: Watch point matching stop signal.

·NOP:空操作指令。· NOP: No operation instruction.

·CCLK:CPU正常工作的时钟信号。CCLK: The clock signal for the normal operation of the CPU.

·CPU_STOP:停止CPU的工作时钟的信号。·CPU_STOP: The signal to stop the working clock of the CPU.

从图7可以看出,观察点寄存器WP0中存储的地址为75H,此即为某条指令的首地址。如果CPU当前正执行指令MOV A,#data,而且该指令的首地址为75H,那么,PCC中的数据就是75H。接下来,检测观察点的步骤为:It can be seen from Figure 7 that the address stored in the observation point register WP0 is 75H, which is the first address of a certain instruction. If the CPU is currently executing the instruction MOV A, #data, and the first address of the instruction is 75H, then the data in the PCC is 75H. Next, the steps to detect watchpoints are:

i)在这条MOV A,#data指令的第3个时钟周期C1P3,OCT模块将WP0的值与PCC进行比较,两者相符,于是WP_MATCH信号立即有效。然后,由于WP_MATCH信号的有效,执行完该MOV指令之后,CPU还要执行一条额外的空操作指令NOP,以保证MOV A,#data指令的完整性。因此,在NOP指令的第一个时钟周期C1P1,PCC的值立即变为NOP指令的首地址77H(因为MOVA,#data的机器码占用两个字节地址,而且在执行完该MOV指令后,处理器的程序指针会指向被这条额外的NOP指令所暂时替换的指令的首地址)。i) In the third clock cycle C1P3 of this MOV A, #data instruction, the OCT module compares the value of WP0 with PCC, and the two match, so the WP_MATCH signal is immediately valid. Then, due to the validity of the WP_MATCH signal, after executing the MOV instruction, the CPU will execute an additional empty operation instruction NOP to ensure the integrity of the MOV A, #data instruction. Therefore, in the first clock cycle C1P1 of the NOP instruction, the value of PCC immediately becomes the first address 77H of the NOP instruction (because MOVA, the machine code of #data occupies two byte addresses, and after executing the MOV instruction, The processor's program pointer will point to the first address of the instruction temporarily replaced by this extra NOP instruction).

ii)在NOP指令的第3个时钟周期C1P3,此时WP0与PCC已经不匹配,于是WP_MATCH信号立即无效。同时,由于该NOP指令是CPU额外执行的,因此在该NOP指令的第2个时钟周期C1P2,OCT模块会使WP_STOP信号有效。然后,在WP_STOP有效之后的下一个时钟周期(即NOP指令的C1P3时刻),发送启动信号TX_BEGIN有效。于是,在观察点75H处被跟踪的数据就被写入到发送移位寄存器TX_SHIFTER_1中,同时,NEA_O端开始发送串行数据的起始位(0电平)。ii) In the third clock cycle C1P3 of the NOP instruction, WP0 and PCC have not matched at this time, so the WP_MATCH signal is immediately invalid. At the same time, since the NOP instruction is additionally executed by the CPU, the OCT module will enable the WP_STOP signal in the second clock cycle C1P2 of the NOP instruction. Then, the next clock cycle after WP_STOP becomes effective (that is, the C1P3 time of the NOP instruction), the sending start signal TX_BEGIN becomes effective. Then, the tracked data at the observation point 75H is written into the transmission shift register TX_SHIFTER_1, and at the same time, the NEA_O terminal starts to transmit the start bit (0 level) of the serial data.

iii)接着,在NOP指令的第4个时钟周期C1P4,CPU_STOP信号有效,并使CPU的工作时钟CCLK停止下来。于是CPU暂停,等待OCT模块将观察点75H处的CPU内部信息串行输出到外部的调试工具进行分析。由于CCLK已经停止,因此NOP指令的第4个时钟周期C1P4会一直维持到CCLK恢复为止。iii) Then, in the fourth clock cycle C1P4 of the NOP instruction, the CPU_STOP signal is valid, and the working clock CCLK of the CPU is stopped. Then the CPU pauses, waiting for the OCT module to serially output the CPU internal information at the observation point 75H to an external debugging tool for analysis. Since CCLK has stopped, the fourth clock cycle C1P4 of the NOP instruction will be maintained until CCLK resumes.

Claims (7)

1. dynamic tracking method on the sheet of a microprocessor, it is characterized in that: by an on-chip tracer OCT, some position in the program process is set to observation point, then the information of the internal register of these given viewpoint appointments is followed the tracks of, is write down and real-time output; Its concrete steps are:
A., an asynchronous serial transmitting-receiving submodule is set, to realize communicating by letter of OCT module and processor outside;
B. set a debug command register DBGCMD, store the dynamic tracking debug command that debugging person is sent to the OCT module;
C. set n observation point address register WPi (i=0~n-1), store the first address that debugged person is set to the program of observation point;
D. set internal register and select sign register SFR SEL, be stored in the selection signal of the internal register of the tracked and record of each given viewpoint;
E. set a present instruction first address register PCC, store the first address of the current instruction of carrying out of CPU automatically;
F. start the dynamic tracking process by " starting the dynamic tracking order ", in the process of dynamic tracking, the OCT module is according to circumstances carried out the dynamic tracking operation then, and sets coherent signal.
2. dynamic tracking method on the sheet of microprocessor according to claim 1 is characterized in that the method that an asynchronous serial transmitting-receiving submodule is set among the described step a is:
This serial transmitting-receiving submodule adopts semiduplex asynchronous serial communication pattern, carries out serial communication by 1 signal wire and processor outside, and transmission and reception are two independently processes; The fundamental purpose of receiving unit is to receive the various debug commands that debugging acid sends, and data and the program address relevant with each order, and the purpose that sends then is the content strings line output with the selected internal register that goes out of each given viewpoint; Simultaneously, reception and process of transmitting have all adopted the data frame format of 1 position of rest+valid data position+1 start bit, and wherein position of rest is 1 level, and start bit is 0 level.Some signals and the register relevant with serial communication are defined as follows:
A.NEA: the external pin that asynchronous serial transmitting-receiving submodule and processor outside communicate then is divided into NEA_I in the OCT inside modules, i.e. serial data input end, and NEA_O, i.e. serial data output terminal;
B.RX_CLK/TX_CLK: the sampling clock when being asynchronous serial transmitting-receiving submodule reception and transmission serial data respectively, frequency all is 1/100 of a processor clock frequency;
C.RX_SHIFT/TX_SHIFT: the serial-shift pulse when being asynchronous serial transmitting-receiving submodule reception and transmission data respectively, frequency all is 1/8 of RX_CLK/TX_CLK, therefore, the baud rate of communication is 1/800 of a processor operating rate;
D.RX_SHIFTER: receive shift register, reception be each debug command and relevant data and address;
E.TX_SHIFTER_1: send shift register, transmission be in the data of each given viewpoint internal register and the address of this observation point.
3. dynamic tracking method on the sheet of microprocessor according to claim 1 is characterized in that the method for setting a debug command register DBGCMD among the described step b is:
Definition DBGCMD is one 4 a register, and it is used to store the binary coding of the debug command that debugging acid sends, and the debug command that receives is decoded as control signal corresponding.
DBGCMD can store 8 orders relevant with dynamic tracking, sees Table 1, and wherein, other binary codings of not using among the DBGCMD temporarily keep, and can expand afterwards.
The dynamic tracking order of table 1 DBGCMD storage Binary coding The order symbol Functional description 0000 DBG_RST Under debugging mode, whole microprocessor system is resetted 1010 WP_SET Certain bar instruction in the program is set to an observation point 1011 WP_REMOVE Remove the observation point of an appointment 1100 WP_CLR The observation point that disposable removing is all 0011 SFR_SET Be set in each given viewpoint and need internal register tracked and record 1101 D_DBG Start the dynamic tracking process 1110 D_DBG_PAUSE Suspend the dynamic tracking process 1111 D_DBG_Stop Stop the dynamic tracking process
4. dynamic tracking method on the sheet of microprocessor according to claim 1, it is characterized in that setting among the described step c n observation point address register WPi (method of i=0~n-1) is:
Definition WPi (i=0~n-1) be the register of individual 16 of n, storage be the first address that is set to the instruction of observation point; After the system reset, the value of this n observation point address register all is a high value;
The OCT module is provided with or removes observation point according to following three kinds of situations:
A) if receive WP_SET order, 16 bit address that the OCT module just will receive with this order are stored in the WPi register as the address of an observation point, and the order of storage is from WP0, arrives WPn-1 at last; If the observation point that debugging person is provided with surpasses n, then the address of n+1 observation point just overrides the 1st observation point, and n+2 observation point overrides the 2nd, and the like;
B) if receive the WP_REMOVE order, the OCT module will be compared 16 bit address that receive this moment with the address that before was set at observation point, will remove with the observation point of this matching addresses then;
C) if receive the WP_CLR order, the OCT module is just with the disposable full scale clearance of all observation point, and the data of the observation point register after being eliminated all are high value.
5. dynamic tracking method on the sheet of microprocessor according to claim 1 is characterized in that setting in the described steps d internal register and selects the method for sign register SFR_SEL to be:
Definition SFR_SEL is the register of a n position, the corresponding according to the order of sequence n of it each internal register commonly used, and it is defined as follows: Internal register n selects signal …… Internal register 2 is selected signal Internal register 1 is selected signal
When receiving selection internal register order SFR_SET, the OCT module just will order the n bit register selection signal storage that receive in SFR_SEL with SFR_SET this moment; If this moment, a certain position of SFR_SEL was 1, then this pairing internal register will be tracked, and the content of this internal register all will be output in each given viewpoint simultaneously; Otherwise if this position is 0, so Dui Ying this internal register does not just need tracked and record.
6. dynamic tracking method on the sheet of microprocessor according to claim 1 is characterized in that the method for setting a present instruction first address register PCC among the described step e is:
Definition PCC is 1 16 a address register, storage be 16 first addresss of the current instruction of carrying out; Its value is by OCT module automatic setting; After the system reset, the value of PCC is 00h;
The concrete grammar of setting the PCC register is: in the process that program is carried out, in the 1st clock period of every instruction, the value of the program pointer that points to this instruction is delivered in the PCC register; PCC can preserve this address always, the 1st clock period up to next bar instruction, just is updated to new address.
7. dynamic tracking method on the sheet of microprocessor according to claim 1 is characterized in that among the described step f that in the process of dynamic tracking, the dynamic tracking operation that the OCT module is according to circumstances carried out has following three kinds:
If after a. the dynamic tracking process started, the OCT module did not receive other control commands, then the OCT module will compare WPi (i=0~n-1) carry out the detection of observation point with the content of PCC automatically in the process that program is carried out; If detect observation point, the OCT module is just analyzed the bit string line output of the selected internal register of this given viewpoint to outside debugging acid;
The concrete steps that detect observation point and export internal register information are:
A) WP_MATCH: the observation point matched signal, high level is effective;
WP_STOP: observation point coupling stop signal;
In the process that program is carried out, in the 3rd clock period of every instruction, (content of i=0~n-1) compares with present instruction first address register PCC respectively with n observation point address register WPi; As long as have the content of an observation point address register and the content of PCC to mate fully, just explanation has detected an observation point, so the WP_MATCH signal is effective immediately; After the instruction that executes this given viewpoint, CPU also needs to carry out a non-operation instruction NOP to guarantee the integrality of execution process instruction again; Then, in the 2nd clock period of this NOP instruction, the WP_STOP signal is effective, simultaneously, the OCT module all is stored in the value of all selected internal registers that go out in the corresponding temporary register, and not having the content of the selected pairing temporary register of internal register with those then all is 0; In the next clock period after effectively of WP_STOP signal and then, the OCT module enters the preparatory stage of serial transmission;
B) TX_SFR_DATA: the register of storing n internal register data and current observation point first address;
TX_SHIFTER_1: send shift register;
TX_BEGIN: send commencing signal;
CPU_STOP: the signal that stops the CPU work clock;
In the preparatory stage that serial sends, i.e. the 3rd clock period of NOP instruction, the TX_BEGIN signal is effective, and serial transmitting-receiving submodule all leaves in the content of n temporary register and the first address of current observation point among the register TX_SFR_DATA according to the order of sequence; Then, TX_SFR_DATA and 1 start bit and 1 position of rest are left in according to the order of sequence send among the shift register TX_SHIFTER_1 again; From the 4th clock period of NOP instruction, the OCT module enters the output stage that serial sends; Simultaneously, the CPU_STOP signal is effective, and CPU is out of service;
C) TX_END: the end signal of serial output;
At the output stage that serial sends, serial transmitting-receiving submodule is sent the content serial of TX_SHIFTER_1, and low level is preceding output the time, and left end constantly mends 0; When position of rest arrived the low order end of TX_SHIFTER_1, the all-zero signal of position of rest left end was detected by one " full null detector ", so the TX_END signal is effective immediately, the OCT module just stops the serial process of transmitting;
After b. if the dynamic tracking process starts, in the process of dynamic tracking, the OCT module receives the order D_DBG_PAUSE that suspends dynamic tracking, then in last clock period of present instruction, the CPU_STOP signal is effective, and CPU is out of service, and total system enters the halted state of dynamic tracking; At this moment, debugging person can come the ruuning situation of routine analyzer according to the processor internal information of the given viewpoint that is detected, thus search program mistake, reconfiguration program flow process etc.; If the current halted state that is in dynamic tracking of system, if debugging person sends the order D_DBG_PAUSE that suspends dynamic tracking once more, then system withdraws from halted state immediately, and reenters the dynamic tracking process; The CPU_STOP signal is invalid immediately simultaneously, and CPU begins to rerun from next bar instruction of previous time-out;
If after c. the dynamic tracking process started, in the process of dynamic tracking, the OCT module received the order D_DBG_STOP that stops dynamic tracking, then system withdraws from the dynamic tracking process immediately, and waits for that debugging person sends new dynamic tracking order.
CNB2006100307547A 2006-09-01 2006-09-01 On-chip Dynamic Tracking Method of Microprocessor Expired - Fee Related CN100401267C (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CNB2006100307547A CN100401267C (en) 2006-09-01 2006-09-01 On-chip Dynamic Tracking Method of Microprocessor

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CNB2006100307547A CN100401267C (en) 2006-09-01 2006-09-01 On-chip Dynamic Tracking Method of Microprocessor

Publications (2)

Publication Number Publication Date
CN1912849A true CN1912849A (en) 2007-02-14
CN100401267C CN100401267C (en) 2008-07-09

Family

ID=37721790

Family Applications (1)

Application Number Title Priority Date Filing Date
CNB2006100307547A Expired - Fee Related CN100401267C (en) 2006-09-01 2006-09-01 On-chip Dynamic Tracking Method of Microprocessor

Country Status (1)

Country Link
CN (1) CN100401267C (en)

Cited By (18)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104169888A (en) * 2012-03-16 2014-11-26 国际商业机器公司 Runtime Instrumentation Directed Sampling
CN104364768A (en) * 2012-03-16 2015-02-18 国际商业机器公司 Determining the state of run-time instrumentation controls
CN104380266A (en) * 2012-05-07 2015-02-25 密克罗奇普技术公司 Processor device with reset condition tracking capability
CN104536859A (en) * 2015-01-08 2015-04-22 中国科学院自动化研究所 Probe device of on-chip debugging system
US9367316B2 (en) 2012-03-16 2016-06-14 International Business Machines Corporation Run-time instrumentation indirect sampling by instruction operation code
US9372693B2 (en) 2012-03-16 2016-06-21 International Business Machines Corporation Run-time instrumentation sampling in transactional-execution mode
US9395989B2 (en) 2012-03-16 2016-07-19 International Business Machines Corporation Run-time-instrumentation controls emit instruction
US9400736B2 (en) 2012-03-16 2016-07-26 International Business Machines Corporation Transformation of a program-event-recording event into a run-time instrumentation event
US9405543B2 (en) 2012-03-16 2016-08-02 International Business Machines Corporation Run-time instrumentation indirect sampling by address
US9454462B2 (en) 2012-03-16 2016-09-27 International Business Machines Corporation Run-time instrumentation monitoring for processor characteristic changes
US9471315B2 (en) 2012-03-16 2016-10-18 International Business Machines Corporation Run-time instrumentation reporting
US9483268B2 (en) 2012-03-16 2016-11-01 International Business Machines Corporation Hardware based run-time instrumentation facility for managed run-times
US9489285B2 (en) 2012-03-16 2016-11-08 International Business Machines Corporation Modifying run-time-instrumentation controls from a lesser-privileged state
CN109495408A (en) * 2017-09-13 2019-03-19 瑞昱半导体股份有限公司 Baud rate tracking and compensation device and method
CN110727577A (en) * 2019-08-29 2020-01-24 华东计算技术研究所(中国电子科技集团公司第三十二研究所) Debugging method, system and medium for probability recurrence problem in embedded system software
CN117827563A (en) * 2023-12-29 2024-04-05 深圳博瑞晶芯科技有限公司 Processor function verification method, device and medium
CN119201750A (en) * 2024-11-22 2024-12-27 深圳康奥兴业科技有限公司 Embedded testing method, device and system
CN119808675A (en) * 2025-03-17 2025-04-11 中国人民解放军军事科学院国防科技创新研究院 State tracking and positioning method and system in processor core FPGA simulation process

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5748878A (en) * 1995-09-11 1998-05-05 Applied Microsystems, Inc. Method and apparatus for analyzing software executed in embedded systems
CN100371907C (en) * 2004-11-19 2008-02-27 凌阳科技股份有限公司 Tracing debugging method and system for processor
CN1648873A (en) * 2005-02-01 2005-08-03 苏州超锐微电子有限公司 Method for realizing break point debugging function

Cited By (34)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9459873B2 (en) 2012-03-16 2016-10-04 International Business Machines Corporation Run-time instrumentation monitoring of processor characteristics
US9465716B2 (en) 2012-03-16 2016-10-11 International Business Machines Corporation Run-time instrumentation directed sampling
CN104364768B (en) * 2012-03-16 2017-03-01 国际商业机器公司 Method and system for determining state of run-time instrumentation controls
US9489285B2 (en) 2012-03-16 2016-11-08 International Business Machines Corporation Modifying run-time-instrumentation controls from a lesser-privileged state
US9367316B2 (en) 2012-03-16 2016-06-14 International Business Machines Corporation Run-time instrumentation indirect sampling by instruction operation code
US9367313B2 (en) 2012-03-16 2016-06-14 International Business Machines Corporation Run-time instrumentation directed sampling
US9372693B2 (en) 2012-03-16 2016-06-21 International Business Machines Corporation Run-time instrumentation sampling in transactional-execution mode
US9395989B2 (en) 2012-03-16 2016-07-19 International Business Machines Corporation Run-time-instrumentation controls emit instruction
US9400736B2 (en) 2012-03-16 2016-07-26 International Business Machines Corporation Transformation of a program-event-recording event into a run-time instrumentation event
US9405543B2 (en) 2012-03-16 2016-08-02 International Business Machines Corporation Run-time instrumentation indirect sampling by address
US9471315B2 (en) 2012-03-16 2016-10-18 International Business Machines Corporation Run-time instrumentation reporting
US9411591B2 (en) 2012-03-16 2016-08-09 International Business Machines Corporation Run-time instrumentation sampling in transactional-execution mode
US9430238B2 (en) 2012-03-16 2016-08-30 International Business Machines Corporation Run-time-instrumentation controls emit instruction
US9442728B2 (en) 2012-03-16 2016-09-13 International Business Machines Corporation Run-time instrumentation indirect sampling by instruction operation code
US9442824B2 (en) 2012-03-16 2016-09-13 International Business Machines Corporation Transformation of a program-event-recording event into a run-time instrumentation event
US9454462B2 (en) 2012-03-16 2016-09-27 International Business Machines Corporation Run-time instrumentation monitoring for processor characteristic changes
CN104364768A (en) * 2012-03-16 2015-02-18 国际商业机器公司 Determining the state of run-time instrumentation controls
CN104169888A (en) * 2012-03-16 2014-11-26 国际商业机器公司 Runtime Instrumentation Directed Sampling
US9405541B2 (en) 2012-03-16 2016-08-02 International Business Machines Corporation Run-time instrumentation indirect sampling by address
US9483268B2 (en) 2012-03-16 2016-11-01 International Business Machines Corporation Hardware based run-time instrumentation facility for managed run-times
US9483269B2 (en) 2012-03-16 2016-11-01 International Business Machines Corporation Hardware based run-time instrumentation facility for managed run-times
CN104380266A (en) * 2012-05-07 2015-02-25 密克罗奇普技术公司 Processor device with reset condition tracking capability
CN104380266B (en) * 2012-05-07 2017-07-18 密克罗奇普技术公司 Processor device with reset condition tracking capability
CN104536859B (en) * 2015-01-08 2018-07-03 北京思朗科技有限责任公司 A kind of probe apparatus of sheet sand covered system
CN104536859A (en) * 2015-01-08 2015-04-22 中国科学院自动化研究所 Probe device of on-chip debugging system
CN109495408A (en) * 2017-09-13 2019-03-19 瑞昱半导体股份有限公司 Baud rate tracking and compensation device and method
CN109495408B (en) * 2017-09-13 2021-06-22 瑞昱半导体股份有限公司 Baud rate tracking and compensating device and method
CN110727577A (en) * 2019-08-29 2020-01-24 华东计算技术研究所(中国电子科技集团公司第三十二研究所) Debugging method, system and medium for probability recurrence problem in embedded system software
CN110727577B (en) * 2019-08-29 2023-06-09 华东计算技术研究所(中国电子科技集团公司第三十二研究所) Debugging method, system and medium for probabilistic recurrence problem in embedded system software
CN117827563B (en) * 2023-12-29 2024-11-05 深圳博瑞晶芯科技有限公司 Processor function verification method, device and medium
CN117827563A (en) * 2023-12-29 2024-04-05 深圳博瑞晶芯科技有限公司 Processor function verification method, device and medium
CN119201750A (en) * 2024-11-22 2024-12-27 深圳康奥兴业科技有限公司 Embedded testing method, device and system
CN119201750B (en) * 2024-11-22 2025-04-04 深圳康奥兴业科技有限公司 Embedded testing method, device and system
CN119808675A (en) * 2025-03-17 2025-04-11 中国人民解放军军事科学院国防科技创新研究院 State tracking and positioning method and system in processor core FPGA simulation process

Also Published As

Publication number Publication date
CN100401267C (en) 2008-07-09

Similar Documents

Publication Publication Date Title
CN1912849A (en) Chip dynamic tracing method of microprocessor
US9223676B2 (en) Introducing timing synchronization indicating stall reason in next synchronization window
EP2847682B1 (en) Processor device with reset condition trace capabilities
CN101770424A (en) Data acquisition and emulation system suitable for underlying protocol stack of digital communication terminal
CN1764903A (en) Diagnostic data capture within an integrated circuit
CN105095040A (en) Chip debugging method and device
CN1779652A (en) A method and device for debugging an operating system kernel state program
CN118860500A (en) A low-complexity serial port read-write register processing method and device
CN1577284A (en) Method and apparatus for realizing boundary Scanning test
CN1222909C (en) Loading method of Flash chip and JTAG controller
CN1570811A (en) Microprocessor equipped with power control function, and instruction converting apparatus
CN1741026A (en) Method for fast generating logical circuit
CN101178685A (en) An Enhanced Microprocessor On-Chip Dynamic Tracing Method with Special Function Register Breakpoints
CN2682491Y (en) Built-in debug function type microcomputer
CN1335962A (en) Thread-oriented debugging
CN1904850A (en) Method for implementing real-time monitoring performance information of embedded operating system
CN1858611A (en) A verification system, a method for creating a verification system, and a verification method
CN100347683C (en) Structure-irrelevant micro-processor verification and evaluation method
CN1284085C (en) Device and method for exporting peripheral device interconnection bus data by using debug card
CN1527064A (en) Information collection device and information collection and analysis system
CN101056312A (en) A method and system for communication between the devices
CN210955072U (en) Integrated circuit computing device and computing processing system
CN115758963A (en) Device, method and system for processing printing information in chip EDA simulation
CN104679557B (en) A kind of EEPROM is in line writing method
CN1892623A (en) Peripheral device and related method for translating redefined framework information structure

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant
C17 Cessation of patent right
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20080709

Termination date: 20120901