Automatic simulation method based on yaml
By using a global configuration file in YAML format and Python parsing, C programs are automatically compiled and VCS simulations are called, solving the problem that C test cases cannot be run directly in chip development. This achieves efficient and unified parameter management and automation of the simulation process, improving the efficiency and reliability of chip development.
Patent Information
- Application Number
- CN202510791556.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-13
- Publication Date
- 2025-10-28
AI Technical Summary
In existing technologies, chip development is isolated from actual application scenarios, C test cases cannot be run directly, and the number of test cases and the complexity of parameters increase with the size of the chip, resulting in high management difficulty, scattered compilation and simulation instructions that require manual configuration, and complex toolchain operations.
The test case parameters are centrally managed using a global configuration file in YAML format. They are parsed and stored in a dictionary structure using Python. The C program is automatically compiled and the VCS simulation is called. The toolchain is driven by Makefile to achieve unified parameter management and automation of simulation commands.
It enables the direct execution of C test cases in the UVM environment, reducing repetitive work, improving parameter management efficiency, shortening compilation and simulation time, enhancing tool synergy, and ensuring the efficiency, maintainability, and accuracy of the simulation process.
Smart Images

Figure CN120850902A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of chip development technology, specifically to an automated simulation method based on YAML. Background Technology
[0002] In chip development, to better align with actual user scenarios, applications are typically developed as system-level verification test cases based on UVM verification. The chip's actual performance, reliability, and compatibility need to be verified in a hardware and software co-processing scenario, and potential problems need to be exposed by running real or simulated applications.
[0003] In existing technologies, typical verification environments use UVM test cases developed based on SV syntax. These cannot directly run test cases provided by users or developed by field application engineers using C syntax. This results in a certain degree of isolation between chip development and application scenarios. Furthermore, in chip verification, the number of test cases developed increases significantly with the size of the chip, and the parameters corresponding to each test case also become more complex and numerous due to the increased complexity of the test cases. Chip verification environments directly use makefiles or vcs commands, with compilation and simulation commands being scattered and requiring manual configuration, which places high demands on the user's toolchain operation skills. Summary of the Invention
[0004] The purpose of this invention is to provide an automated simulation method based on YAML to solve the problems mentioned in the background art, such as the inability to directly run use cases based on C syntax, which leads to the isolation between chip development and actual application scenarios, and the difficulty in efficiently managing the number of use cases and parameter complexity as chip size increases.
[0005] To achieve the above objectives, the present invention provides the following technical solution: an automated simulation method based on YAML, comprising the following steps:
[0006] S1. Define test case parameters: Define the relevant characteristics of test cases in a global configuration file in YAML format, and centrally manage the parameters related to test cases.
[0007] S2. Parse YAML files and store parameters: Using Python as a tool, parse the information in the YAML file and store it in a dictionary data structure;
[0008] S3. Automated compilation of C programs: The test case parameters are divided into categories, and the parameters are input when the corresponding tools are called. The C program is first compiled by gcc through make and the instruction format file aa.hex is generated. aa.hex is placed in the location specified by the UVM test case.
[0009] S4. Automated simulation by calling VCS: The simulation tool VCS is called through make, with the instruction format file as the input file. At the same time, the corresponding parameters of VCS are entered when running the VCS instructions for compilation.
[0010] S5. Unified command triggering and result feedback: Input a unified command to simulate the test case and feed the result back to the user.
[0011] Preferably, in step S1, the defined use case parameters include the following:
[0012] S11. Determine the types of parameters that need to be managed, and review all tools and processes involved in the design;
[0013] S12. Create global_config.yaml to define default parameters shared by all test cases and perform global configuration. Create an independent yaml file for each test case to define differentiated parameters, with local parameters overriding global default values.
[0014] S13. Split parameters according to tool type and write YAML file syntax specifications;
[0015] S14. Use $(variable name) to reference dynamic values in paths and parameters, use the extends keyword to inherit test case parameters in local configurations, and use the when keyword to define conditional parameters.
[0016] S15. Verify the completeness and correctness of the parameters.
[0017] Preferably, in step S13, the specific content of writing the YAML file syntax specification includes: using indentation to distinguish levels; using camelCase for key names; supporting strings, numbers, lists, and dictionaries for values; and adding comments for the purpose of complex parameters.
[0018] Preferably, in step S1, the managed parameters related to the use cases are used to generate a use case parameter list. The use case parameter list includes VCS compilation options, VCS simulation options, waveform file options, C compilation options, regression name, number of regressions, log file keyword filtering and ignoring, use case error keywords, and use case pass keywords.
[0019] Preferably, in step S2, parsing the YAML file and storing the parameters includes the following steps:
[0020] S21. Determine the storage location of the yaml file and read its contents;
[0021] S22. Call the parsing library to convert the YAML text into a Python dictionary, check the correctness of the YAML syntax, read the project-level global YAML configuration, and override the parameters with the same name in the global configuration with the local configuration.
[0022] S23. Identify variable markers, dynamically replace built-in variables and environment variables, organize parameters into nested dictionaries according to tool type, and locate parameters;
[0023] S24. Parse the configuration of the specified use case, obtain the parameter values through the dot path, and cache the parsed configuration.
[0024] Preferably, in step S3, the automated compilation of the C program includes the following steps:
[0025] S31. Parse parameters from YAML, extract GCC-related parameters and UVM environment parameters, and verify the parameters;
[0026] S32. Construct compilation commands, define Makefile rules, generate Makefile instructions, call Make to execute compilation, record standard output and error output during the compilation process, and verify the compilation results;
[0027] S33. Obtain the hex_path of the UVM environment from the yaml parameters, construct the complete target path, use system commands to move the file, and create the target file;
[0028] S34. In the Python script, first parse the YAML parameters, then call the compilation process to perform unit testing and verification.
[0029] Preferably, in step S4, the automated invocation of VCS for simulation includes the following steps:
[0030] S41. Obtain VCS parameters from YAML, determine the path of the generated aa.hex file, convert the parameter list to a format acceptable to the VCS command line, check whether the UVM environment variables are set correctly, and create the simulation working directory.
[0031] S42. Build the compilation command, obtain and add compilation parameters from the YAML file, specify the top-level module, and generate Makefile rules;
[0032] S43. Call Make to execute the compilation, copy the generated aa.hex to the simulation directory, set UVM related variables, create a waveform file directory, build the vcs simulation command, add waveform parameters, update Makefile rules, and call Make to execute the simulation.
[0033] Preferably, in step S43, after executing the simulation command, the simulation results are verified. The verification includes checking whether the log contains keywords, extracting key indicators, checking whether the waveform file is generated and is not empty, and verifying the coverage results.
[0034] Preferably, in step S5, the unified command input by the user is run-tc Test_aa. After the unified command is input, the system automatically completes the compilation and simulation, and judges the result based on the keywords in the log and feeds it back to the user.
[0035] Compared with the prior art, the beneficial effects of the present invention are:
[0036] This invention uses YAML as a carrier to centralize all test case-related parameters in one place. Parameters are configured hierarchically using the YAML format, enabling global and local parameter reuse and overriding, improving parameter management efficiency, reducing repetitive work, and storing them as a dictionary within the test case simulation instructions. This unifies the simulation instructions for all test cases, facilitating rapid parameter retrieval and enhancing tool synergy. Furthermore, the YAML mechanism can simultaneously include parameters from various tools, effectively solving the problem of directly running C test cases in chip development, eliminating the isolation between C test cases and the UVM environment, automating the compilation of C programs and the invocation of the VCS simulation process, and using Makefiles and automatic parameter passing to avoid manual input errors, shortening compilation and simulation time. It also supports automatic generation of Hex files and path adaptation, improving UVM environment integration efficiency, unifying command triggering the entire process, and automatically determining and feeding back results based on log keywords to ensure process reliability, thus improving the overall efficiency, maintainability, and accuracy of the simulation process. Attached Figure Description
[0037] Figure 1 This is a flowchart of an automated simulation method based on YAML according to the present invention. Detailed Implementation
[0038] 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, and 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.
[0039] Example: Refer to Figure 1 As shown: An automated simulation method based on YAML includes the following steps:
[0040] S1. Define test case parameters: Define the relevant characteristics of test cases in a global configuration file in YAML format, and centrally manage the parameters related to test cases.
[0041] The following is an example of defining test case parameters in YAML format:
[0042]
[0043] In step S1, the defined use case parameters include the following:
[0044] S11. Determine the types of parameters that need to be managed, and review all tools and processes in the design to ensure that no parameters are omitted;
[0045] S12. Create global_config.yaml to define default parameters shared by all test cases for global configuration. Create an independent yaml file (such as test_aa.yaml) for each test case to define differentiated parameters. Local parameters automatically override global default values to achieve "reuse of common configurations and independence of differentiated configurations".
[0046] S13. Split parameters according to tool type to avoid confusion, and write a syntax specification for YAML files;
[0047] The specific content of writing YAML file syntax specifications includes: using indentation to distinguish levels; using camelCase for key names, and supporting strings, numbers, lists, and dictionaries for values; adding comments (starting with #) to explain the purpose of complex parameters;
[0048] S14. Use $(variable name) to reference dynamic values in paths and parameters (e.g., $(testcase) is automatically replaced with the test case name, $(date) generates the current date), use the extends keyword in local configurations to inherit parameters from the global or other test cases (e.g., extends:"base_case.yaml"), avoid duplicate definitions, and use the when keyword to define conditional parameters.
[0049] S15. Verify the completeness and correctness of the parameters, check the required fields, ensure that the core parameters exist and are not missing, use a YAML validation tool (such as YAML_INT) to check for syntax errors, verify that the numeric parameter types are correct, and perform logical validation to ensure that the parameters are logically consistent.
[0050] Generate a test case parameter list from the parameters related to the managed test cases. The test case parameter list includes VCS compilation options, VCS simulation options, waveform file options, C compilation options, regression name, number of regressions, log file keyword filtering and ignoring, test case error keywords, and test case pass keywords. This test case parameter list can be expanded without restriction as needed.
[0051] S2. Parse YAML files and store parameters: Using Python as a tool, parse the information in the YAML file and store it in a dictionary data structure;
[0052] In step S2, parsing the YAML file and storing the parameters includes the following steps:
[0053] S21. Determine the storage location of the yaml file, and use Python's open() function to read the file content. Python's open() function can also be replaced by a Perl file handle.
[0054] S22. Call the parsing library to convert the YAML text into a Python dictionary, check the correctness of the YAML syntax, throw a parsing exception and locate the problematic line number if the format is incorrect, read the project-level global YAML configuration, and override the parameters with the same name in the global configuration with the local configuration.
[0055] S23. Identify variable markers, dynamically replace built-in variables and environment variables, organize parameters into nested dictionaries according to tool type, and quickly locate parameters through dictionary key paths;
[0056] S24. Parse the configuration of the specified test case, quickly obtain parameter values through dot paths (such as vcs.compile_args), and cache the parsed configuration to avoid parsing the same file repeatedly.
[0057] S3. Automated compilation of C programs: The test case parameters are divided into categories, and the parameters are input when the corresponding tools are called. The C program is first compiled by gcc through make and the instruction format file aa.hex is generated. aa.hex is placed in the location specified by the UVM test case.
[0058] C compiler directive: Make -C Test_aa_gcc MAIN = aa_main
[0059] In step S3, the automated compilation of the C program includes the following steps:
[0060] S31. Parse parameters from YAML, extract GCC-related parameters and UVM environment parameters, and verify the parameters;
[0061] S32. Construct compilation commands, define Makefile rules, generate Makefile instructions, call Make to execute compilation, record standard output and error output during the compilation process, extract error information and terminate the process if compilation fails, check file generation and verify file format, and verify compilation results.
[0062] S33. Obtain the hex_path of the UVM environment from the yaml parameters, construct the complete target path, use system commands to move files, create target files, identify temporary files and delete them;
[0063] S34. In the Python script, first parse the YAML parameters, then call the compilation process to perform unit testing and verification. Verify that the correct C code can be successfully compiled into a HEX file, confirm that the generated HEX file can be correctly loaded and executed by the UVM environment, and ensure that the C program is correctly converted into an instruction file that can be used by the verification environment.
[0064] S4. Automated simulation by calling VCS: The simulation tool such as VCS is called through make, with the instruction format file as the input file. At the same time, the corresponding parameters of VCS are input when running the VCS instructions for compilation.
[0065] VCS compilation and execution commands: Make -C T_aa_dir tc = Test_aa-debug_acc + enable. In step S4, the automated invocation of VCS for simulation includes the following steps:
[0066] S41. Obtain VCS parameters from YAML, determine the path of the generated aa.hex file, convert the parameter list to a format acceptable to the VCS command line, check whether the UVM environment variables are set correctly, and create the simulation working directory.
[0067] S42. Build the compilation command, obtain and add compilation parameters from the YAML file, specify the top-level module, and generate Makefile rules;
[0068] S43. Call Make to execute the compilation, capture standard output and error output, record compilation logs, copy the generated aa.hex to the simulation directory, set UVM related variables, create a waveform file directory, build the vcs simulation command, add waveform parameters, update Makefile rules, and call Make to execute the simulation.
[0069] In step S43, after executing the simulation command, the simulation results are verified. The log is checked for pass / fail keywords, key indicators are extracted, waveform files are checked for generation and are not empty, coverage results are verified, and test cases are executed efficiently to generate analyzable results.
[0070] S5. Unified command triggering and result feedback: Input a unified command to simulate the test case and feed the result back to the user.
[0071] In step S5, the user inputs the unified command as run-tc Test_aa. After inputting the unified command, the system automatically completes the compilation and simulation, and judges the result based on the keywords in the log (such as test cases by keywords) and feeds it back to the user.
[0072] The technical principle of this invention is as follows:
[0073] 1. Core Idea: Parameter Centralization and Tool Collaboration
[0074] YAML as a parameter hub:
[0075] All test case parameters (including C compilation, VCS simulation, UVM environment, etc.) are centrally managed through YAML files, achieving "one-stop configuration for global reuse" and avoiding management chaos caused by scattered parameters.
[0076] Toolchain Automation Connection:
[0077] By using Python to parse YAML parameters and driving the gcc and vcs toolchains through Makefile, the entire process from C program compilation to UVM simulation is automated, reducing manual input errors and improving efficiency.
[0078] 2. Key technologies
[0079] Layered configuration and dynamic replacement: Global configuration solves the problem of reusing common parameters, local configuration supports differentiated customization, and the extends and $(variable name) mechanisms further reduce redundant configuration and improve flexibility.
[0080] Data structure mapping: After the YAML parameters are parsed into Python dictionaries, they are mapped one-to-one with the tool command-line parameters through nested structures (such as tool type.parameter name), which facilitates quick invocation.
[0081] Closed-loop verification mechanism: Simulation results are verified through multiple dimensions such as log keywords, waveform files, and coverage to ensure test reliability.
[0082] 3. Technical problems to be solved
[0083] C test cases are isolated from the UVM environment: C programs are compiled using gcc to generate HEX files, which are then integrated into the UVM verification process to achieve hardware and software co-verification.
[0084] Parameter management complexity: YAML's layered configuration and automated parsing reduce parameter maintenance costs and support large-scale use case expansion.
[0085] Manual operation of the toolchain is inefficient: Combining Makefile with Python scripts enables the automatic generation and execution of compilation and simulation instructions, shortening the verification cycle.
[0086] This invention first defines test case parameters in YAML format, ensuring no omissions by identifying the types of parameters to be managed; it creates a global configuration file, global_config.yaml, to store shared parameters, and creates an independent YAML file for each test case to define differentiated parameters, forming a reuse system of "global sharing + local customization". Parameters are split according to tool type, and syntax specifications are established to enhance readability. It supports dynamic replacement of $(variable name), the extends inheritance mechanism, and when conditional parameters, improving configuration flexibility.
[0087] Then, Python is used to parse the YAML file. First, the file location is determined and the content is read. Then, the YAML parsing library is called to convert the text into a dictionary. The syntax is checked and format errors are handled. Global and local configurations are read to achieve parameter overriding and merging. Built-in variables and environment variables are identified and replaced. The parameters are organized into nested dictionaries according to the tool type. Fast access is supported through dot paths. The parsing results are cached to avoid repeated operations, forming a structured parameter storage.
[0088] The process begins by parsing and validating the gcc and UVM environment parameters from YAML, constructing compilation commands and Makefile rules, executing compilation via Make, recording output and handling compilation failures, verifying the generated HEX file format, moving it to the specified path in UVM, cleaning up temporary files, and ensuring that the HEX file can be correctly loaded and executed by UVM through unit tests. Then, it automatically calls VCS for simulation, obtaining VCS parameters and the HEX file path, converting them to command-line format, checking environment variables and creating a working directory, constructing VCS compilation commands, specifying the top-level module to generate Makefile rules, executing compilation and copying the HEX file to the simulation directory, setting UVM variables and waveform file paths, constructing and executing simulation commands, verifying simulation results, and ensuring efficient test execution.
[0089] The end user inputs a unified command, run-tc Test_aa, to trigger the entire process. The system automatically completes compilation and simulation, and automatically determines the result based on the pass / fail keywords in the log, returning feedback information to the user, forming a complete automated closed loop from parameter definition to result feedback.
[0090] Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art can still modify the technical solutions described in the foregoing embodiments or make equivalent substitutions for some of the technical features. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.
Claims
1. An automated simulation method based on YAML, characterized in that, Includes the following steps: S1. Define test case parameters: Define the relevant characteristics of test cases in a global configuration file in YAML format, and centrally manage the parameters related to test cases. S2. Parse YAML files and store parameters: Using Python as a tool, parse the information in the YAML file and store it in a dictionary data structure; S3. Automated compilation of C programs: The test case parameters are divided into categories, and the parameters are input when the corresponding tools are called. The C program is first compiled by gcc through make and the instruction format file aa.hex is generated. aa.hex is placed in the location specified by the UVM test case. S4. Automated simulation by calling VCS: The simulation tool VCS is called through make, with the instruction format file as the input file. At the same time, the corresponding parameters of VCS are entered when running the VCS instructions for compilation. S5. Unified command triggering and result feedback: Input a unified command to simulate the test case and feed the result back to the user.
2. The automated simulation method based on YAML according to claim 1, characterized in that: In step S1, the defined use case parameters include the following: S11. Determine the types of parameters that need to be managed, and review all tools and processes involved in the design; S12. Create global_config.yaml to define default parameters shared by all test cases and perform global configuration. Create an independent yaml file for each test case to define differentiated parameters, with local parameters overriding global default values. S13. Split parameters according to tool type and write YAML file syntax specifications; S14. Use $(variable name) to reference dynamic values in paths and parameters, use the extends keyword to inherit test case parameters in local configurations, and use the when keyword to define conditional parameters. S15. Verify the completeness and correctness of the parameters.
3. The automated simulation method based on YAML according to claim 2, characterized in that: In step S13, the specific content of writing the YAML file syntax specification includes: using indentation to distinguish levels; using camelCase for key names; supporting strings, numbers, lists, and dictionaries for values; and adding comments for the purpose of complex parameters.
4. The automated simulation method based on YAML according to claim 1, characterized in that: In step S1, the managed parameters related to the use cases are used to generate a use case parameter list. The use case parameter list includes VCS compilation options, VCS simulation options, waveform file options, C compilation options, regression name, number of regressions, log file keyword filtering and ignoring, use case error keywords, and use case pass keywords.
5. The automated simulation method based on YAML according to claim 1, characterized in that: In step S2, parsing the YAML file and storing the parameters includes the following steps: S21. Determine the storage location of the yaml file and read its contents; S22. Call the parsing library to convert the YAML text into a Python dictionary, check the correctness of the YAML syntax, read the project-level global YAML configuration, and override the parameters with the same name in the global configuration with the local configuration. S23. Identify variable markers, dynamically replace built-in variables and environment variables, organize parameters into nested dictionaries according to tool type, and locate parameters; S24. Parse the configuration of the specified use case, obtain the parameter values through the dot path, and cache the parsed configuration.
6. The automated simulation method based on YAML according to claim 1, characterized in that: In step S3, the automated compilation of the C program includes the following steps: S31. Parse parameters from YAML, extract GCC-related parameters and UVM environment parameters, and verify the parameters; S32. Construct compilation commands, define Makefile rules, generate Makefile instructions, call Make to execute compilation, record standard output and error output during the compilation process, and verify the compilation results; S33. Obtain the hex_path of the UVM environment from the yaml parameters, construct the complete target path, use system commands to move the file, and create the target file; S34. In the Python script, first parse the YAML parameters, then call the compilation process to perform unit testing and verification.
7. The automated simulation method based on YAML according to claim 1, characterized in that: In step S4, the automated invocation of VCS for simulation includes the following steps: S41. Obtain VCS parameters from YAML, determine the path of the generated aa.hex file, convert the parameter list to a format acceptable to the VCS command line, check whether the UVM environment variables are set correctly, and create the simulation working directory. S42. Build the compilation command, obtain and add compilation parameters from the YAML file, specify the top-level module, and generate Makefile rules; S43. Call Make to execute the compilation, copy the generated aa.hex to the simulation directory, set UVM related variables, create a waveform file directory, build the vcs simulation command, add waveform parameters, update Makefile rules, and call Make to execute the simulation.
8. The automated simulation method based on YAML according to claim 7, characterized in that: In step S43, after executing the simulation command, the simulation results are verified. The verification includes checking whether the log contains keywords, extracting key indicators, checking whether the waveform file is generated and not empty, and verifying the coverage results.
9. The automated simulation method based on YAML according to claim 1, characterized in that: In step S5, the user inputs the unified command as run-tc Test_aa. After inputting the unified command, the system automatically completes the compilation and simulation, and judges the result based on the keywords in the log and feeds it back to the user.
Citation Information
Patent Citations
Software and hardware co-simulation system supporting SOC design full-process development
CN113807037A
UVM and C joint verification method and system
CN115563019A
Compilation simulation method and device for front-end verification and electronic equipment
CN117032886A
Processor verification system based on RISC-V architecture
CN117422026A
Simulation test method, system and equipment and storage medium
CN117909244A