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.logSearches for any of the three patterns.
2. grep — Search and Filter:
grep is mainly used to find matching lines.
Basic search
grep 'VIOLATION' report.rptCase-insensitive search
grep -i 'error' run.logShow line numbers
grep -n 'VIOLATION' report.rptExclude matching lines
grep -v '^#' config.txtSearch recursively
grep -r 'ERROR' ./logs/Extended regex
grep -E 'ERROR|FATAL|WARNING' run.logSearch an exact string
This is particularly useful for signal names containing []:
grep -F 'axi_m0_wdata[255]' file.txtAlternatively:
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_X4Here:
$1 → Instance
$2 → Voltage
$3 → Cell typePrint selected columns:
awk '{print $1,$2}' report.txtFilter numerical values
For an IR-drop threshold of 0.675 V:
awk '$2 < 0.675 {print $1,$2,$3}' report.txtMultiple conditions
awk '$2 < 0.675 && $3 ~ /NAND/ {print}' report.txtHere ~ performs regex matching.
4. Counting Violations:
Count all violations:
awk '$2 < 0.675 {count++}
END {print "Violations =",count}' report.txtCount violations by cell type:
awk '$2 < 0.675 {count[$3]++}
END {
for (cell in count)
print cell,count[cell]
}' report.txtThis 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.txtDelete lines containing a pattern
sed '/DEBUG/d' file.txtRemove comments
sed '/^#/d' config.txtRemove blank lines
sed '/^$/d' file.txtPrint a specific range
sed -n '100,150p' report.txtThis 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 -20Flow:
grep → Find relevant lines
↓
awk → Filter/extract columns
↓
sort → Order results
↓
head → Show top resultsAnother useful example:
grep 'VIOLATION' voltus.rpt |
awk '{print $4}' |
sort |
uniq -c |
sort -nrThis gives the violation count by cell type.
7. Useful VLSI Examples:
Find all timing errors
grep -Ei 'error|fatal|failed' timing.logFind negative slack
awk '$1=="slack:" && $2 < 0 {print}' timing.rptFind VDD-related violations
grep 'VDD' voltus.rpt | grep 'VIOLATION'Search compressed reports
zgrep 'VIOLATION' report.rpt.gzFind 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 filesA very useful VLSI command-line pattern is:
grep | awk | sort | uniq | headIt 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 → ModifyOnce combined with pipes, these commands become powerful tools for everyday EDA debugging and automation.
Comments
Post a Comment