Writing a First SDC File
Section 2.3 examined standard cell library characteristics. Section 2.4 examines user-defined timing constraints.
Previous synthesis runs specified CLOCK_PERIOD = 10.0 in config.json. OpenLane translates this setting into Synopsys Design Constraints (SDC). The SDC format provides an industry-standard syntax for timing definitions. Synthesis and static timing analysis tools evaluate paths against SDC rules.
The Need for Timing Constraints
Logic synthesis requires explicit timing targets. ABC evaluates trade-offs between cell area and propagation delay. Without timing constraints, synthesis engines cannot determine required circuit speed. The tool defaults to generic heuristics or minimizes gate count without verifying setup margins. An SDC file defines exact clock periods and port timing requirements.
Constructing an SDC File for alu8
The alu8 design provides the following ports: clk, rst_n, a[7:0], b[7:0], op[2:0], result[7:0], zero, and carry_out.
A complete SDC specification defines three constraint categories:
1. Clock Definition
Define the master clock on the primary clock port:
create_clock -name clk -period 10.0 [get_ports clk]
This command creates a clock named clk with a period of 10.0 ns. This constraint targets an operating frequency of 100 MHz:
$$ f = \frac{1}{T} = \frac{1}{10.0\text{ ns}} = 100\text{ MHz} $$
By default, the command establishes a 50 percent duty cycle.
2. Input Arrival Delays
Constrain input signal arrival times relative to the clock:
set_input_delay -clock clk 2.0 [get_ports {a[*]}]
set_input_delay -clock clk 2.0 [get_ports {b[*]}]
set_input_delay -clock clk 2.0 [get_ports {op[*]}]
This constraint specifies that external upstream logic consumes 2.0 ns of the clock period. Signals on a, b, and op stabilize 2.0 ns after the clock edge. Consequently, alu8 input paths have 8.0 ns remaining.
3. Output Departure Delays
Constrain output data departure requirements:
set_output_delay -clock clk 1.5 [get_ports {result[*]}]
set_output_delay -clock clk 1.5 [get_ports zero]
set_output_delay -clock clk 1.5 [get_ports carry_out]
This constraint specifies that downstream logic requires 1.5 ns of setup margin before the next clock edge.
Complete SDC File
Combine these definitions into alu8.sdc:
# alu8.sdc: Complete timing constraint specification
create_clock -name clk -period 10.0 [get_ports clk]
set_input_delay -clock clk 2.0 [get_ports {a[*]}]
set_input_delay -clock clk 2.0 [get_ports {b[*]}]
set_input_delay -clock clk 2.0 [get_ports {op[*]}]
set_output_delay -clock clk 1.5 [get_ports {result[*]}]
set_output_delay -clock clk 1.5 [get_ports zero]
set_output_delay -clock clk 1.5 [get_ports carry_out]
# Exclude asynchronous reset from synchronous setup analysis
set_false_path -from [get_ports rst_n]
Do not assign input or output delays to the clk port itself. Additionally, mark asynchronous reset ports using set_false_path. Unconstrained asynchronous resets generate misleading timing violation warnings.
Practice Exercise
An updated system specification requires alu8 to operate at 200 MHz. The input bus signals arrive 1.2 ns after the clock edge. Downstream registers require 1.0 ns of output margin. Write the updated SDC commands.
Solution
# 200 MHz requires a 5.0 ns period
create_clock -name clk -period 5.0 [get_ports clk]
set_input_delay -clock clk 1.2 [get_ports {a[*]}]
set_input_delay -clock clk 1.2 [get_ports {b[*]}]
set_input_delay -clock clk 2.0 [get_ports {op[*]}]
set_output_delay -clock clk 1.0 [get_ports {result[*]}]
set_output_delay -clock clk 1.5 [get_ports zero]
set_output_delay -clock clk 1.5 [get_ports carry_out]
A 200 MHz clock frequency requires $T = 1 / (200\text{ MHz}) = 5.0$ ns. Unmodified ports maintain their original constraint values.
The next article examines clock waveforms, duty cycles, and input/output timing budgets.