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 8-Bit Adder: Two Pipeline Stages

Verilog Static Timing Analysis

The same adder split into a low-nibble stage and a high-nibble stage; it runs at about 1.5 ns

Open in IDE
design.v
module add2 (input clk, input [7:0] a, b, output reg [8:0] s);
  reg [7:0] ra, rb;
  reg [4:0] lo; reg [3:0] ha, hb;
  always @(posedge clk) begin
    ra <= a;
    rb <= b;
    lo <= ra[3:0] + rb[3:0];          // stage 1: low nibble and its carry
    ha <= ra[7:4];
    hb <= rb[7:4];
    s <= {ha + hb + lo[4], lo[3:0]};   // stage 2: high nibble
  end
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 clk -period 1.2 [get_ports clk]
set_input_delay  0.1 -clock clk [get_ports {a[*] b[*]}]
set_output_delay 0.1 -clock clk [get_ports {s[*]}]

# Exercise: try 1.4 ns and 1.5 ns and compare with the one-stage adder.
Admin mode — edit and delete controls are visible on each row. Use the IDE to add new snippets via File → Save as Snippet.