Assertion-Based Verification of I2C Module Using SystemVerilog
Abstract
:1. Introduction
2. Overview of the I2C Protocol
2.1. I2C Structure and Data Frame Configuration
- Serial Clock Line (SCL): This is the clock line used by the master to synchronize communication with the slave.
- Serial Data Line (SDA): This is the data line used for transmission and reception between the master and the slave.
2.2. I2C Operation
3. I2C Module Design
3.1. Design Specifications
3.2. Design and RTL Simulation
- When <start_cnt> is incremented and reaches <start_cnt == 2>, <i2c_cnt> begins to increase. When <i2c_cnt == 4>, <i2c_rdwr = 0> (Write) and <iic_wdata = 8′hff> are input.
- When <i2c_cnt == 7>, <iic_req> becomes 1, indicating that the I2C Write operation is being requested.
- When <iic_done == 1>, it indicates that the master’s Write operation to the slave has been successfully completed.
- As <i2c_cnt> is incremented again and reaches <i2c_cnt == 4>, <iic_rdwr = 1> (Read) is input.
- When <i2c_cnt == 7>, <iic_req> becomes 1, signaling that the I2C Read operation is being requested.
- When <iic_done == 1> appears for the second time, it indicates that the slave has transmitted the requested Read data to the master, and the master has successfully received and stored the Read data sent by the slave.
- Simultaneously, at the second occurrence of <iic_done == 1>, the values of <iic_wdata> and <iic_rdata> match at <16′hff>, confirming that the designed I2C module has correctly executed both Write and Read operations.
4. ABV Testbench Using I2C SVA
4.1. SVA Introduction
4.2. ABV Introduction
4.3. I2C ABV Testbench Architecture
- [i2c_tb_top.sv]:The top-level testbench file, responsible for instantiating the DUT and importing the ABV infrastructure through [i2c_sva_bind.sv].
- [i2c_sva_bind.sv] (Figure 11):The central integration file that includes packages and modules required for property definition, evaluation, and binding.
- [i2c_sva_pkg.sv, i2c_sva_property_pkg.sv] (Figure 12):Contains all reusable SVA property templates for I2C protocol verification. These properties are written once and instantiated in downstream modules.
- [import i2c_sva_pkg::*]:Imports all named properties from the package, enabling modularity and avoiding repetitive code.
- [i2c_sva_check.sv] (Figure 13):Acts as a reusable assertion module that receives DUT signal names as parameters and maps them to corresponding assertion properties.
- [i2c_sva_check_with_design.sv] (Figure 14):Connects the reusable assertion module to the actual DUT via signal mapping and bind, allowing non-intrusive verification without modifying RTL.
4.4. Assertion Reusability and Generalization Techniques
- Parameterization of Properties (Figure 15):Assertions can be encapsulated within parameterized modules that accept signal bindings as arguments. This enables a single assertion module to support multiple DUTs with varying signal names.
- Interface-Based Encapsulation (Figure 16):Signal groups are wrapped in SystemVerilog interface blocks, and assertion modules access signals through interface handles. This improves modularity and reduces dependency on signal naming.
- Macro-Based Reusability (Figure 17):SystemVerilog macros (define) allow assertion patterns to be reused inline. This is helpful for repeating standard protocol rules across modules.
4.5. Comparison Between ABV and UVM-Based Verification
- Learning Curve: ABV using SVA requires less initial learning since it avoids class-based design and UVM-specific methodology. This makes it more accessible to verification engineers who are new to SystemVerilog or those working under tight schedules. UVM, by contrast, requires a solid understanding of class hierarchies and the UVM library structure.
- Code Complexity: ABV environments are typically simpler and more direct. Assertions can be embedded directly into the design or bind files. UVM testbenches, while structured and modular, often involve layered components such as sequences, drivers, monitors, agents, and environments, which can increase overhead and setup time.
- Reusability and Scalability: UVM excels in reusability, especially for large-scale SoC verification, due to its modularity and configurability. ABV, although less modular, is highly reusable within protocol-focused or block-level designs.
- Debugging and Traceability: ABV allows fine-grained, time-accurate checks with immediate pass/fail feedback at the signal level. UVM provides transaction-level tracing and sophisticated debug utilities such as scoreboards and functional coverage metrics.
- Simulation Speed and Resource Usage: ABV tends to produce faster simulations, especially in focused, low-level module testing, because of its lightweight nature. UVM’s layered structure may introduce more runtime overhead.
5. Simulation Results
5.1. SCL Frequency Check
5.2. START Condition Check
5.3. Write and Read STOP Condition Check
5.4. SCL Clock Count Verification for Write and Read Operations
5.5. Device Acknowledgment Check via SDA in Write and Read Operations
- PASS (Case 1): After the START condition, the signal i2c_scl == 1 is observed exactly DEVICE_CMD_FLOW_LEN times, followed by i2c_sda == 0, indicating a valid ACK response.
- FAIL (Case 2): After the required number of SCL HIGH pulses, i2c_sda remains HIGH (1), indicating no ACK response.
- FAIL (Case 3): The number of SCL HIGH pulses is either less than or greater than the expected DEVICE_CMD_FLOW_LEN, failing the ACK timing requirement.
- FAIL (Case 4): Although i2c_sda transitions LOW, the SCL count does not align with the specified condition, making the ACK invalid.
- PASS (Case 1): Both the first and second ACKs occur correctly at the expected timing after their respective SCL pulse sequences.
- FAIL (Case 2): The first ACK occurs correctly, but the second ACK does not occur.
- FAIL (Case 3): The first ACK does not occur after the initial SCL pulses. As a result, the assertion fails immediately and the second ACK is not evaluated. In this case, since the first ACK response is missing, the second ACK condition is not checked at all.
- FAIL (Case 4): The first ACK occurs, but the second ACK is either too early or too late, violating the expected timing window.
- FAIL (Case 5): Neither the first nor the second ACK occurs.
5.6. Slave Address ACK Check for Write and Read Operations
- Case 1 (PASS): After the START condition, exactly DEVICE_CMD_FLOW_LEN + ADDR_CMD_FLOW_LEN SCL HIGH pulses occur, and immediately after that, an ACK response (i2c_sda == 0) is correctly detected.
- Case 2 (FAIL): While the SCL HIGH pulse count is correct, the ACK response does not occur (i2c_sda remains HIGH), leading to a failure.
5.7. Data ACK/NACK Phase Verification in Write and Read Operations
- Case 1 represents the situation where, after the START condition, SDA initially falls, SCL stays HIGH exactly WRITE_CYC times, and SDA goes LOW again immediately after—indicating a proper ACK response.
- Case 2 occurs when the number of SCL HIGH pulses is correct, but SDA does not go LOW, meaning no ACK was issued.
- Case 3: Although SDA falls, the number of SCL HIGH pulses is either less than or greater than WRITE_CYC, violating the expected ACK timing.
- Case 4: While the SCL HIGH count is correct, the LOW transition of SDA happens too early or too late, making it fail to meet the ACK positioning condition.
- Case 1 occurs when, after the START condition, SDA initially falls, SCL is HIGH exactly READ_CYC times, and then SDA remains HIGH—indicating a correct NACK response from the master.
- Case 2 happens when the number of SCL HIGH pulses is correct, but SDA goes LOW instead of staying HIGH, resulting in an invalid ACK.
- Case 3: SDA falls, but the number of SCL HIGH pulses is not equal to READ_CYC, making ACK/NACK determination unreliable.
- Case 4: SDA stays HIGH, but the timing of the response is too early or too late to satisfy the NACK positioning requirement.
5.8. Command Phase SDA Status Verification in Write and Read Operations
- First, after DEVICE_CMD_FLOW_LEN-1 clock cycles (Write phase), SDA must be ‘0’.
- Then, after ADDR_CMD_FLOW_LEN + SR_LEN + DEVICE_CMD_FLOW_LEN-1 clock cycles (Read phase), SDA must be ‘1’ to indicate a Read operation.
6. Conclusions
Author Contributions
Funding
Data Availability Statement
Conflicts of Interest
Abbreviations
SVA | SystemVerilog Assertions |
UVM | Universal Verification Methodology |
ABV | Assertion-Based Verification |
OOP | Object-Oriented Programming |
I2C | Inter-Integrated Circuit |
HDL | Hardware Description Language |
SoC | System-on-Chip |
RTL | Register Transfer Level |
SCL | Serial Clock Line |
SDA | Serial Data Line |
ACK | acknowledgment |
NACK | negative acknowledgment |
ID | identification |
References
- Araujo, P. Development of a Reconfigurable Multi-Protocol Verification Environment Using UVM Methodology; Faculdade de Engenharia da Universidade do Porto: Porto, Portugal, 2014; pp. 1–149. [Google Scholar]
- Ni, W.; Zhang, J. Research of Reusability Based on UVM Verification. In Proceedings of the 2015 IEEE 11th International Conference on ASIC (ASICON), Chengdu, China, 3–6 November 2015; pp. 1–4. [Google Scholar]
- Fathy, K.; Salah, K. An Efficient Scenario Based Testing Methodology Using UVM. In Proceedings of the 2016 17th International Workshop on Microprocessor and SOC Test and Verification (MTV), Austin, TX, USA, 11–13 December 2016; pp. 57–60. [Google Scholar]
- Salah, K. A UVM-Based Smart Functional Verification Platform: Concepts, pros, cons, and opportunities. In Proceedings of the 2014 9th International Design & Test Symposium (IDT), Algeries, Algeria, 16–18 December 2014; pp. 94–99. [Google Scholar]
- Jain, A.; Bonanno, G.; Gupta, H.; Goyal, A. Generic System Verilog Universal Verification Methodology Based Reusable Verification Environment for Efficient Verification of Image Signal Processing IPs/SoCs. Int. J. VLSI Des. Commun. Syst. 2012, 3, 13–25. [Google Scholar] [CrossRef]
- Harshitha, N.B.; Kumar, P.; Kurian, M. An Introduction to Universal Verification Methodology for the Digital Design of Integrated Circuits (IC’s): A Review: A review. In Proceedings of the 2021 International Conference on Artificial Intelligence and Smart Systems (ICAIS), Erode, India, 25–27 March 2021; pp. 1710–1713. [Google Scholar]
- IEEE Std 1800-2017 (Revision of IEEE Std 1800-2012); IEEE Standard for SystemVerilog—Unified Hardware Design, Specification, and Verification Language. IEEE: New York, NY, USA, 2018; pp. 1–1315.
- Accellera. Universal Verification Methodology (UVM) 1.2 User’s Guide; Accellera: Elk Grove, CA, USA, 8 October 2015. [Google Scholar]
- IEEE Std 1800.2-2017; IEEE Standard for Universal Verification Methodology Language Reference Manual. IEEE: New York, NY, USA, 2017; pp. 1–472.
- Spear, C.; Tumbush, G. SystemVerilog for Verification: A Guide to Learning the Testbench Language Features, 3rd ed.; Springer: New York, NY, USA, 2012. [Google Scholar]
- Reddy, P.R.; Sreekanth, P.; Kumar, K.A. Serial Peripheral Interface-Master Universal Verification Component using UVM. Int. J. Adv. Sci. Technol. Eng. Manag. Sci. 2017, 3, 27. [Google Scholar]
- Banga, M.; Kumar, A.; Sharma, S.; Choudhary, R. Improving Reusability of SystemVerilog Assertions through Generic Protocol Wrappers. In Proceedings of the International Conference on VLSI Design, Bangalore, India, 2–6 January 2021; pp. 254–259. [Google Scholar]
- Gupta, A.; Saini, R. Formal Verification of On-Chip Communication Protocols Using SystemVerilog Assertions. Microelectron. Reliab. 2020, 104, 113552. [Google Scholar]
- Sarns, S.; Woehr, J. Exploring I2C. Embed. Syst. Program. 1991, 4, 46. [Google Scholar]
- NXP Semiconductors. I2C-bus Specification and User Manual. 1 October 2021. Available online: https://www.nxp.com/docs/en/user-guide/UM10204.pdf (accessed on 27 December 2024).
- Varier, J.E.V.; Prabakar, V.; Balamurugan, K. Design of Generic Verification Procedure for IIC Protocol in UVM. In Proceedings of the 2019 3rd International Conference on Electronics, Communication and Aerospace Technology (ICECA), Coimbatore, India, 12–14 June 2019; pp. 1146–1150. [Google Scholar]
- Wang, D.; Yan, J.; Qiao, Y. Research on Chip Verification Technology Based on UVM. In Proceedings of the 2021 6th International Symposium on Computer and Information Processing Technology (ISCIPT), Nanjing, China, 25–27 June 2021; pp. 117–120. [Google Scholar]
- Kappaganthu, L.M.; Prakash, M.D. I2C Protocol and Its Clock Stretching Verification using System Verilog and UVM. In Proceedings of the 2017 International Conference on Inventive Communication and Computational Technologies (ICICCT), Coimbatore, India, 10–11 March 2017; pp. 478–480. [Google Scholar]
- Francesconi, J.; Rodriguez, J.A.; Julián, P.M. UVM Based Testbench Architecture for Unit Verification. In Proceedings of the 2014 Argentine Conference on Micro-Nanoelectronics, Technology and Applications (EAMTA), Buenos Aires, Argentina, 2–4 July 2014; pp. 89–94. [Google Scholar]
- Deepa, K.; Janakkumar, B.P.; Neeraj, G. An Introduction to Functional Verification of I2C Protocol using UVM. Int. J. Comput. Appl. 2015, 121, 10–14. [Google Scholar]
- Moon, D.W.; Hong, D.K. UVM-based Verification of Equalizer Module for Telecommunication System. J. Semicond. Disp. Technol. 2024, 23, 25–35. [Google Scholar]
Items | Values |
---|---|
Device ID (Number of Bits) | 7 bits |
Address (Number of Bits) | 8 bits |
Command Bit | 1 bit (<1′b0>: Write, <1′b1>: Read) |
ACK (Number of Bits) | 1 bit |
NACK (Number of Bits) | 1 bit |
Clock Frequency | 25 MHz |
I2C SCL Frequency | 100 KHz/400 kHz |
Metric | ABV(SVA) | UVM |
---|---|---|
Simulation Time (ms) | 120 | 280 |
Testbench Code Size (lines) | 350 | 3500 |
Assertion Coverage (%) | 85% | 92% |
Setup Complexity (1–5) | 2 (Simple) | 4 (Complex) |
Average Debug Time (s) | 30 s | 75 s |
No. | I2C Check Item |
---|---|
1 | SCL Frequency Check |
2 | START Condition Check |
3 | STOP Condition Check |
4 | SCL Count Check |
5 | DEVICE ACK SDA Check |
6 | Slave Address ACK SDA Check |
7 | WData ACK and RData NACK SDA Check |
8 | Command (Write/Read) SDA Check |
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2025 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).
Share and Cite
Moon, D.-W.; Pyo, S.-H.; Hong, D.-K.; Bataa, O.; Norinpel, E. Assertion-Based Verification of I2C Module Using SystemVerilog. Electronics 2025, 14, 1687. https://doi.org/10.3390/electronics14081687
Moon D-W, Pyo S-H, Hong D-K, Bataa O, Norinpel E. Assertion-Based Verification of I2C Module Using SystemVerilog. Electronics. 2025; 14(8):1687. https://doi.org/10.3390/electronics14081687
Chicago/Turabian StyleMoon, Dae-Won, Seung-Hyun Pyo, Dae-Ki Hong, Otgonbayar Bataa, and Erdenekhuu Norinpel. 2025. "Assertion-Based Verification of I2C Module Using SystemVerilog" Electronics 14, no. 8: 1687. https://doi.org/10.3390/electronics14081687
APA StyleMoon, D.-W., Pyo, S.-H., Hong, D.-K., Bataa, O., & Norinpel, E. (2025). Assertion-Based Verification of I2C Module Using SystemVerilog. Electronics, 14(8), 1687. https://doi.org/10.3390/electronics14081687