Chip software and hardware simulation character string printing method and device, equipment and medium

By employing a string address-based printing function in chip simulation, the problems of long processing time and CPU resource consumption caused by printing each character one by one are solved, resulting in a more efficient simulation process.

CN121960342APending Publication Date: 2026-05-01SIENGINE TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
SIENGINE TECH CO LTD
Filing Date
2026-04-02
Publication Date
2026-05-01

AI Technical Summary

Technical Problem

In existing chip simulations, printing strings character by character results in long processing times, consumes CPU resources, and affects simulation efficiency.

Method used

A string address-based printing function is used. By assigning a pointer value to the serial port printing address, the string address is assigned to the serial port printing address, thus reducing printing time.

Benefits of technology

It improves simulation efficiency, reduces printing time, saves simulation time, and reduces CPU resource usage.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121960342A_ABST
    Figure CN121960342A_ABST
Patent Text Reader

Abstract

The invention discloses a printing method and device of chip software and hardware simulation character strings, equipment and a medium, and relates to the technical field of chip embedded simulation, and the printing method of the chip software and hardware simulation character strings comprises the following steps that S10, a preset printing function is executed in response to a printing instruction, obtaining a character string needing to be printed according to the obtained character string address; wherein the preset printing function is edited based on a character string address; and step S20, printing the obtained character string. According to the method, the original printing function based on one-by-one printing of the single characters is modified into the printing function based on the character string address, and when the instruction of printing the character string is executed, the time required for printing can be shortened, so that the simulation time can be saved, and the simulation efficiency can be improved. In addition, too many resources of the chip CPU are not occupied when the serial port is written.
Need to check novelty before this filing date? Find Prior Art

Description

Methods, apparatus, equipment, and media for printing strings in chip hardware and software simulation Technical Field

[0001] This invention relates to the field of embedded chip simulation technology, and in particular to a method, apparatus, device, and medium for printing chip hardware and software simulation strings. Background Technology

[0002] With the development of the electronics industry, integrated circuit designs are becoming increasingly larger and more integrated, to the point that a complete system can be integrated into a tiny chip. Under these circumstances, SoC (System-on-a-Chip) technology has emerged. During the chip development phase, the verification of SoC chips is taking up an increasingly large proportion of the time, gradually becoming a bottleneck in the chip development process. Currently, the correctness of SoC chip design must be ensured through simulation.

[0003] In embedded hardware and software co-simulation of chips, print information is often added to the program to help track program execution. However, in current chip simulations, printing strings requires reading characters from the chip's memory and then writing them to the serial port. This means printing a string involves splitting it into multiple characters and outputting each character individually via the serial port. Since only one character can be printed at a time during serial port transmission, the more characters there are, the longer the printing time becomes, wasting simulation time. Furthermore, the chip's CPU is fast, while the serial port is slow, causing writing to the serial port to consume CPU resources. Summary of the Invention

[0004] This invention provides a method, apparatus, device, and medium for printing strings in chip hardware and software simulation, in order to solve the technical problem in the prior art that printing strings in chip hardware and software simulation, based on printing one character at a time, results in a long printing time.

[0005] In a first aspect, a method for printing strings in chip hardware and software simulation is provided, comprising the following steps: executing a preset printing function in response to a printing command, obtaining the string to be printed based on the acquired string address; wherein, the preset printing function is edited based on the string address; and printing the obtained string.

[0006] In some embodiments, the preset printing function is edited based on a string address, including: assigning a pointer value to the serial port printing address; and assigning the string address to the serial port printing address.

[0007] In some embodiments, the response to the print command executes a preset print function to obtain the string to be printed based on the obtained string address, including: compiling the preset print function into a bin file; and storing the compiled bin file.

[0008] In some embodiments, compiling the preset printing function into a bin file includes: using a GCC compiler, LLVM compiler, or ARMCC compiler to compile the preset printing function into a bin file.

[0009] In some embodiments, storing the compiled bin file includes storing the compiled bin file using the chip's random access memory.

[0010] In some embodiments, the step of responding to a print command to execute a preset print function and obtain the string to be printed based on the obtained string address further includes: obtaining the string address from the chip's address bus; and obtaining the string to be printed from the chip's random access memory through a backdoor based on the obtained string address.

[0011] In some embodiments, the printed string includes a string printed using the Universal Validation Methodology (UVM).

[0012] Secondly, a chip hardware and software simulation string printing device is provided, comprising: a response unit for responding to a printing instruction to execute a preset printing function and obtain the string to be printed based on the acquired string address; wherein the preset printing function is edited based on the string address; and a printing unit for printing the obtained string.

[0013] Thirdly, a computer device is provided, comprising: a memory and a processor, wherein the memory stores at least one instruction, the at least one instruction being loaded and executed by the processor to implement the aforementioned method for printing chip hardware and software simulation strings.

[0014] Fourthly, a computer-readable storage medium is provided, the computer-readable storage medium storing computer instructions, which, when executed by a computer, cause the computer to perform the aforementioned method for printing chip hardware and software simulation strings.

[0015] The beneficial effects of the technical solution provided by this invention include: This invention provides a method, apparatus, device, and medium for printing strings in chip hardware and software simulation. The printing method modifies the original printing function based on printing individual characters one by one to a printing function based on string addresses. When executing the instruction to print the string, the printing time can be reduced, thereby saving simulation time and improving simulation efficiency. Furthermore, writing to the serial port does not consume too many resources of the chip's CPU. Attached Figure Description

[0016] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0017] Figure 1 is a flowchart illustrating a method for printing a chip hardware / software simulation string according to an embodiment of the present invention; Figure 2 is a flowchart illustrating execution step S10 according to an embodiment of the present invention; Figure 3 is another flowchart illustrating execution step S10 according to an embodiment of the present invention; Figure 4 is an architectural diagram illustrating a chip hardware / software simulation environment according to an embodiment of the present invention; Figure 5 is a structural diagram illustrating a device for printing a chip hardware / software simulation string according to an embodiment of the present invention; Figure 6 is a structural diagram illustrating a computer device according to an embodiment of the present invention. Detailed Implementation

[0018] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0019] This invention provides a method for printing strings in chip hardware and software simulation, which solves the technical problem that printing strings based on printing one character at a time in existing chip hardware and software simulation methods results in long printing times.

[0020] Referring to Figure 1, this embodiment of the invention provides a method for printing strings in chip hardware and software simulation, including the following steps: Step S10, responding to a printing command to execute a preset printing function, and obtaining the string to be printed based on the obtained string address; wherein, the preset printing function is edited based on the string address.

[0021] Step S20: Print the obtained string.

[0022] Specifically, for example, assuming the serial port print address of the string is 0x68000000, the original print function based on printing each character one by one is as follows: int puts(const *s) {volatile uint32_t *print_address=0x68000000while(*s) {if (*s =='\n') {*print_address = '\r';}*print_address = *s++;}} The embodiment of the present invention improves the original print function. The preset print function is edited based on the string address, including: assigning a pointer value to the serial port print address; and assigning the string address to the serial port print address.

[0023] Furthermore, the print function based on string address in this embodiment of the invention is as follows: `int puts(const *s) {volatile uint32_t *print_address=0x68000000print_address = s}` For example, to print the 10-character string "HelloWorld" to the serial port, the original print function requires the chip's CPU to first read the characters from storage, taking 1ms per character, and then write the characters to the bus, taking 1ms per character. Therefore, printing 10 characters takes (1ms + 1ms) × 11 = 22ms. The print function using the method in this embodiment of the invention only requires one 1ms write to the bus address, improving efficiency by 21 times. That is, if the string contains N characters, the efficiency can be improved by 2N times using the print method in this embodiment of the invention.

[0024] In summary, the chip hardware and software simulation string printing method in this embodiment modifies the original printing function based on printing each character one by one into a printing function based on string address printing. This reduces the printing time required when executing the string printing instruction, thereby saving simulation time and improving simulation efficiency. Furthermore, writing to the serial port does not consume excessive CPU resources.

[0025] As an optional implementation, in one embodiment of the invention, referring to Figure 2, the step of responding to the print command to execute a preset print function and obtain the string to be printed according to the obtained string address includes: step S101, compiling the preset print function into a bin file; step S102, storing the compiled bin file.

[0026] Optionally, the preset print function can be compiled into a bin file using a GCC compiler, LLVM compiler, or ARMCC compiler. Optionally, the preset bin file can be stored in the chip's random access memory, i.e., the bin file can be loaded into the chip's random access memory through a backdoor.

[0027] As an optional implementation, in one embodiment of the invention, referring to Figure 3, the step of responding to the print command to execute a preset print function and obtain the string to be printed according to the obtained string address further includes: step S103, obtaining the string address from the address bus of the chip during the process of the chip writing to the serial port; step S104, obtaining the string to be printed from the random access memory of the chip through a backdoor according to the obtained string address.

[0028] As an optional implementation, in one embodiment of the invention, the printed string includes: a string printed using the Universal Verification Methodology (UVM).

[0029] Specifically, the implementation of printing strings using the general verification methodology UVM is as follows: 1) string m_msg_substr [$]; / / Define a dynamic array to store the string obtained from the backdoor 2) function void get_string(bit [31:0] print_addr); / / Define a method for the backdoor to obtain the string bit zero_detected = 0; / / Define a variable to detect the last character to be printed NULL (0x0) bit[7:0] peek_data; / / Define a variable to store the character obtained from the backdoor bit[9:0] byte_offset = 0; / / Define a variable as a pointer to m_msg_sub_str do begin / / Continuously obtain characters from the backdoor and store them in m_msg_substr until the obtained character is NULL (0x0) peek(print_addr, peek_data); / / The backdoor data acquisition method built into UVM, obtain the character to be printed through the string address if(peek_data != 0x0) begin / / Check if the obtained character is NULL (0x0) m_msg_substr [byte_offset] = peek_data; / / Store the character obtained by the backdoor in m_msg_substr; print_addr = print_addr + 1; / / Address of the next character byte_offset = byte_offset + 1; / / Pointer to the next character in m_msg_substr endelsezero_detected = 1; / / If the obtained character is NULL (0x0), exit the while loop end while(zero_detected == 0) 3) function void print_msg(); / / Define a function to print a string `uvm_info(sformatf(“Get message:%s”, m_msg_substr),UVM_NONE); / / Execute the printing mechanism in UVM to print the string m_msg_substr = “”; / / Clear the dynamic array storing the string endfunction The following example of printing a string further illustrates the traditional printing method and the printing method of this embodiment: Assume the serial port printing address print_address is 0x6800 0000. When there is an instruction to print the string "HelloWorld", that is, the simulation program will execute puts("HelloWorld\n"); convert puts into a binary file, and convert "HelloWorld\n" into hexadecimal ASCII code in the bin file: 48 (H) 65 (e) 6C (l) 6C (l) 6F (o) 57 (W) 6F (o) 72 (r) 6C (l) 64 (d) 0D (\n) 00 (null). Then load the bin file into the chip's memory. Since puts uses a const variable, the above ASCII code has a fixed address in the code segment, such as the starting address of 0x1000. If the last address is 0x1000000C, then the content of the CPU's execution code segment on the chip will not change. The traditional printing method requires the CPU to first read the character from address 0x1000 0000, assuming the time to read the character from memory is 1ms, and then write the character to the serial port address 0x68000000, assuming the CPU's time to write to the bus is 1ms. In the original scheme, it would start from 0x48 and loop until the last character 0x04, taking a total of 11 * 2ms = 22ms. The printing method of this embodiment only requires one write to the CPU, writing 0x10000000 to the serial port address 0x68000000, which only takes 1ms. That is, this embodiment passes the obtained string address 0x10000000 to the get_string(0x1000) function in the Universal Verification Methodology (UVM). 0000), execute get_string, after detecting the last 0x0, m_msg_substr = "HelloWorld\n", then execute print_msg, thus completing the printing of put("HelloWorld\n") in the simulation program in the hardware simulation environment, as shown in Figure 4. The software simulation environment provides a platform for editing printing functions, writing programs, and compiling programs, while the hardware simulation environment provides a platform for string printing and display. Furthermore, because the UVM function mechanism is used, which does not consume simulation time, this embodiment of the invention only uses 1ms of writing time to the CPU once, saving 21ms compared to the traditional printing method.

[0030] Referring to Figure 5, this embodiment of the invention also provides a device for printing chip hardware and software simulation strings, including: a response unit and a printing unit.

[0031] A response unit is used to execute a preset printing function in response to a print command, and obtain the string to be printed based on the obtained string address; wherein, the preset printing function is edited based on the string address; and a printing unit is used to print the obtained string.

[0032] The chip hardware and software simulation string printing device in this embodiment of the invention modifies the original printing function based on printing each character one by one to a printing function based on string address printing. This reduces the printing time required when executing the string printing instruction, thereby saving simulation time and improving simulation efficiency. Furthermore, writing to the serial port does not consume too many resources of the chip's CPU.

[0033] This invention also provides a computer device, including: a memory, a processor, and a network interface connected via a system bus. The memory stores at least one instruction, which is loaded and executed by the processor to implement all or part of the steps of the aforementioned chip hardware and software simulation string printing method.

[0034] The network interface is used for network communication, such as sending assigned tasks. Those skilled in the art will understand that the structure shown in Figure 6 is merely a block diagram of a portion of the structure related to the present invention and does not constitute a limitation on the computer device to which the present invention is applied. Specific computer devices may include more or fewer components than shown in the figure, or combine certain components, or have different component arrangements.

[0035] A processor can be a CPU, or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. A general-purpose processor can be a microprocessor, or any conventional processor. The processor is the control center of a computer device, connecting all parts of the computer device through various interfaces and lines.

[0036] Memory can be used to store computer programs and / or modules. The processor, by running or executing the computer programs and / or modules stored in the memory, and executing data stored in the memory, realizes various functions of the computer device. Memory can mainly include a program storage area and a data storage area. The program storage area can store the operating system, application programs required for at least one function (such as video playback, image playback, etc.), etc.; the data storage area can store data created based on the use of the mobile phone (such as video data, image data, etc.). In addition, memory can include high-speed random access memory, and can also include non-volatile memory, such as hard disks, RAM, plug-in hard disks, SmartMedia Cards (SMC), Secure Digital (SD) cards, Flash Cards, at least one disk storage device, flash memory device, or other volatile solid-state storage devices.

[0037] In one embodiment of the invention, the processor is used to run a computer program stored in the memory to perform the following steps: Step S10, responding to a print instruction to execute a preset print function, and obtaining the string to be printed based on the obtained string address; wherein, the preset print function is edited based on the string address; Step S20, printing the obtained string.

[0038] As an optional implementation, in one embodiment of the invention, the preset printing function is edited based on a string address, including: assigning a pointer value to the serial port printing address; and assigning the string address to the serial port printing address.

[0039] As an optional implementation, in one embodiment of the invention, the step of responding to the print command to execute a preset print function and obtain the string to be printed according to the obtained string address includes: step S101, compiling the preset print function into a bin file; step S102, storing the compiled bin file.

[0040] As an optional implementation, in one embodiment of the invention, compiling the preset printing function into a bin file includes: using a GCC compiler, an LLVM compiler, or an ARMCC compiler to compile the preset printing function into a bin file.

[0041] As an optional implementation, in one embodiment of the invention, storing the compiled bin file includes: storing the compiled bin file using the chip's random access memory.

[0042] As an optional implementation, in one embodiment of the invention, the step of responding to the print command to execute a preset print function and obtain the string to be printed according to the obtained string address further includes: S103, obtaining the string address from the address bus of the chip; S104, obtaining the string to be printed from the random access memory of the chip through a backdoor according to the obtained string address.

[0043] As an optional implementation, in one embodiment of the invention, the printed string includes: a string printed using the Universal Verification Methodology (UVM).

[0044] This invention also provides a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements all or part of the steps of the aforementioned chip hardware and software simulation string printing method.

[0045] The embodiments of the present invention can implement all or part of the aforementioned processes, or they can be accomplished by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various methods described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable medium can include: any entity or device capable of carrying computer program code, recording media, USB flash drives, portable hard drives, magnetic disks, optical disks, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc. It should be noted that the content included in the computer-readable medium can be appropriately added to or subtracted according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electrical carrier signals and telecommunication signals.

[0046] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, systems, servers, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage and optical storage) containing computer-usable program code.

[0047] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or system. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or system that includes that element.

[0048] The serial numbers in the above embodiments of the present invention are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.

[0049] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in one or more blocks of the flowchart illustrations and / or one or more blocks of the block diagrams.

[0050] The above description is merely a specific embodiment of the present invention, enabling those skilled in the art to understand or implement the invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the invention. Therefore, the present invention is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features of the invention herein.

Claims

1. A method for printing strings in chip hardware and software simulation, characterized in that, The process includes the following steps: responding to a print command by executing a preset print function, obtaining the string to be printed based on the acquired string address; wherein, the preset print function is edited based on the string address; and printing the obtained string.

2. The method for printing chip hardware and software simulation strings according to claim 1, characterized in that, The preset printing function is edited based on a string address, including: assigning a pointer value to the serial port printing address; and assigning the string address to the serial port printing address.

3. The method for printing chip hardware and software simulation strings according to claim 1, characterized in that, The response to the print command executes a preset print function and obtains the string to be printed based on the acquired string address, including: compiling the preset print function into a bin file; and storing the compiled bin file.

4. The method for printing chip hardware and software simulation strings according to claim 3, characterized in that, The step of compiling the preset print function into a bin file includes: using a GCC compiler, LLVM compiler, or ARMCC compiler to compile the preset print function into a bin file.

5. The method for printing chip hardware and software simulation strings according to claim 3, characterized in that, The storage of the compiled bin file includes: storing the compiled bin file using the chip's random access memory.

6. The method for printing chip hardware and software simulation strings according to claim 5, characterized in that, The method of responding to a print command to execute a preset print function and obtain the string to be printed based on the obtained string address also includes: obtaining the string address from the address bus of the chip; and obtaining the string to be printed from the random access memory of the chip through a backdoor based on the obtained string address.

7. The method for printing chip hardware and software simulation strings according to claim 1, characterized in that, The printed string includes: the string printed using the Universal Validation Methodology (UVM).

8. A device for printing strings using chip hardware and software simulation, characterized in that, include: A response unit is used to execute a preset printing function in response to a print command, and to obtain the string to be printed based on the obtained string address; wherein, the preset printing function is edited based on the string address; The print unit is used to print the resulting string.

9. A computer device, characterized in that, include: A memory and a processor, wherein the memory stores at least one instruction, which is loaded and executed by the processor to implement the chip hardware and software simulation string printing method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions that, when executed by a computer, cause the computer to perform the chip hardware and software simulation string printing method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Message printing method and device based on SoC system, electronic equipment, storage medium and computer program product

    CN119377138A

  • Methods, systems, and computer program products for deferred computer program tracing

    US7240334B1