Manuscript Offprint
arXiv:2610.32597Automated Multi-Line Bug Repair Using Model Checker Aided LLMs: A Case Study on RISC-V Processors
Debleena Das*§, Chandan Kumar Jha†, Muhammad Hassan†‡, Rolf Drechsler†‡, Ansuman Banerjee*, Subhra K. Das¶, Amlan Chakrabarti§
- Indian Statistical Institute, India, †University of Bremen, Germany, ‡DFKI GmbH, Germany
§ A. K. Choudhury School of Information Technology, University Of Calcutta, India, ¶ Thales India Private Limited, India
Abstract—Functional verification of Register-Transfer Level (RTL) designs has become a critical bottleneck in modern semiconductor development, often consuming the majority of project resources. Debugging, in particular, remains an especially time-consuming task, requiring careful analysis of simulation traces or counterexamples. Recent work has explored applying Large Language Models (LLMs) to RTL debug and repair with great promise. However, the existing approaches typically are for single-line bugs, operate in open-loop, rely heavily on prompts or retrieval, lack scalability, and often produce incorrect fixes. In this paper, we propose a novel automated RTL bug repair methodology that combines LLMs, assertions, and a model checker to provide scalable, trustworthy semantic grounding and formal guarantees. Concretely, the methodology leverages failing assertions to guide the LLM in generating patches for multi-line bugs. Each candidate patch is formally verified using a model checker (JasperGold), ensuring only valid repairs are accepted. We evaluate the efficacy and scalability of our methodology on the BRISC-V RISC-V core using mutation testing, introducing several mutation types, and demonstrate that our methodology can repair up to 98% of single-line RTL bugs and 93% of the multi-line bugs. To the best of our knowledge, this is the first work to show automated, LLM-assisted RTL multi-line bug repair results on a complex RISC-V processor design in a scalable manner.
I. INTRODUCTION
Functional verification of Register-Transfer Level (RTL) designs has emerged as a principal bottleneck in the semiconductor development process, often consuming up to 70% of overall project resources [1], [2]. This growing burden is largely driven by the increasing complexity and functional richness of modern digital systems, which incorporate deep pipelines, multiple interacting sub-systems, and a variety of protocols and timing constraints. As designs scale in size and sophistication, the verification effort required to ensure correctness and safety has grown disproportionately. Among the various verification tasks, debugging, i.e., identifying and correcting functional errors in Hardware Description Language (HDL) code remains particularly time-consuming. It often requires manual analysis of simulation traces or counterexamples, and demands a detailed understanding of both the design intent and implementation [3], [4].
In recent times, Large Language Models (LLMs) have shown success in software engineering tasks such as code generation and automated program repair. This success has motivated research on applying LLMs to hardware design tasks [5], [6], with studies exploring RTL code generation [7]–[9], security bug fixes [10], and syntax error correction [11], [12].
In particular, a number of recent research articles have reported efforts on using LLMs to generate SystemVerilog Assertions (SVAs) from various inputs such as natural-language specifications, source code comments, or even the RTL code itself [13]–[17]. Frameworks like AssertLLM and Spec2Assertion translate design specifications into formal properties, easing the burden of writing assertions manually [18], [19]. Other research has demonstrated iterative, human-in-the-loop flows where feedback from a formal verification tool is used to refine LLM-generated assertions [20], using techniques

Fig. 1: Workflow of LLM-assisted automated bug repair methodology
like Retrieval Augmented Generation (RAG), Chain-Of-Thought (COT), and agentic frameworks [21], [22]. Although these advances streamline the creation of verification artifacts, they do not directly address the task of repairing a buggy RTL.
There have been recent attempts to repair RTL using LLM-based methods.
AssertSolver [23] trains an LLM on a large synthetic dataset of bugs, failure logs, and fixes, enabling it to predict code patches from a given assertion failure log. These methods can suggest plausible fixes, but rely on a static pre-trained model and perform the repair in a single pass. The HDLdebugger framework introduces a retrieval-augmented fine-tuning approach, and along with HDL documents, the LLM takes the buggy code, its error message, task prompt, and code RAG, and the edit distance between the correct code and the buggy code is their evaluation metric [24]. Other bug-patching strategies [25], [26] employ an iterative “bug closure” process using RAG to incorporate design specifications. If the initially retrieved context is insufficient, these methods repeatedly pull in more specification content or code context and re-prompt the LLM. This iterative method can eventually find a fix for up to 60% of the reported bugs.
While these methods have shown a lot of promise by fixing many of the reported bugs, these works focus on single-line bugs, lack trustworthy semantic grounding in a scalable manner, and typically run open-loop. Hence, the identification and fixes often tend to be plausible but wrong.
Contribution: We propose a novel automated RTL bug repair methodology for both single and multi-line bugs that uses LLMs, assertions, and a model checker to synthesise bug patches on a complex RISC-V processor in a scalable manner. More concretely, the goal is to leverage the semantic structure of assertions and the output of a model checker to build a context for the LLM, so that it can propose an accurate fix. Consequently, it provides a trustworthy grounding and formal guarantees as the model checker provides an objective oracle.
To this end, our methodology is two-fold:
Your task: 1 Please identify the bug in the given block of code: ...
Prompt 1: Role setup for the LLM in Stage 1
First, the user asks the LLM to generate the patch only from the buggy code. Second, we provide the failing assertions in addition to the buggy code to aid in the correction process. In both steps, the proposed patch is always formally verified using a model checker. For scalability, we conducted an extensive set of experiments on BRISC-V [27] where we took advantage of mutation testing [28]. Mutation testing allows for a comprehensive assessment of the quality and thoroughness of the verification process by introducing controlled modifications in the given design. We study 10 mutation classes. 9 mutations from the existing literature and 1 new mutation, which injects an "if-else" indentation bug [26]. We inject the mutations in the RTL using LLM. Our proposed method was able to fix up to 98% of the single-line bugs and 93% of the multi-line bugs certified by the model checker. To the best of our knowledge, this is the first work to present an automated LLM-assisted repair result on a complex RISC-V processor code. Our contributions are summarized below:
• We propose a novel LLM-assisted automated RTL bug repair approach with assertions and a model checker in the loop, which provides trustworthy semantic grounding and formal guarantees.
• The methodology successfully fixes single-line and multi-line bugs, where the bug could be anywhere in the procedural blocks.
• We experiment using mutation testing with a set of 10 mutation classes on an open source RISC-V IP, on different modules with a mix of auto-generated and hand-written assertions.
• We implement an immediate prior art [26] (referred to as Stage 1 in our experiments) on LLM-aided RTL repair, and provide comparative results. As seen from our experiments, the presence of assertions indeed helps the fixing task.
II. MOTIVATING EXAMPLE
In this section, we present a small example with a bug in RTL to highlight the problem in using open-loop methods, which do not have trustworthy grounding. The example is a code snippet from the Cache Coherence Controller (CCC) module inside BRISC-V. The CCC typically implements one of the cache coherence protocols to ensure coherence and consistency of data shared across multiple cores [29]. In the BRISC-V core used in this work, the MESI protocol is implemented. In particular, the CCC code describes a finite state machine highlighting the different states of the snoop operation, with 7 different states and respective transitions. This module has an assertion suite consisting of 56 concurrent assertions, all of which evaluate to true when run using the model checker JasperGold [30]. We inject a conditional bug by inverting the "if conditional" statement. The original code was "if (hit) begin" and after the bug injection, it was changed to "if (!hit) begin".
As shown in Prompt 1, a verbose prompt was provided to the LLM to suggest a fix for the mutation. In response to Prompt 1, the LLM was unable to identify the correct patch and produced a hallucination, as shown in Reply 1. This happened despite the simple nature of the single-line bug. This highlights the limitation of only
AI Reply
1 Possible dead/looping path in WAIT_FOR_RESP when line_counter == ratio and intf_msg == MEM_RESP.
2 3 (intf_msg == MEM_RESP) begin 4 r_snoop_msg <= EN_ACCESS; 5 r_snoop_address <= r_bus_address; 6 ... clear r_snoop_data ... 7 state <= WAIT_FOR_RESP; 8 end
Reply 1: LLM's reply to first prompt
using the LLM for bug fixing. Prior works have shown that some of the bugs can be corrected by iteratively prompting the LLM. However, the approach is still non-deterministic and can require an arbitrary number of iterations. In addition, these analysis were limited to single-line bugs. In our work, we alleviate this limitation by using high-quality assertions and a model checker in the loop.
Prior works have relied solely on LLMs for the bug-fixing methodology, greatly limiting their applicability and potential. In this work, rather than only relying on LLMs, we show that having assertions and a model checker in the loop can largely aid and improve the bug-fixing process. We show that using the proposed methodology, we can fix bugs in larger circuits like a RISC-V processor, which has also been chosen as the case study in this work. In addition, while the prior works have mostly been limited to single-line bugs, we show that the proposed methodology is effective for both single-line and multi-line bugs.
III. LLM-ASSISTED AUTOMATED BUG REPAIR
This section presents our LLM-assisted automated RTL bug repair methodology with assertions and a model checker in the loop, which provides trustworthy grounding and formal guarantees. Fig. 1 shows a high-level workflow of our proposed methodology, which takes in RTL code and a set of assertions and carries out 2 steps. First, we take the assertions and pass them to JasperGold, which runs the assertions on the code and produces the set of Failed Assertions. The second phase consists of 2 stages, Stage 1: the LLM is asked to repair the buggy code without any additional context. If the bug is not repaired, then in Stage 2: the set of failed assertions is provided to the LLM in addition to the code, and it is asked to repair the code. If the bug is repaired, then "Code Repaired" is reported, and if the bug is not repaired after Stage 2, "Code not repaired" is reported. We now elaborate on each of the two Stages in detail.
A. Proposed Methodology
Given an RTL design R, a set of assertions P, and a set of bug types, our objective is to be able to localize the bugs of each of the given types and generate fixes with the help of an LLM and a formal verification tool. We assume the bugs can be in any single-line or across multiple-lines anywhere in the RTL code. Also, all assertions in the set P hold on R, when evaluated using the formal verifier, which evaluates an assertion on all possible scenarios before concluding a pass. Fig. 1 shows a high level workflow of our proposed methodology, comprising of 2 main Phases: 1) Phase-1: Assertion Status Check, and 2) Phase-2: Debugging.
-
Phase-1 Assertion Status Check: After obtaining the mutated piece of code from the LLM, it is inserted into R, on which the next steps are carried out. The mutated code is then run in JasperGold against P. Due to the presence of single- or multiple-line mutations that act as bugs in this work, some assertions may result in counterexamples (CEX), showing that these assertions were violated in the design.
-
Phase-2: Debugging: Our repair phase comprises 2 Stages, as discussed below. After each Stage, the patches suggested by the LLMs are examined by the JasperGold tool. If all assertions pass, we conclude that the bugs have been repaired.
• Stage 1: We first provide the mutated code, i.e., the buggy code, and ask the LLM to identify the bugs. The LLM is only provided with the information that the code has bugs, and we want to repair the bug. No additional information is provided at this Stage to the LLM. Each patch generated is examined through the formal verifier against the mutated code, and the number of Failed assertions are counted. If the number of Failed assertions is reduced, then it is considered a correct patch suggested by the LLM. This can happen as in multi-line bugs, as some of the bugs can be corrected, while for the others we may need to go to the Stage 2. We proceed to the next step if the verifier reports that some assertions produce a violation leading to counterexamples.
• Stage 2: Assume out of the set P, a total of N assertions fail in the presence of single-line or multi-line mutations, i.e., bugs. We add these failing assertions to the LLM in the same context window, asking for a patch as shown in Prompt 2. Evidently, this brings in more context to the LLM to understand the bug, in the context of the code block and the failing assertion(s). Note that in the prior state-of-the-art [26], only the line with the bug was given to the LLM for correction. This further highlights the limitation of the prior approach, that the line with the bug needed to be identified before the LLM suggested a patch. However, in our work, we give the entire code block with the bug. Some patches are suggested by the LLMs that are checked to see, if all the assertions are now passing (as shown in Reply 2). If all the assertions are passing at this stage we say that the bugs in the design has been repaired.
Hence, we clearly see that using the proposed method, we not only are able to perform debugging on multi-line bugs, but we are also using the model checker to guarantee that the generated patch is indeed correct. In the following section, we present our experience on the BRISC-V code base with the mutations.
B. Case Study: RISC-V Processor
In this section, we revisit the motivating example from Section II and illustrate the effectiveness of the proposed LLM-assisted bug repair methodology. As mentioned earlier, the LLM was not able to patch the bug. When the mutation was inserted in the Snooper RTL code inside the CCC, several assertions produced counterexamples. When one such failing assertion was passed on to the LLM, the nature of the reply changed. With the structured content of an assertion, the LLM gained more context, and it could identify and repair the bug as shown in Reply 2. In this stage, we invoked the LLM with the prompt shown in Prompt 2, embedding one failing assertion inside to aid in its introspection.
The response received from the LLM is outlined in Reply 2. It clearly explains (a) the perceived cause of the bug, (b) the reason for the presence of the bug, and (c) a suitable patch to fix it. Indeed, the patch given in Reply 2 fixes the issue, thereby asserting the LLM's ability to clearly identify the context and the mutation. It was able to achieve this even though it was not explicitly informed about the location of the bug or the mutation type. This reinforces the fact that the proposed methodology can patch the bugs correctly while providing formal guarantees at the same time. In addition, it advances the state of the art, where only the lines with bugs
User Prompt
Your Task: 2 Your provided solution is incorrect. Please identify the bugs in the following SystemVerilog code based on the given failed assertions on the buggy code. The list of failed assertions on the buggy code:
1 property rfobcast_hit_ratio; 2 @ (posedge clock) disable iff (reset) 3 state == ACTION && r_bus_msg == RFO_BCAST && hit && (line_counter == ratio) |-> 4 ##1 state == WAIT_FOR_RESP && r_snoop_msg == EN_ACCESS && r_invalidate == 1; 5 endproperty 6 ...
Prompt 2: Role setup for the LLM
AI Reply
Identified Bug
1 In the ACTION RFO_BCAST branch the hit test is inverted. The code uses if (!hit) where it should use if (hit).
2
Reason of the Bug
1 When the cache has the line (hit) the FSM takes the non-hit path, so r_invalidate is not asserted.
2 That directly breaks the assertions that expect r_invalidate==1 and a transition to WAIT_FOR_RESP / INVALIDATE_LINE when hit is true.
Patching
1 RFO_BCAST: begin 2 (hit) first 3 if (hit) begin 4 if (line_counter == ratio) begin 5 ...
Reply 2: LLM reply to second prompt
were given to the LLM for correction [26]. This case studied in the prior works is also impractical in certain scenarios, as they assume that the line with the bug is known a priori. Unlike prior work, a section of code with the buggy line is given to the LLM in our methodology. We want to highlight that this simple example was chosen to highlight the efficacy of our methodology.
IV. EXPERIMENTAL EVALUATION
In this section, we discuss the experimental setup, bug insertion, and the results obtained using the proposed methodology.
A. Experimental Setup
The experimental evaluation is carried out on several modules of the BRISC-V core [31], an open source implementation of a parameterized, synthesizable, multicore architecture. We use JasperGold [30] as the formal verification tool and GPT-5.5 [32] as the LLM. All assertions used throughout the experiment, both before and after the mutation insertion, are verified using JasperGold.
- Prompts: For prompting the LLM, we use the OpenAI web-based ChatGPT interface with the GPT-5.5 model. This web-based version of the LLM instance can keep track of the code once it is assigned as a role, and we get the output iteratively, providing multiple tasks. The same can also be automated using the API calls. However, for this work, we have used the web interface. Initially, the code is given to the LLM, and then the role of the LLM is defined. To set the context of the LLM, we set the roles of the LLM as an expert in RTL assertion verification engineering with 25 years of experience in SystemVerilog HDL design. If it is given a
Example of Nested If-else Mutation
| 1 | REQ_FLUSH: begin | 1 | REQ_FLUSH: begin |
|---|---|---|---|
| 2 | if (hit) begin | 2 | if (hit) begin |
| 3 | if (dirty) | 3 | ... |
| begin | 4 | end | |
| 4 | ... | 5 | |
| 5 | end | 6 | else if (dirty) |
| 6 | else begin | begin | |
| 7 | if (line_counter == ratio) | 7 | if (line_counter == ratio) |
| begin | 8 | .... | |
| 8 | ... | 9 | end |
| 9 | end | 10 | else begin |
| 10 | else begin | 11 | ... |
| 11 | ... | 12 | end |
| 12 | end | 13 | end |
| 13 | end | 14 | |
| 14 | Mutated Code | ||
| Correct Code | |||
Fig. 2: Correct and Mutated code before and after Nested If-else Mutation
User Prompt
You are an expert in mutation generation of SystemVerilog code. These are the types of mutations that you need to generate. (Types of mutation described)
Task 1: Generate only one "Mutation type" Mutation in the original reference design and give me the output.
Prompt 3: Mutation Insertion Prompt
hardware design in SystemVerilog, it can detect the bug and patch it. With the role-playing setup, we try to improve responses aligned with assigned roles [33]. In Section IV-C, we discuss the results obtained for each of the Stages in detail in Table II.
-
Assertions: Assertions play a key role in our overall workflow. For some of the modules, assertions were manually generated, while for others, assertions were generated using an LLM in a different session. The important metric of the generated assertion is the formal coverage of the assertion suite, which gives confidence in the proof span of the assertions with respect to the code statements, states, transitions, and faults. Given an RTL model and a set of assertions, JasperGold provides this information to a verification engineer, which guides one in assertion IP development. We utilize this feature crucially in our work. If the assertion coverage is low, it may not always be possible to get failing assertions that can aid in localization. Also, it may be noted that the generation of high coverage assertion IPs is a challenge. One of the important concerns in not being able to reproduce the experiments reported in [26] is the lack of useful assertions for the OpenTitan [34] modules. Several LLM-assisted assertion generators report assertion generation capabilities on OpenTitan modules. In particular, we experimented with [17] and [20], but our experience was negative. Most of the assertions either failed or passed without any trend, making it impractical for us to reproduce their work. Hence, in this work, we used all the assertions that were manually generated and were evaluated to be of high quality using JasperGold.
-
BRISC-V modules used: We consider a set of 6 modules from the BRISC-V RTL code base. A procedural block of an RTL code specifies the behavioral property of the code. It comprises statements like assignment statements, conditional statements, and state transition statements. In all of the experiments, we consider always blocks, and in most cases of the chosen modules, the lines
TABLE I: Various Classes of Mutations inserted in RTL code
| S. No. | Mutation Type | Description |
|---|---|---|
| I | Logical | Change logical operations (e.g., & to ||) |
| II | Relational | Change relational operators (e.g., == to !=) |
| III | Arithmetic | Change arithmetic operators (e.g., + to -) |
| IV | Constant | Change the constant value assigned to a variable |
| V | Conditional | Modify the conditions of the if-else statement |
| VI | Stuck at Fault | Assign a variable from constant 0 to 1 or vice versa |
| VII | Sensitivity List | Change posedge to negedge and vice versa |
| VIII | Connection | Change the interconnection between signals (swap) |
| IX | Slicing | Change the number of bits used when slicing is done |
| X | Nested if-else | Change the Nested if-else alignment |
of code in each block are around 200-300 lines. This is typically representative of a situation where a designer can localize a given bug to a small region of code or an always block, but is unable to pinpoint it. This is also an advantage of the proposed methodology, as the prior work assumed that the line with the bug is known a priori [26]. Given that we have the assertions for the RTL, we could narrow down the region of the bug to 200-300 lines of code for all the introduced mutations. The details of the benchmark modules used for the evaluation are furnished in the following discussion.
-
L1_bus_controller: Comprises 14 states to make the interface between snooper, L1 cache memory and bus for communication.
-
coherence_controller: The purpose of the coherence controller in BRISC-V is to monitor the bus access between the caches and the shared memory. Only one cache at a time gets bus access to communicate with the shared memory. There are 7 states to capture various scenarios that can occur during execution.
-
snooper: Snooper observes the operations performed by the other cores through its 7 states, when to invalidate its own data based on the write operation by other cores.
-
Lxcache_controller: Takes care of the L2 cache through its 9 states, also manages valid, invalid, inclusive bits to exercise the coherence protocol (MESI in this case).
-
Lxbus_interface: Bridges between bus and L2 cache with its 11 states to coordinate the flow of message, address and data.
-
cache_controller: The L1 cache of each core has a cache controller module that controls the required address, data, and message flow between the communicating modules. There are 15 states in the cache controller module to preserve the correctness of the whole system to implement the MESI protocol.
B. Bug Insertion
To evaluate the effectiveness of our methodology, we leverage mutation testing, where we create mutations of . These mutations act as bugs in our design. To ensure that the mutations in code lines are inserted at random locations, we use the LLM itself to create them. It has to be noted that the mutations are created in a separate session so that the LLM does not remember its history during the repair step. The mutations inserted in the correct code are syntax preserving, while semantically non-preserving [35], which results in altering the functionality of the code that was captured in the correct assertions. As mentioned earlier, a single mutation is inserted in a single line of the RTL code, resulting in a semantic change that causes one or more of to be violated.
The mutations engage both the sequential and combinational elements of the code. Specifically, we work on the same set of mutations defined in [26], as summarized in Table I, with one additional type (last item), as discussed below. Prompt 3 is used to generate the mutations.
The list of mutations shown in Table I describes the set of 10 mutations that we have carried out for our experiments. Column 1
TABLE II: Experiments on BRISC-V modules (FC: Formal Coverage, SC: Stimuli Coverage, CC: Checker Coverage, 1: Bug repaired in Stage 1, 2: Bug repaired in Stage 2, X: Bug not repaired after Stage 1 and Stage 2, —: Bug type absent)
| Module | # Lines | #Assertions | Coverage | Mutations | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| FC | SC | CC | I | II | III | IV | V | VI | VII | VIII | IX | X | |||
| L1 bus interface | 315 | 71 | 89.06% | 95.31% | 93.75% | 1 | 1 | 1 | 2 | 1 | 2 | 1 | 2 | 2 | 2 |
| Coherence Controller | 171 | 24 | 91.00% | 99.00% | 92.00% | 2 | 2 | 1 | 2 | 2 | 1 | 1 | 2 | - | 2 |
| Snooper | 322 | 56 | 90.00% | 90.63% | 98.75% | 2 | 1 | 2 | 2 | 1 | 2 | 1 | 2 | 2 | 2 |
| Lxcache controller | 276 | 76 | 97.71% | 97.71% | 100.00% | 1 | 2 | 1 | 2 | 1 | 1 | 1 | 2 | 2 | 2 |
| Lxbus interface | 254 | 35 | 92.73% | 93.64% | 99.09% | × | 1 | 1 | 2 | 2 | 1 | 1 | 1 | 2 | 2 |
| cache controller | 381 | 67 | 91.21% | 100.00% | 91.21% | 1 | 1 | 1 | 2 | 1 | 2 | 1 | 1 | 1 | 2 |
TABLE III: Two mutations introduced in each BRISC-V module (first of type A and second of type B)
| Mutation TypesA : B | # bugs repaired at Stage 1 | #bugs repaired at Stage 2 |
|---|---|---|
| Conditional : Connection | 2 | 0 |
| Arithmetic : Conditional | 2 | 0 |
| Arithmetic : Connection | 1 | 1 |
| Logical : Arithmetic | 1 | 1 |
| Logical : Conditional | 0 | 2 |
| Logical : Connection | 0 | 2 |
| Logical : Relational | 1 | 1 |
| Relational : Arithmetic | 0 | 2 |
| Relational : Conditional | 2 | 0 |
| Relational : Connection | 0 | 2 |
TABLE IV: Three mutations introduced in each BRISC-V module (first of type A, second of type B, third of type C)
| Mutation TypesA : B : C | # bugs repaired at Stage 1 | #bugs repaired at Stage 2 |
|---|---|---|
| Logical : Conditional : Connection | 0 | 3 |
| Logical : Relational : Conditional | 3 | 0 |
| Relational : Conditional : Connection | 2 | 1 |
| Logical : Relational : Connection | 2 | 1 |
| Relational : Connection : If_Else | 2 | 1 |
states the serial number, the second column mentions the name of the mutation, and in the third column, a short description about the mutation is provided.
Nested if-else Mutation: In this mutation [13], the else statement corresponding to an if statement is misaligned. Evidently, this leads to a semantic mismatch with respect to the correct functionality. As shown in Fig. 2, the correct code shows the intended nested if-else alignment, where the "if (dirty)" condition is nested in the "if (hit)" block, but we see in the mutation column that the "if (dirty)" condition is placed with the "else" statement, and the nested if-else construct is broken. This may lead to assertion violations, which are important for our repair task. For each mutation type, we insert an instance in the given RTL using the prompt shown in Prompt 3 and insert the bugs in the design.
TABLE V: Four mutations introduced in each BRISC-V module (first of type A, second of type B, third of type C, and fourth of type D)
| Mutation TypesA : B : C : D | # bugs repaired at Stage 1 | #bugs repaired at Stage 2 |
|---|---|---|
| Logical : Relational : Conditional : Arithmetic | 2 | 2 |
| Logical : Relational : Conditional : Connection | 3 | 1 |
| Logical : Relational : Connection : Arithmetic | 3 | 1 |
TABLE VI: 8 different types of mutations in L1 bus Interface and Snooper module, all at once, 1: Repaired in Stage 1, 2: Repaired in Stage 2
| Stage at which the bug was repaired | ||
|---|---|---|
| Mutation Types | L1 bus interface | Snooper |
| Relational | 1 | 1 |
| Arithmetic | 1 | 1 |
| Conditional | 1 | x |
| Stuck_At_Fault | 1 | 2 |
| Connectivity | 1 | 2 |
| Constant | 2 | 2 |
| Slicing | 2 | 1 |
| Nested If_else | 2 | 2 |
C. Results and Findings
We implement an immediate prior art [26] (referred to as Stage 1 in our experiments) on LLM-aided RTL repair, and provide comparative results. As seen from our experiments, the presence of assertions indeed helps the fixing task. In most cases, after Stage 1, the LLM response is to suggest possible errors that can be present in the code. For a few cases, it is able to firmly say that this is the buggy line with a justification. Consider the case of a constant mutation inserted in the Reset block of the code, where REQ1_read is assigned 1'b1, with all other signals assigned to 1'b0 in the reset block. In this case, the LLM is able to find the bug due to prior knowledge of the reset cycle. In some cases, as well, it is able to identify the bug, but is not able to patch it in Stage 1. An example session is shown in Listing 1 with one mutated line where the index of curr_offset got mutated. Listing 2 shows the patch suggested by LLM after Stage 1, which identifies that the bug is in the offset value, but the patch suggested produces failing assertions. At Stage 2, when a list of failing assertions is given, the correct offset is produced (shown in Listing 3), resulting in all passing assertions. This clearly demonstrates the advantage of having assertions.
1 r_cache_data_out[j] <= (j>=curr_offset & 2 j < (curr_offset+req_words))? 3 curr_data[j] : r_cache_data_out[j];
Listing 1: Sample code with mutated line
1 FIX: use logical && and index curr_data with word_counter offset 2 r_cache_data_out[j] <= ((j >= curr_offset) 3 && (j < (curr_offset + req_words))) ? 4 curr_data[word_counter + j] 5 : r_cache_data_out[j];
Listing 2: Patch suggested by LLM after Stage 1
1 r_cache_data_out[j] <= (j>=curr_offset & 2 j<(curr_offset+req_words))? 3 curr_data[j-curr_offset] 4 : r_cache_data_out[j];
Listing 3: Patch suggested by LLM after Stage 2
We now discuss the overall results obtained using our methodology. Table II shows the following descriptions. The first column shows the name of the module from the BRISC-V module. The second column and the third column give the number of lines of code and the number of assertions, respectively. The fourth column gives the three coverage metrics. Formal Coverage (FC): combines Stimuli Coverage (SC) and Checker Coverage (CC). An item is formally covered if it is covered by SC and CC. SC shows the reachability of the formal engines. CC shows the Cone of Influence (COI) coverage of the generated assertions. In general, the higher the coverage, the better the quality of the assertions. The last column describes the mutation types in each sub-column. A triplet in each sub-column indicates the outcome after the individual stages: Stage 1, Stage 2.
In total, 60 cases (6 modules, and 10 types of mutations) result from Table I. However, we could not introduce the slicing bug in the Coherence Controller IP, so we have 59 cases. This acts as a baseline for our work, which only uses the LLM for bug fixing. From Table II, we see that 28 bugs are correctly patched after Stage 1. This can be considered as a baseline, as the prior works do not have assertions available for the selected IP. In addition, when we tried generating assertions using the existing methodology, the quality of the assertions were poor as discussed in Section IV-A2. After Stage 2, we were able to patch 29 bugs. Overall, after all the stages, 1 of the bug was not patched. This gives us an overall success rate of 98%. For modules like Cache Controller with (381) lines and with 68 assertions, the number of tokens ranges from 4k to 4.5k based on the number of stages required to patch the bug. The JasperGold runtime ranges from 135ms in the cache coherence module to 1273ms in the L1 Bus Interface module. This also shows the effectiveness of a closed-loop LLM-assisted methodology, which is able to provide RTL bug repairs with formal guarantees and a significantly high bug repair rate.
After achieving a success rate of 98%, we applied our methodology to fix multiple bugs across multiple lines. In the first step, we consider a smaller module (number of lines is 171) like Coherence Controller, and introduce a smaller number of mutations there. Firstly, 5 types of mutations (Logical, Conditional, Connection, Arithmetic, and Relational) are considered, and different mutation combinations are introduced on one module for our experiment, the results are reported in Table III. Table III contains 3 columns. Column 1 shows the types of mutation introduced, and the other two columns show the number of bugs repaired in each stage. Column 2 shows the number of bugs fixed in Stage 1, and Column 3 shows the number of bugs fixed in Stage 2. Similarly, Tables IV and V, show the results after introducing 3 and 4 different types of mutations in the module at a time. We also see that, within the Stage 2, all bugs are repaired. In each of the experiments reported in Tables III, IV, and V, we get 100% success in bug repairing. Thus, the proposed methodology is feasible for the correction of multi-line bugs of different types simultaneously.
Lastly, we considered relatively large modules (number of lines is more than 300), like Snooper and L1 bus interface, and introduced 8 different types of mutations all at the same time as shown in Table VI. Column 1 shows the 8 types of different mutations, Column 2 and Column 3 show the Stage number at which that bug gets repaired for the L1 bus interface and Snooper, respectively. We see that in Table VI, except for one case, we were able to correct all the mutations in the two Stages, giving us a 93% success rate here. This clearly highlights that the proposed method can handle multiple bugs from several classes simultaneously and correct them.
Overall, we showed that the proposed methodology, in which the model checker aids the LLM, can be used for the bug patching of larger designs with multi-line bugs.
V. CONCLUSION
In this work, we proposed the first attempt towards LLM-assisted automated RTL bug repair of single-line and multi-line bugs with assertions and a model checker in the loop. The methodology consists of two distinct steps and follows a closed-loop principle to build a context for the LLM from the assertions and the output of the model checker. Consequently, it provides a bug fix along with trustworthy grounding and formal guarantees. We used mutation testing to perform extensive experiments on BRISC-V. Our proposed method was able to fix up to 98% of single-line RTL bugs and 93% of the multi-line bugs. The fixes were formally verified using the model checker. In addition, we believe that our methodology can be further refined to identify the few bugs that were not corrected.
REFERENCES
[1] H. D. Foster, “Trends in functional verification: A 2014 industry study,” in Proceedings of DAC, 2015, pp. 1–6.
[2] H. Shin, “Efficient bug discovery with machine learning for hardware verification,” Retrieved March, 2022. [Online]. Available: https://community.arm.com/arm-research/b/articles/posts/efficient-bug-discovery-with-machine-learning-for-hardware-verification
[3] L. Klemmer et al., “Waving goodbye to manual waveform analysis in hdl design with wal,” IEEE Transactions on Computer-Aided Design of Integrated Circuits and Systems, vol. 43, no. 10, pp. 3198–3211, 2024.
[4] M. Nadeem et al., “Polynomial debugging and fault correction of combinational circuits with constant cutwidth,” IEEE Transactions on Circuits and Systems I: Regular Papers, 2025.
[5] J. Blocklove et al., “Evaluating llms for hardware design and test,” in 2024 IEEE LLM Aided Design Workshop (LAD). IEEE, Jun. 2024, p. 1–6. [Online]. Available: http://dx.doi.org/10.1109/LAD62341.2024.10691811
[6] Z. Zhang et al., “Llm4dv: Using large language models for hardware test stimuli generation,” 2025. [Online]. Available: https://arxiv.org/abs/2310.04535
[7] M. DeLorenzo et al., “Make every move count: Llm-based high-quality rtl code generation using mcts,” 2024. [Online]. Available: https://arxiv.org/abs/2402.03289
[8] C.-T. Ho et al., “Verilogcoder: autonomous verilog coding agents with graph-based planning and abstract syntax tree (ast)-based waveform tracing tool,” in AAAI’25/IAAI’25/EAAI’25, 2025. [Online]. Available: https://doi.org/10.1609/aaai.v39i1.32007
[9] S. Thakur et al., “Verigen: A large language model for verilog code generation,” ACM Trans. Des. Autom. Electron. Syst., vol. 29, no. 3, Apr. 2024. [Online]. Available: https://doi.org/10.1145/3643681
[10] M. Akyash et al., “Self-hwdebug: Automation of llm self-instructing for hardware security verification,” in 2024 IEEE Computer Society Annual Symposium on VLSI (ISVLSI), 2024, pp. 391–396.
[11] Y.-D. Tsai et al., “Rtlfixer: Automatically fixing rtl syntax errors with large language models,” 2024. [Online]. Available: https://arxiv.org/abs/2311.16543
[12] C. K. Jha et al., “Large language models (llms) for verification, testing, and design,” in 2025 IEEE European Test Symposium (ETS), 2025, pp. 1–10.
[13] A. Menon et al., “VERT: A systemverilog assertion dataset to improve hardware verification with LLMs,” 2025. [Online]. Available: https://openreview.net/forum?id=rZmQ2z7MPA
[14] R. Kande et al., “Llm-assisted generation of hardware assertions,” CoRR, vol. abs/2306.14027, 2023. [Online]. Available: https://doi.org/10.48550/arXiv.2306.14027
[15] K. Maddala et al., “Laag-rv: Llm assisted assertion generation for rtl design verification,” 2024. [Online]. Available: https://arxiv.org/abs/2409.15281
[16] M. Orenes-Vera et al., “Using llms to facilitate formal verification of rtl,” 2023. [Online]. Available: https://arxiv.org/abs/2309.09437
[17] A. Gupta et al., “Sangam: Systemverilog assertion generation via monte carlo tree self-refine,” 2025. [Online]. Available: https://arxiv.org/abs/2506.13983
[18] W. Fang et al., “Assertllm: Generating and evaluating hardware verification assertions from design specifications via multi-llms,” 2024. [Online]. Available: https://arxiv.org/abs/2402.00386
[19] F. Wu et al., “Spec2assertion: Automatic pre-rtl assertion generation using large language models with progressive regularization,” 2025. [Online]. Available: https://arxiv.org/abs/2505.07995
[20] S. Paul et al., “Lisa: Llm informed systemverilog assertion generation with rag and chain-of-thought,” 07 2025, pp. 1–6.
[21] S. Paul et al., “Supersaga: A supervisor-subordinate agentic workflow for the generation of assertions,” in 2026 31st Asia and South Pacific Design Automation Conference (ASP-DAC). IEEE, 2026, pp. 420–425.
[22] C. K. Jha et al., “Large language models (llms) for verification, testing, and design,” in 2025 IEEE European Test Symposium (ETS). IEEE, 2025, pp. 1–10.
[23] J. Zhou et al., “Insights from rights and wrongs: A large language model for solving assertion failures in rtl design,” 2025. [Online]. Available: https://arxiv.org/abs/2503.04057
[24] X. Yao et al., “Hdldebugger: Streamlining hdl debugging with large language models,” ACM Trans. Des. Autom. Electron. Syst., May 2025. [Online]. Available: https://doi.org/10.1145/3735638
[25] K. Qayyum et al., “From bugs to fixes: Hdl bug identification and patching using llms and rag,” in 2024 IEEE LLM Aided Design Workshop (LAD). IEEE, 2024, pp. 1–5.
[26] K. Qayyum et al., “Llm-assisted bug identification and correction for verilog hdl,” ACM TODAES, 2025. [Online]. Available: https://doi.org/10.1145/3733237
[27] S. Bandara et al., “BRISC-V: an open-source architecture design space exploration toolbox,” CoRR, vol. abs/1908.09992, 2019. [Online]. Available: http://arxiv.org/abs/1908.09992
[28] Y. Serrestou et al., “Functional verification of rtl designs driven by mutation testing metrics,” in DSD, 2007, pp. 222–227.
[29] D. A. P. John L. Hennessy, Computer Architecture. Morgan Kofmann, 2012.
[30] "Jaspergold." [Online]. Available: https://www.cadence.com/en_US/home/tools/system-design-and-verification/formal-and-static-verification.html
[31] "Brisc-v." [Online]. Available: https://ascslab.org/research/briscv/index.html
[32] “Gpt-5.5 system card,” 2026. [Online]. Available: https://openai.com/index/gpt-5-5-system-card/
[33] Y.-M. Tseng et al., “Two tales of persona in llms: A survey of role-playing and personalization,” 2024. [Online]. Available: https://arxiv.org/abs/2406.01171
[34] [Online]. Available: https://github.com/lowRISC/opentitan
[35] S. Haroon et al., “How accurately do large language models understand code?” 2025. [Online]. Available: https://arxiv.org/abs/2504.04372