Skip to content
/ I2C Public

A versatile and widely used two-wire serial communication interface for connecting various devices in embedded systems

License

Notifications You must be signed in to change notification settings

cp024s/I2C

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

I2C Communication

Overview

This repository contains Verilog code for implementing I2C (Inter-Integrated Circuit) communication between a master and a slave device. I2C is a popular serial communication protocol used for connecting microcontrollers, sensors, and various other digital devices.

The repository includes two main modules:

  1. I2C_Master: This module represents the I2C master device. It is responsible for generating start and stop conditions, transmitting data to the slave, and receiving acknowledgment (ACK) signals.

  2. I2C_Slave: This module represents the I2C slave device. It is responsible for receiving data from the master, recognizing its own address, and sending ACK signals when addressed.

Usage

Prerequisites

Before using the provided Verilog modules, ensure that you have the following:

  • A Verilog simulator or synthesis tool (e.g., Xilinx Vivado, Intel Quartus Prime) installed on your system.

Integration

  1. Clone this repository to your local machine or download the Verilog files (I2C_Master.v and I2C_Slave.v) directly.

  2. Integrate the Verilog modules into your FPGA or ASIC design project using your preferred toolchain.

  3. Customize the modules as needed for your specific application. The provided code serves as a basic template and may require additional features, such as error handling, clock synchronization, or interface adaptations, to suit your requirements.

Simulation

If you wish to simulate the I2C communication, follow these steps:

  1. Create a testbench to instantiate and connect the I2C master and slave modules.

  2. Apply appropriate stimulus to the SDA and SCL signals to simulate data transmission.

  3. Use your Verilog simulator to run the simulation and observe the behavior of the I2C communication.

Module Descriptions

I2C_Master

The I2C_Master module implements the I2C master device. It includes the following key features:

  • Generation of start and stop conditions.
  • Data transmission to the slave device.
  • State machine for managing the I2C communication protocol.
  • Basic error handling (missing acknowledgment).

I2C_Slave

The I2C_Slave module represents the I2C slave device. Key features include:

  • Recognition of the slave's address during communication.
  • Reception of data from the master.
  • Sending acknowledgment signals (ACK) when addressed.
  • Basic state machine for receiving data.

Important Notes

  • This Verilog code is a basic implementation of I2C communication and serves as a starting point for your projects. Depending on your specific application, you may need to extend and customize these modules.

  • Ensure that you thoroughly test and validate the I2C communication in your specific hardware environment.

  • This code is provided as-is, and the authors do not guarantee its suitability for any particular purpose.

License

This code is provided under the MIT License. See the LICENSE file for more details.

About

A versatile and widely used two-wire serial communication interface for connecting various devices in embedded systems

Resources

License

Stars

Watchers

Forks