Altera_Forum
Honored Contributor
15 years agotiming constraints for SPI (or UART)
Hello
I need a little help in writing timing constraints for a SPI interface (slave) that is part of my design. I have a 100 MHz oscillator on my board that is being multiplied by a PLL to generate my system clock of 333.33 MHz. The SPI clock from the master can be as fast as 50 MHz. I wrote the following constraints: create_clock -period 10.0 [get_ports clk_osc] create_clock -name virtual_clk_sys -period 3 derive_pll_clocks derive_clock_uncertainty set_output_delay -clock { virtual_clk_sys } -max 0 [get_ports {spi_miso [*]}] set_output_delay -clock { virtual_clk_sys } -min 0 [get_ports {spi_miso [*]}] Quartus used a 333.33 MHz derived clock (from clk_osc) as launching edge and the virtual clock as latching edge and gave me a huge slack of ~ -4 ns. A report of the slack is attached. I am pretty sure I am not constraining the system correctly. For SPI, my FPGA starts preparing data for the host on the negative edge of spi clock (50 MHz at most) and it has to be valid (meeting setup time etc) before the host samples it at the positive edge of the spi clock. Can someone guide me to writing constraints of this system. Assume the setup time at host dff is tSU. Assume identical paths for clock and data. FPGA centric or system centric, both will work. Thanks a million and happy new year. Regards