Local-cloud collaborative RTL code optimization method for IP security
By employing a local-cloud collaborative RTL code optimization method, a draft is generated using a local large language model to detect leakage risks and ensure intellectual property security. Then, the code is optimized using a cloud model. This approach resolves the contradiction between intellectual property protection and optimization effectiveness for hardware description language code, thereby improving performance and metrics.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- NANJING UNIV OF POSTS & TELECOMM
- Filing Date
- 2025-12-05
- Publication Date
- 2026-05-05
AI Technical Summary
Existing technologies that utilize large language models to optimize hardware description language code present a contradiction between protecting semiconductor intellectual property rights and achieving optimization results. In particular, they pose security vulnerabilities when deployed in the cloud, and their performance is limited when deployed locally.
We employ a local-cloud collaborative RTL code optimization method with IP security. We generate a draft and extract optimization principles through a local large language model, perform IP leakage detection, and upload the code to the cloud large language model for optimization after verification. This ensures intellectual property security and improves optimization results.
This approach achieves the improvement of hardware description language code performance and power consumption-performance-area metrics by leveraging the optimization capabilities of cloud-based large language models, while protecting semiconductor intellectual property rights, thus resolving the contradiction between intellectual property protection and optimization effectiveness.
Smart Images

Figure CN121979528A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of electronic design automation technology, and in particular to an IP-secure local-cloud collaborative RTL code optimization method. Background Technology
[0002] Large Language Models (LLMs) are being applied in the field of Electronic Design Automation (EDA), especially in digital integrated circuit design. These models can generate and optimize Hardware Description Language (HDL) code, producing Register-Transfer Level (RTL) implementations from functional specifications. They are widely used in industrial environments as auxiliary tools for code development and design optimization.
[0003] The optimization performance of large language models depends on the quality and quantity of training data. However, existing open-source hardware datasets suffer from limited size and a lack of diversity in optimization strategies. High-quality training data, on the other hand, is often found in proprietary codebases containing tested solutions developed by engineers for specific application needs. For example, battery-powered IoT devices reduce power consumption through clock gating, while high-performance accelerators focus on minimizing critical path latency through pipelined techniques. Proprietary IP code embodying such domain-specific strategies contains valuable contextual knowledge that can enhance the optimization capabilities of large language models. Semiconductor intellectual property (IP), including proprietary circuit designs, RTL implementations, and design methodologies, is a strategic asset supporting competitive advantage.
[0004] Current state-of-the-art large language models primarily run as cloud services, but they suffer from security vulnerabilities when handling sensitive design data. Proprietary Verilog IP may be stored and remembered during large language model fine-tuning, posing a risk of leakage. Furthermore, powerful models achieve power consumption-performance-power absorption (PPA)-aware optimization, but require uploading proprietary code. While locally deployed large language models can address privacy concerns, their performance is limited. Hybrid approaches employ retrieval-enhanced generation techniques, but still expose design patterns to external services. These solutions primarily focus on optimization effectiveness but fail to resolve the fundamental conflict between privacy protection and performance.
[0005] In summary, this invention aims to propose a local-cloud collaborative RTL code optimization method for IP security. Under the premise of ensuring the security of semiconductor intellectual property rights, it utilizes the optimization capabilities of cloud-based large language models to achieve effective optimization of hardware description language code. Summary of the Invention
[0006] The technical problem to be solved by the present invention is to address the shortcomings of the prior art by providing an IP-secure local-cloud collaborative RTL code optimization method. This IP-secure local-cloud collaborative RTL code optimization method resolves the contradiction between semiconductor intellectual property protection and optimization effect in the hardware description language code optimization process through principle abstraction and verification, and makes full use of the capabilities of local and cloud-based large language models.
[0007] To solve the above-mentioned technical problems, the technical solution adopted by the present invention is as follows:
[0008] A method for optimizing IP-secure local-cloud collaborative RTL code includes the following steps.
[0009] Step 1, Dataset Construction: Utilizing a large local language model based on the selected proprietary module P i Generate a first draft This results in a proprietary code set with K pairs of proprietary modules and an initial draft. Where 1≤i≤K.
[0010] Step 2, Locality Principle Extraction: Utilizing a local large language model to extract locality principles. Extract from To P i Optimization principle set .
[0011] Step 3, Local IP Leakage Detection: Using a local large language model, optimize the set of principles. Perform IP leakage risk detection and verification; if the verification is successful, proceed to step 5; otherwise, it is determined that the verification failed, the leakage feedback value is recorded and proceed to step 4.
[0012] Step 4: Feed the leakage feedback value from Step 3 back to the local large-scale language model in Step 2, and repeat Steps 2 to 4 to re-optimize the principle set. Extraction and local IP leak detection, up to the set of optimization principles. Leakage verification passed.
[0013] Step 5: Optimize the set of principles that have passed the leakage verification. Uploaded to the cloud-based large language model; the cloud-based large language model utilizes an optimization principle set. Optimize the target module.
[0014] Step 1, the method for constructing the dataset, includes the following steps.
[0015] Step 1-1: Select K representative proprietary modules P from the public dataset. i .
[0016] Steps 1-2: Using a local large-scale language model based on functional specifications, divide the K proprietary modules P... i Generate K one-to-one corresponding first drafts This results in K modules that are paired with the initial draft code. .
[0017] Steps 1-3: Perform PPA analysis on the K modules and the initial draft code through simulation to obtain the PPA index for each pair of proprietary modules and the initial draft.
[0018] In step 1-1, the proprietary module P i All were selected from the Resyn27k subset of RTLCoder, each proprietary module P i All include natural language design specifications and corresponding Verilog implementations; proprietary module P i The number K is no less than 1000, covering nine functional categories: multiplier, FIFO, ALU, shift register, counter, decoder, state machine, arbitrator, and bit width configuration.
[0019] In step 1, K includes maximum power reduction samples and maximum latency reduction samples for both proprietary modules and the initial draft. Each sample includes a functional specification, two Verilog implementations, and the corresponding PPA metric.
[0020] In step 2, the set of optimization principles The expression is:
[0021] (1)
[0022] In the formula, This is the leakage feedback value at the previous iteration t-1; at the initial iteration t=1, The default value is empty, with no leakage.
[0023] Prompt text to guide the local large language model in comparing proprietary code and initial drafts to extract optimization principles.
[0024] In step 3, the output model for detection and verification is: The specific expression is:
[0025] (2)
[0026] In the formula, This represents the result of the current t iterations. This indicates that the verification has passed. This indicates that the verification failed.
[0027] This is the leakage feedback value for the current t iterations.
[0028] To guide the validation and optimization of the principle set for local large language models Does it contain a prompt text indicating whether it contains proprietary information?
[0029] In step 5, the target module optimized from the cloud-based large language model is denoted as... The specific expression is:
[0030] (3)
[0031] In the formula, N represents the target module to be optimized.
[0032] To guide the optimization of the principle set after verification of cloud-based large language model applications. Optimize the tooltip text for the new code.
[0033] A storage medium storing a computer program that, when run, executes an IP-secure local-cloud collaborative RTL code optimization method.
[0034] An electronic device, including a storage medium.
[0035] The present invention has the following beneficial effects: The present invention uses a local large language model to extract optimization principles from the proprietary code and the initial draft code pair, verifies the security of the principles through a local IP protection module, and finally uses a cloud-based large language model to apply the verified principles to optimize the code. This can resolve the contradiction between semiconductor intellectual property protection and optimization effect in the process of hardware description language code optimization, and make full use of the capabilities of local and cloud-based large language models. Attached Figure Description
[0036] Figure 1 The flowchart of a local-cloud collaborative RTL code optimization method for IP security according to the present invention is shown.
[0037] Figure 2 The flowchart of the code optimization process based on design principles proposed in this invention is shown, using a comparative PPA analysis.
[0038] Figure 3 The diagram shows an example of critical path optimization within the framework proposed in this invention. Detailed Implementation
[0039] The present invention will now be described in further detail with reference to the accompanying drawings and specific preferred embodiments.
[0040] In the description of this invention, it should be understood that the terms "left side," "right side," "upper part," "lower part," etc., indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings. They are only for the convenience of describing this invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. "First," "second," etc., do not indicate the importance of the components, and therefore should not be construed as a limitation of this invention. The specific dimensions used in this embodiment are only for illustrating the technical solution and do not limit the scope of protection of this invention.
[0041] like Figure 1 and Figure 2 As shown, a local-cloud collaborative RTL code optimization method for IP security includes the following steps.
[0042] Step 1, Dataset Construction: Utilizing a large local language model based on the selected proprietary module P i Generate a first draft This results in a proprietary code set with K pairs of proprietary modules and an initial draft. Where 1≤i≤K, and the quantity K is not less than 1000.
[0043] The method for constructing the above dataset includes the following steps.
[0044] Step 1-1: Select K representative proprietary modules P from the public dataset. i .
[0045] To achieve a comprehensive evaluation, this invention constructs an open PPA benchmark that includes functionally equivalent Verilog implementations that exhibit measurable performance gaps in power consumption, performance, and area metrics.
[0046] The dataset construction pipeline began with the Resyn27k subset of RTLCoder, which contains 27,000 instruction-code pairs, each including a natural language design specification and a corresponding Verilog implementation. Automated synthesis verification using Xilinx Vivado filtered out syntactically correct and synthesizable designs, resulting in 8,531 valid candidates. These selected modules were then categorized by functional type (multiplier, FIFO, ALU, shift register, counter, decoder, state machine, arbitrator) and bit width configuration, yielding 2,163 representative proprietary modules P covering nine functional categories. i .
[0047] Steps 1-2: Using a local large-scale language model based on functional specifications, divide the K proprietary modules P... i Generate K one-to-one corresponding first drafts This results in K modules that are paired with the initial draft code. .
[0048] The above draft For the corresponding module P i Code that is functionally equivalent but performs poorly.
[0049] Steps 1-3: Perform PPA analysis on the K modules and the initial draft code through simulation to obtain the PPA index for each pair of proprietary modules and the initial draft.
[0050] This invention uses Synopsys Design Compiler to synthesize all [materials / technology] under standardized constraints (100 MHz target frequency, 28 nm technology node). Yes, and extract three key indicators from them: unit area Dynamic power consumption (mW) and critical path delay (ns). Calculate each proprietary implementation pair. Compared to the first draft The relative improvement across three metrics was then analyzed. The code pairs were then categorized based on the dominant improvement dimension: 1,196 pairs showed maximum power consumption reduction (average: 22.3%), and 967 pairs showed maximum latency reduction (average: 18.7%). The resulting dataset contains 2,163 PPA comparison samples, covering nine design categories. Each sample includes the functional specification, two Verilog implementations, and the corresponding PPA metric.
[0051] The principle-based code optimization process uses comparative PPA analysis, such as... Figure 2 As shown, preprocessing creates a comparative dataset for extracting principles, collects Verilog code from datasets such as Resyn27k, and collects PPA (power consumption, performance, area) results through simulation.
[0052] Step 2, Locality Principle Extraction: Utilize the local large language model (e.g., Qwen2.5-7B-Instruct) to extract locality principles. Extract from To P i Optimization principle set The preferred expression
[0053] (1)
[0054] In the formula, This is the leakage feedback value at the previous iteration t-1; at the initial iteration t=1, The default value is empty, with no leakage.
[0055] The above To guide the local large language model in comparing proprietary code and initial drafts to extract optimization principles, the hint text needs to be specific to guide optimization, but should not reveal implementation details. For example, when optimizing critical path latency consumption, one principle might be: "Avoid using deeply nested logic in 'assign' statements as much as possible," rather than exposing specific proprietary implementations.
[0056] Step 3, Local IP Leakage Detection: Using a local large language model, optimize the set of principles. Perform IP leakage risk detection and verification; if the verification is successful, proceed to step 5; otherwise, it is determined that the verification failed, the leakage feedback value is recorded and proceed to step 4.
[0057] The output model of the above detection and verification is The preferred specific expression
[0058] (2)
[0059] In the formula, This represents the result of the current t iterations. This indicates that the verification has passed. This indicates that the verification failed.
[0060] This is the leakage feedback value for the current t iterations.
[0061] To guide the validation and optimization of the principle set for local large language models The text prompts whether it contains proprietary information; where proprietary information includes proprietary code snippets, specific implementation details, or information that can uniquely identify proprietary designs and must not be disclosed.
[0062] Step 4: Feed the leakage feedback value from Step 3 back to the local large-scale language model in Step 2, and repeat Steps 2 to 4 to re-optimize the principle set. Extraction and local IP leak detection, up to the set of optimization principles. Leakage verification passed.
[0063] Step 5: Optimize the set of principles that have passed the leakage verification. Uploaded to the cloud-based large language model; the cloud-based large language model utilizes an optimization principle set. Optimize the target module to be optimized as follows: The specific expression is:
[0064] (3)
[0065] In the formula, N represents the target module to be optimized.
[0066] The above To guide the optimization of the principle set after verification of cloud-based large language model applications. Optimize the tooltip text for the new code.
[0067] Furthermore, the aforementioned cloud-based large language model is preferably an Instruct+V3 hybrid model or a Coder+R1 hybrid model, etc.
[0068] In summary, this invention uses a local large language model based on functional specifications, from proprietary code Generate functionally equivalent draft code proprietary code and initial draft code Organization The dataset was compared. The first stage involved local principle extraction, using a large local language model deployed locally with full access to proprietary code to ensure IP address confidentiality. Then, each pair was compared and analyzed. The performance differences between high-quality and low-quality code are analyzed. By comparing high-quality and low-quality code, key methods leading to performance improvements are identified and summarized as design principles. At this stage, these principles are considered insecure because the risk of IP leakage still exists. The second stage involves local IP leakage detection, using another local large language model instance as a local IP protection module to check whether the extracted principles leak any proprietary code details. If a leakage risk is detected, detailed feedback is output, and the process returns to stage one for iterative revision of the principles. Only those that pass verification are marked as secure principles. Stage three involves cloud code generation, which only generates the secure principles and the initial draft code to be optimized. The code is sent to the cloud-based large language model, without accessing any proprietary code at this stage. The cloud-based large language model optimizes the initial draft code according to the received security principles, resulting in optimized code. This optimized code shows improvements in power consumption, performance, and area.
[0069] This invention achieves performance improvements across various model combinations (Instruct+V3, Coder+R1, etc.), as shown in Table 1 below. Cloud-based models for IP data access exhibit high success rates in timing and power optimization; for example, DeepSeek-v3 achieves a power optimization success rate of 65.92%, and R1 achieves a timing optimization success rate of 50.85%. However, uploading proprietary IP data to cloud servers poses significant security risks. This invention addresses this issue by combining the security advantages of local models with the optimization capabilities of large-scale cloud models, enabling even weaker open-source models to achieve results superior to proprietary baselines.
[0070] Table 1
[0071]
[0072] In Table 1 above, SR represents the success rate, which is the proportion of examples where the measurement optimization is functionally correct (through the same test bench as the original) and the target metric value is lower than the original value.
[0073] Relative improvement quantifies the magnitude of improvement in successful cases, specifically:
[0074] Relative improvement = (Original value - Optimized value) / Original value × 100%
[0075] Here, the initial value and the optimized value represent the target index values before and after optimization, respectively.
[0076] In critical path delay optimization, Qwen2.5-Instruct-7B + DeepSeek-V3 achieved a success rate of 50.85%, which is 50% higher than the standalone DeepSeek-V3 (33.90%) and surpasses the proprietary GPT-4o baseline (45.76%).
[0077] For power optimization, the same combination achieved a success rate of 66.67%, which is better than the standalone DeepSeek-V3 (49.81%) and close to the performance of top proprietary models such as Gemini-2.5-Flash.
[0078] The Qwen2.5-Coder-7B + DeepSeek-R1 combination showed continuous improvement across both metrics.
[0079] The success rate in timing optimization was 44.07% (an 8.3% improvement over DeepSeek-R1's 40.68%), and the success rate in power optimization was 57.30% (an 18.6% improvement over DeepSeek-R1's 48.31%).
[0080] Furthermore, the design principles of this invention allow different cloud-based large language models to exhibit unique advantages. DeepSeek-V3 shows significant gains in timing performance optimization, while DeepSeek-R1 demonstrates substantial improvements in power consumption optimization. This indicates that different model architectures, guided by the framework of this invention, possess complementary advantages, enabling them to leverage their respective strengths to achieve specific optimization objectives.
[0081] Table 2
[0082]
[0083] As shown in Table 2 above, this invention demonstrates six improved module examples, and... Figure 3This paper provides a representative case study. It demonstrates that the local model can extract effective design principles to guide significant optimization of a large language model in the cloud, and protects the IP by not uploading the actual RTL code. Figure 3 illustrates how the local model extracts key optimization principles, enabling the large language model in the cloud to reduce critical path latency from 2.76 ns to 2.13 ns, an improvement of 22.83%, by refactoring the calculator's parallel pre-computation arithmetic results. It proves that principle-based guidance is more effective than direct code optimization, and the extracted principles lead to significant improvements for different optimization objectives. For critical path latency, this invention converts the carry-propagating adder to a parallel prefix architecture (3.12% improvement) and folds a multi-stage barrel shifter into a single combinational logic (6.90% improvement). For power consumption optimization, even greater reductions are achieved: by simplifying the shifter to replace the FSM logic, transmitter power consumption is reduced by 81.77% (from 70.49 µW to 12.85 µW), while Schmitt triggers reduce power consumption by 46.39% by eliminating redundant state storage. These results validate that the framework of this invention can achieve effective collaboration between local and cloud-based large language models, performing architectural restructuring rather than superficial modifications.
[0084] The present invention also provides a storage medium, wherein a computer program stored in the storage medium executes the above-described IP-secure local-cloud collaborative RTL code optimization method when running.
[0085] The present invention also provides an electronic device including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the above-described IP-secure local-cloud collaborative RTL code optimization method via the computer program.
[0086] The sequence numbers of the above embodiments of the present invention are merely for description and do not represent the superiority or inferiority of the embodiments. In the above embodiments of the present invention, the descriptions of each embodiment have their own emphasis; for parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments. In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. The device embodiments described above are merely illustrative. For example, the division of units can be a logical functional division, and in actual implementation, there can be other division methods. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Furthermore, the displayed or discussed mutual coupling or direct coupling or communication connection can be through some interfaces; the indirect coupling or communication connection of units or modules can be electrical or other forms. The units described as separate components may or may not be physically separated; the components shown as units may or may not be physical units, that is, they can be located in one place or distributed across multiple units. Some or all of the units can be selected according to actual needs to achieve the purpose of this embodiment. Furthermore, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit. If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes: USB flash drives, read-only memory (ROM), random access memory (RAM), portable hard drives, magnetic disks, optical disks, and other media capable of storing program code.
Claims
1. A method for optimizing IP-secure local-cloud collaborative RTL code, characterized in that: Includes the following steps: Step 1, Dataset Construction: Utilizing a large local language model based on the selected proprietary module P i Generate a first draft This results in a proprietary code set with K pairs of proprietary modules and an initial draft. Where 1≤i≤K; Step 2, Locality Principle Extraction: Utilizing a local large language model to extract locality principles. Extract from To P i Optimization principle set ; Step 3, Local IP Leakage Detection: Use a local large language model to optimize the principle set. Perform IP leakage risk detection and verification; if the verification is successful, proceed to step 5; otherwise, it is determined that the verification failed, the leakage feedback value is recorded and proceed to step 4. Step 4: Feed the leakage feedback value from Step 3 back to the local large-scale language model in Step 2, and repeat Steps 2 to 4 to re-optimize the principle set. Extraction and local IP leak detection, up to the set of optimization principles. Leakage verification passed; Step 5: Optimize the set of principles that have passed the leakage verification. Uploaded to the cloud-based large language model; the cloud-based large language model utilizes an optimization principle set. Optimize the target module.
2. The IP-secure local-cloud collaborative RTL code optimization method according to claim 1, characterized in that: Step 1, the method for constructing the dataset, includes the following steps: Step 1-1: Select K representative proprietary modules P from the public dataset. i ; Steps 1-2: Using a local large-scale language model based on functional specifications, divide the K proprietary modules P... i Generate K one-to-one corresponding first drafts This results in K modules that are paired with the initial draft code. ; Steps 1-3: Perform PPA analysis on the K modules and the initial draft code through simulation to obtain the PPA index for each pair of proprietary modules and the initial draft.
3. The IP-secure local-cloud collaborative RTL code optimization method according to claim 2, characterized in that: In step 1-1, the proprietary module P i All were selected from the Resyn27k subset of RTLCoder, each proprietary module P i All include natural language design specifications and corresponding Verilog implementations; proprietary module P i The number K is no less than 1000, covering nine functional categories: multiplier, FIFO, ALU, shift register, counter, decoder, state machine, arbitrator, and bit width configuration.
4. The IP-secure local-cloud collaborative RTL code optimization method according to claim 1, 2, or 3, characterized in that: In step 1, K includes maximum power reduction samples and maximum latency reduction samples for both proprietary modules and the initial draft. Each sample includes a functional specification, two Verilog implementations, and the corresponding PPA metric.
5. The IP-secure local-cloud collaborative RTL code optimization method according to claim 1, characterized in that: In step 2, the set of optimization principles The expression is: (1) In the formula, This is the leakage feedback value at the previous iteration t-1; at the initial iteration t=1, The default value is empty, with no leakage. Prompt text to guide the local large language model in comparing proprietary code and initial drafts to extract optimization principles.
6. The IP-secure local-cloud collaborative RTL code optimization method according to claim 1, characterized in that: In step 3, the output model for detection and verification is: The specific expression is: (2) In the formula, This represents the result of the current t iterations. This indicates that the verification has passed. This indicates that the verification failed. This is the leakage feedback value for the current t iterations; To guide the validation and optimization of the principle set for local large language models Does it contain a prompt text indicating whether it contains proprietary information? 7. The IP-secure local-cloud collaborative RTL code optimization method according to claim 1, characterized in that: In step 5, the target module optimized from the cloud-based large language model is denoted as... The specific expression is: (3) In the formula, N represents the target module to be optimized; To guide the optimization of the principle set after verification of cloud-based large language model applications. Optimize the tooltip text for the new code.
8. The IP-secure local-cloud collaborative RTL code optimization method according to claim 1, characterized in that: In step 7, the cloud-based large language model is either an Instruct+V3 hybrid model or a Coder+R1 hybrid model.
9. A storage medium, characterized in that: When the computer program stored in the storage medium is run, it executes the IP-secure local-cloud collaborative RTL code optimization method according to any one of claims 1-8.
10. An electronic device, characterized in that: Includes the storage medium as described in claim 9.