Skip to main content

Regular Pattern Search Using grep, awk and sed

Hello, Dear Readers,   In this post, I will share some deep insights into regular pattern searching using grep, awk, and sed. In VLSI/EDA flows, engineers frequently work with large Innovus, Voltus, STA, EMIR, synthesis and simulation reports. Linux commands such as grep , awk , and sed provide a fast way to search, filter and process this data without opening huge files manually. 1. Regular Expressions: A regular expression (regex) defines a pattern for searching text. Common patterns: Pattern Meaning Example . Any character V.D * Zero or more ab* + One or more ab+ [0-9] Digit U [0-9] [a-z] Lowercase [a-z] + ^ Start of line ^VDD $ End of line VDD$ ` ` OR `VDD VSS` For example: grep -E 'ERROR|WARNING|FATAL' voltus.log Searches for any of the three patterns. 2. grep — Search and Filter: grep is mainly used to find matching lines . Basic search grep 'VIOLATION' report.rpt Case-insensitive search grep -i 'error' run.log Show line numbers grep -n 'VIOLATION...

Regular Pattern Search Using grep, awk and sed

Hello, Dear Readers, 

In this post, I will share some deep insights into regular pattern searching using grep, awk, and sed.

In VLSI/EDA flows, engineers frequently work with large Innovus, Voltus, STA, EMIR, synthesis and simulation reports. Linux commands such as grep, awk, and sed provide a fast way to search, filter and process this data without opening huge files manually.

1. Regular Expressions:

A regular expression (regex) defines a pattern for searching text.

Common patterns:

PatternMeaningExample
.Any characterV.D
*Zero or moreab*
+One or moreab+
[0-9]DigitU[0-9]
[a-z]Lowercase[a-z]+
^Start of line^VDD
$End of lineVDD$
``OR`VDDVSS`

For example:

grep -E 'ERROR|WARNING|FATAL' voltus.log

Searches for any of the three patterns.

2. grep — Search and Filter:

grep is mainly used to find matching lines.

Basic search

grep 'VIOLATION' report.rpt

Case-insensitive search

grep -i 'error' run.log

Show line numbers

grep -n 'VIOLATION' report.rpt

Exclude matching lines

grep -v '^#' config.txt

Search recursively

grep -r 'ERROR' ./logs/

Extended regex

grep -E 'ERROR|FATAL|WARNING' run.log

Search an exact string

This is particularly useful for signal names containing []:

grep -F 'axi_m0_wdata[255]' file.txt

Alternatively:

grep 'axi_m0_wdata\[255\]' file.txt

-F is often easier when you want a literal string rather than a regex.

3. awk — Column-Based Processing:

awk becomes useful when a report contains structured columns.

Example:

U1  0.710  NAND2_X1
U2  0.642  NAND2_X2
U3  0.660  INV_X4

Here:

$1 → Instance
$2 → Voltage
$3 → Cell type

Print selected columns:

awk '{print $1,$2}' report.txt

Filter numerical values

For an IR-drop threshold of 0.675 V:

awk '$2 < 0.675 {print $1,$2,$3}' report.txt

Multiple conditions

awk '$2 < 0.675 && $3 ~ /NAND/ {print}' report.txt

Here ~ performs regex matching.

4. Counting Violations:

Count all violations:

awk '$2 < 0.675 {count++}
END {print "Violations =",count}' report.txt

Count violations by cell type:

awk '$2 < 0.675 {count[$3]++}
END {
    for (cell in count)
        print cell,count[cell]
}' report.txt

This is useful for determining which cell types contribute most to IR violations.

5. sed — Modify and Clean Text:

sed is mainly used for text transformation.

Replace text

sed 's/VDD/VCC/g' file.txt

Delete lines containing a pattern

sed '/DEBUG/d' file.txt

Remove comments

sed '/^#/d' config.txt

Remove blank lines

sed '/^$/d' file.txt

Print a specific range

sed -n '100,150p' report.txt

This is useful when grep -n tells you the relevant line number and you want to inspect the surrounding section.

6. Combining the Commands:

The real power comes from combining commands using pipes (|).

For example, find Voltus violations and display the worst cases:

grep 'VIOLATION' voltus.rpt |
awk '$3 < 0.675 {print $3,$1,$4}' |
sort -n |
head -20

Flow:

grep → Find relevant lines
  ↓
awk  → Filter/extract columns
  ↓
sort → Order results
  ↓
head → Show top results

Another useful example:

grep 'VIOLATION' voltus.rpt |
awk '{print $4}' |
sort |
uniq -c |
sort -nr

This gives the violation count by cell type.

7. Useful VLSI Examples:

Find all timing errors

grep -Ei 'error|fatal|failed' timing.log

Find negative slack

awk '$1=="slack:" && $2 < 0 {print}' timing.rpt

Find VDD-related violations

grep 'VDD' voltus.rpt | grep 'VIOLATION'

Search compressed reports

zgrep 'VIOLATION' report.rpt.gz

Find signals with indexed bits

grep -E 'axi_m0_wdata\[[0-9]+\]' file.txt

8. Quick Cheat Sheet:
grep    → Search lines
awk     → Process columns / calculations
sed     → Modify text
sort    → Sort results
uniq    → Count unique/repeated values
head    → First N lines
tail    → Last N lines
zgrep   → Search .gz files

A very useful VLSI command-line pattern is:

grep | awk | sort | uniq | head

It can turn a multi-gigabyte EDA report into a small, meaningful debug summary.

Conclusion:

For VLSI engineers, mastering grep, awk, and sed provides a lightweight and extremely fast way to analyze EMIR, timing, power, synthesis and implementation reports.

The key idea is simple:

grep → Find
awk  → Analyze
sed  → Modify

Once combined with pipes, these commands become powerful tools for everyday EDA debugging and automation.

Connect with me 

4.WhatsApp 


Comments

Popular posts from this blog

Signal Electromigration (Signal EM): Violations, Examples, and Practical Fixes

  Hello Dear Readers,   Today in this post, I will provide some deep insight into the Signal Electromigration (Signal EM): Violations, Examples, and Practical Fixes. 1. Introduction: As technology nodes shrink into the deep‑submicron and nanometer regime (7nm, 5nm, 3nm and beyond), electromigration (EM) has become a first‑order reliability concern—not only for power/ground (PG) networks but also for signal nets. Signal EM failures are often underestimated because signal currents are transient and bidirectional. However, with higher switching activity, tighter metal pitches, thinner wires, and aggressive timing closure, signal EM can cause latent or early‑life failures if not addressed properly. This article explains: What Signal EM is and how it differs from PG EM Typical Signal EM violation scenarios Detailed, practical examples Root causes behind each violation Proven solutions and best practices to fix and prevent Signal EM issues 2. What is Signal Electromigration: El...

Exploring the Role of LEF Files in VLSI Chip Design: A Beginner's Guide

Hello Dear Readers,   Today in this post, I will provide some deep insight into the LEF file role during the VLSI Chip Design process. In VLSI (Very Large Scale Integration) design, a LEF file is a file that contains information about the physical geometry of the standard cells used in a circuit. LEF stands for Library Exchange Format. A standard cell is a pre-designed logic cell that contains a specific function, such as a flip-flop or an AND gate. Standard cells are designed to be easily combinable and scalable to create more complex circuits. The physical geometry of each standard cell is defined in the LEF file. The LEF file contains information such as the width, height, and position of the pins and metal layers of each standard cell. It also contains information about the physical design rules that govern the placement of these cells on the chip. LEF files are important in VLSI design because they enable the interoperability of different design tools from different vend...

Power Analysis in the VLSI Chip Design

  Hello Dear Readers,   Today in this series of posts I will provide some deep insight into Power Analysis in the VLSI Chip Design. The power analysis flow calculates (estimates of) the active and static leakage power dissipation of the SoC design. This electrical analysis step utilizes the detailed extraction model of the block and global SoC layouts. The active power estimates depend on the availability of switching factors for all signals in the cell netlist. Representative simulation test cases are applied to the netlist model, and the signal value change data are recorded. The output data from the power analysis flow guide the following SoC tape out release assessments:  Total SoC power specification (average and standby leakage): The specification for SoC power is critical for package selection and is used by end customers for thermal analysis of the product enclosure. In addition to the package technology selection, the SoC power dissipation is used to ev...