1
\$\begingroup\$

How would you constrain this design? enter image description here

ext_clk and clk_in are asynchronous to each other. clk_div is derived by clk_in with double period.

clk_out may be driven by either clk_in and ext_clk, according to the selector pin of the multiplexer.

This is what I would do:

create_clock -period 42 -waveform {0 21} [get_ports "clk_in"] create_clock -period 300 -waveform {0 21} [get_ports "ext_clk"] create_generated_clock -name clk_out -source [get_ports "clk_in"] -divide_by 2 [get_pins "xmux/y"] create_generated_clock -name clk_out -source [get_ports "ext_clk"] [get_pins "xmux/y"] -add 

I am not totally sure this is the proper way to constrain this design. What do you think will be the impact of these constraints to the CTS generation in terms of balancing for the logic clocked by clk_out if it talks, mutually exclusive, with the logic driven by clk_in and ext_clk?

\$\endgroup\$
5
  • \$\begingroup\$ What do you mean by "if it talks...with the logic driven by clk_in and ext_clk"? How are you planning to use clk_out? This sounds very dangerous to me. \$\endgroup\$ Commented Jul 26, 2018 at 16:24
  • 1
    \$\begingroup\$ You should check if the clock management blocks/tiles/whatever in your FPGA offer a glitch-free clock multiplexer. \$\endgroup\$ Commented Jul 26, 2018 at 16:42
  • \$\begingroup\$ clk_out clocks a module which has a set of inputs also dependent to the select pin of the mux. I mean that inputs are driven coherently with the selection of the mux \$\endgroup\$ Commented Jul 26, 2018 at 16:45
  • \$\begingroup\$ This is a bad "gated clock" design, and it can't be constrained. See Dave's answer. \$\endgroup\$ Commented Jul 26, 2018 at 17:10
  • \$\begingroup\$ Ali that's not a gated clock design, I am not involving any enable nor inhibiting the clock \$\endgroup\$ Commented Jul 26, 2018 at 17:18

2 Answers 2

3
\$\begingroup\$

If the clocks are asynchronous (to each other), there are no meaningful constraints you can place between them.

You need to create a constraint for clk_out that represents the "worst case" for any of the possible clock inputs, and use that to evaluate the rest of the design.

The rest of the design must also be able to handle the timing violations that will occur when you change the control on the mux.

Note that there are more sophisticated (synchronous) clock switching techniques that can avoid creating "runt pulses", etc. that will make the design of the downstream logic simpler. These are usually built into the FPGA/ASIC vendor's clock management IP. You might want to read up on that.

\$\endgroup\$
2
  • \$\begingroup\$ Thanks Dave, with "worst case" you mean shaping clk_out with the highest frequency that can come from clk_in or ext_clk i guess. The switching technique is not part of the problem at the moment, actually I have already implemented it safely, in order to avoid any case of glitch (that mux is just for representation purposes, it's not really there) \$\endgroup\$ Commented Jul 26, 2018 at 17:22
  • 1
    \$\begingroup\$ I can only comment on what I can see. The quality of the question pretty much dictates the quality of the answers. \$\endgroup\$ Commented Jul 26, 2018 at 18:46
0
\$\begingroup\$

Clock definitions seem fine, although generated clocks should have different names to identify which one is ext_clk based and vice versa.

In your case, clk_out is where you define the generated clocks based on ext_clk and clk_div2. This ensures both clocks are active at the output. However, since you mentioned these are asynchronous, you need to set that relationship between them. Regardless of that, Mux only selects one clock at a given time, so there can't be clocks between these 2. So that leads us to logically exclusive relationship between the two generated clocks. For all clocks, talking outside of this mux, you need asynchronous exception.

set_clock_groups -asynchronous -group1 {ext_clk} -group2 {clk_div2} 
\$\endgroup\$

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.