Skip to content
DenseChip
Learn
PracticeCode labInterview

DenseChip

Navigate

Menu

LearnPracticeCode labInterview

Tools

All toolsSV editorCode repoResume
DenseChip

Practice, courses, and chip-design tools in one focused workspace.

LearnPracticeCode labInterviewToolsLearning paths

© 2026 DenseChip

AboutContactPrivacyTerms
Skip to lesson

Course contents

  • Logic Synthesis Glossary
  • Logic Synthesis Cheatsheet
  • Synthesis Foundations14
    • Synthesis Flow Overview
    • Synthesizable RTL and Inference
    • Reading Netlists and Reports
      • Cell Counts from stat
      • Area by Cell Type
      • Hierarchy, Fanout and Net Names
      • Longest Path, Write and Read Back
  • Logic Optimisation and Mapping20
  • Constraints and Timing15
  • Sequential, FSM and Memory19
  • Datapath Synthesis14
  • Area, Power and Test14
  • Verification, ECO and Handoff15
  • Flows and Debugging15
  • Interview and Judgment11
Loading lesson

‹Reading Netlists and Reports
  1. Topics
  2. Logic Synthesis
  3. Synthesis Foundations
  4. Reading Netlists and Reports
  5. Longest Path, Write and Read Back

Part 1 · Synthesis Foundations · Intermediate

Longest Path, Write and Read Back

Longest topological path with ltp, plus write, read back, and recount.

On this page

    The longest topological path

    The longest topological path counts gates from an input to an output. It ignores cell delays and wire load, so it measures structure rather than time.

    The three-gate example has depth 2: one AND level feeding one OR level. The calc block works it out pin by pin.

    Diagram
    gate list: AND2(a, b -> n1), AND2(c, d -> n2), OR2(n1, n2 -> y)
    depth of inputs a, b, c, d = 0
    depth of n1 = 1 + max(0, 0) = 1
    depth of n2 = 1 + max(0, 0) = 1
    depth of y  = 1 + max(1, 1) = 2 logic levels
    longest topological path: a -> n1 -> y (2 gates)

    ltp on the example

    ltp prints that path for the whole design. The block below is an illustrative layout, numbers invented for this lesson.

    Diagram
    illustrative layout, numbers invented for this lesson (an example chain, never tool output):
    path: in -> g1 -> g2 -> g3 -> out
    gates on path = 3, nets on path = 4
    depth = 3 logic levels (topological; delays ignored)

    Write, read back, recount

    write_verilog prints the netlist to a file. Reading it back must restore the same cells, or the file is corrupt.

    The script below writes the three-gate netlist, resets the design, reads the file back and pins the same counts. Its ltp call prints the path first.

    yosys
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    read_verilog <<EOV
    module top(input a, b, c, d, output y);
    wire n1, n2;
    assign n1 = a & b;
    assign n2 = c & d;
    assign y = n1 | n2;
    endmodule
    EOV
    hierarchy -check -top top
    select -assert-count 2 t:$and
    select -assert-count 1 t:$or
    stat
    ltp
    write_verilog netlist.v
    design -reset
    read_verilog netlist.v
    hierarchy -check -top top
    select -assert-count 2 t:$and
    select -assert-count 1 t:$or
    stat
    log PASS: written netlist reads back with identical counts

    The hand recount below replays the same gate list on paper. Its numbers match the asserted blocks: 3 cells, 7 wires, depth 2 and maximum fanout 1.

    Diagram
    printed gate list: AND2(a, b -> n1), AND2(c, d -> n2), OR2(n1, n2 -> y)
    cells by type: AND2 2, OR2 1
    total cells = 2 + 1 = 3
    wires: a, b, c, d, n1, n2, y = 7
    depth of y = 2 logic levels (from the first section)
    every driven internal net has fanout 1 (the output port y has no internal loads), so the maximum fanout is 1

    The program below recounts the list independently. It passes only when cells, wires, depth and fanout all agree.

    example.py
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    import sys
    
    gates = [
        ("AND2", ("a", "b"), "n1"),
        ("AND2", ("c", "d"), "n2"),
        ("OR2", ("n1", "n2"), "y"),
    ]
    roots = ("a", "b", "c", "d")
    
    depth = {}
    for r in roots:
        depth[r] = 0
    fanout = {}
    for g in gates:
        kind, ins, out = g
        depth[out] = 1 + max(depth[i] for i in ins)
        for i in ins:
            fanout[i] = fanout.get(i, 0) + 1
    
    wires = set(roots)
    for g in gates:
        kind, ins, out = g
        wires.add(out)
    
    counts = {}
    for g in gates:
        counts[g[0]] = counts.get(g[0], 0) + 1
    
    bad = 0
    if len(gates) != 3:
        print("FAIL: cell total is " + str(len(gates)) + " want 3")
        bad = 1
    if counts.get("AND2", 0) != 2:
        print("FAIL: AND2 count is " + str(counts.get("AND2", 0)) + " want 2")
        bad = 1
    if counts.get("OR2", 0) != 1:
        print("FAIL: OR2 count is " + str(counts.get("OR2", 0)) + " want 1")
        bad = 1
    if len(wires) != 7:
        print("FAIL: wire total is " + str(len(wires)) + " want 7")
        bad = 1
    if depth["y"] != 2:
        print("FAIL: depth of y is " + str(depth["y"]) + " want 2")
        bad = 1
    if max(fanout.values()) != 1:
        print("FAIL: maximum fanout is " + str(max(fanout.values())) + " want 1")
        bad = 1
    if bad != 0:
        sys.exit(1)
    print("PASS: recount gives 3 cells, 7 wires, depth 2, max fanout 1")

    Common mistakes

    Common pitfall

    The longest topological path is not the critical timing path. ltp counts gates and ignores delay, so a shorter path can still fail timing first.

    Interview

    Likely probes: ltp against timing, and the round trip.

    • ltp reports structure in gates; timing needs delays, which ltp never sees.

    • Write plus read-back checks the file loop, not the synthesis result itself.

    • A recount that matches the script means the list was read correctly.

    Check yourself The example has depth 2 topologically. What does ltp count, and what does it ignore?

    It counts gates on the longest path. It ignores cell delays and wire load.

    Check yourself The written netlist reads back with two $and and one $or. What does that prove, and what does it leave open?

    It proves the round trip preserved the structure. It leaves open whether the netlist still matches the RTL, which needs an equivalence check.

    Related topics

    • Hierarchy, fanout and net names

    • Delay Models and Slack

    Previous

    16 / 139

    Next: Logic Optimisation and Mapping

    Up next

    Up nextLogic Optimisation and Mapping

    Sign in to save progress

    Practice this lessonReport an error

    See also

    • Cell Counts from stat
    • Area by Cell Type