-2
\$\begingroup\$

I really need to I2C interface my FPGA with some slave device. I figured I could use the audio codec in my FPGA as a slave.I have gone through some codes from the internet for I2C. But I do not get them.

To initiate a start sequence, What do I do? I know I want to drive SDL low while SCL is high. But I do not have much idea how I should code.

process(Start)

begin

if Start='0' then

   ACTIVE='0';

else

   SCL='1';

   SDL='1';

   SDL='0';

   ACTIVE='1'; 

end if;

end process;

Is this the way,my start sequence initiation should be? Should I add anything else?

Besides more importantly, How am I supposed to wait for an acknowledgement?

\$\endgroup\$
  • 3
    \$\begingroup\$ I hope this comment is not considered rude, but I think you should first learn how VHDL works and how it can be used to describe hardware. So you can take a class that teaches HDL 'programming' or read a book/tutorial. If you have solved to describe simple structures like counters, FSMs or decoders in hardware, you can try to describe more advanced modules for bus protocols like your requested I²C. Besides that, OpenCores has free I²C cores ready for use. \$\endgroup\$ – Paebbels May 18 '15 at 20:58
2
\$\begingroup\$

in addition to what was said before, you can found I2C specification help on this: http://i2c.info/i2c-bus-specification and VHDL on https://www.eewiki.net/display/LOGIC/I2C+Master+(VHDL) . But take note that I2C can be customized to read/write different bytes and also with other features like clock stretching and oversampling clock so is better to write your code by yourself.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.