Lattice MachXO2 has a wonderful buit-in function named "Embedded Function Block (EFB)". It is hard-coded macro function and XO2 and XO3 (and more?) has I2C, SPI, Timer/Counter function. Datasheet of Lattice says we can save more than 500 LUT by using EFB and it will be true because,, when I think by myself to make I2C slave device,,, it will not be impossible but vast of consideration will be required with bunch of LUT.
This time I've tried to check the operation of I2C EFB and surely confirmed its operation. Indeed my trial is started from RD1124 of Lattice's reference design but FPGA on board is TQFP and we just need reduce the number of GPIO (original is 8 consists of input 4 (each has 8bit) and output 4) down to single input and output for one byte for each.
During making I've noticed (too late?) that, "very slow clock circuit" is useless for large size FPGA. Currently the board has LCMXO2-1200HC (1280 LUT) and very enough to make long-bit counter even for the case of slow clock is needed. (it WAS very useful for small size CPLD) So, 4040 (12bit counter) with 32.768kHz crystal oscillator is not populated on board.
One thing we should understand for EFB activation is, EFB is accessed through WISHBONE interface if we want to utilize the data to external GPIO and for this purpose we need to use Mico8, a tiny 8bit processor. It is a software processor but just consume 200 LUT and still 80% is free for additional circuit implementation. Also one thing to be noted is, we need clock for Mico8 operation. In the current board, 12MHz clock signal is extracted from FTDI's oscillator.
The real operation can be found in the following movie.. have fun!