Design of I2C Master in VHDL

Introduction: Design of I2C Master in VHDL

About: Mitu Raj -- Just a Hobbyst and Learner -- Chip Designer -- Software Developer -- Physics and Mathematics Enthusiast

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

NOTE: click on each image to see full image.

Step 1: I2C Bus Overview

•Stands for Inter Integrated Circuit.

•Synchronous , Half duplex.

•Two Wire Interface - SDA and SCL.

•SDA – Serial Data line controlled by Master and Slave

•SCL – Serial Clock generated by Master

•Multi-master , Multi-slave protocol.

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

Step 2: RTL Design in VHDL

Design Specs of our I2C Master

  • 8-bit data frame.
  • SCL uni-directional control only.
  • 7-bit slave address.
  • Supports both slow and fast modes.
  • Single Master, Multi-slave.
  • Complied with original I2C specs by Philips.

Pure RTL code is used. So the IP is easily portable across all FPGAs. Compact FSM based design using internally generated clock ensures optimal area and performance.

Step 3: Simulation and Testing

Test Environment

  • Functional simulation and testing using third-party I2C Slave IP.
  • Synthesised using Xilinx Vivado tool set.
  • Implemented and tested on Artix-7 FPGA board.
  • Timing verified design for 100 MHz.
  • Tested waveforms on DSO/CRO.
  • Successfully tested communication with Arduino UNO as I2C Slave.

Step 4: Important Notes

  • While testing Master using I2C Slave IP, configure the slave code as per your requirements. You may want to change the default clock frequency and slave address. Clock frequency should be configured in the Master code too.
  • While on-board testing, don't 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 for 100 kHz.
  • If not using test bench and simulating the Master independently, 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.
  • Please go thru the IP Documentation thoroughly.

Step 5: Files Attached

  • All RTL codes of I2C Master.
  • Test bench, I2C Slave codes as well, for testing.
  • IP Documentation.

For any queries, feel free to contact me:

Mitu Raj

follow me: https://www.instructables.com/member/AmCoder/

For queries, contact:iammituraj@gmail.com

Be the First to Share

    Recommendations

    • Lamps and Lighting Contest

      Lamps and Lighting Contest
    • Micro:bit Contest

      Micro:bit Contest
    • First Time Author Contest

      First Time Author Contest

    50 Comments

    0
    nharinathreddy
    nharinathreddy

    7 weeks ago

    could you please send me the password (harinatha.reddy@eldaas
    .com)
    Thanks

    0
    AmCoder
    AmCoder

    Reply 6 weeks ago

    done

    0
    AmCoder
    AmCoder

    Reply 2 months ago

    sure

    0
    FooK2
    FooK2

    2 months ago

    Nice and clear information about the I2C digital communication. Could you please send me the password? Email: fksfoo96@gmail.com
    Thank you very much.

    0
    AmCoder
    AmCoder

    Reply 2 months ago

    sure

    0
    AmCoder
    AmCoder

    Reply 4 months ago

    sent

    0
    antonio.moles1996
    antonio.moles1996

    4 months ago

    can you send me the password? thanks

    0
    AmCoder
    AmCoder

    Reply 4 months ago

    inbox/mail

    0
    AmCoder
    AmCoder

    Reply 4 months ago

    sure

    0
    AmCoder
    AmCoder

    Reply 4 months ago

    inbox/mail

    0
    Evo_23
    Evo_23

    1 year ago

    Password?