# How to constrain a clock signal out from a multiplexer

How would you constrain this design?

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?

• 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. – Elliot Alderson Jul 26 '18 at 16:24
• You should check if the clock management blocks/tiles/whatever in your FPGA offer a glitch-free clock multiplexer. – The Photon Jul 26 '18 at 16:42
• 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 – camillo_benso Jul 26 '18 at 16:45
• This is a bad "gated clock" design, and it can't be constrained. See Dave's answer. – Ale..chenski Jul 26 '18 at 17:10
• Ali that's not a gated clock design, I am not involving any enable nor inhibiting the clock – camillo_benso Jul 26 '18 at 17:18

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.