#! /usr/bin/perl -w
############################################################
## Copyright: 2011 Integrated Sytems Laboratory, ETH Zurich
## http://www.iis.ee.ethz.ch/~sha3
############################################################
use strict;
# v0.1 - kgf@ee.ethz.ch - Wed Sep 21 18:00:56 CEST 2011
# - adapted from gen_mmmc.pl
my @ALGS=qw|ethz_sha2 ethz_blake ethz_groestl ethz_jh ethz_keccak ethz_skein
gmu_sha2 gmu_blake gmu_groestl gmu_jh gmu_keccak gmu_skein
dummy ram1 ram2 ram3 |;
my $DEBUG=1; # set to 0 for less messages
# Generate files with this pattern
my @MULT=qw|1.00 1.10 1.20 1.30 1.40 1.50 1.80 1.20|;
my $TEMP = "temp.tcl";
# update clocks from the design_settings.tcl for the algorithms
foreach my $a (@ALGS){
next unless ($a=~/^(ethz|gmu)/); #skip dummy and ram
my $file = "../../${a}/synopsys/scripts/design_settings.tcl";
if (-f $file){
open (F, "< $file") or die "ERROR: can not open $file for reading\n";
print "opening $file\n" if $DEBUG;
open (T, "> $TEMP") or die "Something wrong with temp file $TEMP\n";
while (F){
if (s/^\s*set CLOCKLIST\s*\{//){ # only when this executes true
s/\}//; # get rid of the last paranthesis
my @s = split; # should be just alist of numbers
print T "# set CLOCKLIST { @s }\n";
my $val = pop(@s); # the last guy
print T "#\n# Automated values\n#\nset CLOCKLIST { ";
foreach my $m (@MULT){
my $new = int(($val * $m) * 20)/20;
printf(T "%4.2f ",$new);
}
print T "}\n";
}
else{
print T;
}
}
close(F);
close(T);
# now move the temp file to the original
rename($TEMP, $file);
}
}