Code, Clock, Conquer Perl Scripting in VLSI
Code, Clock, Conquer Perl Scripting in VLSI
Prasanthi Chanda
1. Write a Perl script to extract and print all setup
violations from a PrimeTime static timing report. The
script should:
Read an STA report file (sta_report.txt)
Identify negative slack values (indicating violations)
Print the violating paths and their slack values
#!/usr/bin/perl
use strict;
use warnings;
open(my $fh, '<', "sta_report.txt") or die "Cannot open file:
$!";
print "Setup Violations Found:\n";
while (my $line = <$fh>) {
if ($line =~ /slack\s+(-\d+\.\d+)/) { # Find negative slack
print "Violation Detected: Slack = $1 ns\n";
}
}
close($fh);
2. Write a Perl script to find the worst slack value in a
PrimeTime timing report (sta_report.txt) and print it.
#!/usr/bin/perl
use strict;
use warnings;
open(my $fh, '<', "sta_report.txt") or die "Cannot open file:
$!";
my $worst_slack = 0;
while (my $line = <$fh>) {
if ($line =~ /slack\s+(-?\d+\.\d+)/) { # Find slack values
$worst_slack = $1 if $1 < $worst_slack;
}
}
close($fh);
print "Worst Slack in Design: $worst_slack ns\n";
3. Write a Perl script that:
Reads a Verilog netlist (design.v)
Checks if critical signals (clk, reset, data_in,
data_out) are present
Prints any missing signals
#!/usr/bin/perl
use strict;
use warnings;
my @signals = ("clk", "reset", "data_in", "data_out");
open(my $fh, '<', "design.v") or die "Cannot open netlist: $!";
my %found = map { $_ => 0 } @signals;
while (my $line = <$fh>) {
foreach my $sig (@signals) {
if ($line =~ /\b$sig\b/) {
$found{$sig} = 1;
}
}
}
close($fh);
print "Missing signals:\n";
foreach my $sig (keys %found) {
print "$sig\n" if !$found{$sig};
}
4. Write a Perl script that:
Prompts the user for clock name and period
Generates a TCL script (clock_constraints.tcl) to
define a clock constraint
#!/usr/bin/perl
use strict;
use warnings;
print "Enter clock name: ";
chomp(my $clk_name = <STDIN>);
print "Enter clock period (ns): ";
chomp(my $clk_period = <STDIN>);
open(my $fh, '>', "clock_constraints.tcl") or die "Cannot
create TCL file: $!";
print $fh "create_clock -name $clk_name -period $clk_period
[get_ports $clk_name]\n";
close($fh);
print "TCL script 'clock_constraints.tcl' generated!\n";
5. Write a Perl script that:
Reads a Calibre DRC report (drc_report.txt)
Counts errors per rule type
Prints a summary
#!/usr/bin/perl
use strict;
use warnings;
open(my $fh, '<', "drc_report.txt") or die "Cannot open DRC
report: $!";
my %errors;
while (my $line = <$fh>) {
if ($line =~ /Rule\s+Violation:\s+(\S+)/) {
$errors{$1}++;
}
}
close($fh);
print "DRC Error Summary:\n";
foreach my $rule (keys %errors) {
print "$rule: $errors{$rule} violations\n";
}
6. Write a Perl script that:
Reads an STA report (sta_report.txt)
Extracts negative slack values
Saves results in a CSV file (violations.csv)
#!/usr/bin/perl
use strict;
use warnings;
open(my $fh, '<', "sta_report.txt") or die "Cannot open STA
report: $!";
open(my $out, '>', "violations.csv") or die "Cannot create
output file: $!";
print $out "Path,Slack(ns)\n";
while (my $line = <$fh>) {
if ($line =~ /Path:\s+(\S+).*slack\s+(-\d+\.\d+)/) {
print $out "$1,$2\n";
}
}
close($fh);
close($out);
print "Violations saved in 'violations.csv'\n";
7. Write a Perl script to extract cell delays from a
Standard Delay Format (SDF) file (timing.sdf) and print
them.
#!/usr/bin/perl
use strict;
use warnings;
open(my $fh, '<', "timing.sdf") or die "Cannot open SDF file:
$!";
print "Cell Delays Extracted:\n";
while (my $line = <$fh>) {
if ($line =~ /\(IOPATH\s+(\S+)\s+(\S+)\s+\(\s*(\d+\.\d+)/)
{
print "From: $1 -> To: $2, Delay: $3 ns\n";
}
}
close($fh);
8. Write a Perl script to extract power consumption
data from a Synopsys power report (power.rpt) and
print the top 5 highest power-consuming modules.
#!/usr/bin/perl
use strict;
use warnings;
open(my $fh, '<', "power.rpt") or die "Cannot open power
report: $!";
my %power_data;
while (my $line = <$fh>) {
if ($line =~ /Module:\s+(\S+)\s+Power:\s+(\d+\.\d+)/) {
$power_data{$1} = $2;
}
}
close($fh);
print "Top 5 Highest Power-Consuming Modules:\n";
foreach my $module (sort { $power_data{$b} <=>
$power_data{$a} } keys %power_data) {
printf "%-20s %10.2f mW\n", $module,
$power_data{$module};
last if ++$module == 5;
}
9. Write a Perl script to extract LVS mismatches from a
Calibre LVS report
#!/usr/bin/perl
use strict;
use warnings;
open(my $fh, '<', "lvs_report.txt") or die "Cannot open LVS
report: $!";
print "LVS Mismatches Found:\n";
while (my $line = <$fh>) {
if ($line =~ /Mismatch:\s+(\S+)\s+Expected:\s+
(\S+)\s+Found:\s+(\S+)/) {
print "Mismatch in $1 -> Expected: $2, Found: $3\n";
}
}
close($fh);
10. Write a Perl script to extract clock skew from a
Synopsys PrimeTime STA report (sta_report.rpt) and
print violations.
#!/usr/bin/perl
use strict;
use warnings;
open(my $fh, '<', "sta_report.rpt") or die "Cannot open STA
report: $!";
print "Clock Skew Violations:\n";
while (my $line = <$fh>) {
if ($line =~ /Clock Skew:\s+(\d+\.\d+)/) {
print "Violation detected! Skew: $1 ns\n" if $1 > 0.5;
}
}
close($fh);
11. Write a Perl script to extract IR drop violations from
a voltage analysis report (ir_drop.rpt).
#!/usr/bin/perl
use strict;
use warnings;
open(my $fh, '<', "ir_drop.rpt") or die "Cannot open IR drop
report: $!";
print "IR Drop Violations:\n";
while (my $line = <$fh>) {
if ($line =~ /Net:\s+(\S+)\s+Voltage Drop:\s+(\d+\.\d+)/)
{
print "Net: $1, IR Drop: $2 V\n" if $2 > 0.1;
}
}
close($fh);
12. Write a Perl script to calculate the defect density
from a DRC (Design Rule Check) report (drc_errors.rpt).
#!/usr/bin/perl
use strict;
use warnings;
open(my $fh, '<', "drc_errors.rpt") or die "Cannot open DRC
report: $!";
my $total_errors = 0;
my $area = 10; # Assume 10 mm² chip area
while (my $line = <$fh>) {
if ($line =~ /DRC Error:\s+(\d+)/) {
$total_errors += $1;
}
}
close($fh);
my $defect_density = $total_errors / $area;
print "Defect Density: $defect_density errors/mm²\n";
13. Write a Perl script to detect Clock Domain Crossing
(CDC) violations from a CDC report (cdc_report.txt).
#!/usr/bin/perl
use strict;
use warnings;
open(my $fh, '<', "cdc_report.txt") or die "Cannot open CDC
report: $!";
print "Clock Domain Crossing Violations:\n";
while (my $line = <$fh>) {
if ($line =~ /Signal:\s+(\S+)\s+From Clock:\s+(\S+)\s+To
Clock:\s+(\S+)/) {
print "Violation: $1 crosses from $2 to $3\n";
}
}
close($fh);
14. Write a Perl script to extract metal layer resistance
values from a LVS report (lvs_resistance.rpt).
#!/usr/bin/perl
use strict;
use warnings;
open(my $fh, '<', "lvs_resistance.rpt") or die "Cannot open
LVS report: $!";
print "Metal Layer Resistances:\n";
while (my $line = <$fh>) {
if ($line =~ /Metal Layer:\s+(\S+)\s+Resistance:\s+
(\d+\.\d+)/) {
print "Layer: $1, Resistance: $2 Ohms\n";
}
}
close($fh);
15. Write a Perl script to detect hold timing violations
from a timing report (timing_analysis.rpt).
#!/usr/bin/perl
use strict;
use warnings;
open(my $fh, '<', "timing_analysis.rpt") or die "Cannot open
timing report: $!";
print "Hold Timing Violations:\n";
while (my $line = <$fh>) {
if ($line =~ /Hold Violation:\s+Path:\s+(\S+)\s+Slack:\s+(-
\d+\.\d+)/) {
print "Path: $1, Slack: $2 ns (VIOLATION!)\n";
}
}
close($fh);
Excellence in World class
VLSI Training & Placements
+91- 9182280927