Design of I2C Master in VHDL

About: Mitu Raj - Just a Hobbyst and Learner

Intro: Design of I2C Master in VHDL

In this instructable, Designing a simple I2C interface in VHDL is discussed.

NOTE: click on each image to see full image.

Step 1: What Is I2C

An overview


•Stands for Inter Integrated Circuit.

•Synchronous , Half duplex.

•Two Wire Interface - SDA and SCL.

•SDA – controlled by both Master and Slave.

•SCL – controlled only by Master.

•Multi-master , Multi-slave protocol.

•Two modes - 100 kbits/sec and 400 kbits/sec : slow and fast.

Step 2: Designing in VHDL

Design Specs

  • 8-bit data frame.
  • 7-bit slave address.
  • Supports both slow and fast modes.
  • Single Master, Multi-slave.
  • Main clock input = 100 MHz.

Step 3: Simulation and Testing

Tested On

  • Implemented on Altera Cyclone III FPGA.
  • Timing verified for 100 MHz.
  • Tested waveforms on DSO/CRO.
  • Successfully tested communication with Arduino UNO's I2C (FPGA as Master).

Simulation was done in Modelsim 10.1.

Step 4: Important Notes

  • Input clock is 100 MHz. In case, you have different crystal clock in FPGA, either use PLL to generate 100 mHz or carefully edit the clock divider process accordingly in i2cmaster.vhd. As it is responsible to generate 400 kHz or 100 kHz i2c clocks.
  • In case of error in communication, i2c master goes to error state. Assert stop signal '1' to generate stop bit and restart communication.
  • While testing, dont forget pull-up resistors as SDA line is common drain output !!! Check google for recommended pull-up resistor for different i2c speeds. I used 2.2K.
  • Carefully simulate SDA signal, as it is a bi-directional signal (inout) signal. It has two drivers, master side and slave side. You should know when to 'force' and when to 'unforce'.
  • SCL is unidirectional line. No need of pull-up.
  • chip_enable is active low in the attached code, unlike in the simulation waveform.

Step 5: Files Attached

  • i2cmaster.vhd
  • i2c_testbench.vhd

for queries contact --

iammituraj@gmail.com

Share

    Recommendations

    • Optics Contest

      Optics Contest
    • Audio Contest 2018

      Audio Contest 2018
    • Plastics Contest

      Plastics Contest

    Discussions