Learning

导航

Clocks and Global lines

 

转自:http://www.fpga4fun.com/FPGAinfo5.html

Clocks and Global lines

An FPGA design is usually "synchronous". Simply put, that means that the design is clock based - each clock rising edge allows the D-flipflops to take a new state.

In a synchronous design, a single clock may drive a lot of flipflops simultaneously. That can cause timing and electrical problems inside the FPGA. To get that working properly, FPGA manufacturers provide special internal wires called "global routing" or "global lines". They allow distributing the clock signal all over the FPGA with a low skew (i.e. the clock signal appears almost simultaneously to all the flipflops).

When you feed a clock signal to your FPGA, you shouldn't use any FPGA pin, but use a dedicated input clock pin. Usually, only such pin has the ability to drive a global line. FPGA software are aware of these dedicated input pins, and will automatically assign clocks to them if given the choice.

Clock domains

An FPGA can use multiple clocks (using multiple global lines and dedicated input pins). Each clock forms a "clock domain" inside the FPGA.

Flipflops and combinatorial logic in each clock domain

For each flipflop inside the FPGA, its clock domain is easy to determine. Just look at the flipflop clock input.
But what about the combinatorial logic that sits in between flipflops?

  • If there is some combinatorial logic in between "same clock domain" flipflops, the logic is said to be part of the clock domain too.
  • If there is some combinatorial logic in between "different clock domains" flipflops, the logic is not owned by any clock domain. But in a typical FPGA design, there is no such logic; the only paths from different clock domains are synchronizers.
Clock domain speeds

For each clock domain, the FPGA software will analyze all flop-to-flop paths and give you a report with the maximum allowed frequencies. In the general case, only the paths from within each clock domains are analyzed. The synchronizer paths (from different clock domains) usually don't matter and are not analyzed.

One clock domain may work at 10MHz, while another may work at 100MHz. As long as each clock uses a global line, and you use clock speeds that are lower than the maximums reported by the software, you don't have to worry about internal timing issues, the design is guaranteed to work internally timing-wise.

There may still be some timing issues from the FPGA input and output pins though. The software will give you a report about that. See also the next section.

Signals between clock domains

If you need to send some information across different clock domains, special considerations need to apply.

In the general case, if your clocks have no relationship with one another, you cannot use a signal generated from one clock domain into another as-is. Doing so would violate setup and hold flipflop timings (in the destination clock domain), and cause metastability.

Crossing clock domains requires special techniques, like the use of synchronizers (that's simple), or FIFOs (that's more complicated). See the fpga4fun's Crossing clock domains project to get some practical ideas, or these external links here, here and here.


posted on 2009-07-13 18:54  xinjie  阅读(200)  评论(0编辑  收藏  举报