2.6.6 Handle repetitive work
A Perl 'for' or 'foreach' loop can handle repetitive work efficiently. For example, to add a 'AND' isolation gate for every output port of a module.
# GOF ECO script, add_ands.pl
use strict;
undo_eco;
# Discard previous ECO operations
setup_eco(
"eco_example");
# Setup ECO name
read_library(
"tsmc.lib");
# Read in standard library
read_design(
"-ref",
"reference.gv");
# Read in Reference Netlist
read_design(
"-imp",
"implementation.gv");
# Read in implementation Netlist which is under ECO
set_top(
"topmod");
# Set the top module that ECO is working on
my @ports =
get_ports(
"-output");
# Get all output ports of module 'topmod'
# For each output port of 'topmod', insert an 'AND' gate to enable it only when 'enable_out' is high
my $cnt = 0;
foreach my $port (@ports){
change_port($port,
"AND2X2",
"eco_add_and_$cnt",
"-,enable_out");
$cnt++;
}
report_eco();
write_verilog(
"eco_verilog.v");
# Write out ECO result in Verilog
exit;
# Exit when the ECO is done, comment it out to go to interactive mode when ’GOF >’ appears