Ready-to-run snippets

Code Examples

Ready-to-run Verilog, SystemVerilog, and UVM examples. Click any to open it live in the IDE.

← All examples

STA Clock Mux: Exclusive Clocks

Verilog Static Timing Analysis

A multiplexer selects between a 2.0 ns and a 3.0 ns clock; remove the clock pairs that cannot happen

Open in IDE
Related tutorial:
design.v
module sta_mux (input clka, clkb, sel, d, output q);
  wire mclk = sel ? clka : clkb;
  reg r1, r2;
  always @(posedge mclk) begin
    r1 <= d;
    r2 <= r1;
  end
  assign q = r2;
endmodule
constraints.sdc
# Run synthesis first, then STA. With PRO you can edit this file and run STA again without synthesis,
# and pick another library and corner in the drop-down.
create_clock -name clka -period 2.0 [get_ports clka]
create_clock -name clkb -period 3.0 [get_ports clkb]
set_input_delay  0.4 -clock clka [get_ports d]
set_output_delay 0.4 -clock clka [get_ports q]

# Exercise: use one of these two fixes (not both).
# set_clock_groups -logically_exclusive -group clka -group clkb
# set_case_analysis 1 [get_ports sel]
Admin mode — edit and delete controls are visible on each row. Use the IDE to add new snippets via File → Save as Snippet.